aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar reed <reed@chromium.org>2014-12-25 13:55:08 -0800
committerGravatar Commit bot <commit-bot@chromium.org>2014-12-25 13:55:08 -0800
commitb4f629cd688b680eba21a5a08daeaf82bbe65b28 (patch)
tree73bb1d72d5c413ad00212207c4b3c70359a2c8dc
parent2f1e50ab26a3da463e93beca32bced4dc49ad64a (diff)
fix images in multi-thread by doing shallow-copies
BUG=skia: TBR=mtklein@google.com Review URL: https://codereview.chromium.org/791473006
-rw-r--r--src/core/SkMultiPictureDraw.cpp11
-rw-r--r--src/image/SkImage_Raster.cpp9
2 files changed, 16 insertions, 4 deletions
diff --git a/src/core/SkMultiPictureDraw.cpp b/src/core/SkMultiPictureDraw.cpp
index ed099a02e1..c85c56735c 100644
--- a/src/core/SkMultiPictureDraw.cpp
+++ b/src/core/SkMultiPictureDraw.cpp
@@ -84,13 +84,22 @@ public:
~AutoMPDReset() { fMPD->reset(); }
};
+//#define FORCE_SINGLE_THREAD_DRAWING_FOR_TESTING
+
void SkMultiPictureDraw::draw() {
AutoMPDReset mpdreset(this);
+
+#ifdef FORCE_SINGLE_THREAD_DRAWING_FOR_TESTING
+ for (int i = 0; i < fThreadSafeDrawData.count(); ++i) {
+ DrawData* dd = &fThreadSafeDrawData.begin()[i];
+ dd->fCanvas->drawPicture(dd->fPicture, &dd->fMatrix, dd->fPaint);
+ }
+#else
// we place the taskgroup after the MPDReset, to ensure that we don't delete the DrawData
// objects until after we're finished the tasks (which have pointers to the data).
-
SkTaskGroup group;
group.batch(DrawData::Draw, fThreadSafeDrawData.begin(), fThreadSafeDrawData.count());
+#endif
// we deliberately don't call wait() here, since the destructor will do that, this allows us
// to continue processing gpu-data without having to wait on the cpu tasks.
diff --git a/src/image/SkImage_Raster.cpp b/src/image/SkImage_Raster.cpp
index 24b971ad84..a06cca6e9b 100644
--- a/src/image/SkImage_Raster.cpp
+++ b/src/image/SkImage_Raster.cpp
@@ -131,12 +131,14 @@ SkShader* SkImage_Raster::onNewShader(SkShader::TileMode tileX, SkShader::TileMo
}
void SkImage_Raster::onDraw(SkCanvas* canvas, SkScalar x, SkScalar y, const SkPaint* paint) const {
- canvas->drawBitmap(fBitmap, x, y, paint);
+ SkBitmap shallowCopy(fBitmap);
+ canvas->drawBitmap(shallowCopy, x, y, paint);
}
void SkImage_Raster::onDrawRect(SkCanvas* canvas, const SkRect* src, const SkRect& dst,
const SkPaint* paint) const {
- canvas->drawBitmapRectToRect(fBitmap, src, dst, paint);
+ SkBitmap shallowCopy(fBitmap);
+ canvas->drawBitmapRectToRect(shallowCopy, src, dst, paint);
}
SkSurface* SkImage_Raster::onNewSurface(const SkImageInfo& info, const SkSurfaceProps& props) const {
@@ -145,7 +147,8 @@ SkSurface* SkImage_Raster::onNewSurface(const SkImageInfo& info, const SkSurface
bool SkImage_Raster::onReadPixels(const SkImageInfo& dstInfo, void* dstPixels, size_t dstRowBytes,
int srcX, int srcY) const {
- return fBitmap.readPixels(dstInfo, dstPixels, dstRowBytes, srcX, srcY);
+ SkBitmap shallowCopy(fBitmap);
+ return shallowCopy.readPixels(dstInfo, dstPixels, dstRowBytes, srcX, srcY);
}
const void* SkImage_Raster::onPeekPixels(SkImageInfo* infoPtr, size_t* rowBytesPtr) const {