OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2013 Google Inc. | 2 * Copyright 2013 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 GrGeometryProcessor_DEFINED | 8 #ifndef GrGeometryProcessor_DEFINED |
9 #define GrGeometryProcessor_DEFINED | 9 #define GrGeometryProcessor_DEFINED |
10 | 10 |
(...skipping 26 matching lines...) Expand all Loading... |
37 | 37 |
38 const VertexAttribArray& getVertexAttribs() const { return fVertexAttribs; } | 38 const VertexAttribArray& getVertexAttribs() const { return fVertexAttribs; } |
39 | 39 |
40 /** Returns true if this and other processor conservatively draw identically
. It can only return | 40 /** Returns true if this and other processor conservatively draw identically
. It can only return |
41 true when the two prcoessors are of the same subclass (i.e. they return
the same object from | 41 true when the two prcoessors are of the same subclass (i.e. they return
the same object from |
42 from getFactory()). | 42 from getFactory()). |
43 A return value of true from isEqual() should not be used to test whether
the prcoessors | 43 A return value of true from isEqual() should not be used to test whether
the prcoessors |
44 would generate the same shader code. To test for identical code generati
on use the | 44 would generate the same shader code. To test for identical code generati
on use the |
45 processors' keys computed by the GrBackendEffectFactory. */ | 45 processors' keys computed by the GrBackendEffectFactory. */ |
46 bool isEqual(const GrGeometryProcessor& that) const { | 46 bool isEqual(const GrGeometryProcessor& that) const { |
47 if (&this->getFactory() != &that.getFactory()) { | 47 if (&this->getFactory() != &that.getFactory() || !this->hasSameTextureAc
cesses(that)) { |
48 return false; | 48 return false; |
49 } | 49 } |
50 bool result = this->onIsEqual(that); | 50 return this->onIsEqual(that); |
51 #ifdef SK_DEBUG | |
52 if (result) { | |
53 this->assertTexturesEqual(that); | |
54 } | |
55 #endif | |
56 return result; | |
57 } | 51 } |
58 | 52 |
59 protected: | 53 protected: |
60 /** | 54 /** |
61 * Subclasses call this from their constructor to register vertex attributes
(at most | 55 * Subclasses call this from their constructor to register vertex attributes
(at most |
62 * kMaxVertexAttribs). This must only be called from the constructor because
GrProcessors are | 56 * kMaxVertexAttribs). This must only be called from the constructor because
GrProcessors are |
63 * immutable. | 57 * immutable. |
64 */ | 58 */ |
65 const GrShaderVar& addVertexAttrib(const GrShaderVar& var) { | 59 const GrShaderVar& addVertexAttrib(const GrShaderVar& var) { |
66 SkASSERT(fVertexAttribs.count() < kMaxVertexAttribs); | 60 SkASSERT(fVertexAttribs.count() < kMaxVertexAttribs); |
67 return fVertexAttribs.push_back(var); | 61 return fVertexAttribs.push_back(var); |
68 } | 62 } |
69 | 63 |
70 private: | 64 private: |
71 virtual bool onIsEqual(const GrGeometryProcessor&) const = 0; | 65 virtual bool onIsEqual(const GrGeometryProcessor&) const = 0; |
72 | 66 |
73 SkSTArray<kMaxVertexAttribs, GrShaderVar, true> fVertexAttribs; | 67 SkSTArray<kMaxVertexAttribs, GrShaderVar, true> fVertexAttribs; |
74 | 68 |
75 typedef GrProcessor INHERITED; | 69 typedef GrProcessor INHERITED; |
76 }; | 70 }; |
77 | 71 |
78 #endif | 72 #endif |
OLD | NEW |