diff options
author | John Reck <jreck@google.com> | 2018-09-20 13:00:04 -0700 |
---|---|---|
committer | John Reck <jreck@google.com> | 2018-09-20 13:41:56 -0700 |
commit | f3c724fd7c18e78b8d981b0ff35477ecbf383298 (patch) | |
tree | 5c06fb350f53d79461e1c50da96c1977e81ff058 /libs/hwui/CanvasTransform.cpp | |
parent | bd5fed399f93183eaf1ad6d69f73019713682d2d (diff) |
Make auto-dark a bit better
Handles transform of basic bitmaps
Tweak to always treat text as foreground
Test: builds, poked around with force_dark
Change-Id: I733d39e05067438335da5a7eac06111f66f1228d
Diffstat (limited to 'libs/hwui/CanvasTransform.cpp')
-rw-r--r-- | libs/hwui/CanvasTransform.cpp | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/libs/hwui/CanvasTransform.cpp b/libs/hwui/CanvasTransform.cpp index adcdc18ab418..a03b31723808 100644 --- a/libs/hwui/CanvasTransform.cpp +++ b/libs/hwui/CanvasTransform.cpp @@ -28,6 +28,7 @@ #include <cmath> #include <log/log.h> +#include <SkHighContrastFilter.h> namespace android::uirenderer { @@ -113,4 +114,20 @@ bool transformPaint(ColorTransform transform, SkPaint* paint) { return true; } +bool transformPaint(ColorTransform transform, SkPaint* paint, BitmapPalette palette) { + bool shouldInvert = false; + if (palette == BitmapPalette::Light && transform == ColorTransform::Dark) { + shouldInvert = true; + } + if (palette == BitmapPalette::Dark && transform == ColorTransform::Light) { + shouldInvert = true; + } + if (shouldInvert) { + SkHighContrastConfig config; + config.fInvertStyle = SkHighContrastConfig::InvertStyle::kInvertLightness; + paint->setColorFilter(SkHighContrastFilter::Make(config)->makeComposed(paint->refColorFilter())); + } + return shouldInvert; +} + }; // namespace android::uirenderer
\ No newline at end of file |