diff options
author | Minkyoung Kim <sleepigmk@gmail.com> | 2021-02-05 18:55:04 +0900 |
---|---|---|
committer | John Reck <jreck@google.com> | 2021-02-22 16:39:20 +0000 |
commit | 1c5eb597fd0f13034740bff7888a0caecec7d84d (patch) | |
tree | 7d0e55fea9dd6a8491857c2f9faf5aa1e068b578 /libs/hwui/RecordingCanvas.cpp | |
parent | be75db951ad4ddb93ccca256793faa13d098e414 (diff) |
Fix bug on High Contrast Text : where DarkTheme is enabled &&
ForceDarkAllowed is true.
In this condition, text seems be bold so far.
From now, in this case, text would have black outline, white inline
color.
this is related to
https://partnerissuetracker.corp.google.com/u/1/issues/175363190.
Change-Id: Icf0048ef8d55c2e29676944c24c2050f531616d5
Merged-In: Icf0048ef8d55c2e29676944c24c2050f531616d5
Diffstat (limited to 'libs/hwui/RecordingCanvas.cpp')
-rw-r--r-- | libs/hwui/RecordingCanvas.cpp | 21 |
1 files changed, 20 insertions, 1 deletions
diff --git a/libs/hwui/RecordingCanvas.cpp b/libs/hwui/RecordingCanvas.cpp index dc467c41baed..41ecd5e49acd 100644 --- a/libs/hwui/RecordingCanvas.cpp +++ b/libs/hwui/RecordingCanvas.cpp @@ -401,10 +401,11 @@ struct DrawImageLattice final : Op { struct DrawTextBlob final : Op { static const auto kType = Type::DrawTextBlob; 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; SkScalar x, y; SkPaint paint; + DrawTextBlobMode drawTextBlobMode; void draw(SkCanvas* c, const SkMatrix&) const { c->drawTextBlob(blob.get(), x, y, paint); } }; @@ -791,6 +792,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>(), static const color_transform_fn color_transform_fns[] = { #include "DisplayListOps.in" |