Merge "Fix bug on High Contrast Text : where DarkTheme is enabled && ForceDarkAllowed is true." into sc-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
d7eae488be
@@ -384,10 +384,11 @@ struct DrawImageLattice final : Op {
|
|||||||
struct DrawTextBlob final : Op {
|
struct DrawTextBlob final : Op {
|
||||||
static const auto kType = Type::DrawTextBlob;
|
static const auto kType = Type::DrawTextBlob;
|
||||||
DrawTextBlob(const SkTextBlob* blob, SkScalar x, SkScalar y, const SkPaint& paint)
|
DrawTextBlob(const SkTextBlob* blob, SkScalar x, SkScalar y, const SkPaint& paint)
|
||||||
: blob(sk_ref_sp(blob)), x(x), y(y), paint(paint) {}
|
: blob(sk_ref_sp(blob)), x(x), y(y), paint(paint), drawTextBlobMode(gDrawTextBlobMode) {}
|
||||||
sk_sp<const SkTextBlob> blob;
|
sk_sp<const SkTextBlob> blob;
|
||||||
SkScalar x, y;
|
SkScalar x, y;
|
||||||
SkPaint paint;
|
SkPaint paint;
|
||||||
|
DrawTextBlobMode drawTextBlobMode;
|
||||||
void draw(SkCanvas* c, const SkMatrix&) const { c->drawTextBlob(blob.get(), x, y, paint); }
|
void draw(SkCanvas* c, const SkMatrix&) const { c->drawTextBlob(blob.get(), x, y, paint); }
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -832,6 +833,24 @@ constexpr color_transform_fn colorTransformForOp() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template<>
|
||||||
|
constexpr color_transform_fn colorTransformForOp<DrawTextBlob>() {
|
||||||
|
return [](const void *opRaw, ColorTransform transform) {
|
||||||
|
const DrawTextBlob *op = reinterpret_cast<const DrawTextBlob*>(opRaw);
|
||||||
|
switch (op->drawTextBlobMode) {
|
||||||
|
case DrawTextBlobMode::HctOutline:
|
||||||
|
const_cast<SkPaint&>(op->paint).setColor(SK_ColorBLACK);
|
||||||
|
break;
|
||||||
|
case DrawTextBlobMode::HctInner:
|
||||||
|
const_cast<SkPaint&>(op->paint).setColor(SK_ColorWHITE);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
transformPaint(transform, const_cast<SkPaint*>(&(op->paint)));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
#define X(T) colorTransformForOp<T>(),
|
#define X(T) colorTransformForOp<T>(),
|
||||||
static const color_transform_fn color_transform_fns[] = {
|
static const color_transform_fn color_transform_fns[] = {
|
||||||
#include "DisplayListOps.in"
|
#include "DisplayListOps.in"
|
||||||
|
|||||||
@@ -110,16 +110,19 @@ public:
|
|||||||
bool darken = channelSum < (128 * 3);
|
bool darken = channelSum < (128 * 3);
|
||||||
|
|
||||||
// outline
|
// outline
|
||||||
|
gDrawTextBlobMode = DrawTextBlobMode::HctOutline;
|
||||||
Paint outlinePaint(paint);
|
Paint outlinePaint(paint);
|
||||||
simplifyPaint(darken ? SK_ColorWHITE : SK_ColorBLACK, &outlinePaint);
|
simplifyPaint(darken ? SK_ColorWHITE : SK_ColorBLACK, &outlinePaint);
|
||||||
outlinePaint.setStyle(SkPaint::kStrokeAndFill_Style);
|
outlinePaint.setStyle(SkPaint::kStrokeAndFill_Style);
|
||||||
canvas->drawGlyphs(glyphFunc, glyphCount, outlinePaint, x, y, totalAdvance);
|
canvas->drawGlyphs(glyphFunc, glyphCount, outlinePaint, x, y, totalAdvance);
|
||||||
|
|
||||||
// inner
|
// inner
|
||||||
|
gDrawTextBlobMode = DrawTextBlobMode::HctInner;
|
||||||
Paint innerPaint(paint);
|
Paint innerPaint(paint);
|
||||||
simplifyPaint(darken ? SK_ColorBLACK : SK_ColorWHITE, &innerPaint);
|
simplifyPaint(darken ? SK_ColorBLACK : SK_ColorWHITE, &innerPaint);
|
||||||
innerPaint.setStyle(SkPaint::kFill_Style);
|
innerPaint.setStyle(SkPaint::kFill_Style);
|
||||||
canvas->drawGlyphs(glyphFunc, glyphCount, innerPaint, x, y, totalAdvance);
|
canvas->drawGlyphs(glyphFunc, glyphCount, innerPaint, x, y, totalAdvance);
|
||||||
|
gDrawTextBlobMode = DrawTextBlobMode::Normal;
|
||||||
} else {
|
} else {
|
||||||
// standard draw path
|
// standard draw path
|
||||||
canvas->drawGlyphs(glyphFunc, glyphCount, paint, x, y, totalAdvance);
|
canvas->drawGlyphs(glyphFunc, glyphCount, paint, x, y, totalAdvance);
|
||||||
|
|||||||
@@ -61,6 +61,14 @@ class Bitmap;
|
|||||||
class Paint;
|
class Paint;
|
||||||
struct Typeface;
|
struct Typeface;
|
||||||
|
|
||||||
|
enum class DrawTextBlobMode {
|
||||||
|
Normal,
|
||||||
|
HctOutline,
|
||||||
|
HctInner,
|
||||||
|
};
|
||||||
|
|
||||||
|
inline DrawTextBlobMode gDrawTextBlobMode = DrawTextBlobMode::Normal;
|
||||||
|
|
||||||
class ANDROID_API Canvas {
|
class ANDROID_API Canvas {
|
||||||
public:
|
public:
|
||||||
virtual ~Canvas(){};
|
virtual ~Canvas(){};
|
||||||
|
|||||||
Reference in New Issue
Block a user