Create GLSL base class for ProgramDataManager
BUG=skia:
Review URL: https://codereview.chromium.org/1428543003
diff --git a/src/gpu/GrDefaultGeoProcFactory.cpp b/src/gpu/GrDefaultGeoProcFactory.cpp
index 2f7d14a..23530ac 100644
--- a/src/gpu/GrDefaultGeoProcFactory.cpp
+++ b/src/gpu/GrDefaultGeoProcFactory.cpp
@@ -131,18 +131,19 @@
b->add32(key);
}
- void setData(const GrGLProgramDataManager& pdman, const GrPrimitiveProcessor& gp) override {
+ void setData(const GrGLSLProgramDataManager& pdman,
+ const GrPrimitiveProcessor& gp) override {
const DefaultGeoProc& dgp = gp.cast<DefaultGeoProc>();
if (!dgp.viewMatrix().isIdentity() && !fViewMatrix.cheapEqualTo(dgp.viewMatrix())) {
fViewMatrix = dgp.viewMatrix();
- GrGLfloat viewMatrix[3 * 3];
+ float viewMatrix[3 * 3];
GrGLGetMatrix<3>(viewMatrix, fViewMatrix);
pdman.setMatrix3f(fViewMatrixUniform, viewMatrix);
}
if (dgp.color() != fColor && !dgp.hasVertexColor()) {
- GrGLfloat c[4];
+ float c[4];
GrColorToRGBAFloat(dgp.color(), c);
pdman.set4fv(fColorUniform, 1, c);
fColor = dgp.color();
@@ -156,7 +157,7 @@
}
void setTransformData(const GrPrimitiveProcessor& primProc,
- const GrGLProgramDataManager& pdman,
+ const GrGLSLProgramDataManager& pdman,
int index,
const SkTArray<const GrCoordTransform*, true>& transforms) override {
this->setTransformDataHelper<DefaultGeoProc>(primProc, pdman, index, transforms);
diff --git a/src/gpu/GrFragmentProcessor.cpp b/src/gpu/GrFragmentProcessor.cpp
index d1a3fa1..ec5aaac 100644
--- a/src/gpu/GrFragmentProcessor.cpp
+++ b/src/gpu/GrFragmentProcessor.cpp
@@ -10,6 +10,7 @@
#include "GrCoordTransform.h"
#include "gl/GrGLFragmentProcessor.h"
#include "gl/builders/GrGLProgramBuilder.h"
+#include "glsl/GrGLSLProgramDataManager.h"
#include "effects/GrConstColorProcessor.h"
#include "effects/GrXfermodeFragmentProcessor.h"
@@ -231,12 +232,12 @@
}
private:
- void onSetData(const GrGLProgramDataManager& pdman,
+ void onSetData(const GrGLSLProgramDataManager& pdman,
const GrProcessor& fp) override {
GrColor color = fp.cast<ReplaceInputFragmentProcessor>().fColor;
if (!fHaveSetColor || color != fPreviousColor) {
- static const GrGLfloat scale = 1.f / 255.f;
- GrGLfloat floatColor[4] = {
+ static const float scale = 1.f / 255.f;
+ float floatColor[4] = {
GrColorUnpackR(color) * scale,
GrColorUnpackG(color) * scale,
GrColorUnpackB(color) * scale,
@@ -248,7 +249,7 @@
}
}
- GrGLProgramDataManager::UniformHandle fColorUni;
+ GrGLSLProgramDataManager::UniformHandle fColorUni;
bool fHaveSetColor;
GrColor fPreviousColor;
};
diff --git a/src/gpu/GrOvalRenderer.cpp b/src/gpu/GrOvalRenderer.cpp
index 258e3f4..a647e62 100644
--- a/src/gpu/GrOvalRenderer.cpp
+++ b/src/gpu/GrOvalRenderer.cpp
@@ -25,6 +25,7 @@
#include "gl/GrGLProcessor.h"
#include "gl/GrGLGeometryProcessor.h"
#include "gl/builders/GrGLProgramBuilder.h"
+#include "glsl/GrGLSLProgramDataManager.h"
// TODO(joshualitt) - Break this file up during GrBatch post implementation cleanup
@@ -139,10 +140,11 @@
b->add32(key);
}
- void setData(const GrGLProgramDataManager& pdman, const GrPrimitiveProcessor& gp) override {
+ void setData(const GrGLSLProgramDataManager& pdman,
+ const GrPrimitiveProcessor& gp) override {
const CircleEdgeEffect& ce = gp.cast<CircleEdgeEffect>();
if (ce.color() != fColor) {
- GrGLfloat c[4];
+ float c[4];
GrColorToRGBAFloat(ce.color(), c);
pdman.set4fv(fColorUniform, 1, c);
fColor = ce.color();
@@ -150,7 +152,7 @@
}
void setTransformData(const GrPrimitiveProcessor& primProc,
- const GrGLProgramDataManager& pdman,
+ const GrGLSLProgramDataManager& pdman,
int index,
const SkTArray<const GrCoordTransform*, true>& transforms) override {
this->setTransformDataHelper<CircleEdgeEffect>(primProc, pdman, index, transforms);
@@ -307,10 +309,10 @@
b->add32(key);
}
- void setData(const GrGLProgramDataManager& pdman, const GrPrimitiveProcessor& gp) override {
+ void setData(const GrGLSLProgramDataManager& pdman, const GrPrimitiveProcessor& gp) override {
const EllipseEdgeEffect& ee = gp.cast<EllipseEdgeEffect>();
if (ee.color() != fColor) {
- GrGLfloat c[4];
+ float c[4];
GrColorToRGBAFloat(ee.color(), c);
pdman.set4fv(fColorUniform, 1, c);
fColor = ee.color();
@@ -318,7 +320,7 @@
}
void setTransformData(const GrPrimitiveProcessor& primProc,
- const GrGLProgramDataManager& pdman,
+ const GrGLSLProgramDataManager& pdman,
int index,
const SkTArray<const GrCoordTransform*, true>& transforms) override {
this->setTransformDataHelper<EllipseEdgeEffect>(primProc, pdman, index, transforms);
@@ -497,18 +499,19 @@
b->add32(key);
}
- void setData(const GrGLProgramDataManager& pdman, const GrPrimitiveProcessor& gp) override {
+ void setData(const GrGLSLProgramDataManager& pdman,
+ const GrPrimitiveProcessor& gp) override {
const DIEllipseEdgeEffect& dee = gp.cast<DIEllipseEdgeEffect>();
if (!dee.viewMatrix().isIdentity() && !fViewMatrix.cheapEqualTo(dee.viewMatrix())) {
fViewMatrix = dee.viewMatrix();
- GrGLfloat viewMatrix[3 * 3];
+ float viewMatrix[3 * 3];
GrGLGetMatrix<3>(viewMatrix, fViewMatrix);
pdman.setMatrix3f(fViewMatrixUniform, viewMatrix);
}
if (dee.color() != fColor) {
- GrGLfloat c[4];
+ float c[4];
GrColorToRGBAFloat(dee.color(), c);
pdman.set4fv(fColorUniform, 1, c);
fColor = dee.color();
diff --git a/src/gpu/GrPathProcessor.cpp b/src/gpu/GrPathProcessor.cpp
index aa50954..e4050a9 100644
--- a/src/gpu/GrPathProcessor.cpp
+++ b/src/gpu/GrPathProcessor.cpp
@@ -71,10 +71,11 @@
}
}
- void setData(const GrGLProgramDataManager& pd, const GrPrimitiveProcessor& primProc) override {
+ void setData(const GrGLSLProgramDataManager& pd,
+ const GrPrimitiveProcessor& primProc) override {
const GrPathProcessor& pathProc = primProc.cast<GrPathProcessor>();
if (pathProc.opts().readsColor() && pathProc.color() != fColor) {
- GrGLfloat c[4];
+ float c[4];
GrColorToRGBAFloat(pathProc.color(), c);
pd.set4fv(fColorUniform, 1, c);
fColor = pathProc.color();
@@ -82,7 +83,7 @@
}
void setTransformData(const GrPrimitiveProcessor& primProc,
- const GrGLProgramDataManager& pdman,
+ const GrGLSLProgramDataManager& pdman,
int index,
const SkTArray<const GrCoordTransform*, true>& coordTransforms) override {
const GrPathProcessor& pathProc = primProc.cast<GrPathProcessor>();
diff --git a/src/gpu/batches/GrAAConvexPathRenderer.cpp b/src/gpu/batches/GrAAConvexPathRenderer.cpp
index 543885e..cb015f8 100644
--- a/src/gpu/batches/GrAAConvexPathRenderer.cpp
+++ b/src/gpu/batches/GrAAConvexPathRenderer.cpp
@@ -28,6 +28,7 @@
#include "gl/GrGLProcessor.h"
#include "gl/GrGLGeometryProcessor.h"
#include "gl/builders/GrGLProgramBuilder.h"
+#include "glsl/GrGLSLProgramDataManager.h"
GrAAConvexPathRenderer::GrAAConvexPathRenderer() {
}
@@ -605,10 +606,11 @@
b->add32(key);
}
- void setData(const GrGLProgramDataManager& pdman, const GrPrimitiveProcessor& gp) override {
+ void setData(const GrGLSLProgramDataManager& pdman,
+ const GrPrimitiveProcessor& gp) override {
const QuadEdgeEffect& qe = gp.cast<QuadEdgeEffect>();
if (qe.color() != fColor) {
- GrGLfloat c[4];
+ float c[4];
GrColorToRGBAFloat(qe.color(), c);
pdman.set4fv(fColorUniform, 1, c);
fColor = qe.color();
@@ -616,7 +618,7 @@
}
void setTransformData(const GrPrimitiveProcessor& primProc,
- const GrGLProgramDataManager& pdman,
+ const GrGLSLProgramDataManager& pdman,
int index,
const SkTArray<const GrCoordTransform*, true>& transforms) override {
this->setTransformDataHelper<QuadEdgeEffect>(primProc, pdman, index, transforms);
diff --git a/src/gpu/effects/GrBezierEffect.cpp b/src/gpu/effects/GrBezierEffect.cpp
index 25362e6..41fe7fc 100644
--- a/src/gpu/effects/GrBezierEffect.cpp
+++ b/src/gpu/effects/GrBezierEffect.cpp
@@ -11,6 +11,7 @@
#include "gl/GrGLGeometryProcessor.h"
#include "gl/GrGLUtil.h"
#include "gl/builders/GrGLProgramBuilder.h"
+#include "glsl/GrGLSLProgramDataManager.h"
class GrGLConicEffect : public GrGLGeometryProcessor {
public:
@@ -22,19 +23,19 @@
const GrGLSLCaps&,
GrProcessorKeyBuilder*);
- void setData(const GrGLProgramDataManager& pdman,
+ void setData(const GrGLSLProgramDataManager& pdman,
const GrPrimitiveProcessor& primProc) override {
const GrConicEffect& ce = primProc.cast<GrConicEffect>();
if (!ce.viewMatrix().isIdentity() && !fViewMatrix.cheapEqualTo(ce.viewMatrix())) {
fViewMatrix = ce.viewMatrix();
- GrGLfloat viewMatrix[3 * 3];
+ float viewMatrix[3 * 3];
GrGLGetMatrix<3>(viewMatrix, fViewMatrix);
pdman.setMatrix3f(fViewMatrixUniform, viewMatrix);
}
if (ce.color() != fColor) {
- GrGLfloat c[4];
+ float c[4];
GrColorToRGBAFloat(ce.color(), c);
pdman.set4fv(fColorUniform, 1, c);
fColor = ce.color();
@@ -47,7 +48,7 @@
}
void setTransformData(const GrPrimitiveProcessor& primProc,
- const GrGLProgramDataManager& pdman,
+ const GrGLSLProgramDataManager& pdman,
int index,
const SkTArray<const GrCoordTransform*, true>& transforms) override {
this->setTransformDataHelper<GrConicEffect>(primProc, pdman, index, transforms);
@@ -238,19 +239,19 @@
const GrGLSLCaps&,
GrProcessorKeyBuilder*);
- void setData(const GrGLProgramDataManager& pdman,
+ void setData(const GrGLSLProgramDataManager& pdman,
const GrPrimitiveProcessor& primProc) override {
const GrQuadEffect& qe = primProc.cast<GrQuadEffect>();
if (!qe.viewMatrix().isIdentity() && !fViewMatrix.cheapEqualTo(qe.viewMatrix())) {
fViewMatrix = qe.viewMatrix();
- GrGLfloat viewMatrix[3 * 3];
+ float viewMatrix[3 * 3];
GrGLGetMatrix<3>(viewMatrix, fViewMatrix);
pdman.setMatrix3f(fViewMatrixUniform, viewMatrix);
}
if (qe.color() != fColor) {
- GrGLfloat c[4];
+ float c[4];
GrColorToRGBAFloat(qe.color(), c);
pdman.set4fv(fColorUniform, 1, c);
fColor = qe.color();
@@ -263,7 +264,7 @@
}
void setTransformData(const GrPrimitiveProcessor& primProc,
- const GrGLProgramDataManager& pdman,
+ const GrGLSLProgramDataManager& pdman,
int index,
const SkTArray<const GrCoordTransform*, true>& transforms) override {
this->setTransformDataHelper<GrQuadEffect>(primProc, pdman, index, transforms);
@@ -440,19 +441,19 @@
const GrGLSLCaps&,
GrProcessorKeyBuilder*);
- void setData(const GrGLProgramDataManager& pdman,
+ void setData(const GrGLSLProgramDataManager& pdman,
const GrPrimitiveProcessor& primProc) override {
const GrCubicEffect& ce = primProc.cast<GrCubicEffect>();
if (!ce.viewMatrix().isIdentity() && !fViewMatrix.cheapEqualTo(ce.viewMatrix())) {
fViewMatrix = ce.viewMatrix();
- GrGLfloat viewMatrix[3 * 3];
+ float viewMatrix[3 * 3];
GrGLGetMatrix<3>(viewMatrix, fViewMatrix);
pdman.setMatrix3f(fViewMatrixUniform, viewMatrix);
}
if (ce.color() != fColor) {
- GrGLfloat c[4];
+ float c[4];
GrColorToRGBAFloat(ce.color(), c);
pdman.set4fv(fColorUniform, 1, c);
fColor = ce.color();
diff --git a/src/gpu/effects/GrBicubicEffect.cpp b/src/gpu/effects/GrBicubicEffect.cpp
index 3bed4be..a6ed190 100644
--- a/src/gpu/effects/GrBicubicEffect.cpp
+++ b/src/gpu/effects/GrBicubicEffect.cpp
@@ -8,6 +8,7 @@
#include "GrBicubicEffect.h"
#include "GrInvariantOutput.h"
#include "gl/builders/GrGLProgramBuilder.h"
+#include "glsl/GrGLSLProgramDataManager.h"
#define DS(x) SkDoubleToScalar(x)
@@ -32,10 +33,10 @@
}
protected:
- void onSetData(const GrGLProgramDataManager&, const GrProcessor&) override;
+ void onSetData(const GrGLSLProgramDataManager&, const GrProcessor&) override;
private:
- typedef GrGLProgramDataManager::UniformHandle UniformHandle;
+ typedef GrGLSLProgramDataManager::UniformHandle UniformHandle;
UniformHandle fCoefficientsUni;
UniformHandle fImageIncrementUni;
@@ -105,8 +106,8 @@
GrGLSLExpr4(args.fInputColor)).c_str());
}
-void GrGLBicubicEffect::onSetData(const GrGLProgramDataManager& pdman,
- const GrProcessor& processor) {
+void GrGLBicubicEffect::onSetData(const GrGLSLProgramDataManager& pdman,
+ const GrProcessor& processor) {
const GrBicubicEffect& bicubicEffect = processor.cast<GrBicubicEffect>();
const GrTexture& texture = *processor.texture(0);
float imageIncrement[2];
diff --git a/src/gpu/effects/GrBitmapTextGeoProc.cpp b/src/gpu/effects/GrBitmapTextGeoProc.cpp
index c866ae6..371ef01 100644
--- a/src/gpu/effects/GrBitmapTextGeoProc.cpp
+++ b/src/gpu/effects/GrBitmapTextGeoProc.cpp
@@ -12,6 +12,7 @@
#include "gl/GrGLTexture.h"
#include "gl/GrGLGeometryProcessor.h"
#include "gl/builders/GrGLProgramBuilder.h"
+#include "glsl/GrGLSLProgramDataManager.h"
class GrGLBitmapTextGeoProc : public GrGLGeometryProcessor {
public:
@@ -78,10 +79,10 @@
}
}
- void setData(const GrGLProgramDataManager& pdman, const GrPrimitiveProcessor& gp) override {
+ void setData(const GrGLSLProgramDataManager& pdman, const GrPrimitiveProcessor& gp) override {
const GrBitmapTextGeoProc& btgp = gp.cast<GrBitmapTextGeoProc>();
if (btgp.color() != fColor && !btgp.hasVertexColor()) {
- GrGLfloat c[4];
+ float c[4];
GrColorToRGBAFloat(btgp.color(), c);
pdman.set4fv(fColorUniform, 1, c);
fColor = btgp.color();
@@ -89,7 +90,7 @@
}
void setTransformData(const GrPrimitiveProcessor& primProc,
- const GrGLProgramDataManager& pdman,
+ const GrGLSLProgramDataManager& pdman,
int index,
const SkTArray<const GrCoordTransform*, true>& transforms) override {
this->setTransformDataHelper<GrBitmapTextGeoProc>(primProc, pdman, index, transforms);
diff --git a/src/gpu/effects/GrConstColorProcessor.cpp b/src/gpu/effects/GrConstColorProcessor.cpp
index 627139f..a290b84 100644
--- a/src/gpu/effects/GrConstColorProcessor.cpp
+++ b/src/gpu/effects/GrConstColorProcessor.cpp
@@ -8,6 +8,7 @@
#include "effects/GrConstColorProcessor.h"
#include "gl/GrGLFragmentProcessor.h"
#include "gl/builders/GrGLProgramBuilder.h"
+#include "glsl/GrGLSLProgramDataManager.h"
class GLConstColorProcessor : public GrGLFragmentProcessor {
public:
@@ -39,14 +40,14 @@
}
protected:
- void onSetData(const GrGLProgramDataManager& pdm, const GrProcessor& processor) override {
+ void onSetData(const GrGLSLProgramDataManager& pdm, const GrProcessor& processor) override {
GrColor color = processor.cast<GrConstColorProcessor>().color();
// We use the "illegal" color value as an uninit sentinel. However, ut isn't inherently
// illegal to use this processor with unpremul colors. So we correctly handle the case
// when the "illegal" color is used but we will always upload it.
if (GrColor_ILLEGAL == color || fPrevColor != color) {
- static const GrGLfloat scale = 1.f / 255.f;
- GrGLfloat floatColor[4] = {
+ static const float scale = 1.f / 255.f;
+ float floatColor[4] = {
GrColorUnpackR(color) * scale,
GrColorUnpackG(color) * scale,
GrColorUnpackB(color) * scale,
@@ -58,7 +59,7 @@
}
private:
- GrGLProgramDataManager::UniformHandle fColorUniform;
+ GrGLSLProgramDataManager::UniformHandle fColorUniform;
GrColor fPrevColor;
typedef GrGLFragmentProcessor INHERITED;
diff --git a/src/gpu/effects/GrConvexPolyEffect.cpp b/src/gpu/effects/GrConvexPolyEffect.cpp
index 3596ab5..d22a347 100644
--- a/src/gpu/effects/GrConvexPolyEffect.cpp
+++ b/src/gpu/effects/GrConvexPolyEffect.cpp
@@ -11,6 +11,7 @@
#include "gl/GrGLContext.h"
#include "gl/GrGLFragmentProcessor.h"
#include "gl/builders/GrGLProgramBuilder.h"
+#include "glsl/GrGLSLProgramDataManager.h"
//////////////////////////////////////////////////////////////////////////////
class AARectEffect : public GrFragmentProcessor {
@@ -87,10 +88,10 @@
static inline void GenKey(const GrProcessor&, const GrGLSLCaps&, GrProcessorKeyBuilder*);
protected:
- void onSetData(const GrGLProgramDataManager&, const GrProcessor&) override;
+ void onSetData(const GrGLSLProgramDataManager&, const GrProcessor&) override;
private:
- GrGLProgramDataManager::UniformHandle fRectUniform;
+ GrGLSLProgramDataManager::UniformHandle fRectUniform;
SkRect fPrevRect;
typedef GrGLFragmentProcessor INHERITED;
};
@@ -138,7 +139,8 @@
(GrGLSLExpr4(args.fInputColor) * GrGLSLExpr1("alpha")).c_str());
}
-void GLAARectEffect::onSetData(const GrGLProgramDataManager& pdman, const GrProcessor& processor) {
+void GLAARectEffect::onSetData(const GrGLSLProgramDataManager& pdman,
+ const GrProcessor& processor) {
const AARectEffect& aare = processor.cast<AARectEffect>();
const SkRect& rect = aare.getRect();
if (rect != fPrevRect) {
@@ -173,10 +175,10 @@
static inline void GenKey(const GrProcessor&, const GrGLSLCaps&, GrProcessorKeyBuilder*);
protected:
- void onSetData(const GrGLProgramDataManager&, const GrProcessor&) override;
+ void onSetData(const GrGLSLProgramDataManager&, const GrProcessor&) override;
private:
- GrGLProgramDataManager::UniformHandle fEdgeUniform;
+ GrGLSLProgramDataManager::UniformHandle fEdgeUniform;
SkScalar fPrevEdges[3 * GrConvexPolyEffect::kMaxEdges];
typedef GrGLFragmentProcessor INHERITED;
};
@@ -222,7 +224,8 @@
(GrGLSLExpr4(args.fInputColor) * GrGLSLExpr1("alpha")).c_str());
}
-void GrGLConvexPolyEffect::onSetData(const GrGLProgramDataManager& pdman, const GrProcessor& effect) {
+void GrGLConvexPolyEffect::onSetData(const GrGLSLProgramDataManager& pdman,
+ const GrProcessor& effect) {
const GrConvexPolyEffect& cpe = effect.cast<GrConvexPolyEffect>();
size_t byteSize = 3 * cpe.getEdgeCount() * sizeof(SkScalar);
if (0 != memcmp(fPrevEdges, cpe.getEdges(), byteSize)) {
diff --git a/src/gpu/effects/GrConvolutionEffect.cpp b/src/gpu/effects/GrConvolutionEffect.cpp
index ef4e791..96d1578 100644
--- a/src/gpu/effects/GrConvolutionEffect.cpp
+++ b/src/gpu/effects/GrConvolutionEffect.cpp
@@ -9,9 +9,10 @@
#include "gl/GrGLFragmentProcessor.h"
#include "gl/GrGLTexture.h"
#include "gl/builders/GrGLProgramBuilder.h"
+#include "glsl/GrGLSLProgramDataManager.h"
// For brevity
-typedef GrGLProgramDataManager::UniformHandle UniformHandle;
+typedef GrGLSLProgramDataManager::UniformHandle UniformHandle;
class GrGLConvolutionEffect : public GrGLFragmentProcessor {
public:
@@ -22,7 +23,7 @@
static inline void GenKey(const GrProcessor&, const GrGLSLCaps&, GrProcessorKeyBuilder*);
protected:
- void onSetData(const GrGLProgramDataManager& pdman, const GrProcessor&) override;
+ void onSetData(const GrGLSLProgramDataManager& pdman, const GrProcessor&) override;
private:
int width() const { return Gr1DKernelEffect::WidthFromRadius(fRadius); }
@@ -100,8 +101,8 @@
fsBuilder->codeAppend(modulate.c_str());
}
-void GrGLConvolutionEffect::onSetData(const GrGLProgramDataManager& pdman,
- const GrProcessor& processor) {
+void GrGLConvolutionEffect::onSetData(const GrGLSLProgramDataManager& pdman,
+ const GrProcessor& processor) {
const GrConvolutionEffect& conv = processor.cast<GrConvolutionEffect>();
GrTexture& texture = *conv.texture(0);
// the code we generated was for a specific kernel radius
diff --git a/src/gpu/effects/GrCoverageSetOpXP.cpp b/src/gpu/effects/GrCoverageSetOpXP.cpp
index 89d7565..b3fe096 100644
--- a/src/gpu/effects/GrCoverageSetOpXP.cpp
+++ b/src/gpu/effects/GrCoverageSetOpXP.cpp
@@ -81,7 +81,7 @@
}
}
- void onSetData(const GrGLProgramDataManager&, const GrXferProcessor&) override {};
+ void onSetData(const GrGLSLProgramDataManager&, const GrXferProcessor&) override {};
typedef GrGLXferProcessor INHERITED;
};
diff --git a/src/gpu/effects/GrCustomXfermode.cpp b/src/gpu/effects/GrCustomXfermode.cpp
index 0d31034..8ebb80a 100644
--- a/src/gpu/effects/GrCustomXfermode.cpp
+++ b/src/gpu/effects/GrCustomXfermode.cpp
@@ -22,6 +22,7 @@
#include "gl/GrGLProgramDataManager.h"
#include "gl/builders/GrGLProgramBuilder.h"
#include "glsl/GrGLSLCaps.h"
+#include "glsl/GrGLSLProgramDataManager.h"
bool GrCustomXfermode::IsSupportedMode(SkXfermode::Mode mode) {
return mode > SkXfermode::kLastCoeffMode && mode <= SkXfermode::kLastMode;
@@ -168,7 +169,7 @@
GrGLSLBlend::AppendMode(fsBuilder, srcColor, dstColor, outColor, xp.mode());
}
- void onSetData(const GrGLProgramDataManager&, const GrXferProcessor&) override {}
+ void onSetData(const GrGLSLProgramDataManager&, const GrXferProcessor&) override {}
typedef GrGLXferProcessor INHERITED;
};
diff --git a/src/gpu/effects/GrDashingEffect.cpp b/src/gpu/effects/GrDashingEffect.cpp
index 106ee49..4a8c09e 100644
--- a/src/gpu/effects/GrDashingEffect.cpp
+++ b/src/gpu/effects/GrDashingEffect.cpp
@@ -24,6 +24,7 @@
#include "gl/GrGLGeometryProcessor.h"
#include "gl/GrGLFragmentProcessor.h"
#include "gl/builders/GrGLProgramBuilder.h"
+#include "glsl/GrGLSLProgramDataManager.h"
///////////////////////////////////////////////////////////////////////////////
@@ -821,10 +822,10 @@
const GrGLSLCaps&,
GrProcessorKeyBuilder*);
- void setData(const GrGLProgramDataManager&, const GrPrimitiveProcessor&) override;
+ void setData(const GrGLSLProgramDataManager&, const GrPrimitiveProcessor&) override;
void setTransformData(const GrPrimitiveProcessor& primProc,
- const GrGLProgramDataManager& pdman,
+ const GrGLSLProgramDataManager& pdman,
int index,
const SkTArray<const GrCoordTransform*, true>& transforms) override {
this->setTransformDataHelper<DashingCircleEffect>(primProc, pdman, index, transforms);
@@ -896,11 +897,11 @@
fsBuilder->codeAppendf("%s = vec4(alpha);", args.fOutputCoverage);
}
-void GLDashingCircleEffect::setData(const GrGLProgramDataManager& pdman,
+void GLDashingCircleEffect::setData(const GrGLSLProgramDataManager& pdman,
const GrPrimitiveProcessor& processor) {
const DashingCircleEffect& dce = processor.cast<DashingCircleEffect>();
if (dce.color() != fColor) {
- GrGLfloat c[4];
+ float c[4];
GrColorToRGBAFloat(dce.color(), c);
pdman.set4fv(fColorUniform, 1, c);
fColor = dce.color();
@@ -1032,10 +1033,10 @@
const GrGLSLCaps&,
GrProcessorKeyBuilder*);
- void setData(const GrGLProgramDataManager&, const GrPrimitiveProcessor&) override;
+ void setData(const GrGLSLProgramDataManager&, const GrPrimitiveProcessor&) override;
void setTransformData(const GrPrimitiveProcessor& primProc,
- const GrGLProgramDataManager& pdman,
+ const GrGLSLProgramDataManager& pdman,
int index,
const SkTArray<const GrCoordTransform*, true>& transforms) override {
this->setTransformDataHelper<DashingLineEffect>(primProc, pdman, index, transforms);
@@ -1120,11 +1121,11 @@
fsBuilder->codeAppendf("%s = vec4(alpha);", args.fOutputCoverage);
}
-void GLDashingLineEffect::setData(const GrGLProgramDataManager& pdman,
+void GLDashingLineEffect::setData(const GrGLSLProgramDataManager& pdman,
const GrPrimitiveProcessor& processor) {
const DashingLineEffect& de = processor.cast<DashingLineEffect>();
if (de.color() != fColor) {
- GrGLfloat c[4];
+ float c[4];
GrColorToRGBAFloat(de.color(), c);
pdman.set4fv(fColorUniform, 1, c);
fColor = de.color();
diff --git a/src/gpu/effects/GrDisableColorXP.cpp b/src/gpu/effects/GrDisableColorXP.cpp
index 3e1024b..0f3382f 100644
--- a/src/gpu/effects/GrDisableColorXP.cpp
+++ b/src/gpu/effects/GrDisableColorXP.cpp
@@ -10,6 +10,7 @@
#include "gl/GrGLXferProcessor.h"
#include "gl/builders/GrGLFragmentShaderBuilder.h"
#include "gl/builders/GrGLProgramBuilder.h"
+#include "glsl/GrGLSLProgramDataManager.h"
/**
* This xfer processor disables color writing. Thus color and coverage and ignored and no blending
@@ -66,7 +67,7 @@
fsBuilder->codeAppendf("%s = vec4(0);", args.fOutputPrimary);
}
- void onSetData(const GrGLProgramDataManager&, const GrXferProcessor&) override {}
+ void onSetData(const GrGLSLProgramDataManager&, const GrXferProcessor&) override {}
typedef GrGLXferProcessor INHERITED;
};
diff --git a/src/gpu/effects/GrDistanceFieldGeoProc.cpp b/src/gpu/effects/GrDistanceFieldGeoProc.cpp
index 79004ae..0cef6be 100644
--- a/src/gpu/effects/GrDistanceFieldGeoProc.cpp
+++ b/src/gpu/effects/GrDistanceFieldGeoProc.cpp
@@ -15,6 +15,7 @@
#include "gl/GrGLTexture.h"
#include "gl/GrGLGeometryProcessor.h"
#include "gl/builders/GrGLProgramBuilder.h"
+#include "glsl/GrGLSLProgramDataManager.h"
// Assuming a radius of a little less than the diagonal of the fragment
#define SK_DistanceFieldAAFactor "0.65"
@@ -143,7 +144,7 @@
fsBuilder->codeAppendf("%s = vec4(val);", args.fOutputCoverage);
}
- void setData(const GrGLProgramDataManager& pdman, const GrPrimitiveProcessor& proc) override {
+ void setData(const GrGLSLProgramDataManager& pdman, const GrPrimitiveProcessor& proc) override {
#ifdef SK_GAMMA_APPLY_TO_A8
const GrDistanceFieldA8TextGeoProc& dfTexEffect = proc.cast<GrDistanceFieldA8TextGeoProc>();
float distanceAdjust = dfTexEffect.getDistanceAdjust();
@@ -156,13 +157,13 @@
if (!dfa8gp.viewMatrix().isIdentity() && !fViewMatrix.cheapEqualTo(dfa8gp.viewMatrix())) {
fViewMatrix = dfa8gp.viewMatrix();
- GrGLfloat viewMatrix[3 * 3];
+ float viewMatrix[3 * 3];
GrGLGetMatrix<3>(viewMatrix, fViewMatrix);
pdman.setMatrix3f(fViewMatrixUniform, viewMatrix);
}
if (dfa8gp.color() != fColor && !dfa8gp.hasVertexColor()) {
- GrGLfloat c[4];
+ float c[4];
GrColorToRGBAFloat(dfa8gp.color(), c);
pdman.set4fv(fColorUniform, 1, c);
fColor = dfa8gp.color();
@@ -370,7 +371,7 @@
fsBuilder->codeAppendf("%s = vec4(val);", args.fOutputCoverage);
}
- void setData(const GrGLProgramDataManager& pdman, const GrPrimitiveProcessor& proc) override {
+ void setData(const GrGLSLProgramDataManager& pdman, const GrPrimitiveProcessor& proc) override {
SkASSERT(fTextureSizeUni.isValid());
GrTexture* texture = proc.texture(0);
@@ -386,13 +387,13 @@
if (!dfpgp.viewMatrix().isIdentity() && !fViewMatrix.cheapEqualTo(dfpgp.viewMatrix())) {
fViewMatrix = dfpgp.viewMatrix();
- GrGLfloat viewMatrix[3 * 3];
+ float viewMatrix[3 * 3];
GrGLGetMatrix<3>(viewMatrix, fViewMatrix);
pdman.setMatrix3f(fViewMatrixUniform, viewMatrix);
}
if (dfpgp.color() != fColor) {
- GrGLfloat c[4];
+ float c[4];
GrColorToRGBAFloat(dfpgp.color(), c);
pdman.set4fv(fColorUniform, 1, c);
fColor = dfpgp.color();
@@ -639,7 +640,7 @@
fsBuilder->codeAppendf("%s = val;", args.fOutputCoverage);
}
- void setData(const GrGLProgramDataManager& pdman,
+ void setData(const GrGLSLProgramDataManager& pdman,
const GrPrimitiveProcessor& processor) override {
SkASSERT(fDistanceAdjustUni.isValid());
@@ -655,13 +656,13 @@
if (!dflcd.viewMatrix().isIdentity() && !fViewMatrix.cheapEqualTo(dflcd.viewMatrix())) {
fViewMatrix = dflcd.viewMatrix();
- GrGLfloat viewMatrix[3 * 3];
+ float viewMatrix[3 * 3];
GrGLGetMatrix<3>(viewMatrix, fViewMatrix);
pdman.setMatrix3f(fViewMatrixUniform, viewMatrix);
}
if (dflcd.color() != fColor) {
- GrGLfloat c[4];
+ float c[4];
GrColorToRGBAFloat(dflcd.color(), c);
pdman.set4fv(fColorUniform, 1, c);
fColor = dflcd.color();
diff --git a/src/gpu/effects/GrMatrixConvolutionEffect.cpp b/src/gpu/effects/GrMatrixConvolutionEffect.cpp
index 8de8580..af09db5 100644
--- a/src/gpu/effects/GrMatrixConvolutionEffect.cpp
+++ b/src/gpu/effects/GrMatrixConvolutionEffect.cpp
@@ -8,6 +8,7 @@
#include "gl/GrGLFragmentProcessor.h"
#include "gl/GrGLTexture.h"
#include "gl/builders/GrGLProgramBuilder.h"
+#include "glsl/GrGLSLProgramDataManager.h"
class GrGLMatrixConvolutionEffect : public GrGLFragmentProcessor {
public:
@@ -17,10 +18,10 @@
static inline void GenKey(const GrProcessor&, const GrGLSLCaps&, GrProcessorKeyBuilder*);
protected:
- void onSetData(const GrGLProgramDataManager&, const GrProcessor&) override;
+ void onSetData(const GrGLSLProgramDataManager&, const GrProcessor&) override;
private:
- typedef GrGLProgramDataManager::UniformHandle UniformHandle;
+ typedef GrGLSLProgramDataManager::UniformHandle UniformHandle;
SkISize fKernelSize;
bool fConvolveAlpha;
@@ -111,8 +112,8 @@
b->add32(GrTextureDomain::GLDomain::DomainKey(m.domain()));
}
-void GrGLMatrixConvolutionEffect::onSetData(const GrGLProgramDataManager& pdman,
- const GrProcessor& processor) {
+void GrGLMatrixConvolutionEffect::onSetData(const GrGLSLProgramDataManager& pdman,
+ const GrProcessor& processor) {
const GrMatrixConvolutionEffect& conv = processor.cast<GrMatrixConvolutionEffect>();
GrTexture& texture = *conv.texture(0);
// the code we generated was for a specific kernel size
diff --git a/src/gpu/effects/GrOvalEffect.cpp b/src/gpu/effects/GrOvalEffect.cpp
index 42b71ad..1bc6589 100644
--- a/src/gpu/effects/GrOvalEffect.cpp
+++ b/src/gpu/effects/GrOvalEffect.cpp
@@ -12,6 +12,7 @@
#include "SkRect.h"
#include "gl/GrGLFragmentProcessor.h"
#include "gl/builders/GrGLProgramBuilder.h"
+#include "glsl/GrGLSLProgramDataManager.h"
//////////////////////////////////////////////////////////////////////////////
@@ -98,12 +99,12 @@
static inline void GenKey(const GrProcessor&, const GrGLSLCaps&, GrProcessorKeyBuilder*);
protected:
- void onSetData(const GrGLProgramDataManager&, const GrProcessor&) override;
+ void onSetData(const GrGLSLProgramDataManager&, const GrProcessor&) override;
private:
- GrGLProgramDataManager::UniformHandle fCircleUniform;
- SkPoint fPrevCenter;
- SkScalar fPrevRadius;
+ GrGLSLProgramDataManager::UniformHandle fCircleUniform;
+ SkPoint fPrevCenter;
+ SkScalar fPrevRadius;
typedef GrGLFragmentProcessor INHERITED;
};
@@ -153,7 +154,8 @@
b->add32(ce.getEdgeType());
}
-void GLCircleEffect::onSetData(const GrGLProgramDataManager& pdman, const GrProcessor& processor) {
+void GLCircleEffect::onSetData(const GrGLSLProgramDataManager& pdman,
+ const GrProcessor& processor) {
const CircleEffect& ce = processor.cast<CircleEffect>();
if (ce.getRadius() != fPrevRadius || ce.getCenter() != fPrevCenter) {
SkScalar radius = ce.getRadius();
@@ -269,12 +271,12 @@
static inline void GenKey(const GrProcessor&, const GrGLSLCaps&, GrProcessorKeyBuilder*);
protected:
- void onSetData(const GrGLProgramDataManager&, const GrProcessor&) override;
+ void onSetData(const GrGLSLProgramDataManager&, const GrProcessor&) override;
private:
- GrGLProgramDataManager::UniformHandle fEllipseUniform;
- SkPoint fPrevCenter;
- SkVector fPrevRadii;
+ GrGLSLProgramDataManager::UniformHandle fEllipseUniform;
+ SkPoint fPrevCenter;
+ SkVector fPrevRadii;
typedef GrGLFragmentProcessor INHERITED;
};
@@ -334,7 +336,8 @@
b->add32(ee.getEdgeType());
}
-void GLEllipseEffect::onSetData(const GrGLProgramDataManager& pdman, const GrProcessor& effect) {
+void GLEllipseEffect::onSetData(const GrGLSLProgramDataManager& pdman,
+ const GrProcessor& effect) {
const EllipseEffect& ee = effect.cast<EllipseEffect>();
if (ee.getRadii() != fPrevRadii || ee.getCenter() != fPrevCenter) {
SkScalar invRXSqd = 1.f / (ee.getRadii().fX * ee.getRadii().fX);
diff --git a/src/gpu/effects/GrPorterDuffXferProcessor.cpp b/src/gpu/effects/GrPorterDuffXferProcessor.cpp
index e31ff65..a7f390a 100644
--- a/src/gpu/effects/GrPorterDuffXferProcessor.cpp
+++ b/src/gpu/effects/GrPorterDuffXferProcessor.cpp
@@ -17,6 +17,7 @@
#include "gl/GrGLXferProcessor.h"
#include "gl/builders/GrGLFragmentShaderBuilder.h"
#include "gl/builders/GrGLProgramBuilder.h"
+#include "glsl/GrGLSLProgramDataManager.h"
/**
* Wraps the shader outputs and HW blend state that comprise a Porter Duff blend mode with coverage.
@@ -450,7 +451,7 @@
args.fOutputPrimary, args.fInputColor, args.fInputCoverage);
}
- void onSetData(const GrGLProgramDataManager&, const GrXferProcessor&) override {}
+ void onSetData(const GrGLSLProgramDataManager&, const GrXferProcessor&) override {}
typedef GrGLXferProcessor INHERITED;
};
@@ -550,7 +551,7 @@
GrGLSLBlend::AppendMode(fsBuilder, srcColor, dstColor, outColor, xp.getXfermode());
}
- void onSetData(const GrGLProgramDataManager&, const GrXferProcessor&) override {}
+ void onSetData(const GrGLSLProgramDataManager&, const GrXferProcessor&) override {}
typedef GrGLXferProcessor INHERITED;
};
@@ -628,7 +629,7 @@
args.fInputCoverage);
}
- void onSetData(const GrGLProgramDataManager&, const GrXferProcessor&) override {};
+ void onSetData(const GrGLSLProgramDataManager&, const GrXferProcessor&) override {};
typedef GrGLXferProcessor INHERITED;
};
diff --git a/src/gpu/effects/GrRRectEffect.cpp b/src/gpu/effects/GrRRectEffect.cpp
index b5b9567..aeab0e4 100644
--- a/src/gpu/effects/GrRRectEffect.cpp
+++ b/src/gpu/effects/GrRRectEffect.cpp
@@ -14,6 +14,7 @@
#include "SkRRect.h"
#include "gl/GrGLFragmentProcessor.h"
#include "gl/builders/GrGLProgramBuilder.h"
+#include "glsl/GrGLSLProgramDataManager.h"
// The effects defined here only handle rrect radii >= kRadiusMin.
static const SkScalar kRadiusMin = SK_ScalarHalf;
@@ -133,11 +134,11 @@
static inline void GenKey(const GrProcessor&, const GrGLSLCaps&, GrProcessorKeyBuilder*);
protected:
- void onSetData(const GrGLProgramDataManager&, const GrProcessor&) override;
+ void onSetData(const GrGLSLProgramDataManager&, const GrProcessor&) override;
private:
- GrGLProgramDataManager::UniformHandle fInnerRectUniform;
- GrGLProgramDataManager::UniformHandle fRadiusPlusHalfUniform;
+ GrGLSLProgramDataManager::UniformHandle fInnerRectUniform;
+ GrGLSLProgramDataManager::UniformHandle fRadiusPlusHalfUniform;
SkRRect fPrevRRect;
typedef GrGLFragmentProcessor INHERITED;
};
@@ -281,8 +282,8 @@
b->add32((crre.getCircularCornerFlags() << 3) | crre.getEdgeType());
}
-void GLCircularRRectEffect::onSetData(const GrGLProgramDataManager& pdman,
- const GrProcessor& processor) {
+void GLCircularRRectEffect::onSetData(const GrGLSLProgramDataManager& pdman,
+ const GrProcessor& processor) {
const CircularRRectEffect& crre = processor.cast<CircularRRectEffect>();
const SkRRect& rrect = crre.getRRect();
if (rrect != fPrevRRect) {
@@ -479,11 +480,11 @@
static inline void GenKey(const GrProcessor&, const GrGLSLCaps&, GrProcessorKeyBuilder*);
protected:
- void onSetData(const GrGLProgramDataManager&, const GrProcessor&) override;
+ void onSetData(const GrGLSLProgramDataManager&, const GrProcessor&) override;
private:
- GrGLProgramDataManager::UniformHandle fInnerRectUniform;
- GrGLProgramDataManager::UniformHandle fInvRadiiSqdUniform;
+ GrGLSLProgramDataManager::UniformHandle fInnerRectUniform;
+ GrGLSLProgramDataManager::UniformHandle fInvRadiiSqdUniform;
SkRRect fPrevRRect;
typedef GrGLFragmentProcessor INHERITED;
};
@@ -572,8 +573,8 @@
b->add32(erre.getRRect().getType() | erre.getEdgeType() << 3);
}
-void GLEllipticalRRectEffect::onSetData(const GrGLProgramDataManager& pdman,
- const GrProcessor& effect) {
+void GLEllipticalRRectEffect::onSetData(const GrGLSLProgramDataManager& pdman,
+ const GrProcessor& effect) {
const EllipticalRRectEffect& erre = effect.cast<EllipticalRRectEffect>();
const SkRRect& rrect = erre.getRRect();
if (rrect != fPrevRRect) {
diff --git a/src/gpu/effects/GrTextureDomain.cpp b/src/gpu/effects/GrTextureDomain.cpp
index 93d3afb..760fd57 100644
--- a/src/gpu/effects/GrTextureDomain.cpp
+++ b/src/gpu/effects/GrTextureDomain.cpp
@@ -12,6 +12,7 @@
#include "gl/GrGLContext.h"
#include "gl/GrGLFragmentProcessor.h"
#include "gl/builders/GrGLProgramBuilder.h"
+#include "glsl/GrGLSLProgramDataManager.h"
GrTextureDomain::GrTextureDomain(const SkRect& domain, Mode mode, int index)
: fIndex(index) {
@@ -142,12 +143,12 @@
}
}
-void GrTextureDomain::GLDomain::setData(const GrGLProgramDataManager& pdman,
+void GrTextureDomain::GLDomain::setData(const GrGLSLProgramDataManager& pdman,
const GrTextureDomain& textureDomain,
GrSurfaceOrigin textureOrigin) {
SkASSERT(textureDomain.mode() == fMode);
if (kIgnore_Mode != textureDomain.mode()) {
- GrGLfloat values[kPrevDomainCount] = {
+ float values[kPrevDomainCount] = {
SkScalarToFloat(textureDomain.domain().left()),
SkScalarToFloat(textureDomain.domain().top()),
SkScalarToFloat(textureDomain.domain().right()),
@@ -161,9 +162,9 @@
// of elements so that values = (l, t, r, b).
SkTSwap(values[1], values[3]);
}
- if (0 != memcmp(values, fPrevDomain, kPrevDomainCount * sizeof(GrGLfloat))) {
+ if (0 != memcmp(values, fPrevDomain, kPrevDomainCount * sizeof(float))) {
pdman.set4fv(fDomainUni, 1, values);
- memcpy(fPrevDomain, values, kPrevDomainCount * sizeof(GrGLfloat));
+ memcpy(fPrevDomain, values, kPrevDomainCount * sizeof(float));
}
}
}
@@ -180,7 +181,7 @@
static inline void GenKey(const GrProcessor&, const GrGLSLCaps&, GrProcessorKeyBuilder*);
protected:
- void onSetData(const GrGLProgramDataManager&, const GrProcessor&) override;
+ void onSetData(const GrGLSLProgramDataManager&, const GrProcessor&) override;
private:
GrTextureDomain::GLDomain fGLDomain;
@@ -200,8 +201,8 @@
args.fInputColor);
}
-void GrGLTextureDomainEffect::onSetData(const GrGLProgramDataManager& pdman,
- const GrProcessor& processor) {
+void GrGLTextureDomainEffect::onSetData(const GrGLSLProgramDataManager& pdman,
+ const GrProcessor& processor) {
const GrTextureDomainEffect& textureDomainEffect = processor.cast<GrTextureDomainEffect>();
const GrTextureDomain& domain = textureDomainEffect.textureDomain();
fGLDomain.setData(pdman, domain, processor.texture(0)->origin());
diff --git a/src/gpu/effects/GrTextureDomain.h b/src/gpu/effects/GrTextureDomain.h
index 978a68c..0b93ac8 100644
--- a/src/gpu/effects/GrTextureDomain.h
+++ b/src/gpu/effects/GrTextureDomain.h
@@ -10,6 +10,7 @@
#include "GrSingleTextureEffect.h"
#include "gl/GrGLFragmentProcessor.h"
+#include "glsl/GrGLSLProgramDataManager.h"
class GrGLProgramBuilder;
class GrGLShaderBuilder;
@@ -122,7 +123,7 @@
* Call this from GrGLProcessor::setData() to upload uniforms necessary for the texture
* domain. The rectangle is automatically adjusted to account for the texture's origin.
*/
- void setData(const GrGLProgramDataManager& pdman, const GrTextureDomain& textureDomain,
+ void setData(const GrGLSLProgramDataManager& pdman, const GrTextureDomain& textureDomain,
GrSurfaceOrigin textureOrigin);
enum {
@@ -140,10 +141,10 @@
private:
static const int kPrevDomainCount = 4;
- SkDEBUGCODE(Mode fMode;)
- GrGLProgramDataManager::UniformHandle fDomainUni;
- SkString fDomainName;
- GrGLfloat fPrevDomain[kPrevDomainCount];
+ SkDEBUGCODE(Mode fMode;)
+ GrGLSLProgramDataManager::UniformHandle fDomainUni;
+ SkString fDomainName;
+ float fPrevDomain[kPrevDomainCount];
};
protected:
diff --git a/src/gpu/effects/GrYUVtoRGBEffect.cpp b/src/gpu/effects/GrYUVtoRGBEffect.cpp
index a0ee114..39a9743 100644
--- a/src/gpu/effects/GrYUVtoRGBEffect.cpp
+++ b/src/gpu/effects/GrYUVtoRGBEffect.cpp
@@ -12,6 +12,7 @@
#include "GrProcessor.h"
#include "gl/GrGLFragmentProcessor.h"
#include "gl/builders/GrGLProgramBuilder.h"
+#include "glsl/GrGLSLProgramDataManager.h"
namespace {
@@ -52,9 +53,9 @@
class GLProcessor : public GrGLFragmentProcessor {
public:
- static const GrGLfloat kJPEGConversionMatrix[16];
- static const GrGLfloat kRec601ConversionMatrix[16];
- static const GrGLfloat kRec709ConversionMatrix[16];
+ static const float kJPEGConversionMatrix[16];
+ static const float kRec601ConversionMatrix[16];
+ static const float kRec709ConversionMatrix[16];
// this class always generates the same code.
static void GenKey(const GrProcessor&, const GrGLSLCaps&, GrProcessorKeyBuilder*) {}
@@ -81,8 +82,8 @@
}
protected:
- virtual void onSetData(const GrGLProgramDataManager& pdman,
- const GrProcessor& processor) override {
+ virtual void onSetData(const GrGLSLProgramDataManager& pdman,
+ const GrProcessor& processor) override {
const YUVtoRGBEffect& yuvEffect = processor.cast<YUVtoRGBEffect>();
switch (yuvEffect.getColorSpace()) {
case kJPEG_SkYUVColorSpace:
@@ -98,7 +99,7 @@
}
private:
- GrGLProgramDataManager::UniformHandle fMatrixUni;
+ GrGLSLProgramDataManager::UniformHandle fMatrixUni;
typedef GrGLFragmentProcessor INHERITED;
};
@@ -152,17 +153,17 @@
typedef GrFragmentProcessor INHERITED;
};
-const GrGLfloat YUVtoRGBEffect::GLProcessor::kJPEGConversionMatrix[16] = {
+const float YUVtoRGBEffect::GLProcessor::kJPEGConversionMatrix[16] = {
1.0f, 0.0f, 1.402f, -0.701f,
1.0f, -0.34414f, -0.71414f, 0.529f,
1.0f, 1.772f, 0.0f, -0.886f,
0.0f, 0.0f, 0.0f, 1.0};
-const GrGLfloat YUVtoRGBEffect::GLProcessor::kRec601ConversionMatrix[16] = {
+const float YUVtoRGBEffect::GLProcessor::kRec601ConversionMatrix[16] = {
1.164f, 0.0f, 1.596f, -0.87075f,
1.164f, -0.391f, -0.813f, 0.52925f,
1.164f, 2.018f, 0.0f, -1.08175f,
0.0f, 0.0f, 0.0f, 1.0};
-const GrGLfloat YUVtoRGBEffect::GLProcessor::kRec709ConversionMatrix[16] = {
+const float YUVtoRGBEffect::GLProcessor::kRec709ConversionMatrix[16] = {
1.164f, 0.0f, 1.793f, -0.96925f,
1.164f, -0.213f, -0.533f, 0.30025f,
1.164f, 2.112f, 0.0f, -1.12875f,
diff --git a/src/gpu/gl/GrGLFragmentProcessor.cpp b/src/gpu/gl/GrGLFragmentProcessor.cpp
index 225e5bf..5f30262 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 1e4dd48..00bd063 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 @@
}
}
- typedef GrGLProgramDataManager::UniformHandle UniformHandle;
+ typedef GrGLSLProgramDataManager::UniformHandle UniformHandle;
typedef GrGLProcessor::TransformedCoordsArray TransformedCoordsArray;
typedef GrGLProcessor::TextureSamplerArray TextureSamplerArray;
@@ -70,7 +70,7 @@
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 @@
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 1c7ab53..1b3b8d9 100644
--- a/src/gpu/gl/GrGLGeometryProcessor.h
+++ b/src/gpu/gl/GrGLGeometryProcessor.h
@@ -24,7 +24,7 @@
// 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 @@
// 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 @@
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 d74b54a..84794ac 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 @@
"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 a74014b..f18a4c6 100644
--- a/src/gpu/gl/GrGLPathRendering.cpp
+++ b/src/gpu/gl/GrGLPathRendering.cpp
@@ -186,7 +186,7 @@
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 @@
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 651ddee..d61df2f 100644
--- a/src/gpu/gl/GrGLPathRendering.h
+++ b/src/gpu/gl/GrGLPathRendering.h
@@ -94,7 +94,7 @@
/**
* 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 bf1c388..cff9640 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 @@
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 @@
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 @@
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 f99b1c5..c389ce4 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 08127c8..552a0fb 100644
--- a/src/gpu/gl/GrGLProgram.cpp
+++ b/src/gpu/gl/GrGLProgram.cpp
@@ -135,7 +135,7 @@
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 9c5ab73..dc64a70 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 @@
* 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 @@
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 590287e..7320b2d 100644
--- a/src/gpu/gl/GrGLProgramDataManager.cpp
+++ b/src/gpu/gl/GrGLProgramDataManager.cpp
@@ -60,7 +60,7 @@
}
}
-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::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::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::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::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::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::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::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::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::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::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::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::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::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 04d519f..ea7b19e 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 @@
* 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 @@
/** 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 @@
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 5579701..7f0713e 100644
--- a/src/gpu/gl/GrGLUtil.cpp
+++ b/src/gpu/gl/GrGLUtil.cpp
@@ -306,7 +306,8 @@
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 @@
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 35dfe6a..dec784c 100644
--- a/src/gpu/gl/GrGLUtil.h
+++ b/src/gpu/gl/GrGLUtil.h
@@ -141,7 +141,7 @@
/**
* 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 e624971..528d354 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::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 c9c6cb5..bf16cf4 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 @@
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 @@
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 a0ddcf2..b74a867 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 @@
}
}
-GrGLProgramDataManager::UniformHandle GrGLProgramBuilder::addUniformArray(
+GrGLSLProgramDataManager::UniformHandle GrGLProgramBuilder::addUniformArray(
uint32_t visibility,
GrSLType type,
GrSLPrecision precision,
@@ -152,7 +153,7 @@
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 11c367d..7690b39 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 @@
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.
diff --git a/src/gpu/glsl/GrGLSLProgramDataManager.h b/src/gpu/glsl/GrGLSLProgramDataManager.h
new file mode 100644
index 0000000..29513f0
--- /dev/null
+++ b/src/gpu/glsl/GrGLSLProgramDataManager.h
@@ -0,0 +1,78 @@
+/*
+ * Copyright 2015 Google Inc.
+ *
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#ifndef GrGLSLProgramDataManager_DEFINED
+#define GrGLSLProgramDataManager_DEFINED
+
+#include "SkTypes.h"
+
+/** Manages the resources used by a shader program.
+ * The resources are objects the program uses to communicate with the
+ * application code.
+ */
+class GrGLSLProgramDataManager : SkNoncopyable {
+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;
+
+ virtual ~GrGLSLProgramDataManager() {}
+
+ /** 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.
+ */
+ virtual void set1f(UniformHandle, float v0) const = 0;
+ virtual void set1fv(UniformHandle, int arrayCount, const float v[]) const = 0;
+ virtual void set2f(UniformHandle, float, float) const = 0;
+ virtual void set2fv(UniformHandle, int arrayCount, const float v[]) const = 0;
+ virtual void set3f(UniformHandle, float, float, float) const = 0;
+ virtual void set3fv(UniformHandle, int arrayCount, const float v[]) const = 0;
+ virtual void set4f(UniformHandle, float, float, float, float) const = 0;
+ virtual void set4fv(UniformHandle, int arrayCount, const float v[]) const = 0;
+ // matrices are column-major, the first three upload a single matrix, the latter three upload
+ // arrayCount matrices into a uniform array.
+ virtual void setMatrix3f(UniformHandle, const float matrix[]) const = 0;
+ virtual void setMatrix4f(UniformHandle, const float matrix[]) const = 0;
+ virtual void setMatrix3fv(UniformHandle, int arrayCount, const float matrices[]) const = 0;
+ virtual void setMatrix4fv(UniformHandle, int arrayCount, const float matrices[]) const = 0;
+
+ // convenience method for uploading a SkMatrix to a 3x3 matrix uniform
+ virtual void setSkMatrix(UniformHandle, const SkMatrix&) const = 0;
+
+ // for nvpr only
+ typedef ShaderResourceHandle SeparableVaryingHandle;
+ virtual void setPathFragmentInputTransform(SeparableVaryingHandle u, int components,
+ const SkMatrix& matrix) const = 0;
+
+protected:
+ GrGLSLProgramDataManager() {}
+
+private:
+
+ typedef SkNoncopyable INHERITED;
+};
+
+#endif