Loading libs/hwui/Matrix.h +3 −0 Original line number Diff line number Diff line Loading @@ -88,6 +88,9 @@ public: void copyTo(float* v) const; void copyTo(SkMatrix& v) const; /** * Does not apply rotations! */ void mapRect(Rect& r) const; float getTranslateX(); Loading libs/hwui/OpenGLRenderer.cpp +10 −5 Original line number Diff line number Diff line Loading @@ -406,7 +406,7 @@ bool OpenGLRenderer::quickReject(float left, float top, float right, float botto } bool OpenGLRenderer::clipRect(float left, float top, float right, float bottom) { bool clipped = mSnapshot->clipRect.intersect(left, top, right, bottom); bool clipped = mSnapshot->clip(left, top, right, bottom); if (clipped) { mSnapshot->flags |= Snapshot::kFlagClipSet; setScissorFromClip(); Loading Loading @@ -492,8 +492,8 @@ void OpenGLRenderer::drawPatch(SkBitmap* bitmap, Res_png_9patch* patch, } void OpenGLRenderer::drawColor(int color, SkXfermode::Mode mode) { const Rect& clip = mSnapshot->clipRect; drawColorRect(clip.left, clip.top, clip.right, clip.bottom, color, mode); const Rect& clip = mSnapshot->getMappedClip(); drawColorRect(clip.left, clip.top, clip.right, clip.bottom, color, mode, true); } void OpenGLRenderer::drawRect(float left, float top, float right, float bottom, const SkPaint* p) { Loading Loading @@ -524,7 +524,7 @@ void OpenGLRenderer::drawRect(float left, float top, float right, float bottom, /////////////////////////////////////////////////////////////////////////////// void OpenGLRenderer::drawColorRect(float left, float top, float right, float bottom, int color, SkXfermode::Mode mode) { int color, SkXfermode::Mode mode, bool ignoreTransform) { const int alpha = (color >> 24) & 0xFF; const GLfloat a = alpha / 255.0f; const GLfloat r = ((color >> 16) & 0xFF) / 255.0f; Loading @@ -538,7 +538,12 @@ void OpenGLRenderer::drawColorRect(float left, float top, float right, float bot mModelView.scale(right - left, bottom - top, 1.0f); const bool inUse = useShader(mDrawColorShader); if (!ignoreTransform) { mDrawColorShader->set(mOrthoMatrix, mModelView, mSnapshot->transform); } else { mat4 identity; mDrawColorShader->set(mOrthoMatrix, mModelView, identity); } if (!inUse) { const GLvoid* p = &gDrawColorVertices[0].position[0]; Loading libs/hwui/OpenGLRenderer.h +2 −1 Original line number Diff line number Diff line Loading @@ -160,9 +160,10 @@ private: * @param bottom The bottom coordinate of the rectangle * @param color The rectangle's ARGB color, defined as a packed 32 bits word * @param mode The Skia xfermode to use * @param ignoreTransform True if the current transform should be ignored */ void drawColorRect(float left, float top, float right, float bottom, int color, SkXfermode::Mode mode); int color, SkXfermode::Mode mode, bool ignoreTransform = false); /** * Draws a textured rectangle with the specified texture. The specified coordinates Loading libs/hwui/Snapshot.h +11 −1 Original line number Diff line number Diff line Loading @@ -56,6 +56,8 @@ public: previous(s), layer(NULL), fbo(s->fbo) { mappedClip.set(s->clipRect); transform.mapRect(mappedClip); } /** Loading Loading @@ -87,12 +89,20 @@ public: * Returns the current clip region mapped by the current transform. */ const Rect& getMappedClip() { return mappedClip; } /** * Intersects the current clip with the new clip rectangle. */ bool clip(float left, float top, float right, float bottom) { bool clipped = clipRect.intersect(left, top, right, bottom); if (flags & kFlagDirtyTransform) { flags &= ~kFlagDirtyTransform; mappedClip.set(clipRect); transform.mapRect(mappedClip); } return mappedClip; return clipped; } /** Loading tests/HwAccelerationTest/AndroidManifest.xml +9 −0 Original line number Diff line number Diff line Loading @@ -88,5 +88,14 @@ </intent-filter> </activity> <activity android:name="RotationActivity" android:label="_Rotation"> <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> </application> </manifest> Loading
libs/hwui/Matrix.h +3 −0 Original line number Diff line number Diff line Loading @@ -88,6 +88,9 @@ public: void copyTo(float* v) const; void copyTo(SkMatrix& v) const; /** * Does not apply rotations! */ void mapRect(Rect& r) const; float getTranslateX(); Loading
libs/hwui/OpenGLRenderer.cpp +10 −5 Original line number Diff line number Diff line Loading @@ -406,7 +406,7 @@ bool OpenGLRenderer::quickReject(float left, float top, float right, float botto } bool OpenGLRenderer::clipRect(float left, float top, float right, float bottom) { bool clipped = mSnapshot->clipRect.intersect(left, top, right, bottom); bool clipped = mSnapshot->clip(left, top, right, bottom); if (clipped) { mSnapshot->flags |= Snapshot::kFlagClipSet; setScissorFromClip(); Loading Loading @@ -492,8 +492,8 @@ void OpenGLRenderer::drawPatch(SkBitmap* bitmap, Res_png_9patch* patch, } void OpenGLRenderer::drawColor(int color, SkXfermode::Mode mode) { const Rect& clip = mSnapshot->clipRect; drawColorRect(clip.left, clip.top, clip.right, clip.bottom, color, mode); const Rect& clip = mSnapshot->getMappedClip(); drawColorRect(clip.left, clip.top, clip.right, clip.bottom, color, mode, true); } void OpenGLRenderer::drawRect(float left, float top, float right, float bottom, const SkPaint* p) { Loading Loading @@ -524,7 +524,7 @@ void OpenGLRenderer::drawRect(float left, float top, float right, float bottom, /////////////////////////////////////////////////////////////////////////////// void OpenGLRenderer::drawColorRect(float left, float top, float right, float bottom, int color, SkXfermode::Mode mode) { int color, SkXfermode::Mode mode, bool ignoreTransform) { const int alpha = (color >> 24) & 0xFF; const GLfloat a = alpha / 255.0f; const GLfloat r = ((color >> 16) & 0xFF) / 255.0f; Loading @@ -538,7 +538,12 @@ void OpenGLRenderer::drawColorRect(float left, float top, float right, float bot mModelView.scale(right - left, bottom - top, 1.0f); const bool inUse = useShader(mDrawColorShader); if (!ignoreTransform) { mDrawColorShader->set(mOrthoMatrix, mModelView, mSnapshot->transform); } else { mat4 identity; mDrawColorShader->set(mOrthoMatrix, mModelView, identity); } if (!inUse) { const GLvoid* p = &gDrawColorVertices[0].position[0]; Loading
libs/hwui/OpenGLRenderer.h +2 −1 Original line number Diff line number Diff line Loading @@ -160,9 +160,10 @@ private: * @param bottom The bottom coordinate of the rectangle * @param color The rectangle's ARGB color, defined as a packed 32 bits word * @param mode The Skia xfermode to use * @param ignoreTransform True if the current transform should be ignored */ void drawColorRect(float left, float top, float right, float bottom, int color, SkXfermode::Mode mode); int color, SkXfermode::Mode mode, bool ignoreTransform = false); /** * Draws a textured rectangle with the specified texture. The specified coordinates Loading
libs/hwui/Snapshot.h +11 −1 Original line number Diff line number Diff line Loading @@ -56,6 +56,8 @@ public: previous(s), layer(NULL), fbo(s->fbo) { mappedClip.set(s->clipRect); transform.mapRect(mappedClip); } /** Loading Loading @@ -87,12 +89,20 @@ public: * Returns the current clip region mapped by the current transform. */ const Rect& getMappedClip() { return mappedClip; } /** * Intersects the current clip with the new clip rectangle. */ bool clip(float left, float top, float right, float bottom) { bool clipped = clipRect.intersect(left, top, right, bottom); if (flags & kFlagDirtyTransform) { flags &= ~kFlagDirtyTransform; mappedClip.set(clipRect); transform.mapRect(mappedClip); } return mappedClip; return clipped; } /** Loading
tests/HwAccelerationTest/AndroidManifest.xml +9 −0 Original line number Diff line number Diff line Loading @@ -88,5 +88,14 @@ </intent-filter> </activity> <activity android:name="RotationActivity" android:label="_Rotation"> <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> </application> </manifest>