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

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

Issue 791743003: Remove GP from drawstate, revision of invariant output for GP (Closed) Base URL: https://skia.googlesource.com/skia.git@color-to-gp
Patch Set: more windows fix 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
74 /** Human-meaningful string to identify this prcoessor; may be embedded 64 /** Human-meaningful string to identify this prcoessor; may be embedded
75 in generated shader code. */ 65 in generated shader code. */
76 virtual const char* name() const = 0; 66 virtual const char* name() const = 0;
77 67
78 int numTextures() const { return fTextureAccesses.count(); } 68 int numTextures() const { return fTextureAccesses.count(); }
79 69
80 /** Returns the access pattern for the texture at index. index must be valid according to 70 /** Returns the access pattern for the texture at index. index must be valid according to
81 numTextures(). */ 71 numTextures(). */
82 const GrTextureAccess& textureAccess(int index) const { return *fTextureAcce sses[index]; } 72 const GrTextureAccess& textureAccess(int index) const { return *fTextureAcce sses[index]; }
83 73
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
125 void setWillReadFragmentPosition() { fWillReadFragmentPosition = true; } 115 void setWillReadFragmentPosition() { fWillReadFragmentPosition = true; }
126 116
127 template <typename PROC_SUBCLASS> void initClassID() { 117 template <typename PROC_SUBCLASS> void initClassID() {
128 static uint32_t kClassID = GenClassID(); 118 static uint32_t kClassID = GenClassID();
129 fClassID = kClassID; 119 fClassID = kClassID;
130 } 120 }
131 121
132 uint32_t fClassID; 122 uint32_t fClassID;
133 123
134 private: 124 private:
135 /**
136 * Subclass implements this to support getConstantColorComponents(...).
137 */
138 virtual void onComputeInvariantOutput(GrInvariantOutput* inout) const = 0;
139
140 static uint32_t GenClassID() { 125 static uint32_t GenClassID() {
141 // fCurrProcessorClassID has been initialized to kIllegalProcessorClassI D. The 126 // fCurrProcessorClassID has been initialized to kIllegalProcessorClassI D. The
142 // atomic inc returns the old value not the incremented value. So we add 127 // atomic inc returns the old value not the incremented value. So we add
143 // 1 to the returned value. 128 // 1 to the returned value.
144 uint32_t id = static_cast<uint32_t>(sk_atomic_inc(&gCurrProcessorClassID )) + 1; 129 uint32_t id = static_cast<uint32_t>(sk_atomic_inc(&gCurrProcessorClassID )) + 1;
145 if (!id) { 130 if (!id) {
146 SkFAIL("This should never wrap as it should only be called once for each GrProcessor " 131 SkFAIL("This should never wrap as it should only be called once for each GrProcessor "
147 "subclass."); 132 "subclass.");
148 } 133 }
149 return id; 134 return id;
(...skipping 13 matching lines...) Expand all
163 /** 148 /**
164 * This creates a processor outside of the memory pool. The processor's destruct or will be called 149 * This creates a processor outside of the memory pool. The processor's destruct or will be called
165 * at global destruction time. NAME will be the name of the created instance. 150 * at global destruction time. NAME will be the name of the created instance.
166 */ 151 */
167 #define GR_CREATE_STATIC_PROCESSOR(NAME, PROC_CLASS, ARGS) \ 152 #define GR_CREATE_STATIC_PROCESSOR(NAME, PROC_CLASS, ARGS) \
168 static SkAlignedSStorage<sizeof(PROC_CLASS)> g_##NAME##_Storage; \ 153 static SkAlignedSStorage<sizeof(PROC_CLASS)> g_##NAME##_Storage; \
169 static PROC_CLASS* NAME SkNEW_PLACEMENT_ARGS(g_##NAME##_Storage.get(), PROC_CLAS S, ARGS); \ 154 static PROC_CLASS* NAME SkNEW_PLACEMENT_ARGS(g_##NAME##_Storage.get(), PROC_CLAS S, ARGS); \
170 static SkAutoTDestroy<GrProcessor> NAME##_ad(NAME); 155 static SkAutoTDestroy<GrProcessor> NAME##_ad(NAME);
171 156
172 #endif 157 #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