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

Side by Side 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 unified diff | Download patch
« no previous file with comments | « no previous file | src/gpu/GrProcessor.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 1
2 /* 2 /*
3 * Copyright 2006 The Android Open Source Project 3 * Copyright 2006 The Android Open Source Project
4 * 4 *
5 * Use of this source code is governed by a BSD-style license that can be 5 * Use of this source code is governed by a BSD-style license that can be
6 * found in the LICENSE file. 6 * found in the LICENSE file.
7 */ 7 */
8 8
9 9
10 #include "SkComposeShader.h" 10 #include "SkComposeShader.h"
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after
191 x += n; 191 x += n;
192 count -= n; 192 count -= n;
193 } while (count > 0); 193 } while (count > 0);
194 } 194 }
195 } 195 }
196 196
197 #if SK_SUPPORT_GPU 197 #if SK_SUPPORT_GPU
198 198
199 #include "SkGr.h" 199 #include "SkGr.h"
200 #include "GrProcessor.h" 200 #include "GrProcessor.h"
201 #include "effects/GrConstColorProcessor.h"
201 #include "gl/GrGLBlend.h" 202 #include "gl/GrGLBlend.h"
202 #include "gl/builders/GrGLProgramBuilder.h" 203 #include "gl/builders/GrGLProgramBuilder.h"
203 #include "effects/GrConstColorProcessor.h"
204 204
205 ///////////////////////////////////////////////////////////////////// 205 /////////////////////////////////////////////////////////////////////
206 206
207 class GrComposeEffect : public GrFragmentProcessor { 207 class GrComposeEffect : public GrFragmentProcessor {
208 public: 208 public:
209 209
210 static GrFragmentProcessor* Create(const GrFragmentProcessor* fpA, 210 static GrFragmentProcessor* Create(const GrFragmentProcessor* fpA,
211 const GrFragmentProcessor* fpB, SkXfermod e::Mode mode) { 211 const GrFragmentProcessor* fpB, SkXfermod e::Mode mode) {
212 return SkNEW_ARGS(GrComposeEffect, (fpA, fpB, mode)); 212 return SkNEW_ARGS(GrComposeEffect, (fpA, fpB, mode));
213 } 213 }
(...skipping 14 matching lines...) Expand all
228 SkDEBUGCODE(int shaderAChildIndex = )this->registerChildProcessor(fpA); 228 SkDEBUGCODE(int shaderAChildIndex = )this->registerChildProcessor(fpA);
229 SkDEBUGCODE(int shaderBChildIndex = )this->registerChildProcessor(fpB); 229 SkDEBUGCODE(int shaderBChildIndex = )this->registerChildProcessor(fpB);
230 SkASSERT(0 == shaderAChildIndex); 230 SkASSERT(0 == shaderAChildIndex);
231 SkASSERT(1 == shaderBChildIndex); 231 SkASSERT(1 == shaderBChildIndex);
232 } 232 }
233 233
234 GrGLFragmentProcessor* onCreateGLInstance() const override; 234 GrGLFragmentProcessor* onCreateGLInstance() const override;
235 235
236 SkXfermode::Mode fMode; 236 SkXfermode::Mode fMode;
237 237
238 GR_DECLARE_FRAGMENT_PROCESSOR_TEST;
239
238 typedef GrFragmentProcessor INHERITED; 240 typedef GrFragmentProcessor INHERITED;
239 }; 241 };
240 242
241 ///////////////////////////////////////////////////////////////////// 243 /////////////////////////////////////////////////////////////////////
242 244
243 class GrGLComposeEffect : public GrGLFragmentProcessor { 245 class GrGLComposeEffect : public GrGLFragmentProcessor {
244 public: 246 public:
245 GrGLComposeEffect(const GrProcessor& processor) {} 247 GrGLComposeEffect(const GrProcessor& processor) {}
246 248
247 void emitCode(EmitArgs&) override; 249 void emitCode(EmitArgs&) override;
248 250
249 private: 251 private:
250 typedef GrGLFragmentProcessor INHERITED; 252 typedef GrGLFragmentProcessor INHERITED;
251 }; 253 };
252 254
255 /////////////////////////////////////////////////////////////////////
256
257 GR_DEFINE_FRAGMENT_PROCESSOR_TEST(GrComposeEffect);
258
259 const GrFragmentProcessor* GrComposeEffect::TestCreate(GrProcessorTestData* d) {
260 #if SK_ALLOW_STATIC_GLOBAL_INITIALIZERS
261 // Create two random frag procs.
262 // For now, we'll prevent either children from being a shader with children to prevent the
263 // possibility of an arbitrarily large tree of procs.
264 SkAutoTUnref<const GrFragmentProcessor> fpA;
265 do {
266 fpA.reset(GrProcessorTestFactory<GrFragmentProcessor>::CreateStage(d));
267 SkASSERT(fpA);
268 } while (fpA->numChildProcessors() != 0);
269 SkAutoTUnref<const GrFragmentProcessor> fpB;
270 do {
271 fpB.reset(GrProcessorTestFactory<GrFragmentProcessor>::CreateStage(d));
272 SkASSERT(fpB);
273 } while (fpB->numChildProcessors() != 0);
274
275 SkXfermode::Mode mode = static_cast<SkXfermode::Mode>(
276 d->fRandom->nextRangeU(0, SkXfermode::kLastCoeffMode));
277 return SkNEW_ARGS(GrComposeEffect, (fpA, fpB, mode));
278 #else
279 SkFAIL("Should not be called if !SK_ALLOW_STATIC_GLOBAL_INITIALIZERS");
280 return nullptr;
281 #endif
282 }
283
253 bool GrComposeEffect::onIsEqual(const GrFragmentProcessor& other) const { 284 bool GrComposeEffect::onIsEqual(const GrFragmentProcessor& other) const {
254 const GrComposeEffect& cs = other.cast<GrComposeEffect>(); 285 const GrComposeEffect& cs = other.cast<GrComposeEffect>();
255 return fMode == cs.fMode; 286 return fMode == cs.fMode;
256 } 287 }
257 288
258 void GrComposeEffect::onComputeInvariantOutput(GrInvariantOutput* inout) const { 289 void GrComposeEffect::onComputeInvariantOutput(GrInvariantOutput* inout) const {
259 inout->setToUnknown(GrInvariantOutput::kWill_ReadInput); 290 inout->setToUnknown(GrInvariantOutput::kWill_ReadInput);
260 } 291 }
261 292
262 void GrComposeEffect::onGetGLProcessorKey(const GrGLSLCaps& caps, GrProcessorKey Builder* b) const { 293 void GrComposeEffect::onGetGLProcessorKey(const GrGLSLCaps& caps, GrProcessorKey Builder* b) const {
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
360 if (fMode) { 391 if (fMode) {
361 str->append(" Xfermode: "); 392 str->append(" Xfermode: ");
362 fMode->toString(str); 393 fMode->toString(str);
363 } 394 }
364 395
365 this->INHERITED::toString(str); 396 this->INHERITED::toString(str);
366 397
367 str->append(")"); 398 str->append(")");
368 } 399 }
369 #endif 400 #endif
OLDNEW
« 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