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

Side by Side Diff: include/gpu/GrXferProcessor.h

Issue 767873006: Check XpFactory equality in DrawState (Closed) Base URL: https://skia.googlesource.com/skia.git@moveXPHeader
Patch Set: Rebase 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 unified diff | Download patch
« no previous file with comments | « no previous file | include/gpu/effects/GrPorterDuffXferProcessor.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 #ifndef GrXferProcessor_DEFINED 8 #ifndef GrXferProcessor_DEFINED
9 #define GrXferProcessor_DEFINED 9 #define GrXferProcessor_DEFINED
10 10
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
47 public: 47 public:
48 virtual const GrXferProcessor* createXferProcessor() const = 0; 48 virtual const GrXferProcessor* createXferProcessor() const = 0;
49 49
50 /** 50 /**
51 * This function returns true if the GrXferProcessor generated from this fac tory will be able to 51 * This function returns true if the GrXferProcessor generated from this fac tory will be able to
52 * correctly blend when using RGB coverage. The knownColor and knownColorFla gs represent the 52 * correctly blend when using RGB coverage. The knownColor and knownColorFla gs represent the
53 * final computed color from the color stages. 53 * final computed color from the color stages.
54 */ 54 */
55 virtual bool supportsRGBCoverage(GrColor knownColor, uint32_t knownColorFlag s) const = 0; 55 virtual bool supportsRGBCoverage(GrColor knownColor, uint32_t knownColorFlag s) const = 0;
56 56
57 bool isEqual(const GrXPFactory& that) const {
58 if (this->classID() != that.classID()) {
59 return false;
60 }
61 return this->onIsEqual(that);
62 }
63
64 /**
65 * Helper for down-casting to a GrXPFactory subclass
66 */
67 template <typename T> const T& cast() const { return *static_cast<const T*>( this); }
68
69 uint32_t classID() const { SkASSERT(kIllegalXPFClassID != fClassID); return fClassID; }
70
71 protected:
72 GrXPFactory() : fClassID(kIllegalXPFClassID) {}
73
74 template <typename XPF_SUBCLASS> void initClassID() {
75 static uint32_t kClassID = GenClassID();
76 fClassID = kClassID;
77 }
78
79 uint32_t fClassID;
80
57 private: 81 private:
82 virtual bool onIsEqual(const GrXPFactory&) const = 0;
83
84 static uint32_t GenClassID() {
85 // fCurrXPFactoryID has been initialized to kIllegalXPFactoryID. The
86 // atomic inc returns the old value not the incremented value. So we add
87 // 1 to the returned value.
88 uint32_t id = static_cast<uint32_t>(sk_atomic_inc(&gCurrXPFClassID)) + 1 ;
89 if (!id) {
90 SkFAIL("This should never wrap as it should only be called once for each GrXPFactory "
91 "subclass.");
92 }
93 return id;
94 }
95
96 enum {
97 kIllegalXPFClassID = 0,
98 };
99 static int32_t gCurrXPFClassID;
100
58 typedef GrProgramElement INHERITED; 101 typedef GrProgramElement INHERITED;
59 }; 102 };
60 103
61 #endif 104 #endif
62 105
OLDNEW
« no previous file with comments | « no previous file | include/gpu/effects/GrPorterDuffXferProcessor.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698