diff options
-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); |