aboutsummaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorGravatar Yuqian Li <liyuqian@google.com>2018-02-23 17:29:14 +0800
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2018-02-25 16:31:19 +0000
commit8a3f65421214a21c480d6ee268eb29f2c5769078 (patch)
treed18926a5067ecf7d2b0102534949496d36d6155c /src
parent88fdee9bde97df106a8d81b450982b8296a2bc90 (diff)
Copy the bitmap in SkThreadedBMPDevice::drawDevice
The new threaded DM sink revealed skia:7414 again with xfermodes GM test. Bug: skia:7414 Change-Id: I5565065f81d1e982027e2cc965bb7659793b27dc Reviewed-on: https://skia-review.googlesource.com/109722 Reviewed-by: Herb Derby <herb@google.com> Commit-Queue: Yuqian Li <liyuqian@google.com>
Diffstat (limited to 'src')
-rw-r--r--src/core/SkThreadedBMPDevice.cpp6
-rw-r--r--src/core/SkThreadedBMPDevice.h2
2 files changed, 6 insertions, 2 deletions
diff --git a/src/core/SkThreadedBMPDevice.cpp b/src/core/SkThreadedBMPDevice.cpp
index 7c1394d351..eb68ddfb4f 100644
--- a/src/core/SkThreadedBMPDevice.cpp
+++ b/src/core/SkThreadedBMPDevice.cpp
@@ -67,6 +67,7 @@ SkThreadedBMPDevice::SkThreadedBMPDevice(const SkBitmap& bitmap,
void SkThreadedBMPDevice::flush() {
fQueue.reset();
+ fAlloc.reset();
}
SkThreadedBMPDevice::DrawState::DrawState(SkThreadedBMPDevice* dev) {
@@ -218,8 +219,9 @@ void SkThreadedBMPDevice::drawVertices(const SkVertices* vertices, SkBlendMode b
void SkThreadedBMPDevice::drawDevice(SkBaseDevice* device, int x, int y, const SkPaint& paint) {
SkASSERT(!paint.getImageFilter());
SkRect drawBounds = SkRect::MakeXYWH(x, y, device->width(), device->height());
+ // copy the bitmap because it may deleted after this call
+ SkBitmap* bitmap = fAlloc.make<SkBitmap>(static_cast<SkBitmapDevice*>(device)->fBitmap);
fQueue.push(drawBounds, [=](SkArenaAlloc*, const DrawState& ds, const SkIRect& tileBounds){
- TileDraw(ds, tileBounds).drawSprite(static_cast<SkBitmapDevice*>(device)->fBitmap,
- x, y, paint);
+ TileDraw(ds, tileBounds).drawSprite(*bitmap, x, y, paint);
});
}
diff --git a/src/core/SkThreadedBMPDevice.h b/src/core/SkThreadedBMPDevice.h
index c2e1aa375d..3f0984110b 100644
--- a/src/core/SkThreadedBMPDevice.h
+++ b/src/core/SkThreadedBMPDevice.h
@@ -170,6 +170,8 @@ private:
SkExecutor* fExecutor = nullptr;
std::unique_ptr<SkExecutor> fInternalExecutor;
+ SkSTArenaAlloc<8 << 10> fAlloc; // so we can allocate memory that lives until flush
+
DrawQueue fQueue;
friend struct SkInitOnceData; // to access DrawElement