aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar bsalomon@google.com <bsalomon@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2012-07-24 17:59:01 +0000
committerGravatar bsalomon@google.com <bsalomon@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2012-07-24 17:59:01 +0000
commit8f4fdc9968123d508d4bb17b5d15946a990613d4 (patch)
treebfbe342ecdf41b8810678b5a4edcc039a04c8a70
parent0eec2d0486e8a5184a95a48d31fdc8052774dec7 (diff)
Fix npot bitmap tiling
Review URL: http://codereview.appspot.com/6419073/ git-svn-id: http://skia.googlecode.com/svn/trunk@4736 2bbb7eff-a529-9590-31e7-b0007b416f81
-rw-r--r--src/gpu/GrContext.cpp2
-rw-r--r--src/gpu/SkGpuDevice.cpp23
2 files changed, 12 insertions, 13 deletions
diff --git a/src/gpu/GrContext.cpp b/src/gpu/GrContext.cpp
index 8c6db5d0e2..7321ffb61f 100644
--- a/src/gpu/GrContext.cpp
+++ b/src/gpu/GrContext.cpp
@@ -368,7 +368,6 @@ GrContext::TextureCacheEntry GrContext::createAndLockTexture(
GrDrawTarget::kReset_ASRInit);
GrDrawState* drawState = fGpu->drawState();
drawState->setRenderTarget(texture->asRenderTarget());
- drawState->createTextureEffect(0, clampEntry.texture());
GrSamplerState::Filter filter;
// if filtering is not desired then we want to ensure all
@@ -381,6 +380,7 @@ GrContext::TextureCacheEntry GrContext::createAndLockTexture(
}
drawState->sampler(0)->reset(GrSamplerState::kClamp_WrapMode,
filter);
+ drawState->createTextureEffect(0, clampEntry.texture());
static const GrVertexLayout layout =
GrDrawTarget::StageTexCoordVertexLayoutBit(0,0);
diff --git a/src/gpu/SkGpuDevice.cpp b/src/gpu/SkGpuDevice.cpp
index 1da5a0a0a4..c92af64bc8 100644
--- a/src/gpu/SkGpuDevice.cpp
+++ b/src/gpu/SkGpuDevice.cpp
@@ -621,8 +621,19 @@ inline bool skPaint2GrPaintShader(SkGpuDevice* dev,
return false;
}
+ // Must set wrap and filter on the sampler before requesting a texture.
GrSamplerState* sampler = grPaint->textureSampler(kShaderTextureIdx);
+ sampler->setWrapX(sk_tile_mode_to_grwrap(tileModes[0]));
+ sampler->setWrapY(sk_tile_mode_to_grwrap(tileModes[1]));
+ GrSamplerState::Filter filter;
+ if (SkShader::kDefault_BitmapType == bmptype && !skPaint.isFilterBitmap()) {
+ filter = GrSamplerState::kNearest_Filter;
+ } else {
+ filter = GrSamplerState::kBilinear_Filter;
+ }
+ sampler->setFilter(filter);
GrTexture* texture = textures[kShaderTextureIdx].set(dev, bitmap, sampler);
+
if (NULL == texture) {
SkDebugf("Couldn't convert bitmap to texture.\n");
return false;
@@ -631,11 +642,9 @@ inline bool skPaint2GrPaintShader(SkGpuDevice* dev,
switch (bmptype) {
case SkShader::kRadial_BitmapType:
sampler->setCustomStage(SkNEW_ARGS(GrRadialGradient, (texture)))->unref();
- sampler->setFilter(GrSamplerState::kBilinear_Filter);
break;
case SkShader::kSweep_BitmapType:
sampler->setCustomStage(SkNEW_ARGS(GrSweepGradient, (texture)))->unref();
- sampler->setFilter(GrSamplerState::kBilinear_Filter);
break;
case SkShader::kTwoPointRadial_BitmapType:
sampler->setCustomStage(SkNEW_ARGS(GrRadial2Gradient,
@@ -643,7 +652,6 @@ inline bool skPaint2GrPaintShader(SkGpuDevice* dev,
twoPointParams[0],
twoPointParams[1],
twoPointParams[2] < 0)))->unref();
- sampler->setFilter(GrSamplerState::kBilinear_Filter);
break;
case SkShader::kTwoPointConical_BitmapType:
sampler->setCustomStage(SkNEW_ARGS(GrConical2Gradient,
@@ -651,23 +659,14 @@ inline bool skPaint2GrPaintShader(SkGpuDevice* dev,
twoPointParams[0],
twoPointParams[1],
twoPointParams[2])))->unref();
- sampler->setFilter(GrSamplerState::kBilinear_Filter);
break;
case SkShader::kLinear_BitmapType:
sampler->setCustomStage(SkNEW_ARGS(GrLinearGradient, (texture)))->unref();
- sampler->setFilter(GrSamplerState::kBilinear_Filter);
break;
default:
- if (skPaint.isFilterBitmap()) {
- sampler->setFilter(GrSamplerState::kBilinear_Filter);
- } else {
- sampler->setFilter(GrSamplerState::kNearest_Filter);
- }
sampler->setCustomStage(SkNEW_ARGS(GrSingleTextureEffect, (texture)))->unref();
break;
}
- sampler->setWrapX(sk_tile_mode_to_grwrap(tileModes[0]));
- sampler->setWrapY(sk_tile_mode_to_grwrap(tileModes[1]));
// since our texture coords will be in local space, we wack the texture
// matrix to map them back into 0...1 before we load it