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

Side by Side Diff: src/gpu/effects/GrConvexPolyEffect.cpp

Issue 654273002: Push isEqual/onIsEqual down from GrProcessor to subclasses. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 6 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 unified diff | Download patch
« no previous file with comments | « src/gpu/effects/GrConvexPolyEffect.h ('k') | src/gpu/effects/GrConvolutionEffect.h » ('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 * Copyright 2014 Google Inc. 2 * Copyright 2014 Google Inc.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 7
8 #include "gl/builders/GrGLProgramBuilder.h" 8 #include "gl/builders/GrGLProgramBuilder.h"
9 #include "GrConvexPolyEffect.h" 9 #include "GrConvexPolyEffect.h"
10 10
(...skipping 20 matching lines...) Expand all
31 31
32 GrPrimitiveEdgeType getEdgeType() const { return fEdgeType; } 32 GrPrimitiveEdgeType getEdgeType() const { return fEdgeType; }
33 33
34 virtual const GrBackendFragmentProcessorFactory& getFactory() const SK_OVERR IDE; 34 virtual const GrBackendFragmentProcessorFactory& getFactory() const SK_OVERR IDE;
35 35
36 private: 36 private:
37 AARectEffect(GrPrimitiveEdgeType edgeType, const SkRect& rect) : fRect(rect) , fEdgeType(edgeType) { 37 AARectEffect(GrPrimitiveEdgeType edgeType, const SkRect& rect) : fRect(rect) , fEdgeType(edgeType) {
38 this->setWillReadFragmentPosition(); 38 this->setWillReadFragmentPosition();
39 } 39 }
40 40
41 virtual bool onIsEqual(const GrProcessor& other) const SK_OVERRIDE { 41 virtual bool onIsEqual(const GrFragmentProcessor& other) const SK_OVERRIDE {
42 const AARectEffect& aare = other.cast<AARectEffect>(); 42 const AARectEffect& aare = other.cast<AARectEffect>();
43 return fRect == aare.fRect; 43 return fRect == aare.fRect;
44 } 44 }
45 45
46 virtual void onComputeInvariantOutput(InvariantOutput* inout) const SK_OVERR IDE { 46 virtual void onComputeInvariantOutput(InvariantOutput* inout) const SK_OVERR IDE {
47 if (fRect.isEmpty()) { 47 if (fRect.isEmpty()) {
48 // An empty rect will have no coverage anywhere. 48 // An empty rect will have no coverage anywhere.
49 inout->setToTransparentBlack(); 49 inout->setToTransparentBlack();
50 } else { 50 } else {
51 inout->mulByUnknownAlpha(); 51 inout->mulByUnknownAlpha();
(...skipping 289 matching lines...) Expand 10 before | Expand all | Expand 10 after
341 SkASSERT(n <= kMaxEdges); 341 SkASSERT(n <= kMaxEdges);
342 memcpy(fEdges, edges, 3 * n * sizeof(SkScalar)); 342 memcpy(fEdges, edges, 3 * n * sizeof(SkScalar));
343 // Outset the edges by 0.5 so that a pixel with center on an edge is 50% cov ered in the AA case 343 // Outset the edges by 0.5 so that a pixel with center on an edge is 50% cov ered in the AA case
344 // and 100% covered in the non-AA case. 344 // and 100% covered in the non-AA case.
345 for (int i = 0; i < n; ++i) { 345 for (int i = 0; i < n; ++i) {
346 fEdges[3 * i + 2] += SK_ScalarHalf; 346 fEdges[3 * i + 2] += SK_ScalarHalf;
347 } 347 }
348 this->setWillReadFragmentPosition(); 348 this->setWillReadFragmentPosition();
349 } 349 }
350 350
351 bool GrConvexPolyEffect::onIsEqual(const GrProcessor& other) const { 351 bool GrConvexPolyEffect::onIsEqual(const GrFragmentProcessor& other) const {
352 const GrConvexPolyEffect& cpe = other.cast<GrConvexPolyEffect>(); 352 const GrConvexPolyEffect& cpe = other.cast<GrConvexPolyEffect>();
353 // ignore the fact that 0 == -0 and just use memcmp. 353 // ignore the fact that 0 == -0 and just use memcmp.
354 return (cpe.fEdgeType == fEdgeType && cpe.fEdgeCount == fEdgeCount && 354 return (cpe.fEdgeType == fEdgeType && cpe.fEdgeCount == fEdgeCount &&
355 0 == memcmp(cpe.fEdges, fEdges, 3 * fEdgeCount * sizeof(SkScalar))); 355 0 == memcmp(cpe.fEdges, fEdges, 3 * fEdgeCount * sizeof(SkScalar)));
356 } 356 }
357 357
358 ////////////////////////////////////////////////////////////////////////////// 358 //////////////////////////////////////////////////////////////////////////////
359 359
360 GR_DEFINE_FRAGMENT_PROCESSOR_TEST(GrConvexPolyEffect); 360 GR_DEFINE_FRAGMENT_PROCESSOR_TEST(GrConvexPolyEffect);
361 361
362 GrFragmentProcessor* GrConvexPolyEffect::TestCreate(SkRandom* random, 362 GrFragmentProcessor* GrConvexPolyEffect::TestCreate(SkRandom* random,
363 GrContext*, 363 GrContext*,
364 const GrDrawTargetCaps& caps , 364 const GrDrawTargetCaps& caps ,
365 GrTexture*[]) { 365 GrTexture*[]) {
366 int count = random->nextULessThan(kMaxEdges) + 1; 366 int count = random->nextULessThan(kMaxEdges) + 1;
367 SkScalar edges[kMaxEdges * 3]; 367 SkScalar edges[kMaxEdges * 3];
368 for (int i = 0; i < 3 * count; ++i) { 368 for (int i = 0; i < 3 * count; ++i) {
369 edges[i] = random->nextSScalar1(); 369 edges[i] = random->nextSScalar1();
370 } 370 }
371 371
372 GrFragmentProcessor* fp; 372 GrFragmentProcessor* fp;
373 do { 373 do {
374 GrPrimitiveEdgeType edgeType = static_cast<GrPrimitiveEdgeType>( 374 GrPrimitiveEdgeType edgeType = static_cast<GrPrimitiveEdgeType>(
375 random->nextULessThan(kGrProcessorEdgeTy peCnt)); 375 random->nextULessThan(kGrProcessorEdgeTy peCnt));
376 fp = GrConvexPolyEffect::Create(edgeType, count, edges); 376 fp = GrConvexPolyEffect::Create(edgeType, count, edges);
377 } while (NULL == fp); 377 } while (NULL == fp);
378 return fp; 378 return fp;
379 } 379 }
OLDNEW
« no previous file with comments | « src/gpu/effects/GrConvexPolyEffect.h ('k') | src/gpu/effects/GrConvolutionEffect.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698