OSDN Git Service

Merge "Sync canvas proxy CTM (b/21945972)" into mnc-dev
authorTom Hudson <tomhudson@google.com>
Wed, 24 Jun 2015 14:53:56 +0000 (14:53 +0000)
committerAndroid (Google) Code Review <android-gerrit@google.com>
Wed, 24 Jun 2015 14:53:58 +0000 (14:53 +0000)
1  2 
libs/hwui/DisplayListCanvas.cpp

@@@ -99,6 -99,14 +99,14 @@@ SkCanvas* DisplayListCanvas::asSkCanvas
      if (!mSkiaCanvasProxy) {
          mSkiaCanvasProxy.reset(new SkiaCanvasProxy(this));
      }
+     // SkCanvas instances default to identity transform, but should inherit
+     // the state of this Canvas; if this code was in the SkiaCanvasProxy
+     // constructor, we couldn't cache mSkiaCanvasProxy.
+     SkMatrix parentTransform;
+     getMatrix(&parentTransform);
+     mSkiaCanvasProxy.get()->setMatrix(parentTransform);
      return mSkiaCanvasProxy.get();
  }
  
@@@ -135,8 -143,6 +143,8 @@@ int DisplayListCanvas::saveLayer(float 
  }
  
  void DisplayListCanvas::translate(float dx, float dy) {
 +    if (dx == 0.0f && dy == 0.0f) return;
 +
      mHasDeferredTranslate = true;
      mTranslateX += dx;
      mTranslateY += dy;
  }
  
  void DisplayListCanvas::rotate(float degrees) {
 +    if (degrees == 0.0f) return;
 +
      addStateOp(new (alloc()) RotateOp(degrees));
      mState.rotate(degrees);
  }
  
  void DisplayListCanvas::scale(float sx, float sy) {
 +    if (sx == 1.0f && sy == 1.0f) return;
 +
      addStateOp(new (alloc()) ScaleOp(sx, sy));
      mState.scale(sx, sy);
  }