aboutsummaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorGravatar robertphillips <robertphillips@google.com>2015-07-20 10:22:29 -0700
committerGravatar Commit bot <commit-bot@chromium.org>2015-07-20 10:22:29 -0700
commit1accc4cc35a1360c086fd8ffab9f6f4e3948ed7b (patch)
tree96f3c0f07367bd8956c4d89112e23053a28ae0df /src
parenta6ae14e2232a46fbc3baed74e2581dde119e7f1e (diff)
Fix textureDomain/bleed prevention in msaa
This updates Ganesh's bleed avoidance check to handle the case where the sample location may be outside of the rect geometry but used because it partially covers the pixel. BUG=skia:4066 Review URL: https://codereview.chromium.org/1237623012
Diffstat (limited to 'src')
-rw-r--r--src/gpu/SkGpuDevice.cpp27
1 files changed, 17 insertions, 10 deletions
diff --git a/src/gpu/SkGpuDevice.cpp b/src/gpu/SkGpuDevice.cpp
index 703b7cab5c..ea2b537520 100644
--- a/src/gpu/SkGpuDevice.cpp
+++ b/src/gpu/SkGpuDevice.cpp
@@ -868,13 +868,18 @@ static bool has_aligned_samples(const SkRect& srcRect,
static bool may_color_bleed(const SkRect& srcRect,
const SkRect& transformedRect,
- const SkMatrix& m) {
+ const SkMatrix& m,
+ bool isMSAA) {
// Only gets called if has_aligned_samples returned false.
// So we can assume that sampling is axis aligned but not texel aligned.
SkASSERT(!has_aligned_samples(srcRect, transformedRect));
SkRect innerSrcRect(srcRect), innerTransformedRect,
outerTransformedRect(transformedRect);
- innerSrcRect.inset(SK_ScalarHalf, SK_ScalarHalf);
+ if (isMSAA) {
+ innerSrcRect.inset(SK_Scalar1, SK_Scalar1);
+ } else {
+ innerSrcRect.inset(SK_ScalarHalf, SK_ScalarHalf);
+ }
m.mapRect(&innerTransformedRect, innerSrcRect);
// The gap between outerTransformedRect and innerTransformedRect
@@ -895,7 +900,8 @@ static bool needs_texture_domain(const SkBitmap& bitmap,
const SkRect& srcRect,
GrTextureParams &params,
const SkMatrix& contextMatrix,
- bool bicubic) {
+ bool bicubic,
+ bool isMSAA) {
bool needsTextureDomain = false;
GrTexture* tex = bitmap.getTexture();
int width = tex ? tex->width() : bitmap.width();
@@ -914,7 +920,8 @@ static bool needs_texture_domain(const SkBitmap& bitmap,
params.setFilterMode(GrTextureParams::kNone_FilterMode);
needsTextureDomain = false;
} else {
- needsTextureDomain = may_color_bleed(srcRect, transformedRect, contextMatrix);
+ needsTextureDomain = may_color_bleed(srcRect, transformedRect,
+ contextMatrix, isMSAA);
}
}
}
@@ -1095,7 +1102,8 @@ void SkGpuDevice::drawBitmapCommon(const SkDraw& draw,
srcRect,
params,
viewM,
- doBicubic);
+ doBicubic,
+ fRenderTarget->isUnifiedMultisampled());
this->internalDrawBitmap(bitmap,
viewM,
srcRect,
@@ -1176,11 +1184,10 @@ void SkGpuDevice::drawTiledBitmap(const SkBitmap& bitmap,
// now offset it to make it "local" to our tmp bitmap
tileR.offset(-offset.fX, -offset.fY);
GrTextureParams paramsTemp = params;
- bool needsTextureDomain = needs_texture_domain(bitmap,
- srcRect,
- paramsTemp,
- viewM,
- bicubic);
+ bool needsTextureDomain = needs_texture_domain(
+ bitmap, srcRect, paramsTemp,
+ viewM, bicubic,
+ fRenderTarget->isUnifiedMultisampled());
this->internalDrawBitmap(tmpB,
viewM,
tileR,