aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/gpu/gl
diff options
context:
space:
mode:
authorGravatar tomhudson@google.com <tomhudson@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2012-07-12 17:23:52 +0000
committerGravatar tomhudson@google.com <tomhudson@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2012-07-12 17:23:52 +0000
commitd0c1a06cb98dd4a009dfa79e37ba6ca23a8c180b (patch)
tree8da05f518d09f633dfd00f94b45593182089deac /src/gpu/gl
parentd7727ceb82e271f8b5580c51571c57b09c5e3ced (diff)
Introduces new SingleTextureEffect base class for GrCustomStage objects.
This class tracks the texture that the object uses. A future commit will get rid of the GrTexture pointer currenty stored in the GrDrawState, allowing us to have CustomStages *without* textures. Requires gyp change on next roll. http://codereview.appspot.com/6306097/ git-svn-id: http://skia.googlecode.com/svn/trunk@4576 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'src/gpu/gl')
-rw-r--r--src/gpu/gl/GrGLProgramStage.cpp1
-rw-r--r--src/gpu/gl/GrGLProgramStage.h1
-rw-r--r--src/gpu/gl/GrGpuGL.cpp15
-rw-r--r--src/gpu/gl/GrGpuGL.h1
-rw-r--r--src/gpu/gl/GrGpuGL_program.cpp2
-rw-r--r--src/gpu/gl/GrGpuGL_unittest.cpp27
6 files changed, 32 insertions, 15 deletions
diff --git a/src/gpu/gl/GrGLProgramStage.cpp b/src/gpu/gl/GrGLProgramStage.cpp
index 487b46865f..b5e4f4068c 100644
--- a/src/gpu/gl/GrGLProgramStage.cpp
+++ b/src/gpu/gl/GrGLProgramStage.cpp
@@ -26,7 +26,6 @@ void GrGLProgramStage::initUniforms(const GrGLInterface*, int progID) {
}
void GrGLProgramStage::setData(const GrGLInterface*,
- const GrGLTexture&,
const GrCustomStage&,
int stageNum) {
}
diff --git a/src/gpu/gl/GrGLProgramStage.h b/src/gpu/gl/GrGLProgramStage.h
index fe3ed4b9b7..9cf2c1aa97 100644
--- a/src/gpu/gl/GrGLProgramStage.h
+++ b/src/gpu/gl/GrGLProgramStage.h
@@ -82,7 +82,6 @@ public:
a stage and uploads any uniform variables required by the shaders
created in emit*(). */
virtual void setData(const GrGLInterface* gl,
- const GrGLTexture& texture,
const GrCustomStage& stage,
int stageNum);
diff --git a/src/gpu/gl/GrGpuGL.cpp b/src/gpu/gl/GrGpuGL.cpp
index 7ebe9d7f06..edabb9c108 100644
--- a/src/gpu/gl/GrGpuGL.cpp
+++ b/src/gpu/gl/GrGpuGL.cpp
@@ -2140,6 +2140,21 @@ void GrGpuGL::flushBoundTextureAndParams(int stage) {
GrGLTexture* nextTexture =
static_cast<GrGLTexture*>(drawState->getTexture(stage));
+ // HACK - if we're using a new SingleTextureEffect, override
+ // the old texture pointer
+ const GrSamplerState& sampler = drawState->getSampler(stage);
+ GrCustomStage* customStage = sampler.getCustomStage();
+ if (customStage && customStage->numTextures()) {
+ nextTexture =
+ static_cast<GrGLTexture*>(customStage->texture(0));
+ }
+
+ flushBoundTextureAndParams(stage, nextTexture);
+}
+
+void GrGpuGL::flushBoundTextureAndParams(int stage, GrGLTexture* nextTexture) {
+ GrDrawState* drawState = this->drawState();
+
// true for now, but maybe not with GrEffect.
GrAssert(NULL != nextTexture);
// if we created a rt/tex and rendered to it without using a
diff --git a/src/gpu/gl/GrGpuGL.h b/src/gpu/gl/GrGpuGL.h
index 2d6aa68120..0871a57b7e 100644
--- a/src/gpu/gl/GrGpuGL.h
+++ b/src/gpu/gl/GrGpuGL.h
@@ -213,6 +213,7 @@ private:
// call to flushScissor must occur after all textures have been flushed via
// this function.
void flushBoundTextureAndParams(int stage);
+ void flushBoundTextureAndParams(int stage, GrGLTexture* nextTexture);
// sets the texture matrix and domain for the currently bound program
void flushTextureMatrixAndDomain(int stage);
diff --git a/src/gpu/gl/GrGpuGL_program.cpp b/src/gpu/gl/GrGpuGL_program.cpp
index 3a3d6386f0..a7187d548c 100644
--- a/src/gpu/gl/GrGpuGL_program.cpp
+++ b/src/gpu/gl/GrGpuGL_program.cpp
@@ -479,7 +479,7 @@ bool GrGpuGL::flushGraphicsState(DrawType type) {
static_cast<const GrGLTexture*>(
this->getDrawState().getTexture(s));
fProgramData->fCustomStage[s]->setData(
- this->glInterface(), *texture,
+ this->glInterface(),
*sampler.getCustomStage(), s);
}
}
diff --git a/src/gpu/gl/GrGpuGL_unittest.cpp b/src/gpu/gl/GrGpuGL_unittest.cpp
index 044d4777d9..004013a55a 100644
--- a/src/gpu/gl/GrGpuGL_unittest.cpp
+++ b/src/gpu/gl/GrGpuGL_unittest.cpp
@@ -77,7 +77,8 @@ GrCustomStage* create_random_effect(StageDesc* stageDesc,
stageDesc->fOptFlags |= StageDesc::kNoPerspective_OptFlagBit;
stageDesc->fInConfigFlags &= ~kMulByAlphaMask;
return SkNEW_ARGS(GrConvolutionEffect,
- (gKernelDirections[direction],
+ (NULL,
+ gKernelDirections[direction],
kernelRadius,
kernel));
}
@@ -88,7 +89,8 @@ GrCustomStage* create_random_effect(StageDesc* stageDesc,
stageDesc->fOptFlags |= StageDesc::kNoPerspective_OptFlagBit;
stageDesc->fInConfigFlags &= ~kMulByAlphaMask;
return SkNEW_ARGS(GrMorphologyEffect,
- (gKernelDirections[direction],
+ (NULL,
+ gKernelDirections[direction],
kernelRadius,
GrContext::kErode_MorphologyType));
}
@@ -99,12 +101,13 @@ GrCustomStage* create_random_effect(StageDesc* stageDesc,
stageDesc->fOptFlags |= StageDesc::kNoPerspective_OptFlagBit;
stageDesc->fInConfigFlags &= ~kMulByAlphaMask;
return SkNEW_ARGS(GrMorphologyEffect,
- (gKernelDirections[direction],
+ (NULL,
+ gKernelDirections[direction],
kernelRadius,
GrContext::kDilate_MorphologyType));
}
case kRadialGradient_EffectType: {
- return SkNEW(GrRadialGradient);
+ return SkNEW_ARGS(GrRadialGradient, (NULL));
}
case kRadial2Gradient_EffectType: {
float center;
@@ -113,10 +116,10 @@ GrCustomStage* create_random_effect(StageDesc* stageDesc,
} while (GR_Scalar1 == center);
float radius = random->nextF();
bool root = random_bool(random);
- return SkNEW_ARGS(GrRadial2Gradient, (center, radius, root));
+ return SkNEW_ARGS(GrRadial2Gradient, (NULL, center, radius, root));
}
case kSweepGradient_EffectType: {
- return SkNEW(GrSweepGradient);
+ return SkNEW_ARGS(GrSweepGradient, (NULL));
}
case kDiffuseDistant_EffectType: {
SkPoint3 direction = random_point3(random);
@@ -127,7 +130,7 @@ GrCustomStage* create_random_effect(StageDesc* stageDesc,
SkAutoTUnref<SkImageFilter> filter(SkLightingImageFilter::CreateDistantLitDiffuse(direction, lightColor, surfaceScale, kd));
// does not work with perspective or mul-by-alpha-mask
GrCustomStage* stage;
- bool ok = filter->asNewCustomStage(&stage);
+ bool ok = filter->asNewCustomStage(&stage, NULL);
SkASSERT(ok);
return stage;
}
@@ -139,7 +142,7 @@ GrCustomStage* create_random_effect(StageDesc* stageDesc,
SkAutoTUnref<SkImageFilter> filter(SkLightingImageFilter::CreatePointLitDiffuse(location, lightColor, surfaceScale, kd));
// does not work with perspective or mul-by-alpha-mask
GrCustomStage* stage;
- bool ok = filter->asNewCustomStage(&stage);
+ bool ok = filter->asNewCustomStage(&stage, NULL);
SkASSERT(ok);
return stage;
}
@@ -156,7 +159,7 @@ GrCustomStage* create_random_effect(StageDesc* stageDesc,
location, target, specularExponent, cutoffAngle, lightColor, surfaceScale, ks, shininess));
// does not work with perspective or mul-by-alpha-mask
GrCustomStage* stage;
- bool ok = filter->asNewCustomStage(&stage);
+ bool ok = filter->asNewCustomStage(&stage, NULL);
SkASSERT(ok);
return stage;
}
@@ -170,7 +173,7 @@ GrCustomStage* create_random_effect(StageDesc* stageDesc,
SkAutoTUnref<SkImageFilter> filter(SkLightingImageFilter::CreateDistantLitSpecular(direction, lightColor, surfaceScale, ks, shininess));
// does not work with perspective or mul-by-alpha-mask
GrCustomStage* stage;
- bool ok = filter->asNewCustomStage(&stage);
+ bool ok = filter->asNewCustomStage(&stage, NULL);
SkASSERT(ok);
return stage;
}
@@ -183,7 +186,7 @@ GrCustomStage* create_random_effect(StageDesc* stageDesc,
SkAutoTUnref<SkImageFilter> filter(SkLightingImageFilter::CreatePointLitSpecular(location, lightColor, surfaceScale, ks, shininess));
// does not work with perspective or mul-by-alpha-mask
GrCustomStage* stage;
- bool ok = filter->asNewCustomStage(&stage);
+ bool ok = filter->asNewCustomStage(&stage, NULL);
SkASSERT(ok);
return stage;
}
@@ -200,7 +203,7 @@ GrCustomStage* create_random_effect(StageDesc* stageDesc,
location, target, specularExponent, cutoffAngle, lightColor, surfaceScale, ks, shininess));
// does not work with perspective or mul-by-alpha-mask
GrCustomStage* stage;
- bool ok = filter->asNewCustomStage(&stage);
+ bool ok = filter->asNewCustomStage(&stage, NULL);
SkASSERT(ok);
return stage;
}