diff options
author | Florin Malita <fmalita@chromium.org> | 2017-06-19 10:21:43 -0400 |
---|---|---|
committer | Skia Commit-Bot <skia-commit-bot@chromium.org> | 2017-06-19 14:59:38 +0000 |
commit | d4a70ee36717493cc071f878b16b037463e6ce9a (patch) | |
tree | 91ee41cf719bb3e63cea243aecea2bc73a8a1c83 /src/core/SkPaintPriv.cpp | |
parent | 0bdaf05fc17ebe5d4ad01d70c80df2425e83c737 (diff) |
Disable dithering of const paints
... except for 565.
Change-Id: I8ab633661c54583478234a46942ef804eb74a619
Reviewed-on: https://skia-review.googlesource.com/19880
Commit-Queue: Florin Malita <fmalita@chromium.org>
Reviewed-by: Mike Klein <mtklein@google.com>
Reviewed-by: Brian Salomon <bsalomon@google.com>
Reviewed-by: Mike Reed <reed@google.com>
Reviewed-by: Herb Derby <herb@google.com>
Diffstat (limited to 'src/core/SkPaintPriv.cpp')
-rw-r--r-- | src/core/SkPaintPriv.cpp | 21 |
1 files changed, 20 insertions, 1 deletions
diff --git a/src/core/SkPaintPriv.cpp b/src/core/SkPaintPriv.cpp index 7dfb2e30ff..b37c28655d 100644 --- a/src/core/SkPaintPriv.cpp +++ b/src/core/SkPaintPriv.cpp @@ -10,7 +10,7 @@ #include "SkPaintPriv.h" #include "SkImage.h" #include "SkPaint.h" -#include "SkShader.h" +#include "SkShaderBase.h" #include "SkXfermodePriv.h" static bool changes_alpha(const SkPaint& paint) { @@ -69,3 +69,22 @@ void SkPaintPriv::ScaleFontMetrics(SkPaint::FontMetrics* metrics, SkScalar scale metrics->fUnderlinePosition *= scale; } +bool SkPaintPriv::ShouldDither(const SkPaint& p, SkColorType dstCT) { + // The paint dither flag can veto. + if (!p.isDither()) { + return false; + } + +#ifndef SK_SUPPORT_LEGACY_DITHERING + // We always dither 565 when requested. + if (dstCT == SkColorType::kRGB_565_SkColorType) { + return true; + } + + // Otherwise, dither is only needed for non-const paints. + return p.getImageFilter() || p.getMaskFilter() + || !p.getShader() || !as_SB(p.getShader())->isConstant(); +#else + return true; +#endif +} |