| 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 19 matching lines...) Expand all Loading... |
| 30 /* | 30 /* |
| 31 * This only has a max because GLProgramsTest needs to generate test arrays,
and these have to | 31 * This only has a max because GLProgramsTest needs to generate test arrays,
and these have to |
| 32 * be static | 32 * be static |
| 33 * TODO make this truly dynamic | 33 * TODO make this truly dynamic |
| 34 */ | 34 */ |
| 35 static const int kMaxVertexAttribs = 2; | 35 static const int kMaxVertexAttribs = 2; |
| 36 typedef SkTArray<GrShaderVar, true> VertexAttribArray; | 36 typedef SkTArray<GrShaderVar, true> VertexAttribArray; |
| 37 | 37 |
| 38 const VertexAttribArray& getVertexAttribs() const { return fVertexAttribs; } | 38 const VertexAttribArray& getVertexAttribs() const { return fVertexAttribs; } |
| 39 | 39 |
| 40 bool isEqual(const GrGeometryProcessor& that) const { |
| 41 if (&this->getFactory() != &that.getFactory()) { |
| 42 return false; |
| 43 } |
| 44 bool result = this->onIsEqual(that); |
| 45 #ifdef SK_DEBUG |
| 46 if (result) { |
| 47 this->assertTexturesEqual(that); |
| 48 } |
| 49 #endif |
| 50 return result; |
| 51 } |
| 52 |
| 40 protected: | 53 protected: |
| 41 /** | 54 /** |
| 42 * 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 |
| 43 * 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 |
| 44 * immutable. | 57 * immutable. |
| 45 */ | 58 */ |
| 46 const GrShaderVar& addVertexAttrib(const GrShaderVar& var) { | 59 const GrShaderVar& addVertexAttrib(const GrShaderVar& var) { |
| 47 SkASSERT(fVertexAttribs.count() < kMaxVertexAttribs); | 60 SkASSERT(fVertexAttribs.count() < kMaxVertexAttribs); |
| 48 return fVertexAttribs.push_back(var); | 61 return fVertexAttribs.push_back(var); |
| 49 } | 62 } |
| 50 | 63 |
| 51 private: | 64 private: |
| 65 virtual bool onIsEqual(const GrGeometryProcessor&) const = 0; |
| 66 |
| 52 SkSTArray<kMaxVertexAttribs, GrShaderVar, true> fVertexAttribs; | 67 SkSTArray<kMaxVertexAttribs, GrShaderVar, true> fVertexAttribs; |
| 53 | 68 |
| 54 typedef GrProcessor INHERITED; | 69 typedef GrProcessor INHERITED; |
| 55 }; | 70 }; |
| 56 | 71 |
| 57 /** | 72 /** |
| 58 * This creates an effect outside of the effect memory pool. The effect's destru
ctor will be called | 73 * This creates an effect outside of the effect memory pool. The effect's destru
ctor will be called |
| 59 * at global destruction time. NAME will be the name of the created GrProcessor. | 74 * at global destruction time. NAME will be the name of the created GrProcessor. |
| 60 */ | 75 */ |
| 61 #define GR_CREATE_STATIC_GEOMETRY_PROCESSOR(NAME, GP_CLASS, ARGS)
\ | 76 #define GR_CREATE_STATIC_GEOMETRY_PROCESSOR(NAME, GP_CLASS, ARGS)
\ |
| 62 static SkAlignedSStorage<sizeof(GP_CLASS)> g_##NAME##_Storage;
\ | 77 static SkAlignedSStorage<sizeof(GP_CLASS)> g_##NAME##_Storage;
\ |
| 63 static GrGeometryProcessor* NAME SkNEW_PLACEMENT_ARGS(g_##NAME##_Storage.get(),
GP_CLASS, ARGS); \ | 78 static GrGeometryProcessor* NAME SkNEW_PLACEMENT_ARGS(g_##NAME##_Storage.get(),
GP_CLASS, ARGS); \ |
| 64 static SkAutoTDestroy<GrGeometryProcessor> NAME##_ad(NAME); | 79 static SkAutoTDestroy<GrGeometryProcessor> NAME##_ad(NAME); |
| 65 | 80 |
| 66 #endif | 81 #endif |
| OLD | NEW |