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

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

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 | « no previous file | include/gpu/GrProcessor.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 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
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
OLDNEW
« no previous file with comments | « no previous file | include/gpu/GrProcessor.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698