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

Unified Diff: include/gpu/GrProcessorUnitTest.h

Issue 783763002: Initial CL to move color / coverage off of drawstate (Closed) Base URL: https://skia.googlesource.com/skia.git@no-static-gp
Patch Set: bug fix Created 6 years 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 | « include/gpu/GrContext.h ('k') | src/gpu/GrAAConvexPathRenderer.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: include/gpu/GrProcessorUnitTest.h
diff --git a/include/gpu/GrProcessorUnitTest.h b/include/gpu/GrProcessorUnitTest.h
index 3e1601dc8e049e20c9c4110f9d917b5db4559e87..fbf4382d69533011541581d6548db4741e36cb66 100644
--- a/include/gpu/GrProcessorUnitTest.h
+++ b/include/gpu/GrProcessorUnitTest.h
@@ -8,6 +8,7 @@
#ifndef GrProcessorUnitTest_DEFINED
#define GrProcessorUnitTest_DEFINED
+#include "GrColor.h"
#include "SkRandom.h"
#include "SkTArray.h"
#include "SkTypes.h"
@@ -29,6 +30,66 @@ const SkMatrix& TestMatrix(SkRandom*);
}
+static inline GrColor GrRandomColor(SkRandom* random) {
+ // There are only a few cases of random colors which interest us
+ enum ColorMode {
+ kAllOnes_ColorMode,
+ kAllZeros_ColorMode,
+ kAlphaOne_ColorMode,
+ kRandom_ColorMode,
+ kLast_ColorMode = kRandom_ColorMode
+ };
+
+ ColorMode colorMode = ColorMode(random->nextULessThan(kLast_ColorMode + 1));
+ GrColor color;
+ switch (colorMode) {
+ case kAllOnes_ColorMode:
+ color = GrColorPackRGBA(0xFF, 0xFF, 0xFF, 0xFF);
+ break;
+ case kAllZeros_ColorMode:
+ color = GrColorPackRGBA(0, 0, 0, 0);
+ break;
+ case kAlphaOne_ColorMode:
+ color = GrColorPackRGBA(random->nextULessThan(256),
+ random->nextULessThan(256),
+ random->nextULessThan(256),
+ 0xFF);
+ break;
+ case kRandom_ColorMode:
+ uint8_t alpha = random->nextULessThan(256);
+ color = GrColorPackRGBA(random->nextRangeU(0, alpha),
+ random->nextRangeU(0, alpha),
+ random->nextRangeU(0, alpha),
+ alpha);
+ break;
+ }
+ GrColorIsPMAssert(color);
+ return color;
+}
+
+static inline uint8_t GrRandomCoverage(SkRandom* random) {
+ enum CoverageMode {
+ kZero_CoverageMode,
+ kAllOnes_CoverageMode,
+ kRandom_CoverageMode,
+ kLast_CoverageMode = kRandom_CoverageMode
+ };
+
+ CoverageMode colorMode = CoverageMode(random->nextULessThan(kLast_CoverageMode + 1));
+ uint8_t coverage;
+ switch (colorMode) {
+ case kZero_CoverageMode:
+ coverage = 0;
+ case kAllOnes_CoverageMode:
+ coverage = 0xff;
+ break;
+ case kRandom_CoverageMode:
+ coverage = random->nextULessThan(256);
+ break;
+ }
+ return coverage;
+}
+
#if SK_ALLOW_STATIC_GLOBAL_INITIALIZERS
class GrContext;
« no previous file with comments | « include/gpu/GrContext.h ('k') | src/gpu/GrAAConvexPathRenderer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698