diff options
author | Matt Sarett <msarett@google.com> | 2016-10-28 13:25:40 -0400 |
---|---|---|
committer | Skia Commit-Bot <skia-commit-bot@chromium.org> | 2016-10-31 14:42:52 +0000 |
commit | a9fd106d0c4dd5449c607add0716db7bbd81bc73 (patch) | |
tree | ec415318b93882559750dc46ffb6d788ee8023d3 | |
parent | cd5e7d75e96922d041cca9f10486e4f02974a545 (diff) |
Draw Alpha8 + color filter correctly in software
This makes the behavior match our gpu backend.
BUG=android:31019366
GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=3979
Change-Id: I941623d0bdf54f61aafb1383de46bbedceb7578d
Reviewed-on: https://skia-review.googlesource.com/3979
Reviewed-by: Mike Klein <mtklein@chromium.org>
Commit-Queue: Matt Sarett <msarett@google.com>
-rw-r--r-- | gm/colorfilteralpha8.cpp | 48 | ||||
-rw-r--r-- | gn/gm.gni | 1 | ||||
-rw-r--r-- | src/core/SkDraw.cpp | 3 |
3 files changed, 51 insertions, 1 deletions
diff --git a/gm/colorfilteralpha8.cpp b/gm/colorfilteralpha8.cpp new file mode 100644 index 0000000000..08514108e4 --- /dev/null +++ b/gm/colorfilteralpha8.cpp @@ -0,0 +1,48 @@ +/* + * Copyright 2016 Google Inc. + * + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#include "gm.h" +#include "SkBitmap.h" +#include "SkColorFilter.h" + +class ColorFilterAlpha8 : public skiagm::GM { +public: + ColorFilterAlpha8() {} + +protected: + SkString onShortName() override { + return SkString("colorfilteralpha8"); + } + + SkISize onISize() override { + return SkISize::Make(400, 400); + } + + void onDraw(SkCanvas* canvas) override { + canvas->clear(SK_ColorRED); + + SkBitmap bitmap; + SkImageInfo info = SkImageInfo::MakeA8(200, 200); + bitmap.allocPixels(info); + bitmap.eraseColor(0x88FFFFFF); + + SkPaint paint; + float opaqueGrayMatrix[20] = { + 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, + 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, + 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, + 0.0f, 0.0f, 0.0f, 0.0f, 255.0f + }; + paint.setColorFilter(SkColorFilter::MakeMatrixFilterRowMajor255(opaqueGrayMatrix)); + + canvas->drawBitmap(bitmap, 100.0f, 100.0f, &paint); + } + +private: + typedef skiagm::GM INHERITED; +}; +DEF_GM( return new ColorFilterAlpha8; ) @@ -59,6 +59,7 @@ gm_sources = [ "$_gm/color4f.cpp", "$_gm/colorcube.cpp", "$_gm/coloremoji.cpp", + "$_gm/colorfilteralpha8.cpp", "$_gm/colorfilterimagefilter.cpp", "$_gm/colorfilters.cpp", "$_gm/colormatrix.cpp", diff --git a/src/core/SkDraw.cpp b/src/core/SkDraw.cpp index 44e31c4872..a3c2dff4ec 100644 --- a/src/core/SkDraw.cpp +++ b/src/core/SkDraw.cpp @@ -1342,7 +1342,8 @@ void SkDraw::drawBitmap(const SkBitmap& bitmap, const SkMatrix& prematrix, SkDraw draw(*this); draw.fMatrix = &matrix; - if (bitmap.colorType() == kAlpha_8_SkColorType) { + if (bitmap.colorType() == kAlpha_8_SkColorType && !paint->getColorFilter() && + !paint->getShader()) { draw.drawBitmapAsMask(bitmap, *paint); } else { SkAutoBitmapShaderInstall install(bitmap, *paint); |