aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--include/gpu/GrPaint.h18
-rw-r--r--src/gpu/GrContext.cpp2
-rw-r--r--src/gpu/GrDrawState.h14
-rw-r--r--src/gpu/SkGpuDevice.cpp5
-rw-r--r--src/gpu/gl/GrGpuGL.cpp9
5 files changed, 24 insertions, 24 deletions
diff --git a/include/gpu/GrPaint.h b/include/gpu/GrPaint.h
index 3c8c47afe4..8b1bf2c51e 100644
--- a/include/gpu/GrPaint.h
+++ b/include/gpu/GrPaint.h
@@ -149,19 +149,15 @@ public:
}
for (int i = 0; i < kMaxTextures; ++i) {
- GrSafeUnref(fTextures[i]);
- fTextures[i] = paint.fTextures[i];
- if (NULL != fTextures[i]) {
+ GrSafeAssign(fTextures[i], paint.fTextures[i]);
+ if (paint.isTextureStageEnabled(i)) {
fTextureSamplers[i] = paint.fTextureSamplers[i];
- fTextures[i]->ref();
}
}
for (int i = 0; i < kMaxMasks; ++i) {
- GrSafeUnref(fMaskTextures[i]);
- fMaskTextures[i] = paint.fMaskTextures[i];
- if (NULL != fMaskTextures[i]) {
+ GrSafeAssign(fMaskTextures[i], paint.fMaskTextures[i]);
+ if (paint.isMaskStageEnabled(i)) {
fMaskSamplers[i] = paint.fMaskSamplers[i];
- fMaskTextures[i]->ref();
}
}
return *this;
@@ -209,7 +205,8 @@ public:
int getActiveTextureStageMask() const {
int mask = 0;
for (int i = 0; i < kMaxTextures; ++i) {
- if (NULL != fTextures[i]) {
+ if ((NULL != fTextures[i]) ||
+ (NULL != fTextureSamplers[i].getCustomStage())) {
mask |= 1 << (i + kFirstTextureStage);
}
}
@@ -219,7 +216,8 @@ public:
int getActiveMaskStageMask() const {
int mask = 0;
for (int i = 0; i < kMaxMasks; ++i) {
- if (NULL != fMaskTextures[i]) {
+ if ((NULL != fMaskTextures[i]) ||
+ (NULL != fMaskSamplers[i].getCustomStage())) {
mask |= 1 << (i + kFirstMaskStage);
}
}
diff --git a/src/gpu/GrContext.cpp b/src/gpu/GrContext.cpp
index 95e0ecac63..e70ac5c2ca 100644
--- a/src/gpu/GrContext.cpp
+++ b/src/gpu/GrContext.cpp
@@ -246,7 +246,6 @@ void apply_morphology(GrGpu* gpu,
SkAutoTUnref<GrCustomStage> morph(
SkNEW_ARGS(GrMorphologyEffect, (texture, direction, radius, morphType)));
drawState->sampler(0)->setCustomStage(morph);
- drawState->setTexture(0, texture);
gpu->drawSimpleRect(rect, NULL, 1 << 0);
}
@@ -267,7 +266,6 @@ void convolve_gaussian(GrGpu* gpu,
(texture, direction, radius)));
conv->setGaussianKernel(sigma);
drawState->sampler(0)->setCustomStage(conv);
- drawState->setTexture(0, texture);
gpu->drawSimpleRect(rect, NULL, 1 << 0);
}
diff --git a/src/gpu/GrDrawState.h b/src/gpu/GrDrawState.h
index c07001c3a3..3de33d82a7 100644
--- a/src/gpu/GrDrawState.h
+++ b/src/gpu/GrDrawState.h
@@ -209,10 +209,22 @@ public:
*/
const GrTexture* getTexture(int stage) const {
GrAssert((unsigned)stage < kNumStages);
+ GrAssert(!this->getSampler(stage).getCustomStage() ||
+ !fTextures[stage] ||
+ fTextures[stage] == this->getSampler(stage).getCustomStage()->texture(0));
+ if (this->getSampler(stage).getCustomStage()) {
+ return this->getSampler(stage).getCustomStage()->texture(0);
+ }
return fTextures[stage];
}
GrTexture* getTexture(int stage) {
GrAssert((unsigned)stage < kNumStages);
+ GrAssert(!this->getSampler(stage).getCustomStage() ||
+ !fTextures[stage] ||
+ fTextures[stage] == this->getSampler(stage).getCustomStage()->texture(0));
+ if (this->getSampler(stage).getCustomStage()) {
+ return this->getSampler(stage).getCustomStage()->texture(0);
+ }
return fTextures[stage];
}
@@ -811,7 +823,7 @@ public:
for (int i = 0; i < kNumStages; i++) {
SkSafeRef(fTextures[i]); // already copied by memcpy
- if (s.fTextures[i]) {
+ if (s.isStageEnabled(i)) {
this->fSamplerStates[i] = s.fSamplerStates[i];
}
}
diff --git a/src/gpu/SkGpuDevice.cpp b/src/gpu/SkGpuDevice.cpp
index 6443fa28e7..dfded26c65 100644
--- a/src/gpu/SkGpuDevice.cpp
+++ b/src/gpu/SkGpuDevice.cpp
@@ -562,7 +562,6 @@ inline bool skPaint2GrPaintShader(SkGpuDevice* dev,
SkDebugf("Couldn't convert bitmap to texture.\n");
return false;
}
- grPaint->setTexture(kShaderTextureIdx, texture);
switch (bmptype) {
case SkShader::kRadial_BitmapType:
@@ -595,6 +594,9 @@ inline bool skPaint2GrPaintShader(SkGpuDevice* dev,
} else {
sampler->setFilter(GrSamplerState::kNearest_Filter);
}
+ // TODO - once we have a trivial GrCustomStage for texture drawing,
+ // create that here & get rid of the paint's texture
+ grPaint->setTexture(kShaderTextureIdx, texture);
break;
}
sampler->setWrapX(sk_tile_mode_to_grwrap(tileModes[0]));
@@ -1476,7 +1478,6 @@ void apply_custom_stage(GrContext* context,
paint.textureSampler(0)->setFilter(GrSamplerState::kBilinear_Filter);
paint.textureSampler(0)->reset(sampleM);
paint.textureSampler(0)->setCustomStage(stage);
- paint.setTexture(0, srcTexture);
context->drawRect(paint, rect);
}
diff --git a/src/gpu/gl/GrGpuGL.cpp b/src/gpu/gl/GrGpuGL.cpp
index edabb9c108..4a63b3322f 100644
--- a/src/gpu/gl/GrGpuGL.cpp
+++ b/src/gpu/gl/GrGpuGL.cpp
@@ -2140,15 +2140,6 @@ 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);
}