Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(403)

Unified Diff: src/gpu/SkGpuDevice.cpp

Issue 30593003: Apply matrix early in draw bitmap (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Add flattenable registration for local image filter subclass to fix GM serialization failure Created 7 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/core/SkImageFilterUtils.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/gpu/SkGpuDevice.cpp
diff --git a/src/gpu/SkGpuDevice.cpp b/src/gpu/SkGpuDevice.cpp
index 47ddd521cb8fd01b3a6cde8e808516eba9a3a52f..6617989848771e231c7141dd16c4b458b3adad05 100644
--- a/src/gpu/SkGpuDevice.cpp
+++ b/src/gpu/SkGpuDevice.cpp
@@ -1164,6 +1164,8 @@ void SkGpuDevice::drawBitmapCommon(const SkDraw& draw,
return;
}
+ fContext->concatMatrix(m);
+
GrTextureParams params;
SkPaint::FilterLevel paintFilterLevel = paint.getFilterLevel();
GrTextureParams::FilterMode textureFilterMode;
@@ -1195,9 +1197,9 @@ void SkGpuDevice::drawBitmapCommon(const SkDraw& draw,
if (!this->shouldTileBitmap(bitmap, params, srcRectPtr)) {
// take the simple case
- this->internalDrawBitmap(bitmap, srcRect, m, params, paint, flags);
+ this->internalDrawBitmap(bitmap, srcRect, params, paint, flags);
} else {
- this->drawTiledBitmap(bitmap, srcRect, m, params, paint, flags);
+ this->drawTiledBitmap(bitmap, srcRect, params, paint, flags);
}
}
@@ -1205,7 +1207,6 @@ void SkGpuDevice::drawBitmapCommon(const SkDraw& draw,
// been determined to be too large to fit in VRAM
void SkGpuDevice::drawTiledBitmap(const SkBitmap& bitmap,
const SkRect& srcRect,
- const SkMatrix& m,
const GrTextureParams& params,
const SkPaint& paint,
SkCanvas::DrawBitmapRectFlags flags) {
@@ -1226,9 +1227,8 @@ void SkGpuDevice::drawTiledBitmap(const SkBitmap& bitmap,
if (!fContext->getClip()->fClipStack->intersectRectWithClip(&clipRect)) {
return;
}
- SkMatrix matrix, inverse;
- matrix.setConcat(fContext->getMatrix(), m);
- if (!matrix.invert(&inverse)) {
+ SkMatrix inverse;
+ if (!fContext->getMatrix().invert(&inverse)) {
return;
}
inverse.mapRect(&clipRect);
@@ -1278,10 +1278,11 @@ void SkGpuDevice::drawTiledBitmap(const SkBitmap& bitmap,
if (bitmap.extractSubset(&tmpB, iTileR)) {
// now offset it to make it "local" to our tmp bitmap
tileR.offset(-offset.fX, -offset.fY);
- SkMatrix tmpM(m);
- tmpM.preTranslate(offset.fX, offset.fY);
-
- this->internalDrawBitmap(tmpB, tileR, tmpM, params, paint, flags);
+ SkMatrix tmpM;
+ tmpM.setTranslate(offset.fX, offset.fY);
+ GrContext::AutoMatrix am;
+ am.setPreConcat(fContext, tmpM);
+ this->internalDrawBitmap(tmpB, tileR, params, paint, flags);
}
}
}
@@ -1338,7 +1339,6 @@ static bool may_color_bleed(const SkRect& srcRect,
*/
void SkGpuDevice::internalDrawBitmap(const SkBitmap& bitmap,
const SkRect& srcRect,
- const SkMatrix& m,
const GrTextureParams& params,
const SkPaint& paint,
SkCanvas::DrawBitmapRectFlags flags) {
@@ -1366,19 +1366,18 @@ void SkGpuDevice::internalDrawBitmap(const SkBitmap& bitmap,
// Need texture domain if drawing a sub rect.
needsTextureDomain = srcRect.width() < bitmap.width() ||
srcRect.height() < bitmap.height();
- if (needsTextureDomain && m.rectStaysRect() && fContext->getMatrix().rectStaysRect()) {
+ if (needsTextureDomain && fContext->getMatrix().rectStaysRect()) {
+ const SkMatrix& matrix = fContext->getMatrix();
// sampling is axis-aligned
SkRect transformedRect;
- SkMatrix srcToDeviceMatrix(m);
- srcToDeviceMatrix.postConcat(fContext->getMatrix());
- srcToDeviceMatrix.mapRect(&transformedRect, srcRect);
-
+ matrix.mapRect(&transformedRect, srcRect);
+
if (has_aligned_samples(srcRect, transformedRect)) {
// We could also turn off filtering here (but we already did a cache lookup with
// params).
needsTextureDomain = false;
} else {
- needsTextureDomain = may_color_bleed(srcRect, transformedRect, m);
+ needsTextureDomain = may_color_bleed(srcRect, transformedRect, matrix);
}
}
}
@@ -1421,7 +1420,7 @@ void SkGpuDevice::internalDrawBitmap(const SkBitmap& bitmap,
return;
}
- fContext->drawRectToRect(grPaint, dstRect, paintRect, &m);
+ fContext->drawRectToRect(grPaint, dstRect, paintRect, NULL);
}
static bool filter_texture(SkBaseDevice* device, GrContext* context,
« no previous file with comments | « src/core/SkImageFilterUtils.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698