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

Side by Side Diff: src/gpu/gl/GrGLShaderBuilder.h

Issue 24853002: Make GPU coord transforms automatic (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Created 7 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 | Annotate | Revision Log
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 GrGLShaderBuilder_DEFINED 8 #ifndef GrGLShaderBuilder_DEFINED
9 #define GrGLShaderBuilder_DEFINED 9 #define GrGLShaderBuilder_DEFINED
10 10
11 #include "GrAllocator.h" 11 #include "GrAllocator.h"
12 #include "GrBackendEffectFactory.h" 12 #include "GrBackendEffectFactory.h"
13 #include "GrColor.h" 13 #include "GrColor.h"
14 #include "GrEffect.h" 14 #include "GrEffect.h"
15 #include "SkTypes.h" 15 #include "SkTypes.h"
16 #include "gl/GrGLCoordTransform.h"
16 #include "gl/GrGLSL.h" 17 #include "gl/GrGLSL.h"
17 #include "gl/GrGLUniformManager.h" 18 #include "gl/GrGLUniformManager.h"
18 19
19 #include <stdarg.h> 20 #include <stdarg.h>
20 21
21 class GrGLContextInfo; 22 class GrGLContextInfo;
22 class GrEffectStage; 23 class GrEffectStage;
23 class GrGLProgramDesc; 24 class GrGLProgramDesc;
24 25
25 /** 26 /**
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
89 idx); 90 idx);
90 } 91 }
91 92
92 uint32_t fConfigComponentMask; 93 uint32_t fConfigComponentMask;
93 char fSwizzle[5]; 94 char fSwizzle[5];
94 GrGLUniformManager::UniformHandle fSamplerUniform; 95 GrGLUniformManager::UniformHandle fSamplerUniform;
95 96
96 friend class GrGLShaderBuilder; // to call init(). 97 friend class GrGLShaderBuilder; // to call init().
97 }; 98 };
98 99
100 typedef SkTArray<GrGLCoordTransform::TransformedCoords> TransformedCoordsArr ay;
99 typedef SkTArray<TextureSampler> TextureSamplerArray; 101 typedef SkTArray<TextureSampler> TextureSamplerArray;
100 typedef GrTAllocator<GrGLShaderVar> VarArray; 102 typedef GrTAllocator<GrGLShaderVar> VarArray;
103 typedef GrBackendEffectFactory::EffectKey EffectKey;
101 104
102 enum ShaderVisibility { 105 enum ShaderVisibility {
103 kVertex_Visibility = 0x1, 106 kVertex_Visibility = 0x1,
104 kGeometry_Visibility = 0x2, 107 kGeometry_Visibility = 0x2,
105 kFragment_Visibility = 0x4, 108 kFragment_Visibility = 0x4,
106 }; 109 };
107 110
108 GrGLShaderBuilder(GrGpuGL*, 111 GrGLShaderBuilder(GrGpuGL*,
109 GrGLUniformManager&, 112 GrGLUniformManager&,
110 const GrGLProgramDesc&, 113 const GrGLProgramDesc&,
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
168 const GrGLShaderVar* args, 171 const GrGLShaderVar* args,
169 const char* body, 172 const char* body,
170 SkString* outName); 173 SkString* outName);
171 174
172 /** Add input/output variable declarations (i.e. 'varying') to the fragment shader. */ 175 /** Add input/output variable declarations (i.e. 'varying') to the fragment shader. */
173 GrGLShaderVar& fsInputAppend() { return fFSInputs.push_back(); } 176 GrGLShaderVar& fsInputAppend() { return fFSInputs.push_back(); }
174 177
175 /** Generates a EffectKey for the shader code based on the texture access pa rameters and the 178 /** Generates a EffectKey for the shader code based on the texture access pa rameters and the
176 capabilities of the GL context. This is useful for keying the shader pr ograms that may 179 capabilities of the GL context. This is useful for keying the shader pr ograms that may
177 have multiple representations, based on the type/format of textures used . */ 180 have multiple representations, based on the type/format of textures used . */
178 static GrBackendEffectFactory::EffectKey KeyForTextureAccess(const GrTexture Access&, 181 static EffectKey KeyForTextureAccess(const GrTextureAccess&, const GrGLCaps& );
179 const GrGLCaps& );
180 182
181 typedef uint8_t DstReadKey; 183 typedef uint8_t DstReadKey;
182 typedef uint8_t FragPosKey; 184 typedef uint8_t FragPosKey;
183 185
184 /** Returns a key for adding code to read the copy-of-dst color in service of effects that 186 /** Returns a key for adding code to read the copy-of-dst color in service of effects that
185 require reading the dst. It must not return 0 because 0 indicates that there is no dst 187 require reading the dst. It must not return 0 because 0 indicates that there is no dst
186 copy read at all (in which case this function should not be called). */ 188 copy read at all (in which case this function should not be called). */
187 static DstReadKey KeyForDstRead(const GrTexture* dstCopy, const GrGLCaps&); 189 static DstReadKey KeyForDstRead(const GrTexture* dstCopy, const GrGLCaps&);
188 190
189 /** Returns a key for reading the fragment location. This should only be cal led if there is an 191 /** Returns a key for reading the fragment location. This should only be cal led if there is an
(...skipping 28 matching lines...) Expand all
218 return fUniformManager.getBuilderUniform(fUniforms, u).fVariable; 220 return fUniformManager.getBuilderUniform(fUniforms, u).fVariable;
219 } 221 }
220 222
221 /** 223 /**
222 * Shortcut for getUniformVariable(u).c_str() 224 * Shortcut for getUniformVariable(u).c_str()
223 */ 225 */
224 const char* getUniformCStr(GrGLUniformManager::UniformHandle u) const { 226 const char* getUniformCStr(GrGLUniformManager::UniformHandle u) const {
225 return this->getUniformVariable(u).c_str(); 227 return this->getUniformVariable(u).c_str();
226 } 228 }
227 229
230 /**
231 * This returns a variable name to access the 2D, perspective correct versio n of the coords in
232 * the fragment shader. If the coordinates at index are 3-dimensional, it em its a perspective
233 * divide (xy / z) to convert them to 2D.
234 */
235 SkString ensureFSCoords2D(const TransformedCoordsArray&, int index);
bsalomon 2013/09/27 20:04:25 Might want to document that this may emit code int
Chris Dalton 2013/09/27 23:33:45 Done.
236
228 /** Returns a variable name that represents the position of the fragment in the FS. The position 237 /** Returns a variable name that represents the position of the fragment in the FS. The position
229 is in device space (e.g. 0,0 is the top left and pixel centers are at ha lf-integers). */ 238 is in device space (e.g. 0,0 is the top left and pixel centers are at ha lf-integers). */
230 const char* fragmentPosition(); 239 const char* fragmentPosition();
231 240
232 /** Returns the color of the destination pixel. This may be NULL if no effec t advertised 241 /** Returns the color of the destination pixel. This may be NULL if no effec t advertised
233 that it will read the destination. */ 242 that it will read the destination. */
234 const char* dstColor(); 243 const char* dstColor();
235 244
236 /** 245 /**
237 * Interfaces used by GrGLProgram. 246 * Interfaces used by GrGLProgram.
(...skipping 10 matching lines...) Expand all
248 * generated from effectStages[i]. An entry in effectStages can be NULL, in which case it is 257 * generated from effectStages[i]. An entry in effectStages can be NULL, in which case it is
249 * skipped. Moreover, if the corresponding key is GrGLEffect::NoEffectKey th en it is skipped. 258 * skipped. Moreover, if the corresponding key is GrGLEffect::NoEffectKey th en it is skipped.
250 * inOutFSColor specifies the input color to the first stage and is updated to be the 259 * inOutFSColor specifies the input color to the first stage and is updated to be the
251 * output color of the last stage. fsInOutColorKnownValue specifies whether the input color 260 * output color of the last stage. fsInOutColorKnownValue specifies whether the input color
252 * has a known constant value and is updated to refer to the status of the o utput color. 261 * has a known constant value and is updated to refer to the status of the o utput color.
253 * The handles to texture samplers for effectStage[i] are added to effectSam plerHandles[i]. The 262 * The handles to texture samplers for effectStage[i] are added to effectSam plerHandles[i]. The
254 * glEffects array is updated to contain the GrGLEffect generated for each e ntry in 263 * glEffects array is updated to contain the GrGLEffect generated for each e ntry in
255 * effectStages. 264 * effectStages.
256 */ 265 */
257 void emitEffects(const GrEffectStage* effectStages[], 266 void emitEffects(const GrEffectStage* effectStages[],
258 const GrBackendEffectFactory::EffectKey effectKeys[], 267 const EffectKey effectKeys[],
259 int effectCnt, 268 int effectCnt,
260 SkString* inOutFSColor, 269 SkString* inOutFSColor,
261 GrSLConstantVec* fsInOutColorKnownValue, 270 GrSLConstantVec* fsInOutColorKnownValue,
271 SkTArray<GrGLCoordTransform, false>* effectCoordTransformAr rays[],
262 SkTArray<GrGLUniformManager::UniformHandle, true>* effectSa mplerHandles[], 272 SkTArray<GrGLUniformManager::UniformHandle, true>* effectSa mplerHandles[],
263 GrGLEffect* glEffects[]); 273 GrGLEffect* glEffects[]);
264 274
265 const char* getColorOutputName() const; 275 const char* getColorOutputName() const;
266 const char* enableSecondaryOutput(); 276 const char* enableSecondaryOutput();
267 277
268 GrGLUniformManager::UniformHandle getRTHeightUniform() const { return fRTHei ghtUniform; } 278 GrGLUniformManager::UniformHandle getRTHeightUniform() const { return fRTHei ghtUniform; }
269 GrGLUniformManager::UniformHandle getDstCopyTopLeftUniform() const { 279 GrGLUniformManager::UniformHandle getDstCopyTopLeftUniform() const {
270 return fDstCopyTopLeftUniform; 280 return fDstCopyTopLeftUniform;
271 } 281 }
(...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after
489 GrGLUniformManager::UniformHandle fDstCopyScaleUniform; 499 GrGLUniformManager::UniformHandle fDstCopyScaleUniform;
490 GrGLUniformManager::UniformHandle fColorUniform; 500 GrGLUniformManager::UniformHandle fColorUniform;
491 GrGLUniformManager::UniformHandle fCoverageUniform; 501 GrGLUniformManager::UniformHandle fCoverageUniform;
492 502
493 bool fTopLeftFragPosRead; 503 bool fTopLeftFragPosRead;
494 504
495 SkAutoTDelete<VertexBuilder> fVertexBuilder; 505 SkAutoTDelete<VertexBuilder> fVertexBuilder;
496 }; 506 };
497 507
498 #endif 508 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698