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: include/gpu/GrProcessor.h

Issue 794843002: Revert of Remove GP from drawstate, revision of invariant output for GP (Closed) Base URL: https://skia.googlesource.com/skia.git@color-to-gp
Patch Set: 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 | « include/gpu/GrInvariantOutput.h ('k') | include/gpu/GrXferProcessor.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 2012 Google Inc. 2 * Copyright 2012 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 GrProcessor_DEFINED 8 #ifndef GrProcessor_DEFINED
9 #define GrProcessor_DEFINED 9 #define GrProcessor_DEFINED
10 10
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
54 Dynamically allocated GrProcessors are managed by a per-thread memory pool. The ref count of an 54 Dynamically allocated GrProcessors are managed by a per-thread memory pool. The ref count of an
55 processor must reach 0 before the thread terminates and the pool is destroye d. To create a 55 processor must reach 0 before the thread terminates and the pool is destroye d. To create a
56 static processor use the helper macro GR_CREATE_STATIC_PROCESSOR declared be low. 56 static processor use the helper macro GR_CREATE_STATIC_PROCESSOR declared be low.
57 */ 57 */
58 class GrProcessor : public GrProgramElement { 58 class GrProcessor : public GrProgramElement {
59 public: 59 public:
60 SK_DECLARE_INST_COUNT(GrProcessor) 60 SK_DECLARE_INST_COUNT(GrProcessor)
61 61
62 virtual ~GrProcessor(); 62 virtual ~GrProcessor();
63 63
64 /**
65 * This function is used to perform optimizations. When called the invarient Ouput param
66 * indicate whether the input components to this processor in the FS will ha ve known values.
67 * In inout the validFlags member is a bitfield of GrColorComponentFlags. Th e isSingleComponent
68 * member indicates whether the input will be 1 or 4 bytes. The function upd ates the members of
69 * inout to indicate known values of its output. A component of the color me mber only has
70 * meaning if the corresponding bit in validFlags is set.
71 */
72 void computeInvariantOutput(GrInvariantOutput* inout) const;
73
64 /** Human-meaningful string to identify this prcoessor; may be embedded 74 /** Human-meaningful string to identify this prcoessor; may be embedded
65 in generated shader code. */ 75 in generated shader code. */
66 virtual const char* name() const = 0; 76 virtual const char* name() const = 0;
67 77
68 int numTextures() const { return fTextureAccesses.count(); } 78 int numTextures() const { return fTextureAccesses.count(); }
69 79
70 /** Returns the access pattern for the texture at index. index must be valid according to 80 /** Returns the access pattern for the texture at index. index must be valid according to
71 numTextures(). */ 81 numTextures(). */
72 const GrTextureAccess& textureAccess(int index) const { return *fTextureAcce sses[index]; } 82 const GrTextureAccess& textureAccess(int index) const { return *fTextureAcce sses[index]; }
73 83
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
115 void setWillReadFragmentPosition() { fWillReadFragmentPosition = true; } 125 void setWillReadFragmentPosition() { fWillReadFragmentPosition = true; }
116 126
117 template <typename PROC_SUBCLASS> void initClassID() { 127 template <typename PROC_SUBCLASS> void initClassID() {
118 static uint32_t kClassID = GenClassID(); 128 static uint32_t kClassID = GenClassID();
119 fClassID = kClassID; 129 fClassID = kClassID;
120 } 130 }
121 131
122 uint32_t fClassID; 132 uint32_t fClassID;
123 133
124 private: 134 private:
135 /**
136 * Subclass implements this to support getConstantColorComponents(...).
137 */
138 virtual void onComputeInvariantOutput(GrInvariantOutput* inout) const = 0;
139
125 static uint32_t GenClassID() { 140 static uint32_t GenClassID() {
126 // fCurrProcessorClassID has been initialized to kIllegalProcessorClassI D. The 141 // fCurrProcessorClassID has been initialized to kIllegalProcessorClassI D. The
127 // atomic inc returns the old value not the incremented value. So we add 142 // atomic inc returns the old value not the incremented value. So we add
128 // 1 to the returned value. 143 // 1 to the returned value.
129 uint32_t id = static_cast<uint32_t>(sk_atomic_inc(&gCurrProcessorClassID )) + 1; 144 uint32_t id = static_cast<uint32_t>(sk_atomic_inc(&gCurrProcessorClassID )) + 1;
130 if (!id) { 145 if (!id) {
131 SkFAIL("This should never wrap as it should only be called once for each GrProcessor " 146 SkFAIL("This should never wrap as it should only be called once for each GrProcessor "
132 "subclass."); 147 "subclass.");
133 } 148 }
134 return id; 149 return id;
(...skipping 13 matching lines...) Expand all
148 /** 163 /**
149 * This creates a processor outside of the memory pool. The processor's destruct or will be called 164 * This creates a processor outside of the memory pool. The processor's destruct or will be called
150 * at global destruction time. NAME will be the name of the created instance. 165 * at global destruction time. NAME will be the name of the created instance.
151 */ 166 */
152 #define GR_CREATE_STATIC_PROCESSOR(NAME, PROC_CLASS, ARGS) \ 167 #define GR_CREATE_STATIC_PROCESSOR(NAME, PROC_CLASS, ARGS) \
153 static SkAlignedSStorage<sizeof(PROC_CLASS)> g_##NAME##_Storage; \ 168 static SkAlignedSStorage<sizeof(PROC_CLASS)> g_##NAME##_Storage; \
154 static PROC_CLASS* NAME SkNEW_PLACEMENT_ARGS(g_##NAME##_Storage.get(), PROC_CLAS S, ARGS); \ 169 static PROC_CLASS* NAME SkNEW_PLACEMENT_ARGS(g_##NAME##_Storage.get(), PROC_CLAS S, ARGS); \
155 static SkAutoTDestroy<GrProcessor> NAME##_ad(NAME); 170 static SkAutoTDestroy<GrProcessor> NAME##_ad(NAME);
156 171
157 #endif 172 #endif
OLDNEW
« no previous file with comments | « include/gpu/GrInvariantOutput.h ('k') | include/gpu/GrXferProcessor.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698