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

Unified Diff: src/gpu/gl/GrGLShaderBuilder.h

Issue 12547012: Make GrGLEffects use an interface to append their code. (Closed) Base URL: http://skia.googlecode.com/svn/trunk/
Patch Set: Created 7 years, 9 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/gpu/gl/GrGLProgram.cpp ('k') | src/gpu/gl/GrGLShaderBuilder.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/gpu/gl/GrGLShaderBuilder.h
===================================================================
--- src/gpu/gl/GrGLShaderBuilder.h (revision 8005)
+++ src/gpu/gl/GrGLShaderBuilder.h (working copy)
@@ -14,6 +14,8 @@
#include "gl/GrGLSL.h"
#include "gl/GrGLUniformManager.h"
+#include <stdarg.h>
+
class GrGLContextInfo;
/**
@@ -80,6 +82,34 @@
GrGLShaderBuilder(const GrGLContextInfo&, GrGLUniformManager&);
+ /**
+ * Called by GrGLEffects to add code to one of the shaders.
+ */
+ void vsCodeAppendf(const char format[], ...) SK_PRINTF_LIKE(2, 3) {
+ va_list args;
+ va_start(args, format);
+ this->codeAppendf(kVertex_ShaderType, format, args);
+ va_end(args);
+ }
+
+ void gsCodeAppendf(const char format[], ...) SK_PRINTF_LIKE(2, 3) {
+ va_list args;
+ va_start(args, format);
+ this->codeAppendf(kGeometry_ShaderType, format, args);
+ va_end(args);
+ }
+
+ void fsCodeAppendf(const char format[], ...) SK_PRINTF_LIKE(2, 3) {
+ va_list args;
+ va_start(args, format);
+ this->codeAppendf(kFragment_ShaderType, format, args);
+ va_end(args);
+ }
+
+ void vsCodeAppend(const char* str) { this->codeAppend(kVertex_ShaderType, str); }
+ void gsCodeAppend(const char* str) { this->codeAppend(kGeometry_ShaderType, str); }
+ void fsCodeAppend(const char* str) { this->codeAppend(kFragment_ShaderType, str); }
+
/** Appends a 2D texture sample with projection if necessary. coordType must either be Vec2f or
Vec3f. The latter is interpreted as projective texture coords. The vec length and swizzle
order of the result depends on the GrTextureAccess associated with the TextureSampler. */
@@ -88,15 +118,23 @@
const char* coordName,
GrSLType coordType = kVec2f_GrSLType) const;
+ /** Version of above that appends the result to the shader code rather than an SkString.
+ Currently the shader type must be kFragment */
+ void appendTextureLookup(ShaderType,
+ const TextureSampler&,
+ const char* coordName,
+ GrSLType coordType = kVec2f_GrSLType);
+
+
/** Does the work of appendTextureLookup and modulates the result by modulation. The result is
always a vec4. modulation and the swizzle specified by TextureSampler must both be vec4 or
float. If modulation is "" or NULL it this function acts as though appendTextureLookup were
called. */
- void appendTextureLookupAndModulate(SkString* out,
+ void appendTextureLookupAndModulate(ShaderType,
const char* modulation,
const TextureSampler&,
const char* coordName,
- GrSLType coordType = kVec2f_GrSLType) const;
+ GrSLType coordType = kVec2f_GrSLType);
/** Emits a helper function outside of main(). Currently ShaderType must be
kFragment_ShaderType. */
@@ -190,6 +228,9 @@
const GrGLContextInfo& ctxInfo() const { return fCtxInfo; }
private:
+ void codeAppendf(ShaderType type, const char format[], va_list args);
+ void codeAppend(ShaderType type, const char* str);
+
typedef GrTAllocator<GrGLShaderVar> VarArray;
void appendDecls(const VarArray&, SkString*) const;
@@ -209,9 +250,6 @@
VarArray fFSInputs;
SkString fGSHeader; // layout qualifiers specific to GS
VarArray fFSOutputs;
- SkString fVSCode;
- SkString fGSCode;
- SkString fFSCode;
bool fUsesGS;
private:
@@ -225,6 +263,10 @@
SkString fFSFunctions;
SkString fFSHeader;
+ SkString fFSCode;
+ SkString fVSCode;
+ SkString fGSCode;
+
bool fSetupFragPosition;
GrGLUniformManager::UniformHandle fRTHeightUniform;
« no previous file with comments | « src/gpu/gl/GrGLProgram.cpp ('k') | src/gpu/gl/GrGLShaderBuilder.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698