Loading libs/surfaceflinger/LayerOrientationAnim.cpp +102 −85 Original line number Original line Diff line number Diff line Loading @@ -55,7 +55,6 @@ LayerOrientationAnim::LayerOrientationAnim( mOrientationCompleted = false; mOrientationCompleted = false; mFirstRedraw = false; mFirstRedraw = false; mLastNormalizedTime = 0; mLastNormalizedTime = 0; mLastAngle = 0; mLastScale = 0; mLastScale = 0; mNeedsBlending = false; mNeedsBlending = false; } } Loading Loading @@ -95,6 +94,10 @@ void LayerOrientationAnim::validateVisibility(const Transform&) transparentRegionScreen.clear(); transparentRegionScreen.clear(); mTransformed = true; mTransformed = true; mCanUseCopyBit = false; mCanUseCopyBit = false; copybit_device_t* copybit = mFlinger->getBlitEngine(); if (copybit) { mCanUseCopyBit = true; } } } void LayerOrientationAnim::onOrientationCompleted() void LayerOrientationAnim::onOrientationCompleted() Loading @@ -106,33 +109,35 @@ void LayerOrientationAnim::onOrientationCompleted() mFlinger->invalidateLayerVisibility(this); mFlinger->invalidateLayerVisibility(this); } } const float ROTATION = M_PI * 0.5f; const float ROTATION_FACTOR = 1.0f; // 1.0 or 2.0 const float DURATION = ms2ns(200); const float BOUNCES_PER_SECOND = 1.618f; const float BOUNCES_AMPLITUDE = (5.0f/180.f) * M_PI; void LayerOrientationAnim::onDraw(const Region& clip) const void LayerOrientationAnim::onDraw(const Region& clip) const { { // Animation... // Animation... const float MIN_SCALE = 0.5f; // FIXME: works only for portrait framebuffers const float DURATION = ms2ns(200); const Point size(getPhysicalSize()); const float BOUNCES_PER_SECOND = 1.618f; const float TARGET_SCALE = size.x * (1.0f / size.y); const float BOUNCES_AMPLITUDE = 1.0f/32.0f; const nsecs_t now = systemTime(); const nsecs_t now = systemTime(); float angle, scale, alpha; float scale, alpha; if (mOrientationCompleted) { if (mOrientationCompleted) { if (mFirstRedraw) { if (mFirstRedraw) { mFirstRedraw = false; // make a copy of what's on screen // make a copy of what's on screen copybit_image_t image; copybit_image_t image; mBitmapIn.getBitmapSurface(&image); mBitmapIn.getBitmapSurface(&image); const DisplayHardware& hw(graphicPlane(0).displayHardware()); const DisplayHardware& hw(graphicPlane(0).displayHardware()); hw.copyBackToImage(image); hw.copyBackToImage(image); // and erase the screen for this round glDisable(GL_BLEND); glDisable(GL_DITHER); glDisable(GL_SCISSOR_TEST); glClearColor(0,0,0,0); glClear(GL_COLOR_BUFFER_BIT); // FIXME: code below is gross // FIXME: code below is gross mFirstRedraw = false; mNeedsBlending = false; mNeedsBlending = false; LayerOrientationAnim* self(const_cast<LayerOrientationAnim*>(this)); LayerOrientationAnim* self(const_cast<LayerOrientationAnim*>(this)); mFlinger->invalidateLayerVisibility(self); mFlinger->invalidateLayerVisibility(self); Loading @@ -143,39 +148,36 @@ void LayerOrientationAnim::onDraw(const Region& clip) const const float normalizedTime = (float(now - mFinishTime) / duration); const float normalizedTime = (float(now - mFinishTime) / duration); if (normalizedTime <= 1.0f) { if (normalizedTime <= 1.0f) { const float squaredTime = normalizedTime*normalizedTime; const float squaredTime = normalizedTime*normalizedTime; angle = (ROTATION*ROTATION_FACTOR - mLastAngle)*squaredTime + mLastAngle; scale = (1.0f - mLastScale)*squaredTime + mLastScale; scale = (1.0f - mLastScale)*squaredTime + mLastScale; alpha = normalizedTime; alpha = (1.0f - normalizedTime); alpha *= alpha; alpha *= alpha; } else { } else { mAnim->onAnimationFinished(); mAnim->onAnimationFinished(); angle = ROTATION; alpha = 1.0f; scale = 1.0f; scale = 1.0f; alpha = 0.0f; } } } else { } else { const float normalizedTime = float(now - mStartTime) / DURATION; const float normalizedTime = float(now - mStartTime) / DURATION; if (normalizedTime <= 1.0f) { if (normalizedTime <= 1.0f) { mLastNormalizedTime = normalizedTime; mLastNormalizedTime = normalizedTime; const float squaredTime = normalizedTime*normalizedTime; const float squaredTime = normalizedTime*normalizedTime; angle = ROTATION * squaredTime; scale = (MIN_SCALE-1.0f)*squaredTime + 1.0f; scale = (TARGET_SCALE - 1.0f)*squaredTime + 1.0f; alpha = 1.0f; alpha = 0; } else { } else { mLastNormalizedTime = 1.0f; mLastNormalizedTime = 1.0f; const float to_seconds = DURATION / seconds(1); const float to_seconds = DURATION / seconds(1); const float phi = BOUNCES_PER_SECOND * const float phi = BOUNCES_PER_SECOND * (((normalizedTime - 1.0f) * to_seconds)*M_PI*2); (((normalizedTime - 1.0f) * to_seconds)*M_PI*2); angle = ROTATION + BOUNCES_AMPLITUDE * sinf(phi); scale = MIN_SCALE + BOUNCES_AMPLITUDE * (1.0f - cosf(phi)); scale = TARGET_SCALE; alpha = 1.0f; alpha = 0; } } mLastAngle = angle; mLastScale = scale; mLastScale = scale; } } drawScaled(angle, scale, alpha); drawScaled(scale, alpha); } } void LayerOrientationAnim::drawScaled(float f, float s, float alpha) const void LayerOrientationAnim::drawScaled(float f, float alpha) const { { copybit_image_t dst; copybit_image_t dst; const GraphicPlane& plane(graphicPlane(0)); const GraphicPlane& plane(graphicPlane(0)); Loading @@ -185,20 +187,47 @@ void LayerOrientationAnim::drawScaled(float f, float s, float alpha) const // clear screen // clear screen // TODO: with update on demand, we may be able // TODO: with update on demand, we may be able // to not erase the screen at all during the animation // to not erase the screen at all during the animation if (!mOrientationCompleted) { glDisable(GL_BLEND); glDisable(GL_BLEND); glDisable(GL_DITHER); glDisable(GL_DITHER); glDisable(GL_SCISSOR_TEST); glDisable(GL_SCISSOR_TEST); glClearColor(0,0,0,0); glClearColor(0,0,0,0); glClear(GL_COLOR_BUFFER_BIT); glClear(GL_COLOR_BUFFER_BIT); } const int w = dst.w; const int w = dst.w*f; const int h = dst.h; const int h = dst.h*f; const int xc = uint32_t(dst.w-w)/2; const int yc = uint32_t(dst.h-h)/2; const copybit_rect_t drect = { xc, yc, xc+w, yc+h }; copybit_image_t src; copybit_image_t src; mBitmap.getBitmapSurface(&src); mBitmap.getBitmapSurface(&src); const copybit_rect_t srect = { 0, 0, src.w, src.h }; const copybit_rect_t srect = { 0, 0, src.w, src.h }; int err = NO_ERROR; const int can_use_copybit = canUseCopybit(); if (can_use_copybit) { copybit_device_t* copybit = mFlinger->getBlitEngine(); copybit->set_parameter(copybit, COPYBIT_TRANSFORM, 0); copybit->set_parameter(copybit, COPYBIT_DITHER, COPYBIT_ENABLE); if (alpha < 1.0f) { copybit_image_t srcIn; mBitmapIn.getBitmapSurface(&srcIn); region_iterator it(Region(Rect( drect.l, drect.t, drect.r, drect.b ))); copybit->set_parameter(copybit, COPYBIT_PLANE_ALPHA, 0xFF); err = copybit->stretch(copybit, &dst, &srcIn, &drect, &srect, &it); } if (!err && alpha > 0.0f) { region_iterator it(Region(Rect( drect.l, drect.t, drect.r, drect.b ))); copybit->set_parameter(copybit, COPYBIT_PLANE_ALPHA, int(alpha*255)); err = copybit->stretch(copybit, &dst, &src, &drect, &srect, &it); } LOGE_IF(err != NO_ERROR, "copybit failed (%s)", strerror(err)); } if (!can_use_copybit || err) { GGLSurface t; GGLSurface t; t.version = sizeof(GGLSurface); t.version = sizeof(GGLSurface); t.width = src.w; t.width = src.w; Loading @@ -208,14 +237,9 @@ void LayerOrientationAnim::drawScaled(float f, float s, float alpha) const t.format = src.format; t.format = src.format; t.data = (GGLubyte*)(intptr_t(src.base) + src.offset); t.data = (GGLubyte*)(intptr_t(src.base) + src.offset); const int targetOrientation = plane.getOrientation(); if (!targetOrientation) { f = -f; } Transform tr; Transform tr; tr.set(f, w*0.5f, h*0.5f); tr.set(f,0,0,f); tr.scale(s, w*0.5f, h*0.5f); tr.set(xc, yc); // FIXME: we should not access mVertices and mDrawingState like that, // FIXME: we should not access mVertices and mDrawingState like that, // but since we control the animation, we know it's going to work okay. // but since we control the animation, we know it's going to work okay. Loading @@ -225,31 +249,12 @@ void LayerOrientationAnim::drawScaled(float f, float s, float alpha) const tr.transform(self.mVertices[1], 0, src.h); tr.transform(self.mVertices[1], 0, src.h); tr.transform(self.mVertices[2], src.w, src.h); tr.transform(self.mVertices[2], src.w, src.h); tr.transform(self.mVertices[3], src.w, 0); tr.transform(self.mVertices[3], src.w, 0); if (!(mFlags & DisplayHardware::SLOW_CONFIG)) { if (!(mFlags & DisplayHardware::SLOW_CONFIG)) { // Too slow to do this in software // Too slow to do this in software self.mDrawingState.flags |= ISurfaceComposer::eLayerFilter; self.mDrawingState.flags |= ISurfaceComposer::eLayerFilter; } } if (UNLIKELY(mTextureName == -1LU)) { if (alpha < 1.0f) { mTextureName = createTexture(); GLuint w=0, h=0; const Region dirty(Rect(t.width, t.height)); loadTexture(dirty, mTextureName, t, w, h); } self.mDrawingState.alpha = 255; //-int(alpha*255); const Region clip(Rect( srect.l, srect.t, srect.r, srect.b )); drawWithOpenGL(clip, mTextureName, t); if (alpha > 0) { const float sign = (!targetOrientation) ? 1.0f : -1.0f; tr.set(f + sign*(M_PI * 0.5f * ROTATION_FACTOR), w*0.5f, h*0.5f); tr.scale(s, w*0.5f, h*0.5f); tr.transform(self.mVertices[0], 0, 0); tr.transform(self.mVertices[1], 0, src.h); tr.transform(self.mVertices[2], src.w, src.h); tr.transform(self.mVertices[3], src.w, 0); copybit_image_t src; copybit_image_t src; mBitmapIn.getBitmapSurface(&src); mBitmapIn.getBitmapSurface(&src); t.data = (GGLubyte*)(intptr_t(src.base) + src.offset); t.data = (GGLubyte*)(intptr_t(src.base) + src.offset); Loading @@ -259,9 +264,21 @@ void LayerOrientationAnim::drawScaled(float f, float s, float alpha) const const Region dirty(Rect(t.width, t.height)); const Region dirty(Rect(t.width, t.height)); loadTexture(dirty, mTextureNameIn, t, w, h); loadTexture(dirty, mTextureNameIn, t, w, h); } } self.mDrawingState.alpha = 255; const Region clip(Rect( drect.l, drect.t, drect.r, drect.b )); drawWithOpenGL(clip, mTextureName, t); } t.data = (GGLubyte*)(intptr_t(src.base) + src.offset); if (UNLIKELY(mTextureName == -1LU)) { mTextureName = createTexture(); GLuint w=0, h=0; const Region dirty(Rect(t.width, t.height)); loadTexture(dirty, mTextureName, t, w, h); } self.mDrawingState.alpha = int(alpha*255); self.mDrawingState.alpha = int(alpha*255); const Region clip(Rect( srect.l, srect.t, srect.r, srect.b )); const Region clip(Rect( drect.l, drect.t, drect.r, drect.b )); drawWithOpenGL(clip, mTextureNameIn, t); drawWithOpenGL(clip, mTextureName, t); } } } } Loading libs/surfaceflinger/LayerOrientationAnim.h +1 −2 Original line number Original line Diff line number Diff line Loading @@ -52,7 +52,7 @@ public: virtual bool needsBlending() const; virtual bool needsBlending() const; virtual bool isSecure() const { return false; } virtual bool isSecure() const { return false; } private: private: void drawScaled(float angle, float scale, float alpha) const; void drawScaled(float scale, float alpha) const; OrientationAnimation* mAnim; OrientationAnimation* mAnim; LayerBitmap mBitmap; LayerBitmap mBitmap; Loading @@ -62,7 +62,6 @@ private: bool mOrientationCompleted; bool mOrientationCompleted; mutable bool mFirstRedraw; mutable bool mFirstRedraw; mutable float mLastNormalizedTime; mutable float mLastNormalizedTime; mutable float mLastAngle; mutable float mLastScale; mutable float mLastScale; mutable GLuint mTextureName; mutable GLuint mTextureName; mutable GLuint mTextureNameIn; mutable GLuint mTextureNameIn; Loading libs/surfaceflinger/SurfaceFlinger.cpp +1 −2 Original line number Original line Diff line number Diff line Loading @@ -1804,7 +1804,6 @@ status_t GraphicPlane::setOrientation(int orientation) if (orientation == ISurfaceComposer::eOrientationDefault) { if (orientation == ISurfaceComposer::eOrientationDefault) { // make sure the default orientation is optimal // make sure the default orientation is optimal mOrientationTransform.reset(); mOrientationTransform.reset(); mOrientation = orientation; mGlobalTransform = mTransform; mGlobalTransform = mTransform; return NO_ERROR; return NO_ERROR; } } Loading @@ -1825,7 +1824,7 @@ status_t GraphicPlane::setOrientation(int orientation) GraphicPlane::orientationToTransfrom(orientation, w, h, GraphicPlane::orientationToTransfrom(orientation, w, h, &mOrientationTransform); &mOrientationTransform); } } mOrientation = orientation; mGlobalTransform = mOrientationTransform * mTransform; mGlobalTransform = mOrientationTransform * mTransform; return NO_ERROR; return NO_ERROR; } } Loading libs/surfaceflinger/SurfaceFlinger.h +0 −2 Original line number Original line Diff line number Diff line Loading @@ -122,7 +122,6 @@ public: void setDisplayHardware(DisplayHardware *); void setDisplayHardware(DisplayHardware *); void setTransform(const Transform& tr); void setTransform(const Transform& tr); status_t setOrientation(int orientation); status_t setOrientation(int orientation); int getOrientation() const { return mOrientation; } const DisplayHardware& displayHardware() const; const DisplayHardware& displayHardware() const; const Transform& transform() const; const Transform& transform() const; Loading @@ -134,7 +133,6 @@ private: Transform mTransform; Transform mTransform; Transform mOrientationTransform; Transform mOrientationTransform; Transform mGlobalTransform; Transform mGlobalTransform; int mOrientation; }; }; // --------------------------------------------------------------------------- // --------------------------------------------------------------------------- Loading libs/surfaceflinger/Transform.cpp +0 −19 Original line number Original line Diff line number Diff line Loading @@ -103,25 +103,6 @@ void Transform::set( float xx, float xy, mType |= 0x80000000; mType |= 0x80000000; } } void Transform::set(float radian, float x, float y) { float r00 = cosf(radian); float r01 = -sinf(radian); float r10 = sinf(radian); float r11 = cosf(radian); mTransform.set(SkMatrix::kMScaleX, SkFloatToScalar(r00)); mTransform.set(SkMatrix::kMSkewX, SkFloatToScalar(r01)); mTransform.set(SkMatrix::kMSkewY, SkFloatToScalar(r10)); mTransform.set(SkMatrix::kMScaleY, SkFloatToScalar(r11)); mTransform.set(SkMatrix::kMTransX, SkIntToScalar(x - r00*x - r01*y)); mTransform.set(SkMatrix::kMTransY, SkIntToScalar(y - r10*x - r11*y)); mType |= 0x80000000 | SkMatrix::kTranslate_Mask; } void Transform::scale(float s, float x, float y) { mTransform.postScale(s, s, x, y); mType |= 0x80000000; } void Transform::set(int tx, int ty) void Transform::set(int tx, int ty) { { if (tx | ty) { if (tx | ty) { Loading Loading
libs/surfaceflinger/LayerOrientationAnim.cpp +102 −85 Original line number Original line Diff line number Diff line Loading @@ -55,7 +55,6 @@ LayerOrientationAnim::LayerOrientationAnim( mOrientationCompleted = false; mOrientationCompleted = false; mFirstRedraw = false; mFirstRedraw = false; mLastNormalizedTime = 0; mLastNormalizedTime = 0; mLastAngle = 0; mLastScale = 0; mLastScale = 0; mNeedsBlending = false; mNeedsBlending = false; } } Loading Loading @@ -95,6 +94,10 @@ void LayerOrientationAnim::validateVisibility(const Transform&) transparentRegionScreen.clear(); transparentRegionScreen.clear(); mTransformed = true; mTransformed = true; mCanUseCopyBit = false; mCanUseCopyBit = false; copybit_device_t* copybit = mFlinger->getBlitEngine(); if (copybit) { mCanUseCopyBit = true; } } } void LayerOrientationAnim::onOrientationCompleted() void LayerOrientationAnim::onOrientationCompleted() Loading @@ -106,33 +109,35 @@ void LayerOrientationAnim::onOrientationCompleted() mFlinger->invalidateLayerVisibility(this); mFlinger->invalidateLayerVisibility(this); } } const float ROTATION = M_PI * 0.5f; const float ROTATION_FACTOR = 1.0f; // 1.0 or 2.0 const float DURATION = ms2ns(200); const float BOUNCES_PER_SECOND = 1.618f; const float BOUNCES_AMPLITUDE = (5.0f/180.f) * M_PI; void LayerOrientationAnim::onDraw(const Region& clip) const void LayerOrientationAnim::onDraw(const Region& clip) const { { // Animation... // Animation... const float MIN_SCALE = 0.5f; // FIXME: works only for portrait framebuffers const float DURATION = ms2ns(200); const Point size(getPhysicalSize()); const float BOUNCES_PER_SECOND = 1.618f; const float TARGET_SCALE = size.x * (1.0f / size.y); const float BOUNCES_AMPLITUDE = 1.0f/32.0f; const nsecs_t now = systemTime(); const nsecs_t now = systemTime(); float angle, scale, alpha; float scale, alpha; if (mOrientationCompleted) { if (mOrientationCompleted) { if (mFirstRedraw) { if (mFirstRedraw) { mFirstRedraw = false; // make a copy of what's on screen // make a copy of what's on screen copybit_image_t image; copybit_image_t image; mBitmapIn.getBitmapSurface(&image); mBitmapIn.getBitmapSurface(&image); const DisplayHardware& hw(graphicPlane(0).displayHardware()); const DisplayHardware& hw(graphicPlane(0).displayHardware()); hw.copyBackToImage(image); hw.copyBackToImage(image); // and erase the screen for this round glDisable(GL_BLEND); glDisable(GL_DITHER); glDisable(GL_SCISSOR_TEST); glClearColor(0,0,0,0); glClear(GL_COLOR_BUFFER_BIT); // FIXME: code below is gross // FIXME: code below is gross mFirstRedraw = false; mNeedsBlending = false; mNeedsBlending = false; LayerOrientationAnim* self(const_cast<LayerOrientationAnim*>(this)); LayerOrientationAnim* self(const_cast<LayerOrientationAnim*>(this)); mFlinger->invalidateLayerVisibility(self); mFlinger->invalidateLayerVisibility(self); Loading @@ -143,39 +148,36 @@ void LayerOrientationAnim::onDraw(const Region& clip) const const float normalizedTime = (float(now - mFinishTime) / duration); const float normalizedTime = (float(now - mFinishTime) / duration); if (normalizedTime <= 1.0f) { if (normalizedTime <= 1.0f) { const float squaredTime = normalizedTime*normalizedTime; const float squaredTime = normalizedTime*normalizedTime; angle = (ROTATION*ROTATION_FACTOR - mLastAngle)*squaredTime + mLastAngle; scale = (1.0f - mLastScale)*squaredTime + mLastScale; scale = (1.0f - mLastScale)*squaredTime + mLastScale; alpha = normalizedTime; alpha = (1.0f - normalizedTime); alpha *= alpha; alpha *= alpha; } else { } else { mAnim->onAnimationFinished(); mAnim->onAnimationFinished(); angle = ROTATION; alpha = 1.0f; scale = 1.0f; scale = 1.0f; alpha = 0.0f; } } } else { } else { const float normalizedTime = float(now - mStartTime) / DURATION; const float normalizedTime = float(now - mStartTime) / DURATION; if (normalizedTime <= 1.0f) { if (normalizedTime <= 1.0f) { mLastNormalizedTime = normalizedTime; mLastNormalizedTime = normalizedTime; const float squaredTime = normalizedTime*normalizedTime; const float squaredTime = normalizedTime*normalizedTime; angle = ROTATION * squaredTime; scale = (MIN_SCALE-1.0f)*squaredTime + 1.0f; scale = (TARGET_SCALE - 1.0f)*squaredTime + 1.0f; alpha = 1.0f; alpha = 0; } else { } else { mLastNormalizedTime = 1.0f; mLastNormalizedTime = 1.0f; const float to_seconds = DURATION / seconds(1); const float to_seconds = DURATION / seconds(1); const float phi = BOUNCES_PER_SECOND * const float phi = BOUNCES_PER_SECOND * (((normalizedTime - 1.0f) * to_seconds)*M_PI*2); (((normalizedTime - 1.0f) * to_seconds)*M_PI*2); angle = ROTATION + BOUNCES_AMPLITUDE * sinf(phi); scale = MIN_SCALE + BOUNCES_AMPLITUDE * (1.0f - cosf(phi)); scale = TARGET_SCALE; alpha = 1.0f; alpha = 0; } } mLastAngle = angle; mLastScale = scale; mLastScale = scale; } } drawScaled(angle, scale, alpha); drawScaled(scale, alpha); } } void LayerOrientationAnim::drawScaled(float f, float s, float alpha) const void LayerOrientationAnim::drawScaled(float f, float alpha) const { { copybit_image_t dst; copybit_image_t dst; const GraphicPlane& plane(graphicPlane(0)); const GraphicPlane& plane(graphicPlane(0)); Loading @@ -185,20 +187,47 @@ void LayerOrientationAnim::drawScaled(float f, float s, float alpha) const // clear screen // clear screen // TODO: with update on demand, we may be able // TODO: with update on demand, we may be able // to not erase the screen at all during the animation // to not erase the screen at all during the animation if (!mOrientationCompleted) { glDisable(GL_BLEND); glDisable(GL_BLEND); glDisable(GL_DITHER); glDisable(GL_DITHER); glDisable(GL_SCISSOR_TEST); glDisable(GL_SCISSOR_TEST); glClearColor(0,0,0,0); glClearColor(0,0,0,0); glClear(GL_COLOR_BUFFER_BIT); glClear(GL_COLOR_BUFFER_BIT); } const int w = dst.w; const int w = dst.w*f; const int h = dst.h; const int h = dst.h*f; const int xc = uint32_t(dst.w-w)/2; const int yc = uint32_t(dst.h-h)/2; const copybit_rect_t drect = { xc, yc, xc+w, yc+h }; copybit_image_t src; copybit_image_t src; mBitmap.getBitmapSurface(&src); mBitmap.getBitmapSurface(&src); const copybit_rect_t srect = { 0, 0, src.w, src.h }; const copybit_rect_t srect = { 0, 0, src.w, src.h }; int err = NO_ERROR; const int can_use_copybit = canUseCopybit(); if (can_use_copybit) { copybit_device_t* copybit = mFlinger->getBlitEngine(); copybit->set_parameter(copybit, COPYBIT_TRANSFORM, 0); copybit->set_parameter(copybit, COPYBIT_DITHER, COPYBIT_ENABLE); if (alpha < 1.0f) { copybit_image_t srcIn; mBitmapIn.getBitmapSurface(&srcIn); region_iterator it(Region(Rect( drect.l, drect.t, drect.r, drect.b ))); copybit->set_parameter(copybit, COPYBIT_PLANE_ALPHA, 0xFF); err = copybit->stretch(copybit, &dst, &srcIn, &drect, &srect, &it); } if (!err && alpha > 0.0f) { region_iterator it(Region(Rect( drect.l, drect.t, drect.r, drect.b ))); copybit->set_parameter(copybit, COPYBIT_PLANE_ALPHA, int(alpha*255)); err = copybit->stretch(copybit, &dst, &src, &drect, &srect, &it); } LOGE_IF(err != NO_ERROR, "copybit failed (%s)", strerror(err)); } if (!can_use_copybit || err) { GGLSurface t; GGLSurface t; t.version = sizeof(GGLSurface); t.version = sizeof(GGLSurface); t.width = src.w; t.width = src.w; Loading @@ -208,14 +237,9 @@ void LayerOrientationAnim::drawScaled(float f, float s, float alpha) const t.format = src.format; t.format = src.format; t.data = (GGLubyte*)(intptr_t(src.base) + src.offset); t.data = (GGLubyte*)(intptr_t(src.base) + src.offset); const int targetOrientation = plane.getOrientation(); if (!targetOrientation) { f = -f; } Transform tr; Transform tr; tr.set(f, w*0.5f, h*0.5f); tr.set(f,0,0,f); tr.scale(s, w*0.5f, h*0.5f); tr.set(xc, yc); // FIXME: we should not access mVertices and mDrawingState like that, // FIXME: we should not access mVertices and mDrawingState like that, // but since we control the animation, we know it's going to work okay. // but since we control the animation, we know it's going to work okay. Loading @@ -225,31 +249,12 @@ void LayerOrientationAnim::drawScaled(float f, float s, float alpha) const tr.transform(self.mVertices[1], 0, src.h); tr.transform(self.mVertices[1], 0, src.h); tr.transform(self.mVertices[2], src.w, src.h); tr.transform(self.mVertices[2], src.w, src.h); tr.transform(self.mVertices[3], src.w, 0); tr.transform(self.mVertices[3], src.w, 0); if (!(mFlags & DisplayHardware::SLOW_CONFIG)) { if (!(mFlags & DisplayHardware::SLOW_CONFIG)) { // Too slow to do this in software // Too slow to do this in software self.mDrawingState.flags |= ISurfaceComposer::eLayerFilter; self.mDrawingState.flags |= ISurfaceComposer::eLayerFilter; } } if (UNLIKELY(mTextureName == -1LU)) { if (alpha < 1.0f) { mTextureName = createTexture(); GLuint w=0, h=0; const Region dirty(Rect(t.width, t.height)); loadTexture(dirty, mTextureName, t, w, h); } self.mDrawingState.alpha = 255; //-int(alpha*255); const Region clip(Rect( srect.l, srect.t, srect.r, srect.b )); drawWithOpenGL(clip, mTextureName, t); if (alpha > 0) { const float sign = (!targetOrientation) ? 1.0f : -1.0f; tr.set(f + sign*(M_PI * 0.5f * ROTATION_FACTOR), w*0.5f, h*0.5f); tr.scale(s, w*0.5f, h*0.5f); tr.transform(self.mVertices[0], 0, 0); tr.transform(self.mVertices[1], 0, src.h); tr.transform(self.mVertices[2], src.w, src.h); tr.transform(self.mVertices[3], src.w, 0); copybit_image_t src; copybit_image_t src; mBitmapIn.getBitmapSurface(&src); mBitmapIn.getBitmapSurface(&src); t.data = (GGLubyte*)(intptr_t(src.base) + src.offset); t.data = (GGLubyte*)(intptr_t(src.base) + src.offset); Loading @@ -259,9 +264,21 @@ void LayerOrientationAnim::drawScaled(float f, float s, float alpha) const const Region dirty(Rect(t.width, t.height)); const Region dirty(Rect(t.width, t.height)); loadTexture(dirty, mTextureNameIn, t, w, h); loadTexture(dirty, mTextureNameIn, t, w, h); } } self.mDrawingState.alpha = 255; const Region clip(Rect( drect.l, drect.t, drect.r, drect.b )); drawWithOpenGL(clip, mTextureName, t); } t.data = (GGLubyte*)(intptr_t(src.base) + src.offset); if (UNLIKELY(mTextureName == -1LU)) { mTextureName = createTexture(); GLuint w=0, h=0; const Region dirty(Rect(t.width, t.height)); loadTexture(dirty, mTextureName, t, w, h); } self.mDrawingState.alpha = int(alpha*255); self.mDrawingState.alpha = int(alpha*255); const Region clip(Rect( srect.l, srect.t, srect.r, srect.b )); const Region clip(Rect( drect.l, drect.t, drect.r, drect.b )); drawWithOpenGL(clip, mTextureNameIn, t); drawWithOpenGL(clip, mTextureName, t); } } } } Loading
libs/surfaceflinger/LayerOrientationAnim.h +1 −2 Original line number Original line Diff line number Diff line Loading @@ -52,7 +52,7 @@ public: virtual bool needsBlending() const; virtual bool needsBlending() const; virtual bool isSecure() const { return false; } virtual bool isSecure() const { return false; } private: private: void drawScaled(float angle, float scale, float alpha) const; void drawScaled(float scale, float alpha) const; OrientationAnimation* mAnim; OrientationAnimation* mAnim; LayerBitmap mBitmap; LayerBitmap mBitmap; Loading @@ -62,7 +62,6 @@ private: bool mOrientationCompleted; bool mOrientationCompleted; mutable bool mFirstRedraw; mutable bool mFirstRedraw; mutable float mLastNormalizedTime; mutable float mLastNormalizedTime; mutable float mLastAngle; mutable float mLastScale; mutable float mLastScale; mutable GLuint mTextureName; mutable GLuint mTextureName; mutable GLuint mTextureNameIn; mutable GLuint mTextureNameIn; Loading
libs/surfaceflinger/SurfaceFlinger.cpp +1 −2 Original line number Original line Diff line number Diff line Loading @@ -1804,7 +1804,6 @@ status_t GraphicPlane::setOrientation(int orientation) if (orientation == ISurfaceComposer::eOrientationDefault) { if (orientation == ISurfaceComposer::eOrientationDefault) { // make sure the default orientation is optimal // make sure the default orientation is optimal mOrientationTransform.reset(); mOrientationTransform.reset(); mOrientation = orientation; mGlobalTransform = mTransform; mGlobalTransform = mTransform; return NO_ERROR; return NO_ERROR; } } Loading @@ -1825,7 +1824,7 @@ status_t GraphicPlane::setOrientation(int orientation) GraphicPlane::orientationToTransfrom(orientation, w, h, GraphicPlane::orientationToTransfrom(orientation, w, h, &mOrientationTransform); &mOrientationTransform); } } mOrientation = orientation; mGlobalTransform = mOrientationTransform * mTransform; mGlobalTransform = mOrientationTransform * mTransform; return NO_ERROR; return NO_ERROR; } } Loading
libs/surfaceflinger/SurfaceFlinger.h +0 −2 Original line number Original line Diff line number Diff line Loading @@ -122,7 +122,6 @@ public: void setDisplayHardware(DisplayHardware *); void setDisplayHardware(DisplayHardware *); void setTransform(const Transform& tr); void setTransform(const Transform& tr); status_t setOrientation(int orientation); status_t setOrientation(int orientation); int getOrientation() const { return mOrientation; } const DisplayHardware& displayHardware() const; const DisplayHardware& displayHardware() const; const Transform& transform() const; const Transform& transform() const; Loading @@ -134,7 +133,6 @@ private: Transform mTransform; Transform mTransform; Transform mOrientationTransform; Transform mOrientationTransform; Transform mGlobalTransform; Transform mGlobalTransform; int mOrientation; }; }; // --------------------------------------------------------------------------- // --------------------------------------------------------------------------- Loading
libs/surfaceflinger/Transform.cpp +0 −19 Original line number Original line Diff line number Diff line Loading @@ -103,25 +103,6 @@ void Transform::set( float xx, float xy, mType |= 0x80000000; mType |= 0x80000000; } } void Transform::set(float radian, float x, float y) { float r00 = cosf(radian); float r01 = -sinf(radian); float r10 = sinf(radian); float r11 = cosf(radian); mTransform.set(SkMatrix::kMScaleX, SkFloatToScalar(r00)); mTransform.set(SkMatrix::kMSkewX, SkFloatToScalar(r01)); mTransform.set(SkMatrix::kMSkewY, SkFloatToScalar(r10)); mTransform.set(SkMatrix::kMScaleY, SkFloatToScalar(r11)); mTransform.set(SkMatrix::kMTransX, SkIntToScalar(x - r00*x - r01*y)); mTransform.set(SkMatrix::kMTransY, SkIntToScalar(y - r10*x - r11*y)); mType |= 0x80000000 | SkMatrix::kTranslate_Mask; } void Transform::scale(float s, float x, float y) { mTransform.postScale(s, s, x, y); mType |= 0x80000000; } void Transform::set(int tx, int ty) void Transform::set(int tx, int ty) { { if (tx | ty) { if (tx | ty) { Loading