diff options
| author | Raph Levien <raph@google.com> | 2012-10-03 15:26:47 -0700 |
|---|---|---|
| committer | Raph Levien <raph@google.com> | 2012-10-03 15:26:47 -0700 |
| commit | e174ae210e4756985c17da5bf4457e2009ec5b61 (patch) | |
| tree | 6a50399943f4de2eed813d61215e92b1237b169c | |
| parent | 4b576e39f0ae8fb595843a6e442e39ca90dad51a (diff) | |
| download | frameworks_base-e174ae210e4756985c17da5bf4457e2009ec5b61.zip frameworks_base-e174ae210e4756985c17da5bf4457e2009ec5b61.tar.gz frameworks_base-e174ae210e4756985c17da5bf4457e2009ec5b61.tar.bz2 | |
Fix for testPaintFlagsDrawFilter CTS test
This fixes bug 6948776
android.graphics.cts.PaintFlagsDrawFilterTest#testPaintFlagsDrawFilter
failures on JO
When we moved the drawing of text decorations (underline, strikethrough)
from Skia to our own drawing (so we could take into account the metrics
computed by TextLayoutEngine), we just used the raw flags from the
paint, which ignored the overrides that a DrawFilter can effect.
The patch simply checks for the existence of a DrawFilter in the canvas,
and applies it to a copy of the paint where present. This will be one
extra paint copy where the filter exists, but that's expected to be rare
(other than running this CTS test, of course).
Change-Id: I664c478b73a3a1cc43599ee11bbc02c69b7a96c2
| -rw-r--r-- | core/jni/android/graphics/Canvas.cpp | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/core/jni/android/graphics/Canvas.cpp b/core/jni/android/graphics/Canvas.cpp index 2a02f7c..5d6f738 100644 --- a/core/jni/android/graphics/Canvas.cpp +++ b/core/jni/android/graphics/Canvas.cpp @@ -20,6 +20,7 @@ #include "SkCanvas.h" #include "SkDevice.h" +#include "SkDrawFilter.h" #include "SkGraphics.h" #include "SkImageRef_GlobalPool.h" #include "SkPorterDuff.h" @@ -784,7 +785,15 @@ public: #define kStdUnderline_Thickness (1.0f / 18.0f) static void doDrawTextDecorations(SkCanvas* canvas, jfloat x, jfloat y, jfloat length, SkPaint* paint) { - uint32_t flags = paint->getFlags(); + uint32_t flags; + SkDrawFilter* drawFilter = canvas->getDrawFilter(); + if (drawFilter) { + SkPaint paintCopy(*paint); + drawFilter->filter(&paintCopy, SkDrawFilter::kText_Type); + flags = paintCopy.getFlags(); + } else { + flags = paint->getFlags(); + } if (flags & (SkPaint::kUnderlineText_Flag | SkPaint::kStrikeThruText_Flag)) { SkScalar left = SkFloatToScalar(x); SkScalar right = SkFloatToScalar(x + length); |
