Skip to content

Commit e174ae2

Browse files
committed
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
1 parent 4b576e3 commit e174ae2

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

core/jni/android/graphics/Canvas.cpp

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020

2121
#include "SkCanvas.h"
2222
#include "SkDevice.h"
23+
#include "SkDrawFilter.h"
2324
#include "SkGraphics.h"
2425
#include "SkImageRef_GlobalPool.h"
2526
#include "SkPorterDuff.h"
@@ -784,7 +785,15 @@ class SkCanvasGlue {
784785
#define kStdUnderline_Thickness (1.0f / 18.0f)
785786

786787
static void doDrawTextDecorations(SkCanvas* canvas, jfloat x, jfloat y, jfloat length, SkPaint* paint) {
787-
uint32_t flags = paint->getFlags();
788+
uint32_t flags;
789+
SkDrawFilter* drawFilter = canvas->getDrawFilter();
790+
if (drawFilter) {
791+
SkPaint paintCopy(*paint);
792+
drawFilter->filter(&paintCopy, SkDrawFilter::kText_Type);
793+
flags = paintCopy.getFlags();
794+
} else {
795+
flags = paint->getFlags();
796+
}
788797
if (flags & (SkPaint::kUnderlineText_Flag | SkPaint::kStrikeThruText_Flag)) {
789798
SkScalar left = SkFloatToScalar(x);
790799
SkScalar right = SkFloatToScalar(x + length);

0 commit comments

Comments
 (0)