Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(271)

Unified Diff: src/image/SkImage_Raster.cpp

Issue 1327313002: make a shallow-copy so we don't get racy trying to lock/unlock our private bitmap (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 5 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/image/SkImage_Raster.cpp
diff --git a/src/image/SkImage_Raster.cpp b/src/image/SkImage_Raster.cpp
index af8f79010f134047b0ebf25678f9a22364dcb0d3..8afe7fd13aeec1668dd08c6ea15b1f985387c375 100644
--- a/src/image/SkImage_Raster.cpp
+++ b/src/image/SkImage_Raster.cpp
@@ -165,8 +165,11 @@ const void* SkImage_Raster::onPeekPixels(SkImageInfo* infoPtr, size_t* rowBytesP
}
void SkImage_Raster::onPreroll(GrContext* ctx) const {
- fBitmap.lockPixels();
- fBitmap.unlockPixels();
+ // SkImage can be called from lots of threads, but our fBitmap is *not* thread-safe,
+ // so we have to perform this lock/unlock in a non-racy way... we make a copy!
+ SkBitmap localShallowCopy(fBitmap);
+ localShallowCopy.lockPixels();
+ localShallowCopy.unlockPixels();
f(malita) 2015/09/10 18:36:37 This may solve the preRoll race, but don't we have
}
SkData* SkImage_Raster::onRefEncoded() const {
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698