Apply matrix early in draw bitmap
R=robertphillips@google.com
Author: bsalomon@google.com
Review URL: https://codereview.chromium.org/30593003
git-svn-id: http://skia.googlecode.com/svn/trunk@11880 2bbb7eff-a529-9590-31e7-b0007b416f81
diff --git a/include/gpu/SkGpuDevice.h b/include/gpu/SkGpuDevice.h
index 5d669e4..debfd37 100644
--- a/include/gpu/SkGpuDevice.h
+++ b/include/gpu/SkGpuDevice.h
@@ -191,13 +191,11 @@
const SkRect* srcRectPtr) const;
void internalDrawBitmap(const SkBitmap&,
const SkRect&,
- const SkMatrix&,
const GrTextureParams& params,
const SkPaint& paint,
SkCanvas::DrawBitmapRectFlags flags);
void drawTiledBitmap(const SkBitmap& bitmap,
const SkRect& srcRect,
- const SkMatrix& m,
const GrTextureParams& params,
const SkPaint& paint,
SkCanvas::DrawBitmapRectFlags flags);
diff --git a/src/gpu/SkGpuDevice.cpp b/src/gpu/SkGpuDevice.cpp
index 1498fc4..89578e8 100644
--- a/src/gpu/SkGpuDevice.cpp
+++ b/src/gpu/SkGpuDevice.cpp
@@ -1170,6 +1170,8 @@
return;
}
+
+ fContext->concatMatrix(m);
GrTextureParams params;
SkPaint::FilterLevel paintFilterLevel = paint.getFilterLevel();
@@ -1202,9 +1204,9 @@
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);
}
}
@@ -1212,7 +1214,6 @@
// 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) {
@@ -1233,9 +1234,8 @@
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);
@@ -1285,10 +1285,11 @@
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);
}
}
}
@@ -1345,7 +1346,6 @@
*/
void SkGpuDevice::internalDrawBitmap(const SkBitmap& bitmap,
const SkRect& srcRect,
- const SkMatrix& m,
const GrTextureParams& params,
const SkPaint& paint,
SkCanvas::DrawBitmapRectFlags flags) {
@@ -1373,19 +1373,18 @@
// 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);
}
}
}
@@ -1428,7 +1427,7 @@
return;
}
- fContext->drawRectToRect(grPaint, dstRect, paintRect, &m);
+ fContext->drawRectToRect(grPaint, dstRect, paintRect, NULL);
}
static bool filter_texture(SkBaseDevice* device, GrContext* context,