From e174ae210e4756985c17da5bf4457e2009ec5b61 Mon Sep 17 00:00:00 2001 From: Raph Levien Date: Wed, 3 Oct 2012 15:26:47 -0700 Subject: 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 --- core/jni/android/graphics/Canvas.cpp | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/core/jni/android/graphics/Canvas.cpp b/core/jni/android/graphics/Canvas.cpp index 2a02f7c82eba..5d6f73849b8c 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); -- cgit v1.2.3-59-g8ed1b