Revert "Apply matrix early in draw bitmap"
This reverts commit 4c446c8eb50b7a6e6f917fae7b4c4ffe5658a949.
Fix build.
git-svn-id: http://skia.googlecode.com/svn/trunk@11932 2bbb7eff-a529-9590-31e7-b0007b416f81
diff --git a/src/gpu/SkGpuDevice.cpp b/src/gpu/SkGpuDevice.cpp
index 6617989..47ddd52 100644
--- a/src/gpu/SkGpuDevice.cpp
+++ b/src/gpu/SkGpuDevice.cpp
@@ -1164,8 +1164,6 @@
return;
}
- fContext->concatMatrix(m);
-
GrTextureParams params;
SkPaint::FilterLevel paintFilterLevel = paint.getFilterLevel();
GrTextureParams::FilterMode textureFilterMode;
@@ -1197,9 +1195,9 @@
if (!this->shouldTileBitmap(bitmap, params, srcRectPtr)) {
// take the simple case
- this->internalDrawBitmap(bitmap, srcRect, params, paint, flags);
+ this->internalDrawBitmap(bitmap, srcRect, m, params, paint, flags);
} else {
- this->drawTiledBitmap(bitmap, srcRect, params, paint, flags);
+ this->drawTiledBitmap(bitmap, srcRect, m, params, paint, flags);
}
}
@@ -1207,6 +1205,7 @@
// 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) {
@@ -1227,8 +1226,9 @@
if (!fContext->getClip()->fClipStack->intersectRectWithClip(&clipRect)) {
return;
}
- SkMatrix inverse;
- if (!fContext->getMatrix().invert(&inverse)) {
+ SkMatrix matrix, inverse;
+ matrix.setConcat(fContext->getMatrix(), m);
+ if (!matrix.invert(&inverse)) {
return;
}
inverse.mapRect(&clipRect);
@@ -1278,11 +1278,10 @@
if (bitmap.extractSubset(&tmpB, iTileR)) {
// now offset it to make it "local" to our tmp bitmap
tileR.offset(-offset.fX, -offset.fY);
- SkMatrix tmpM;
- tmpM.setTranslate(offset.fX, offset.fY);
- GrContext::AutoMatrix am;
- am.setPreConcat(fContext, tmpM);
- this->internalDrawBitmap(tmpB, tileR, params, paint, flags);
+ SkMatrix tmpM(m);
+ tmpM.preTranslate(offset.fX, offset.fY);
+
+ this->internalDrawBitmap(tmpB, tileR, tmpM, params, paint, flags);
}
}
}
@@ -1339,6 +1338,7 @@
*/
void SkGpuDevice::internalDrawBitmap(const SkBitmap& bitmap,
const SkRect& srcRect,
+ const SkMatrix& m,
const GrTextureParams& params,
const SkPaint& paint,
SkCanvas::DrawBitmapRectFlags flags) {
@@ -1366,18 +1366,19 @@
// Need texture domain if drawing a sub rect.
needsTextureDomain = srcRect.width() < bitmap.width() ||
srcRect.height() < bitmap.height();
- if (needsTextureDomain && fContext->getMatrix().rectStaysRect()) {
- const SkMatrix& matrix = fContext->getMatrix();
+ if (needsTextureDomain && m.rectStaysRect() && fContext->getMatrix().rectStaysRect()) {
// sampling is axis-aligned
SkRect transformedRect;
- matrix.mapRect(&transformedRect, srcRect);
-
+ SkMatrix srcToDeviceMatrix(m);
+ srcToDeviceMatrix.postConcat(fContext->getMatrix());
+ srcToDeviceMatrix.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, matrix);
+ needsTextureDomain = may_color_bleed(srcRect, transformedRect, m);
}
}
}
@@ -1420,7 +1421,7 @@
return;
}
- fContext->drawRectToRect(grPaint, dstRect, paintRect, NULL);
+ fContext->drawRectToRect(grPaint, dstRect, paintRect, &m);
}
static bool filter_texture(SkBaseDevice* device, GrContext* context,