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

Unified Diff: gm/dstreadshuffle.cpp

Issue 1085443005: remove randomness in dstreadshuffle (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: adding comment Created 5 years, 8 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 | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: gm/dstreadshuffle.cpp
diff --git a/gm/dstreadshuffle.cpp b/gm/dstreadshuffle.cpp
index 5a7768590c39405c7f060a763a76682d80d1a73b..756e922ea9cc55ef2cbf01ff7c06a13eb010fd62 100644
--- a/gm/dstreadshuffle.cpp
+++ b/gm/dstreadshuffle.cpp
@@ -94,24 +94,32 @@ protected:
}
}
- static SkColor GetColor(SkRandom* random, int i) {
+ static SkColor GetColor(SkRandom* random, int i, int nextColor) {
+ static SkColor colors[] = { SK_ColorRED,
+ 0xFFFF7F00, // Orange
+ SK_ColorYELLOW,
+ SK_ColorGREEN,
+ SK_ColorBLUE,
+ 0xFF4B0082, // indigo
+ 0xFF7F00FF }; // violet
SkColor color;
+ int index = nextColor % SK_ARRAY_COUNT(colors);
switch (i) {
case 0:
color = SK_ColorTRANSPARENT;
break;
case 1:
color = SkColorSetARGB(0xff,
- random->nextULessThan(256),
- random->nextULessThan(256),
- random->nextULessThan(256));
+ SkColorGetR(colors[index]),
+ SkColorGetG(colors[index]),
+ SkColorGetB(colors[index]));
break;
default:
- uint8_t alpha = random->nextULessThan(256);
+ uint8_t alpha = 0x80;
color = SkColorSetARGB(alpha,
- random->nextRangeU(0, alpha),
- random->nextRangeU(0, alpha),
- random->nextRangeU(0, alpha));
+ SkColorGetR(colors[index]),
+ SkColorGetG(colors[index]),
+ SkColorGetB(colors[index]));
break;
}
return color;
@@ -143,12 +151,14 @@ protected:
for (int width = 0; width <= 1; width++) {
for (int alpha = 0; alpha <= 2; alpha++) {
for (int r = 0; r <= 5; r++) {
- SkColor color = GetColor(&random, alpha);
+ SkColor color = GetColor(&random, alpha, style + width + alpha + r);
SkPaint p;
p.setAntiAlias(true);
p.setColor(color);
- p.setXfermodeMode(r % 3 == 0 ? SkXfermode::kHardLight_Mode :
+ // In order to get some batching on the GPU backend we do 2 src over for
+ // each xfer mode which requires a dst read
+ p.setXfermodeMode(r % 3 == 0 ? SkXfermode::kLighten_Mode :
SkXfermode::kSrcOver_Mode);
SetStyle(&p, style, width);
canvas->save();
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698