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

Unified Diff: src/core/SkComposeShader.cpp

Issue 1306163002: Added TestCreate for GrComposeEffect (Closed) Base URL: https://skia.googlesource.com/skia@cs3_composeshader2
Patch Set: added #if STATIC_GLOBAL Created 5 years, 3 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/gpu/GrProcessor.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/core/SkComposeShader.cpp
diff --git a/src/core/SkComposeShader.cpp b/src/core/SkComposeShader.cpp
index 50fc6aaa392a0e1fb268fb0843ee10658261af35..d3e29be66c9cba8d08188ab31f118ac0de8fb125 100644
--- a/src/core/SkComposeShader.cpp
+++ b/src/core/SkComposeShader.cpp
@@ -198,9 +198,9 @@ void SkComposeShader::ComposeShaderContext::shadeSpan(int x, int y, SkPMColor re
#include "SkGr.h"
#include "GrProcessor.h"
+#include "effects/GrConstColorProcessor.h"
#include "gl/GrGLBlend.h"
#include "gl/builders/GrGLProgramBuilder.h"
-#include "effects/GrConstColorProcessor.h"
/////////////////////////////////////////////////////////////////////
@@ -235,6 +235,8 @@ private:
SkXfermode::Mode fMode;
+ GR_DECLARE_FRAGMENT_PROCESSOR_TEST;
+
typedef GrFragmentProcessor INHERITED;
};
@@ -250,6 +252,35 @@ private:
typedef GrGLFragmentProcessor INHERITED;
};
+/////////////////////////////////////////////////////////////////////
+
+GR_DEFINE_FRAGMENT_PROCESSOR_TEST(GrComposeEffect);
+
+const GrFragmentProcessor* GrComposeEffect::TestCreate(GrProcessorTestData* d) {
+#if SK_ALLOW_STATIC_GLOBAL_INITIALIZERS
+ // Create two random frag procs.
+ // For now, we'll prevent either children from being a shader with children to prevent the
+ // possibility of an arbitrarily large tree of procs.
+ SkAutoTUnref<const GrFragmentProcessor> fpA;
+ do {
+ fpA.reset(GrProcessorTestFactory<GrFragmentProcessor>::CreateStage(d));
+ SkASSERT(fpA);
+ } while (fpA->numChildProcessors() != 0);
+ SkAutoTUnref<const GrFragmentProcessor> fpB;
+ do {
+ fpB.reset(GrProcessorTestFactory<GrFragmentProcessor>::CreateStage(d));
+ SkASSERT(fpB);
+ } while (fpB->numChildProcessors() != 0);
+
+ SkXfermode::Mode mode = static_cast<SkXfermode::Mode>(
+ d->fRandom->nextRangeU(0, SkXfermode::kLastCoeffMode));
+ return SkNEW_ARGS(GrComposeEffect, (fpA, fpB, mode));
+#else
+ SkFAIL("Should not be called if !SK_ALLOW_STATIC_GLOBAL_INITIALIZERS");
+ return nullptr;
+#endif
+}
+
bool GrComposeEffect::onIsEqual(const GrFragmentProcessor& other) const {
const GrComposeEffect& cs = other.cast<GrComposeEffect>();
return fMode == cs.fMode;
« no previous file with comments | « no previous file | src/gpu/GrProcessor.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698