From 708144e828b1a549567ce50cd8ed3cda62930501 Mon Sep 17 00:00:00 2001 From: Derek Sollenberger Date: Thu, 9 May 2013 09:49:41 -0400 Subject: [PATCH] Fix bug where we incorrectly clipped the bounds to the device size. This CL also updates the documenation to make it clear that the API returns in local space, not clipped to the size of the bitmap/device. bug: 8747526 Change-Id: I389844672ce955341863f9940c3b401ab00dc1dc --- core/jni/android/graphics/Canvas.cpp | 8 +------- graphics/java/android/graphics/Canvas.java | 7 +++++-- 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/core/jni/android/graphics/Canvas.cpp b/core/jni/android/graphics/Canvas.cpp index 11c70530e96af..eb97a9cd599ba 100644 --- a/core/jni/android/graphics/Canvas.cpp +++ b/core/jni/android/graphics/Canvas.cpp @@ -964,16 +964,10 @@ static void doDrawTextDecorations(SkCanvas* canvas, jfloat x, jfloat y, jfloat l jobject bounds) { SkRect r; SkIRect ir; - bool result = canvas->getClipBounds(&r); + bool result = canvas->getClipBounds(&r); if (!result) { r.setEmpty(); - } else { - // ensure the clip is not larger than the canvas - SkRect canvasRect; - SkISize deviceSize = canvas->getDeviceSize(); - canvasRect.iset(0, 0, deviceSize.fWidth, deviceSize.fHeight); - r.intersect(canvasRect); } r.round(&ir); diff --git a/graphics/java/android/graphics/Canvas.java b/graphics/java/android/graphics/Canvas.java index 79bf54b387c06..c851844bc2d32 100644 --- a/graphics/java/android/graphics/Canvas.java +++ b/graphics/java/android/graphics/Canvas.java @@ -781,7 +781,10 @@ public class Canvas { } /** - * Retrieve the clip bounds, returning true if they are non-empty. + * Return the bounds of the current clip (in local coordinates) in the + * bounds parameter, and return true if it is non-empty. This can be useful + * in a way similar to quickReject, in that it tells you that drawing + * outside of these bounds will be clipped out. * * @param bounds Return the clip bounds here. If it is null, ignore it but * still return true if the current clip is non-empty. @@ -792,7 +795,7 @@ public class Canvas { } /** - * Retrieve the clip bounds. + * Retrieve the bounds of the current clip (in local coordinates). * * @return the clip bounds, or [0, 0, 0, 0] if the clip is empty. */