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>
This commit is contained in:
parent
cd5e7d75e9
commit
a9fd106d0c
48
gm/colorfilteralpha8.cpp
Normal file
48
gm/colorfilteralpha8.cpp
Normal file
@ -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/color4f.cpp",
|
||||||
"$_gm/colorcube.cpp",
|
"$_gm/colorcube.cpp",
|
||||||
"$_gm/coloremoji.cpp",
|
"$_gm/coloremoji.cpp",
|
||||||
|
"$_gm/colorfilteralpha8.cpp",
|
||||||
"$_gm/colorfilterimagefilter.cpp",
|
"$_gm/colorfilterimagefilter.cpp",
|
||||||
"$_gm/colorfilters.cpp",
|
"$_gm/colorfilters.cpp",
|
||||||
"$_gm/colormatrix.cpp",
|
"$_gm/colormatrix.cpp",
|
||||||
|
@ -1342,7 +1342,8 @@ void SkDraw::drawBitmap(const SkBitmap& bitmap, const SkMatrix& prematrix,
|
|||||||
SkDraw draw(*this);
|
SkDraw draw(*this);
|
||||||
draw.fMatrix = &matrix;
|
draw.fMatrix = &matrix;
|
||||||
|
|
||||||
if (bitmap.colorType() == kAlpha_8_SkColorType) {
|
if (bitmap.colorType() == kAlpha_8_SkColorType && !paint->getColorFilter() &&
|
||||||
|
!paint->getShader()) {
|
||||||
draw.drawBitmapAsMask(bitmap, *paint);
|
draw.drawBitmapAsMask(bitmap, *paint);
|
||||||
} else {
|
} else {
|
||||||
SkAutoBitmapShaderInstall install(bitmap, *paint);
|
SkAutoBitmapShaderInstall install(bitmap, *paint);
|
||||||
|
Loading…
Reference in New Issue
Block a user