Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(559)

Unified Diff: gm/arithmode.cpp

Issue 1410553002: Propagate premultiplied color enforcement flag (Closed) Base URL: https://chromium.googlesource.com/skia.git@master
Patch Set: fix case Created 5 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | src/effects/SkArithmeticMode_gpu.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: gm/arithmode.cpp
diff --git a/gm/arithmode.cpp b/gm/arithmode.cpp
index 53385ea6ab58f4b39b1f557deb0e7b490f734860..1e50e892f7d5ad04ea661ba2c0964e03f3205c25 100644
--- a/gm/arithmode.cpp
+++ b/gm/arithmode.cpp
@@ -78,7 +78,7 @@ protected:
return SkString("arithmode");
}
- virtual SkISize onISize() { return SkISize::Make(640, 480); }
+ virtual SkISize onISize() { return SkISize::Make(640, 572); }
virtual void onDraw(SkCanvas* canvas) {
SkBitmap src = make_src();
@@ -122,6 +122,40 @@ protected:
k += 4;
y += SkIntToScalar(src.height() + 12);
}
+
+ // Draw two special cases to test enforcePMColor. In these cases, we
+ // draw the dst bitmap twice, the first time it is halved and inverted,
+ // leading to invalid premultiplied colors. If we enforcePMColor, these
+ // invalid values should be clamped, and will not contribute to the
+ // second draw.
+ for (int i = 0; i < 2; i++) {
+ const bool enforcePMColor = (i == 0);
+ SkScalar x = gap;
+ canvas->drawBitmap(dst, x, y, nullptr);
+ x += gap;
+ SkRect rect = SkRect::MakeXYWH(x, y, SkIntToScalar(WW), SkIntToScalar(HH));
+ canvas->saveLayer(&rect, nullptr);
+ SkXfermode* xfer1 = SkArithmeticMode::Create(0, -one / 2, 0, 1, enforcePMColor);
+ SkPaint paint1;
+ paint1.setXfermode(xfer1)->unref();
+ canvas->drawBitmap(dst, x, y, &paint1);
+ SkXfermode* xfer2 = SkArithmeticMode::Create(0, one / 2, -one, 1);
+ SkPaint paint2;
+ paint2.setXfermode(xfer2)->unref();
+ canvas->drawBitmap(dst, x, y, &paint2);
+ canvas->restore();
+ x += gap;
+
+ // Label
+ SkPaint paint;
+ paint.setTextSize(SkIntToScalar(24));
+ paint.setAntiAlias(true);
+ sk_tool_utils::set_portable_typeface(&paint);
+ SkString str(enforcePMColor ? "enforcePM" : "no enforcePM");
+ canvas->drawText(str.c_str(), str.size(), x, y + paint.getTextSize(), paint);
+
+ y += SkIntToScalar(src.height() + 12);
+ }
}
private:
« no previous file with comments | « no previous file | src/effects/SkArithmeticMode_gpu.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698