aboutsummaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorGravatar Yuqian Li <liyuqian@google.com>2018-03-22 15:00:01 -0400
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2018-04-04 17:42:28 +0000
commitbf74a460814a7912ed3d2e1af000afd2c45cd318 (patch)
tree70d33ae06ff97a34b81c45724922b4cc7f220069 /src
parent378679cc474f56661e838a21d6341c061f408372 (diff)
Fix drawBitmapRect in the threaded backend
Previously, the threaded backend failed to drawBitmapRect (see, e.g., GM_bitmaprect_s) because it did not intercept the call to SkDraw::drawBitmap. Bug: skia: Change-Id: I7eeaae98e63d726b2b566c4d15f7ea939f59360e Reviewed-on: https://skia-review.googlesource.com/115983 Reviewed-by: Mike Reed <reed@google.com> Commit-Queue: Yuqian Li <liyuqian@google.com>
Diffstat (limited to 'src')
-rw-r--r--src/core/SkBitmapDevice.cpp9
-rw-r--r--src/core/SkBitmapDevice.h3
-rw-r--r--src/core/SkThreadedBMPDevice.cpp20
-rw-r--r--src/core/SkThreadedBMPDevice.h4
4 files changed, 26 insertions, 10 deletions
diff --git a/src/core/SkBitmapDevice.cpp b/src/core/SkBitmapDevice.cpp
index 8d6ab54d58..dd01a3795e 100644
--- a/src/core/SkBitmapDevice.cpp
+++ b/src/core/SkBitmapDevice.cpp
@@ -331,7 +331,12 @@ void SkBitmapDevice::drawBitmap(const SkBitmap& bitmap, SkScalar x, SkScalar y,
const SkPaint& paint) {
SkMatrix matrix = SkMatrix::MakeTrans(x, y);
LogDrawScaleFactor(SkMatrix::Concat(this->ctm(), matrix), paint.getFilterQuality());
- LOOP_TILER( drawBitmap(bitmap, matrix, nullptr, paint))
+ this->drawBitmap(bitmap, matrix, nullptr, paint);
+}
+
+void SkBitmapDevice::drawBitmap(const SkBitmap& bitmap, const SkMatrix& matrix,
+ const SkRect* dstOrNull, const SkPaint& paint) {
+ LOOP_TILER( drawBitmap(bitmap, matrix, dstOrNull, paint))
}
static inline bool CanApplyDstMatrixAsCTM(const SkMatrix& m, const SkPaint& paint) {
@@ -426,7 +431,7 @@ void SkBitmapDevice::drawBitmapRect(const SkBitmap& bitmap,
// matrix with the CTM, and try to call drawSprite if it can. If not,
// it will make a shader and call drawRect, as we do below.
if (CanApplyDstMatrixAsCTM(matrix, paint)) {
- LOOP_TILER( drawBitmap(*bitmapPtr, matrix, dstPtr, paint))
+ this->drawBitmap(*bitmapPtr, matrix, dstPtr, paint);
return;
}
}
diff --git a/src/core/SkBitmapDevice.h b/src/core/SkBitmapDevice.h
index dbe04fa1cc..26214261a5 100644
--- a/src/core/SkBitmapDevice.h
+++ b/src/core/SkBitmapDevice.h
@@ -137,6 +137,9 @@ protected:
void validateDevBounds(const SkIRect& r) override;
ClipType onGetClipType() const override;
+ virtual void drawBitmap(const SkBitmap&, const SkMatrix&, const SkRect* dstOrNull,
+ const SkPaint&);
+
private:
friend class SkCanvas;
friend struct DeviceCM; //for setMatrixClip
diff --git a/src/core/SkThreadedBMPDevice.cpp b/src/core/SkThreadedBMPDevice.cpp
index eb68ddfb4f..320eb25a44 100644
--- a/src/core/SkThreadedBMPDevice.cpp
+++ b/src/core/SkThreadedBMPDevice.cpp
@@ -169,14 +169,20 @@ void SkThreadedBMPDevice::drawPath(const SkPath& path, const SkPaint& paint,
}
}
-void SkThreadedBMPDevice::drawBitmap(const SkBitmap& bitmap, SkScalar x, SkScalar y,
- const SkPaint& paint) {
- SkMatrix matrix = SkMatrix::MakeTrans(x, y);
- LogDrawScaleFactor(SkMatrix::Concat(this->ctm(), matrix), paint.getFilterQuality());
- SkRect drawBounds = SkRect::MakeWH(bitmap.width(), bitmap.height());
- matrix.mapRect(&drawBounds);
+void SkThreadedBMPDevice::drawBitmap(const SkBitmap& bitmap, const SkMatrix& matrix,
+ const SkRect* dstOrNull, const SkPaint& paint) {
+ SkRect drawBounds;
+ SkRect* clonedDstOrNull = nullptr;
+ if (dstOrNull == nullptr) {
+ drawBounds = SkRect::MakeWH(bitmap.width(), bitmap.height());
+ matrix.mapRect(&drawBounds);
+ } else {
+ drawBounds = *dstOrNull;
+ clonedDstOrNull = fAlloc.make<SkRect>(*dstOrNull);
+ }
+
fQueue.push(drawBounds, [=](SkArenaAlloc*, const DrawState& ds, const SkIRect& tileBounds){
- TileDraw(ds, tileBounds).drawBitmap(bitmap, matrix, nullptr, paint);
+ TileDraw(ds, tileBounds).drawBitmap(bitmap, matrix, clonedDstOrNull, paint);
});
}
diff --git a/src/core/SkThreadedBMPDevice.h b/src/core/SkThreadedBMPDevice.h
index acdbc62414..32fedc4004 100644
--- a/src/core/SkThreadedBMPDevice.h
+++ b/src/core/SkThreadedBMPDevice.h
@@ -30,7 +30,6 @@ protected:
void drawPath(const SkPath&, const SkPaint&, const SkMatrix* prePathMatrix,
bool pathIsMutable) override;
- void drawBitmap(const SkBitmap&, SkScalar x, SkScalar y, const SkPaint&) override;
void drawSprite(const SkBitmap&, int x, int y, const SkPaint&) override;
void drawText(const void* text, size_t len, SkScalar x, SkScalar y,
@@ -40,6 +39,9 @@ protected:
void drawVertices(const SkVertices*, SkBlendMode, const SkPaint&) override;
void drawDevice(SkBaseDevice*, int x, int y, const SkPaint&) override;
+ void drawBitmap(const SkBitmap&, const SkMatrix&, const SkRect* dstOrNull,
+ const SkPaint&) override;
+
void flush() override;
private: