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

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

Issue 1266633003: Added registerChild; transforms, textures, glKey automatically handled. (Closed) Base URL: https://skia.googlesource.com/skia@master
Patch Set: refactored to onGetGLProcessorKey; removed emitSamplers specialized template; fixed nits Created 5 years, 4 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/GrOvalEffect.cpp ('k') | src/gpu/effects/GrSimpleTextureEffect.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 "GrRRectEffect.h" 8 #include "GrRRectEffect.h"
9 9
10 #include "GrConvexPolyEffect.h" 10 #include "GrConvexPolyEffect.h"
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
42 42
43 // The flags are used to indicate which corners are circluar (unflagged corn ers are assumed to 43 // The flags are used to indicate which corners are circluar (unflagged corn ers are assumed to
44 // be square). 44 // be square).
45 static GrFragmentProcessor* Create(GrPrimitiveEdgeType, uint32_t circularCor nerFlags, 45 static GrFragmentProcessor* Create(GrPrimitiveEdgeType, uint32_t circularCor nerFlags,
46 const SkRRect&); 46 const SkRRect&);
47 47
48 virtual ~CircularRRectEffect() {}; 48 virtual ~CircularRRectEffect() {};
49 49
50 const char* name() const override { return "CircularRRect"; } 50 const char* name() const override { return "CircularRRect"; }
51 51
52 void getGLProcessorKey(const GrGLSLCaps&, GrProcessorKeyBuilder*) const over ride;
53
54 GrGLFragmentProcessor* createGLInstance() const override; 52 GrGLFragmentProcessor* createGLInstance() const override;
55 53
56 const SkRRect& getRRect() const { return fRRect; } 54 const SkRRect& getRRect() const { return fRRect; }
57 55
58 uint32_t getCircularCornerFlags() const { return fCircularCornerFlags; } 56 uint32_t getCircularCornerFlags() const { return fCircularCornerFlags; }
59 57
60 GrPrimitiveEdgeType getEdgeType() const { return fEdgeType; } 58 GrPrimitiveEdgeType getEdgeType() const { return fEdgeType; }
61 59
62 private: 60 private:
63 CircularRRectEffect(GrPrimitiveEdgeType, uint32_t circularCornerFlags, const SkRRect&); 61 CircularRRectEffect(GrPrimitiveEdgeType, uint32_t circularCornerFlags, const SkRRect&);
64 62
63 void onGetGLProcessorKey(const GrGLSLCaps&, GrProcessorKeyBuilder*) const ov erride;
64
65 bool onIsEqual(const GrFragmentProcessor& other) const override; 65 bool onIsEqual(const GrFragmentProcessor& other) const override;
66 66
67 void onComputeInvariantOutput(GrInvariantOutput* inout) const override; 67 void onComputeInvariantOutput(GrInvariantOutput* inout) const override;
68 68
69 SkRRect fRRect; 69 SkRRect fRRect;
70 GrPrimitiveEdgeType fEdgeType; 70 GrPrimitiveEdgeType fEdgeType;
71 uint32_t fCircularCornerFlags; 71 uint32_t fCircularCornerFlags;
72 72
73 GR_DECLARE_FRAGMENT_PROCESSOR_TEST; 73 GR_DECLARE_FRAGMENT_PROCESSOR_TEST;
74 74
(...skipping 279 matching lines...) Expand 10 before | Expand all | Expand 10 after
354 SkFAIL("Should have been one of the above cases."); 354 SkFAIL("Should have been one of the above cases.");
355 } 355 }
356 pdman.set4f(fInnerRectUniform, rect.fLeft, rect.fTop, rect.fRight, rect. fBottom); 356 pdman.set4f(fInnerRectUniform, rect.fLeft, rect.fTop, rect.fRight, rect. fBottom);
357 pdman.set1f(fRadiusPlusHalfUniform, radius + 0.5f); 357 pdman.set1f(fRadiusPlusHalfUniform, radius + 0.5f);
358 fPrevRRect = rrect; 358 fPrevRRect = rrect;
359 } 359 }
360 } 360 }
361 361
362 //////////////////////////////////////////////////////////////////////////////// //////////////////// 362 //////////////////////////////////////////////////////////////////////////////// ////////////////////
363 363
364 void CircularRRectEffect::getGLProcessorKey(const GrGLSLCaps& caps, 364 void CircularRRectEffect::onGetGLProcessorKey(const GrGLSLCaps& caps,
365 GrProcessorKeyBuilder* b) const { 365 GrProcessorKeyBuilder* b) const {
366 GLCircularRRectEffect::GenKey(*this, caps, b); 366 GLCircularRRectEffect::GenKey(*this, caps, b);
367 } 367 }
368 368
369 GrGLFragmentProcessor* CircularRRectEffect::createGLInstance() const { 369 GrGLFragmentProcessor* CircularRRectEffect::createGLInstance() const {
370 return SkNEW_ARGS(GLCircularRRectEffect, (*this)); 370 return SkNEW_ARGS(GLCircularRRectEffect, (*this));
371 } 371 }
372 372
373 ////////////////////////////////////////////////////////////////////////////// 373 //////////////////////////////////////////////////////////////////////////////
374 374
375 class EllipticalRRectEffect : public GrFragmentProcessor { 375 class EllipticalRRectEffect : public GrFragmentProcessor {
376 public: 376 public:
377 static GrFragmentProcessor* Create(GrPrimitiveEdgeType, const SkRRect&); 377 static GrFragmentProcessor* Create(GrPrimitiveEdgeType, const SkRRect&);
378 378
379 virtual ~EllipticalRRectEffect() {}; 379 virtual ~EllipticalRRectEffect() {};
380 380
381 const char* name() const override { return "EllipticalRRect"; } 381 const char* name() const override { return "EllipticalRRect"; }
382 382
383 void getGLProcessorKey(const GrGLSLCaps&, GrProcessorKeyBuilder*) const over ride;
384
385 GrGLFragmentProcessor* createGLInstance() const override; 383 GrGLFragmentProcessor* createGLInstance() const override;
386 384
387 const SkRRect& getRRect() const { return fRRect; } 385 const SkRRect& getRRect() const { return fRRect; }
388 386
389 GrPrimitiveEdgeType getEdgeType() const { return fEdgeType; } 387 GrPrimitiveEdgeType getEdgeType() const { return fEdgeType; }
390 388
391 private: 389 private:
392 EllipticalRRectEffect(GrPrimitiveEdgeType, const SkRRect&); 390 EllipticalRRectEffect(GrPrimitiveEdgeType, const SkRRect&);
393 391
392 void onGetGLProcessorKey(const GrGLSLCaps&, GrProcessorKeyBuilder*) const ov erride;
393
394 bool onIsEqual(const GrFragmentProcessor& other) const override; 394 bool onIsEqual(const GrFragmentProcessor& other) const override;
395 395
396 void onComputeInvariantOutput(GrInvariantOutput* inout) const override; 396 void onComputeInvariantOutput(GrInvariantOutput* inout) const override;
397 397
398 SkRRect fRRect; 398 SkRRect fRRect;
399 GrPrimitiveEdgeType fEdgeType; 399 GrPrimitiveEdgeType fEdgeType;
400 400
401 GR_DECLARE_FRAGMENT_PROCESSOR_TEST; 401 GR_DECLARE_FRAGMENT_PROCESSOR_TEST;
402 402
403 typedef GrFragmentProcessor INHERITED; 403 typedef GrFragmentProcessor INHERITED;
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after
600 default: 600 default:
601 SkFAIL("RRect should always be simple or nine-patch."); 601 SkFAIL("RRect should always be simple or nine-patch.");
602 } 602 }
603 pdman.set4f(fInnerRectUniform, rect.fLeft, rect.fTop, rect.fRight, rect. fBottom); 603 pdman.set4f(fInnerRectUniform, rect.fLeft, rect.fTop, rect.fRight, rect. fBottom);
604 fPrevRRect = rrect; 604 fPrevRRect = rrect;
605 } 605 }
606 } 606 }
607 607
608 //////////////////////////////////////////////////////////////////////////////// //////////////////// 608 //////////////////////////////////////////////////////////////////////////////// ////////////////////
609 609
610 void EllipticalRRectEffect::getGLProcessorKey(const GrGLSLCaps& caps, 610 void EllipticalRRectEffect::onGetGLProcessorKey(const GrGLSLCaps& caps,
611 GrProcessorKeyBuilder* b) const { 611 GrProcessorKeyBuilder* b) const {
612 GLEllipticalRRectEffect::GenKey(*this, caps, b); 612 GLEllipticalRRectEffect::GenKey(*this, caps, b);
613 } 613 }
614 614
615 GrGLFragmentProcessor* EllipticalRRectEffect::createGLInstance() const { 615 GrGLFragmentProcessor* EllipticalRRectEffect::createGLInstance() const {
616 return SkNEW_ARGS(GLEllipticalRRectEffect, (*this)); 616 return SkNEW_ARGS(GLEllipticalRRectEffect, (*this));
617 } 617 }
618 618
619 ////////////////////////////////////////////////////////////////////////////// 619 //////////////////////////////////////////////////////////////////////////////
620 620
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
707 if (rrect.isNinePatch()) { 707 if (rrect.isNinePatch()) {
708 return EllipticalRRectEffect::Create(edgeType, rrect); 708 return EllipticalRRectEffect::Create(edgeType, rrect);
709 } 709 }
710 return NULL; 710 return NULL;
711 } 711 }
712 } 712 }
713 } 713 }
714 714
715 return NULL; 715 return NULL;
716 } 716 }
OLDNEW
« no previous file with comments | « src/gpu/effects/GrOvalEffect.cpp ('k') | src/gpu/effects/GrSimpleTextureEffect.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698