OSDN Git Service

[HWUI]: fix residual line on FrameBuffer
authorhenry.uh_chen <henry.uh_chen@htc.com>
Wed, 2 Jul 2014 11:36:56 +0000 (19:36 +0800)
committerChris Craik <ccraik@google.com>
Thu, 17 Jul 2014 21:50:01 +0000 (21:50 +0000)
Symptom: If app applies animation to enlarge a bitmap, there will be an residual
         line on the screen

Root Cause: On platform which has Tile Rendering implementation (ex. Qualcomm
            CPU), startTiling() call will restrict the framebuffer region which
            GPU can affect. So the expansion of clear region by 1 will not take
            effect if startTiling region is not expanded.

Solution: Expand the startTiling region by 1, too.

Reproduce steps: Apply animation to enlarge (and then shrink) a bitmap icon.

Cherry-pick of 20adb6ce4d52b15472e7e5ee953e06cc349a827c from AOSP

Change-Id: I163b898b87b74d221dc4210b7fa657aa93c82c19

libs/hwui/OpenGLRenderer.cpp [changed mode: 0644->0755]
libs/hwui/OpenGLRenderer.h [changed mode: 0644->0755]

old mode 100644 (file)
new mode 100755 (executable)
index 7fa1975..278dd75
@@ -258,7 +258,7 @@ void OpenGLRenderer::syncState() {
     }
 }
 
-void OpenGLRenderer::startTilingCurrentClip(bool opaque) {
+void OpenGLRenderer::startTilingCurrentClip(bool opaque, bool expand) {
     if (!mSuppressTiling) {
         const Snapshot* snapshot = currentSnapshot();
 
@@ -267,14 +267,27 @@ void OpenGLRenderer::startTilingCurrentClip(bool opaque) {
             clip = &(snapshot->layer->clipRect);
         }
 
-        startTiling(*clip, getViewportHeight(), opaque);
+        startTiling(*clip, getViewportHeight(), opaque, expand);
     }
 }
 
-void OpenGLRenderer::startTiling(const Rect& clip, int windowHeight, bool opaque) {
+void OpenGLRenderer::startTiling(const Rect& clip, int windowHeight, bool opaque, bool expand) {
     if (!mSuppressTiling) {
-        mCaches.startTiling(clip.left, windowHeight - clip.bottom,
+        if(expand) {
+            // Expand the startTiling region by 1
+            int leftNotZero = (clip.left > 0) ? 1 : 0;
+            int topNotZero = (windowHeight - clip.bottom > 0) ? 1 : 0;
+
+            mCaches.startTiling(
+                clip.left - leftNotZero,
+                windowHeight - clip.bottom - topNotZero,
+                clip.right - clip.left + leftNotZero + 1,
+                clip.bottom - clip.top + topNotZero + 1,
+                opaque);
+        } else {
+            mCaches.startTiling(clip.left, windowHeight - clip.bottom,
                 clip.right - clip.left, clip.bottom - clip.top, opaque);
+        }
     }
 }
 
@@ -820,7 +833,8 @@ bool OpenGLRenderer::createFboLayer(Layer* layer, Rect& bounds, Rect& clip) {
     glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D,
             layer->getTexture(), 0);
 
-    startTilingCurrentClip(true);
+    // Expand the startTiling region by 1
+    startTilingCurrentClip(true, true);
 
     // Clear the FBO, expand the clear region by 1 to get nice bilinear filtering
     mCaches.enableScissor();
old mode 100644 (file)
new mode 100755 (executable)
index e7328be..4e7844b
@@ -491,14 +491,14 @@ private:
      * This method needs to be invoked every time getTargetFbo() is
      * bound again.
      */
-    void startTilingCurrentClip(bool opaque = false);
+    void startTilingCurrentClip(bool opaque = false, bool expand = false);
 
     /**
      * Tells the GPU what part of the screen is about to be redrawn.
      * This method needs to be invoked every time getTargetFbo() is
      * bound again.
      */
-    void startTiling(const Rect& clip, int windowHeight, bool opaque = false);
+    void startTiling(const Rect& clip, int windowHeight, bool opaque = false, bool expand = false);
 
     /**
      * Tells the GPU that we are done drawing the frame or that we