diff options
author | Derek Sollenberger <djsollen@google.com> | 2013-05-16 09:31:27 -0400 |
---|---|---|
committer | Derek Sollenberger <djsollen@google.com> | 2013-05-16 09:31:27 -0400 |
commit | 00a33a8ce8ed8863786fa3a0cd313da57aae2af1 (patch) | |
tree | 15daef096cb0e069b9d57a9d9fe29130fd262490 /core/jni | |
parent | 94160cd1d72ee0d74ddd70298811cbe16e2ef0db (diff) | |
download | frameworks_base-00a33a8ce8ed8863786fa3a0cd313da57aae2af1.zip frameworks_base-00a33a8ce8ed8863786fa3a0cd313da57aae2af1.tar.gz frameworks_base-00a33a8ce8ed8863786fa3a0cd313da57aae2af1.tar.bz2 |
Update Canvas.getClipBounds to not account for AA clips.
This preserves the existing behavior at the SDK level while skia
investigates a more comprehensive solution.
bug: 8986473
Change-Id: Ief82dcfd47f1ba08d28d43402b3c28694f94f2e4
Diffstat (limited to 'core/jni')
-rw-r--r-- | core/jni/android/graphics/Canvas.cpp | 29 |
1 files changed, 28 insertions, 1 deletions
diff --git a/core/jni/android/graphics/Canvas.cpp b/core/jni/android/graphics/Canvas.cpp index eb97a9c..3308064 100644 --- a/core/jni/android/graphics/Canvas.cpp +++ b/core/jni/android/graphics/Canvas.cpp @@ -960,11 +960,38 @@ static void doDrawTextDecorations(SkCanvas* canvas, jfloat x, jfloat y, jfloat l env->ReleaseStringChars(text, text_); } + + // This function is a mirror of SkCanvas::getClipBounds except that it does + // not outset the edge of the clip to account for anti-aliasing. There is + // a skia bug to investigate pushing this logic into back into skia. + // (see https://code.google.com/p/skia/issues/detail?id=1303) + static bool getHardClipBounds(SkCanvas* canvas, SkRect* bounds) { + SkIRect ibounds; + if (!canvas->getClipDeviceBounds(&ibounds)) { + return false; + } + + SkMatrix inverse; + // if we can't invert the CTM, we can't return local clip bounds + if (!canvas->getTotalMatrix().invert(&inverse)) { + if (bounds) { + bounds->setEmpty(); + } + return false; + } + + if (NULL != bounds) { + SkRect r = SkRect::Make(ibounds); + inverse.mapRect(bounds, r); + } + return true; + } + static bool getClipBounds(JNIEnv* env, jobject, SkCanvas* canvas, jobject bounds) { SkRect r; SkIRect ir; - bool result = canvas->getClipBounds(&r); + bool result = getHardClipBounds(canvas, &r); if (!result) { r.setEmpty(); |