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

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

Issue 13314002: Add support for reading the dst pixel value in an effect. Use in a new effect for the kDarken xfer … (Closed) Base URL: http://skia.googlecode.com/svn/trunk/
Patch Set: Revert whitespace/comment changes accidentally made in GrGLProgramDesc.cpp 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/GrGLProgramDesc.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 8448)
+++ src/gpu/gl/GrGLShaderBuilder.h (working copy)
@@ -19,6 +19,7 @@
class GrGLContextInfo;
class GrEffectStage;
+class GrGLProgramDesc;
/**
Contains all the incremental state of a shader as it is being built,as well as helpers to
@@ -55,6 +56,8 @@
const char* swizzle() const { return fSwizzle; }
+ bool isInitialized() const { return 0 != fConfigComponentMask; }
+
private:
// The idx param is used to ensure multiple samplers within a single effect have unique
// uniform names. swizzle is a four char max string made up of chars 'r', 'g', 'b', and 'a'.
@@ -62,7 +65,8 @@
uint32_t configComponentMask,
const char* swizzle,
int idx) {
- GrAssert(0 == fConfigComponentMask);
+ GrAssert(!this->isInitialized());
+ GrAssert(0 != configComponentMask);
GrAssert(GrGLUniformManager::kInvalidUniformHandle == fSamplerUniform);
GrAssert(NULL != builder);
@@ -100,7 +104,7 @@
kFragment_ShaderType = 0x4,
};
- GrGLShaderBuilder(const GrGLContextInfo&, GrGLUniformManager&, bool explicitLocalCoords);
+ GrGLShaderBuilder(const GrGLContextInfo&, GrGLUniformManager&, const GrGLProgramDesc&);
/**
* Called by GrGLEffects to add code to one of the shaders.
@@ -172,6 +176,13 @@
static GrBackendEffectFactory::EffectKey KeyForTextureAccess(const GrTextureAccess&,
const GrGLCaps&);
+ typedef uint8_t DstReadKey;
+
+ /** Returns a key for adding code to read the copy-of-dst color in service of effects that
+ require reading the dst. It must not return 0 because 0 indicates that there is no dst
+ copy read at all. */
+ static DstReadKey KeyForDstRead(const GrTexture* dstCopy, const GrGLCaps&);
+
/** If texture swizzling is available using tex parameters then it is preferred over mangling
the generated shader code. This potentially allows greater reuse of cached shaders. */
static const GrGLenum* GetTexParamSwizzle(GrPixelConfig config, const GrGLCaps& caps);
@@ -230,6 +241,10 @@
specified explicit local coords or not in the GrDrawState. */
const GrGLShaderVar& localCoordsAttribute() const { return *fLocalCoordsVar; }
+ /** Returns the color of the destination pixel. This may be NULL if no effect advertised
+ that it will read the destination. */
+ const char* dstColor() const;
+
/**
* Are explicit local coordinates provided as input to the vertex shader.
*/
@@ -254,7 +269,17 @@
const char* fsInColor, // NULL means no incoming color
const char* fsOutColor,
SkTArray<GrGLUniformManager::UniformHandle, true>* samplerHandles);
+
GrGLUniformManager::UniformHandle getRTHeightUniform() const { return fRTHeightUniform; }
+ GrGLUniformManager::UniformHandle getDstCopyTopLeftUniform() const {
+ return fDstCopyTopLeftUniform;
+ }
+ GrGLUniformManager::UniformHandle getDstCopyScaleUniform() const {
+ return fDstCopyScaleUniform;
+ }
+ GrGLUniformManager::UniformHandle getDstCopySamplerUniform() const {
+ return fDstCopySampler.fSamplerUniform;
+ }
struct AttributePair {
void set(int index, const SkString& name) {
@@ -263,7 +288,7 @@
int fIndex;
SkString fName;
};
- const SkSTArray<10, AttributePair, true>& getEffectAttributes() const {
+ const SkTArray<AttributePair, true>& getEffectAttributes() const {
return fEffectAttributes;
}
const SkString* getEffectAttributeName(int attributeIndex) const;
@@ -296,25 +321,38 @@
VarArray fFSInputs;
SkString fGSHeader; // layout qualifiers specific to GS
VarArray fFSOutputs;
- bool fUsesGS;
private:
enum {
kNonStageIdx = -1,
};
+ // Interpretation of DstReadKey when generating code
+ enum {
+ kNoDstRead_DstReadKey = 0,
+ kYesDstRead_DstReadKeyBit = 0x1, // Set if we do a dst-copy-read.
+ kUseAlphaConfig_DstReadKeyBit = 0x2, // Set if dst-copy config is alpha only.
+ kTopLeftOrigin_DstReadKeyBit = 0x4, // Set if dst-copy origin is top-left.
+ };
+
const GrGLContextInfo& fCtxInfo;
GrGLUniformManager& fUniformManager;
int fCurrentStageIdx;
SkString fFSFunctions;
SkString fFSHeader;
+ bool fUsesGS;
+
SkString fFSCode;
SkString fVSCode;
SkString fGSCode;
bool fSetupFragPosition;
+ TextureSampler fDstCopySampler;
+
GrGLUniformManager::UniformHandle fRTHeightUniform;
+ GrGLUniformManager::UniformHandle fDstCopyTopLeftUniform;
+ GrGLUniformManager::UniformHandle fDstCopyScaleUniform;
SkSTArray<10, AttributePair, true> fEffectAttributes;
« no previous file with comments | « src/gpu/gl/GrGLProgramDesc.cpp ('k') | src/gpu/gl/GrGLShaderBuilder.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698