diff options
author | 2015-10-28 07:26:40 -0700 | |
---|---|---|
committer | 2015-10-28 07:26:40 -0700 | |
commit | 018fb62d12d1febf121fe265da5b6117b86a6541 (patch) | |
tree | 61d845716f03c05ea86aab539fcc5035b5f30734 /src/gpu/gl | |
parent | fe6876280f6d79deb6a3f9d5a75f90a937e9026f (diff) |
Create GLSL base class for ProgramDataManager
BUG=skia:
Review URL: https://codereview.chromium.org/1428543003
Diffstat (limited to 'src/gpu/gl')
-rw-r--r-- | src/gpu/gl/GrGLFragmentProcessor.cpp | 2 | ||||
-rw-r--r-- | src/gpu/gl/GrGLFragmentProcessor.h | 10 | ||||
-rw-r--r-- | src/gpu/gl/GrGLGeometryProcessor.h | 6 | ||||
-rw-r--r-- | src/gpu/gl/GrGLGpuProgramCache.cpp | 3 | ||||
-rw-r--r-- | src/gpu/gl/GrGLPathRendering.cpp | 4 | ||||
-rw-r--r-- | src/gpu/gl/GrGLPathRendering.h | 2 | ||||
-rw-r--r-- | src/gpu/gl/GrGLPrimitiveProcessor.h | 13 | ||||
-rw-r--r-- | src/gpu/gl/GrGLProcessor.h | 5 | ||||
-rw-r--r-- | src/gpu/gl/GrGLProgram.cpp | 2 | ||||
-rw-r--r-- | src/gpu/gl/GrGLProgram.h | 5 | ||||
-rw-r--r-- | src/gpu/gl/GrGLProgramDataManager.cpp | 34 | ||||
-rw-r--r-- | src/gpu/gl/GrGLProgramDataManager.h | 61 | ||||
-rw-r--r-- | src/gpu/gl/GrGLUtil.cpp | 6 | ||||
-rw-r--r-- | src/gpu/gl/GrGLUtil.h | 2 | ||||
-rw-r--r-- | src/gpu/gl/GrGLXferProcessor.cpp | 7 | ||||
-rw-r--r-- | src/gpu/gl/GrGLXferProcessor.h | 11 | ||||
-rw-r--r-- | src/gpu/gl/builders/GrGLProgramBuilder.cpp | 5 | ||||
-rw-r--r-- | src/gpu/gl/builders/GrGLProgramBuilder.h | 4 |
18 files changed, 85 insertions, 97 deletions
diff --git a/src/gpu/gl/GrGLFragmentProcessor.cpp b/src/gpu/gl/GrGLFragmentProcessor.cpp index 225e5bffff..5f30262508 100644 --- a/src/gpu/gl/GrGLFragmentProcessor.cpp +++ b/src/gpu/gl/GrGLFragmentProcessor.cpp @@ -10,7 +10,7 @@ #include "builders/GrGLFragmentShaderBuilder.h" #include "builders/GrGLProgramBuilder.h" -void GrGLFragmentProcessor::setData(const GrGLProgramDataManager& pdman, +void GrGLFragmentProcessor::setData(const GrGLSLProgramDataManager& pdman, const GrFragmentProcessor& processor) { this->onSetData(pdman, processor); SkASSERT(fChildProcessors.count() == processor.numChildProcessors()); diff --git a/src/gpu/gl/GrGLFragmentProcessor.h b/src/gpu/gl/GrGLFragmentProcessor.h index 1e4dd481b3..00bd063d8e 100644 --- a/src/gpu/gl/GrGLFragmentProcessor.h +++ b/src/gpu/gl/GrGLFragmentProcessor.h @@ -8,11 +8,11 @@ #ifndef GrGLFragmentProcessor_DEFINED #define GrGLFragmentProcessor_DEFINED -#include "GrGLProgramDataManager.h" #include "GrGLProcessor.h" -#include "GrTextureAccess.h" +#include "glsl/GrGLSLProgramDataManager.h" class GrGLFPBuilder; +class GrGLSLCaps; class GrGLFragmentProcessor { public: @@ -24,7 +24,7 @@ public: } } - typedef GrGLProgramDataManager::UniformHandle UniformHandle; + typedef GrGLSLProgramDataManager::UniformHandle UniformHandle; typedef GrGLProcessor::TransformedCoordsArray TransformedCoordsArray; typedef GrGLProcessor::TextureSamplerArray TextureSamplerArray; @@ -70,7 +70,7 @@ public: virtual void emitCode(EmitArgs&) = 0; - void setData(const GrGLProgramDataManager& pdman, const GrFragmentProcessor& processor); + void setData(const GrGLSLProgramDataManager& pdman, const GrFragmentProcessor& processor); static void GenKey(const GrProcessor&, const GrGLSLCaps&, GrProcessorKeyBuilder*) {} @@ -101,7 +101,7 @@ protected: parameter is guaranteed to be of the same type that created this GrGLFragmentProcessor and to have an identical processor key as the one that created this GrGLFragmentProcessor. */ // TODO update this to pass in GrFragmentProcessor - virtual void onSetData(const GrGLProgramDataManager&, const GrProcessor&) {} + virtual void onSetData(const GrGLSLProgramDataManager&, const GrProcessor&) {} private: void internalEmitChild(int, const char*, const char*, EmitArgs&); diff --git a/src/gpu/gl/GrGLGeometryProcessor.h b/src/gpu/gl/GrGLGeometryProcessor.h index 1c7ab5371b..1b3b8d9277 100644 --- a/src/gpu/gl/GrGLGeometryProcessor.h +++ b/src/gpu/gl/GrGLGeometryProcessor.h @@ -24,7 +24,7 @@ public: // By default we use the identity matrix void setTransformData(const GrPrimitiveProcessor&, - const GrGLProgramDataManager& pdman, + const GrGLSLProgramDataManager& pdman, int index, const SkTArray<const GrCoordTransform*, true>& transforms) override { this->setTransformDataMatrix(SkMatrix::I(), pdman, index, transforms); @@ -33,7 +33,7 @@ public: // A helper which subclasses can use if needed template <class GeometryProcessor> void setTransformDataHelper(const GrPrimitiveProcessor& primProc, - const GrGLProgramDataManager& pdman, + const GrGLSLProgramDataManager& pdman, int index, const SkTArray<const GrCoordTransform*, true>& transforms) { const GeometryProcessor& gp = primProc.cast<GeometryProcessor>(); @@ -87,7 +87,7 @@ protected: private: void setTransformDataMatrix(const SkMatrix& localMatrix, - const GrGLProgramDataManager& pdman, + const GrGLSLProgramDataManager& pdman, int index, const SkTArray<const GrCoordTransform*, true>& transforms) { SkSTArray<2, Transform, true>& procTransforms = fInstalledTransforms[index]; diff --git a/src/gpu/gl/GrGLGpuProgramCache.cpp b/src/gpu/gl/GrGLGpuProgramCache.cpp index d74b54aeba..84794ac1cc 100644 --- a/src/gpu/gl/GrGLGpuProgramCache.cpp +++ b/src/gpu/gl/GrGLGpuProgramCache.cpp @@ -11,6 +11,7 @@ #include "GrProcessor.h" #include "GrGLFragmentProcessor.h" #include "GrGLPathRendering.h" +#include "glsl/GrGLSLProgramDataManager.h" #include "SkRTConf.h" #include "SkTSearch.h" @@ -19,7 +20,7 @@ SK_CONF_DECLARE(bool, c_DisplayCache, "gpu.displayCache", false, "Display program cache usage."); #endif -typedef GrGLProgramDataManager::UniformHandle UniformHandle; +typedef GrGLSLProgramDataManager::UniformHandle UniformHandle; struct GrGLGpu::ProgramCache::Entry { diff --git a/src/gpu/gl/GrGLPathRendering.cpp b/src/gpu/gl/GrGLPathRendering.cpp index a74014b96b..f18a4c671b 100644 --- a/src/gpu/gl/GrGLPathRendering.cpp +++ b/src/gpu/gl/GrGLPathRendering.cpp @@ -186,7 +186,7 @@ void GrGLPathRendering::onDrawPaths(const DrawPathArgs& args, const GrPathRange* void GrGLPathRendering::setProgramPathFragmentInputTransform(GrGLuint program, GrGLint location, GrGLenum genMode, GrGLint components, const SkMatrix& matrix) { - GrGLfloat coefficients[3 * 3]; + float coefficients[3 * 3]; SkASSERT(components >= 1 && components <= 3); coefficients[0] = SkScalarToFloat(matrix[SkMatrix::kMScaleX]); @@ -224,7 +224,7 @@ void GrGLPathRendering::setProjectionMatrix(const SkMatrix& matrix, fHWProjectionMatrixState.fRenderTargetSize = renderTargetSize; fHWProjectionMatrixState.fRenderTargetOrigin = renderTargetOrigin; - GrGLfloat glMatrix[4 * 4]; + float glMatrix[4 * 4]; fHWProjectionMatrixState.getRTAdjustedGLMatrix<4>(glMatrix); GL_CALL(MatrixLoadf(GR_GL_PATH_PROJECTION, glMatrix)); } diff --git a/src/gpu/gl/GrGLPathRendering.h b/src/gpu/gl/GrGLPathRendering.h index 651ddeea5d..d61df2fe40 100644 --- a/src/gpu/gl/GrGLPathRendering.h +++ b/src/gpu/gl/GrGLPathRendering.h @@ -94,7 +94,7 @@ private: /** * Gets a matrix that goes from local coordinates to GL normalized device coords. */ - template<int Size> void getRTAdjustedGLMatrix(GrGLfloat* destMatrix) { + template<int Size> void getRTAdjustedGLMatrix(float* destMatrix) { SkMatrix combined; if (kBottomLeft_GrSurfaceOrigin == fRenderTargetOrigin) { combined.setAll(SkIntToScalar(2) / fRenderTargetSize.fWidth, 0, -SK_Scalar1, diff --git a/src/gpu/gl/GrGLPrimitiveProcessor.h b/src/gpu/gl/GrGLPrimitiveProcessor.h index bf1c388698..cff964037d 100644 --- a/src/gpu/gl/GrGLPrimitiveProcessor.h +++ b/src/gpu/gl/GrGLPrimitiveProcessor.h @@ -10,6 +10,7 @@ #include "GrPrimitiveProcessor.h" #include "GrGLProcessor.h" +#include "glsl/GrGLSLProgramDataManager.h" class GrBatchTracker; class GrPrimitiveProcessor; @@ -19,7 +20,7 @@ class GrGLPrimitiveProcessor { public: virtual ~GrGLPrimitiveProcessor() {} - typedef GrGLProgramDataManager::UniformHandle UniformHandle; + typedef GrGLSLProgramDataManager::UniformHandle UniformHandle; typedef GrGLProcessor::TextureSamplerArray TextureSamplerArray; typedef SkSTArray<2, const GrCoordTransform*, true> ProcCoords; @@ -63,12 +64,12 @@ public: GrPrimitiveProcessor parameter is guaranteed to be of the same type that created this GrGLPrimitiveProcessor and to have an identical processor key as the one that created this GrGLPrimitiveProcessor. */ - virtual void setData(const GrGLProgramDataManager&, const GrPrimitiveProcessor&) = 0; + virtual void setData(const GrGLSLProgramDataManager&, const GrPrimitiveProcessor&) = 0; static SkMatrix GetTransformMatrix(const SkMatrix& localMatrix, const GrCoordTransform&); virtual void setTransformData(const GrPrimitiveProcessor&, - const GrGLProgramDataManager& pdman, + const GrGLSLProgramDataManager& pdman, int index, const SkTArray<const GrCoordTransform*, true>& transforms) = 0; @@ -77,9 +78,9 @@ protected: struct Transform { Transform() : fType(kVoid_GrSLType) { fCurrentValue = SkMatrix::InvalidMatrix(); } - GrGLProgramDataManager::UniformHandle fHandle; - SkMatrix fCurrentValue; - GrSLType fType; + GrGLSLProgramDataManager::UniformHandle fHandle; + SkMatrix fCurrentValue; + GrSLType fType; }; SkSTArray<8, SkSTArray<2, Transform, true> > fInstalledTransforms; diff --git a/src/gpu/gl/GrGLProcessor.h b/src/gpu/gl/GrGLProcessor.h index f99b1c5030..c389ce4bfa 100644 --- a/src/gpu/gl/GrGLProcessor.h +++ b/src/gpu/gl/GrGLProcessor.h @@ -8,9 +8,10 @@ #ifndef GrGLProcessor_DEFINED #define GrGLProcessor_DEFINED -#include "GrGLProgramDataManager.h" #include "GrProcessor.h" +#include "GrShaderVar.h" #include "GrTextureAccess.h" +#include "glsl/GrGLSLProgramDataManager.h" /** @file This file contains specializations for OpenGL of the shader stages declared in @@ -29,7 +30,7 @@ // TODO delete this and make TextureSampler its own thing class GrGLProcessor { public: - typedef GrGLProgramDataManager::UniformHandle UniformHandle; + typedef GrGLSLProgramDataManager::UniformHandle UniformHandle; /** * Passed to GrGLProcessors so they can add transformed coordinates to their shader code. diff --git a/src/gpu/gl/GrGLProgram.cpp b/src/gpu/gl/GrGLProgram.cpp index 08127c819a..552a0fb27f 100644 --- a/src/gpu/gl/GrGLProgram.cpp +++ b/src/gpu/gl/GrGLProgram.cpp @@ -135,7 +135,7 @@ void GrGLProgram::setRenderTargetState(const GrPrimitiveProcessor& primProc, fRenderTargetState.fRenderTargetSize = size; fRenderTargetState.fRenderTargetOrigin = rt->origin(); - GrGLfloat rtAdjustmentVec[4]; + float rtAdjustmentVec[4]; fRenderTargetState.getRTAdjustmentVec(rtAdjustmentVec); fProgramDataManager.set4fv(fBuiltinUniformHandles.fRTAdjustmentUni, 1, rtAdjustmentVec); } diff --git a/src/gpu/gl/GrGLProgram.h b/src/gpu/gl/GrGLProgram.h index 9c5ab73ca4..dc64a70d26 100644 --- a/src/gpu/gl/GrGLProgram.h +++ b/src/gpu/gl/GrGLProgram.h @@ -13,6 +13,7 @@ #include "GrGLProgramDesc.h" #include "GrGLTexture.h" #include "GrGLProgramDataManager.h" +#include "glsl/GrGLSLProgramDataManager.h" #include "SkString.h" #include "SkXfermode.h" @@ -74,7 +75,7 @@ public: * pos.x = dot(v.xy, pos.xz) * pos.y = dot(v.zw, pos.yz) */ - void getRTAdjustmentVec(GrGLfloat* destVec) { + void getRTAdjustmentVec(float* destVec) { destVec[0] = 2.f / fRenderTargetSize.fWidth; destVec[1] = -1.f; if (kBottomLeft_GrSurfaceOrigin == fRenderTargetOrigin) { @@ -97,7 +98,7 @@ public: SkTArray<const GrTextureAccess*>* textureBindings); protected: - typedef GrGLProgramDataManager::UniformHandle UniformHandle; + typedef GrGLSLProgramDataManager::UniformHandle UniformHandle; typedef GrGLProgramDataManager::UniformInfoArray UniformInfoArray; typedef GrGLProgramDataManager::SeparableVaryingInfoArray SeparableVaryingInfoArray; diff --git a/src/gpu/gl/GrGLProgramDataManager.cpp b/src/gpu/gl/GrGLProgramDataManager.cpp index 590287e318..7320b2dd8a 100644 --- a/src/gpu/gl/GrGLProgramDataManager.cpp +++ b/src/gpu/gl/GrGLProgramDataManager.cpp @@ -60,7 +60,7 @@ GrGLProgramDataManager::GrGLProgramDataManager(GrGLGpu* gpu, GrGLuint programID, } } -void GrGLProgramDataManager::setSampler(UniformHandle u, GrGLint texUnit) const { +void GrGLProgramDataManager::setSampler(UniformHandle u, int texUnit) const { const Uniform& uni = fUniforms[u.toIndex()]; SkASSERT(uni.fType == kSampler2D_GrSLType); SkASSERT(GrGLSLShaderVar::kNonArray == uni.fArrayCount); @@ -76,7 +76,7 @@ void GrGLProgramDataManager::setSampler(UniformHandle u, GrGLint texUnit) const } } -void GrGLProgramDataManager::set1f(UniformHandle u, GrGLfloat v0) const { +void GrGLProgramDataManager::set1f(UniformHandle u, float v0) const { const Uniform& uni = fUniforms[u.toIndex()]; SkASSERT(uni.fType == kFloat_GrSLType); SkASSERT(GrGLSLShaderVar::kNonArray == uni.fArrayCount); @@ -91,7 +91,7 @@ void GrGLProgramDataManager::set1f(UniformHandle u, GrGLfloat v0) const { void GrGLProgramDataManager::set1fv(UniformHandle u, int arrayCount, - const GrGLfloat v[]) const { + const float v[]) const { const Uniform& uni = fUniforms[u.toIndex()]; SkASSERT(uni.fType == kFloat_GrSLType); SkASSERT(arrayCount > 0); @@ -108,7 +108,7 @@ void GrGLProgramDataManager::set1fv(UniformHandle u, } } -void GrGLProgramDataManager::set2f(UniformHandle u, GrGLfloat v0, GrGLfloat v1) const { +void GrGLProgramDataManager::set2f(UniformHandle u, float v0, float v1) const { const Uniform& uni = fUniforms[u.toIndex()]; SkASSERT(uni.fType == kVec2f_GrSLType); SkASSERT(GrGLSLShaderVar::kNonArray == uni.fArrayCount); @@ -123,7 +123,7 @@ void GrGLProgramDataManager::set2f(UniformHandle u, GrGLfloat v0, GrGLfloat v1) void GrGLProgramDataManager::set2fv(UniformHandle u, int arrayCount, - const GrGLfloat v[]) const { + const float v[]) const { const Uniform& uni = fUniforms[u.toIndex()]; SkASSERT(uni.fType == kVec2f_GrSLType); SkASSERT(arrayCount > 0); @@ -137,7 +137,7 @@ void GrGLProgramDataManager::set2fv(UniformHandle u, } } -void GrGLProgramDataManager::set3f(UniformHandle u, GrGLfloat v0, GrGLfloat v1, GrGLfloat v2) const { +void GrGLProgramDataManager::set3f(UniformHandle u, float v0, float v1, float v2) const { const Uniform& uni = fUniforms[u.toIndex()]; SkASSERT(uni.fType == kVec3f_GrSLType); SkASSERT(GrGLSLShaderVar::kNonArray == uni.fArrayCount); @@ -152,7 +152,7 @@ void GrGLProgramDataManager::set3f(UniformHandle u, GrGLfloat v0, GrGLfloat v1, void GrGLProgramDataManager::set3fv(UniformHandle u, int arrayCount, - const GrGLfloat v[]) const { + const float v[]) const { const Uniform& uni = fUniforms[u.toIndex()]; SkASSERT(uni.fType == kVec3f_GrSLType); SkASSERT(arrayCount > 0); @@ -167,10 +167,10 @@ void GrGLProgramDataManager::set3fv(UniformHandle u, } void GrGLProgramDataManager::set4f(UniformHandle u, - GrGLfloat v0, - GrGLfloat v1, - GrGLfloat v2, - GrGLfloat v3) const { + float v0, + float v1, + float v2, + float v3) const { const Uniform& uni = fUniforms[u.toIndex()]; SkASSERT(uni.fType == kVec4f_GrSLType); SkASSERT(GrGLSLShaderVar::kNonArray == uni.fArrayCount); @@ -185,7 +185,7 @@ void GrGLProgramDataManager::set4f(UniformHandle u, void GrGLProgramDataManager::set4fv(UniformHandle u, int arrayCount, - const GrGLfloat v[]) const { + const float v[]) const { const Uniform& uni = fUniforms[u.toIndex()]; SkASSERT(uni.fType == kVec4f_GrSLType); SkASSERT(arrayCount > 0); @@ -199,7 +199,7 @@ void GrGLProgramDataManager::set4fv(UniformHandle u, } } -void GrGLProgramDataManager::setMatrix3f(UniformHandle u, const GrGLfloat matrix[]) const { +void GrGLProgramDataManager::setMatrix3f(UniformHandle u, const float matrix[]) const { const Uniform& uni = fUniforms[u.toIndex()]; SkASSERT(uni.fType == kMat33f_GrSLType); SkASSERT(GrGLSLShaderVar::kNonArray == uni.fArrayCount); @@ -212,7 +212,7 @@ void GrGLProgramDataManager::setMatrix3f(UniformHandle u, const GrGLfloat matrix } } -void GrGLProgramDataManager::setMatrix4f(UniformHandle u, const GrGLfloat matrix[]) const { +void GrGLProgramDataManager::setMatrix4f(UniformHandle u, const float matrix[]) const { const Uniform& uni = fUniforms[u.toIndex()]; SkASSERT(uni.fType == kMat44f_GrSLType); SkASSERT(GrGLSLShaderVar::kNonArray == uni.fArrayCount); @@ -227,7 +227,7 @@ void GrGLProgramDataManager::setMatrix4f(UniformHandle u, const GrGLfloat matrix void GrGLProgramDataManager::setMatrix3fv(UniformHandle u, int arrayCount, - const GrGLfloat matrices[]) const { + const float matrices[]) const { const Uniform& uni = fUniforms[u.toIndex()]; SkASSERT(uni.fType == kMat33f_GrSLType); SkASSERT(arrayCount > 0); @@ -245,7 +245,7 @@ void GrGLProgramDataManager::setMatrix3fv(UniformHandle u, void GrGLProgramDataManager::setMatrix4fv(UniformHandle u, int arrayCount, - const GrGLfloat matrices[]) const { + const float matrices[]) const { const Uniform& uni = fUniforms[u.toIndex()]; SkASSERT(uni.fType == kMat44f_GrSLType); SkASSERT(arrayCount > 0); @@ -262,7 +262,7 @@ void GrGLProgramDataManager::setMatrix4fv(UniformHandle u, } void GrGLProgramDataManager::setSkMatrix(UniformHandle u, const SkMatrix& matrix) const { - GrGLfloat mt[] = { + float mt[] = { matrix.get(SkMatrix::kMScaleX), matrix.get(SkMatrix::kMSkewY), matrix.get(SkMatrix::kMPersp0), diff --git a/src/gpu/gl/GrGLProgramDataManager.h b/src/gpu/gl/GrGLProgramDataManager.h index 04d519fb16..ea7b19e034 100644 --- a/src/gpu/gl/GrGLProgramDataManager.h +++ b/src/gpu/gl/GrGLProgramDataManager.h @@ -8,6 +8,8 @@ #ifndef GrGLProgramDataManager_DEFINED #define GrGLProgramDataManager_DEFINED +#include "glsl/GrGLSLProgramDataManager.h" + #include "GrAllocator.h" #include "gl/GrGLTypes.h" #include "glsl/GrGLSLShaderVar.h" @@ -23,31 +25,8 @@ class GrGLProgramBuilder; * The resources are objects the program uses to communicate with the * application code. */ -class GrGLProgramDataManager : SkNoncopyable { +class GrGLProgramDataManager : public GrGLSLProgramDataManager { public: - // Opaque handle to a resource - class ShaderResourceHandle { - public: - ShaderResourceHandle(int value) - : fValue(value) { - SkASSERT(this->isValid()); - } - - ShaderResourceHandle() - : fValue(kInvalid_ShaderResourceHandle) { - } - - bool operator==(const ShaderResourceHandle& other) const { return other.fValue == fValue; } - bool isValid() const { return kInvalid_ShaderResourceHandle != fValue; } - int toIndex() const { SkASSERT(this->isValid()); return fValue; } - - private: - static const int kInvalid_ShaderResourceHandle = -1; - int fValue; - }; - - typedef ShaderResourceHandle UniformHandle; - struct UniformInfo { GrGLSLShaderVar fVariable; uint32_t fVisibility; @@ -71,29 +50,29 @@ public: /** Functions for uploading uniform values. The varities ending in v can be used to upload to an * array of uniforms. arrayCount must be <= the array count of the uniform. */ - void setSampler(UniformHandle, GrGLint texUnit) const; - void set1f(UniformHandle, GrGLfloat v0) const; - void set1fv(UniformHandle, int arrayCount, const GrGLfloat v[]) const; - void set2f(UniformHandle, GrGLfloat, GrGLfloat) const; - void set2fv(UniformHandle, int arrayCount, const GrGLfloat v[]) const; - void set3f(UniformHandle, GrGLfloat, GrGLfloat, GrGLfloat) const; - void set3fv(UniformHandle, int arrayCount, const GrGLfloat v[]) const; - void set4f(UniformHandle, GrGLfloat, GrGLfloat, GrGLfloat, GrGLfloat) const; - void set4fv(UniformHandle, int arrayCount, const GrGLfloat v[]) const; + void setSampler(UniformHandle, int texUnit) const; + + void set1f(UniformHandle, float v0) const override; + void set1fv(UniformHandle, int arrayCount, const float v[]) const override; + void set2f(UniformHandle, float, float) const override; + void set2fv(UniformHandle, int arrayCount, const float v[]) const override; + void set3f(UniformHandle, float, float, float) const override; + void set3fv(UniformHandle, int arrayCount, const float v[]) const override; + void set4f(UniformHandle, float, float, float, float) const override; + void set4fv(UniformHandle, int arrayCount, const float v[]) const override; // matrices are column-major, the first three upload a single matrix, the latter three upload // arrayCount matrices into a uniform array. - void setMatrix3f(UniformHandle, const GrGLfloat matrix[]) const; - void setMatrix4f(UniformHandle, const GrGLfloat matrix[]) const; - void setMatrix3fv(UniformHandle, int arrayCount, const GrGLfloat matrices[]) const; - void setMatrix4fv(UniformHandle, int arrayCount, const GrGLfloat matrices[]) const; + void setMatrix3f(UniformHandle, const float matrix[]) const override; + void setMatrix4f(UniformHandle, const float matrix[]) const override; + void setMatrix3fv(UniformHandle, int arrayCount, const float matrices[]) const override; + void setMatrix4fv(UniformHandle, int arrayCount, const float matrices[]) const override; // convenience method for uploading a SkMatrix to a 3x3 matrix uniform - void setSkMatrix(UniformHandle, const SkMatrix&) const; + void setSkMatrix(UniformHandle, const SkMatrix&) const override; // for nvpr only - typedef GrGLProgramDataManager::ShaderResourceHandle SeparableVaryingHandle; void setPathFragmentInputTransform(SeparableVaryingHandle u, int components, - const SkMatrix& matrix) const; + const SkMatrix& matrix) const override; private: enum { @@ -127,7 +106,7 @@ private: GrGLGpu* fGpu; GrGLuint fProgramID; - typedef SkNoncopyable INHERITED; + typedef GrGLSLProgramDataManager INHERITED; }; #endif diff --git a/src/gpu/gl/GrGLUtil.cpp b/src/gpu/gl/GrGLUtil.cpp index 5579701796..7f0713ed6a 100644 --- a/src/gpu/gl/GrGLUtil.cpp +++ b/src/gpu/gl/GrGLUtil.cpp @@ -306,7 +306,8 @@ GrGLRenderer GrGLGetRenderer(const GrGLInterface* gl) { return GrGLGetRendererFromString((const char*) v); } -template<> void GrGLGetMatrix<3>(GrGLfloat* dest, const SkMatrix& src) { +template<> void GrGLGetMatrix<3>(float* dest, const SkMatrix& src) { + GR_STATIC_ASSERT(sizeof(float) == sizeof (GrGLfloat)); // Col 0 dest[0] = SkScalarToFloat(src[SkMatrix::kMScaleX]); dest[1] = SkScalarToFloat(src[SkMatrix::kMSkewY]); @@ -323,7 +324,8 @@ template<> void GrGLGetMatrix<3>(GrGLfloat* dest, const SkMatrix& src) { dest[8] = SkScalarToFloat(src[SkMatrix::kMPersp2]); } -template<> void GrGLGetMatrix<4>(GrGLfloat* dest, const SkMatrix& src) { +template<> void GrGLGetMatrix<4>(float* dest, const SkMatrix& src) { + GR_STATIC_ASSERT(sizeof(float) == sizeof (GrGLfloat)); // Col 0 dest[0] = SkScalarToFloat(src[SkMatrix::kMScaleX]); dest[1] = SkScalarToFloat(src[SkMatrix::kMSkewY]); diff --git a/src/gpu/gl/GrGLUtil.h b/src/gpu/gl/GrGLUtil.h index 35dfe6ae9f..dec784c977 100644 --- a/src/gpu/gl/GrGLUtil.h +++ b/src/gpu/gl/GrGLUtil.h @@ -141,7 +141,7 @@ void GrGLClearErr(const GrGLInterface* gl); /** * Helper for converting SkMatrix to a column-major GL float array */ -template<int MatrixSize> void GrGLGetMatrix(GrGLfloat* dest, const SkMatrix& src); +template<int MatrixSize> void GrGLGetMatrix(float* dest, const SkMatrix& src); //////////////////////////////////////////////////////////////////////////////// diff --git a/src/gpu/gl/GrGLXferProcessor.cpp b/src/gpu/gl/GrGLXferProcessor.cpp index e62497193f..528d354bfc 100644 --- a/src/gpu/gl/GrGLXferProcessor.cpp +++ b/src/gpu/gl/GrGLXferProcessor.cpp @@ -10,6 +10,7 @@ #include "GrXferProcessor.h" #include "gl/builders/GrGLFragmentShaderBuilder.h" #include "gl/builders/GrGLProgramBuilder.h" +#include "glsl/GrGLSLProgramDataManager.h" void GrGLXferProcessor::emitCode(const EmitArgs& args) { if (!args.fXP.willReadDstColor()) { @@ -77,11 +78,11 @@ void GrGLXferProcessor::emitCode(const EmitArgs& args) { } } -void GrGLXferProcessor::setData(const GrGLProgramDataManager& pdm, const GrXferProcessor& xp) { +void GrGLXferProcessor::setData(const GrGLSLProgramDataManager& pdm, const GrXferProcessor& xp) { if (xp.getDstTexture()) { if (fDstTopLeftUni.isValid()) { - pdm.set2f(fDstTopLeftUni, static_cast<GrGLfloat>(xp.dstTextureOffset().fX), - static_cast<GrGLfloat>(xp.dstTextureOffset().fY)); + pdm.set2f(fDstTopLeftUni, static_cast<float>(xp.dstTextureOffset().fX), + static_cast<float>(xp.dstTextureOffset().fY)); pdm.set2f(fDstScaleUni, 1.f / xp.getDstTexture()->width(), 1.f / xp.getDstTexture()->height()); } else { diff --git a/src/gpu/gl/GrGLXferProcessor.h b/src/gpu/gl/GrGLXferProcessor.h index c9c6cb5c41..bf16cf4d36 100644 --- a/src/gpu/gl/GrGLXferProcessor.h +++ b/src/gpu/gl/GrGLXferProcessor.h @@ -8,7 +8,8 @@ #ifndef GrGLXferProcessor_DEFINED #define GrGLXferProcessor_DEFINED -#include "GrGLFragmentProcessor.h" +#include "GrGLProcessor.h" +#include "glsl/GrGLSLProgramDataManager.h" class GrGLXPBuilder; class GrXferProcessor; @@ -56,7 +57,7 @@ public: to have an identical processor key as the one that created this GrGLXferProcessor. This function calls onSetData on the subclass of GrGLXferProcessor */ - void setData(const GrGLProgramDataManager& pdm, const GrXferProcessor& xp); + void setData(const GrGLSLProgramDataManager& pdm, const GrXferProcessor& xp); private: /** @@ -78,10 +79,10 @@ private: SkFAIL("emitBlendCodeForDstRead not implemented."); } - virtual void onSetData(const GrGLProgramDataManager&, const GrXferProcessor&) = 0; + virtual void onSetData(const GrGLSLProgramDataManager&, const GrXferProcessor&) = 0; - GrGLProgramDataManager::UniformHandle fDstTopLeftUni; - GrGLProgramDataManager::UniformHandle fDstScaleUni; + GrGLSLProgramDataManager::UniformHandle fDstTopLeftUni; + GrGLSLProgramDataManager::UniformHandle fDstScaleUni; typedef GrGLProcessor INHERITED; }; diff --git a/src/gpu/gl/builders/GrGLProgramBuilder.cpp b/src/gpu/gl/builders/GrGLProgramBuilder.cpp index a0ddcf2410..b74a8673cd 100644 --- a/src/gpu/gl/builders/GrGLProgramBuilder.cpp +++ b/src/gpu/gl/builders/GrGLProgramBuilder.cpp @@ -19,6 +19,7 @@ #include "gl/GrGLSLPrettyPrint.h" #include "gl/GrGLXferProcessor.h" #include "glsl/GrGLSLCaps.h" +#include "glsl/GrGLSLProgramDataManager.h" #define GL_CALL(X) GR_GL_CALL(this->gpu()->glInterface(), X) #define GL_CALL_RET(R, X) GR_GL_CALL_RET(this->gpu()->glInterface(), R, X) @@ -118,7 +119,7 @@ void GrGLProgramBuilder::nameVariable(SkString* out, char prefix, const char* na } } -GrGLProgramDataManager::UniformHandle GrGLProgramBuilder::addUniformArray( +GrGLSLProgramDataManager::UniformHandle GrGLProgramBuilder::addUniformArray( uint32_t visibility, GrSLType type, GrSLPrecision precision, @@ -152,7 +153,7 @@ GrGLProgramDataManager::UniformHandle GrGLProgramBuilder::addUniformArray( if (outName) { *outName = uni.fVariable.c_str(); } - return GrGLProgramDataManager::UniformHandle(fUniforms.count() - 1); + return GrGLSLProgramDataManager::UniformHandle(fUniforms.count() - 1); } void GrGLProgramBuilder::appendUniformDecls(ShaderVisibility visibility, diff --git a/src/gpu/gl/builders/GrGLProgramBuilder.h b/src/gpu/gl/builders/GrGLProgramBuilder.h index 11c367df8c..7690b39a8b 100644 --- a/src/gpu/gl/builders/GrGLProgramBuilder.h +++ b/src/gpu/gl/builders/GrGLProgramBuilder.h @@ -11,7 +11,7 @@ #include "GrGLFragmentShaderBuilder.h" #include "GrGLGeometryShaderBuilder.h" #include "GrGLVertexShaderBuilder.h" -#include "../GrGLProgramDataManager.h" +#include "glsl/GrGLSLProgramDataManager.h" #include "../GrGLPrimitiveProcessor.h" #include "../GrGLXferProcessor.h" #include "../../GrPipeline.h" @@ -42,7 +42,7 @@ public: virtual ~GrGLUniformBuilder() {} - typedef GrGLProgramDataManager::UniformHandle UniformHandle; + typedef GrGLSLProgramDataManager::UniformHandle UniformHandle; typedef GrGLProgramDataManager::SeparableVaryingHandle SeparableVaryingHandle; /** Add a uniform variable to the current program, that has visibility in one or more shaders. |