 Chromium Code Reviews
 Chromium Code Reviews 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
    
  
    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| 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 { |