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

Unified Diff: src/core/SkBitmapProcShader.cpp

Issue 23591030: start to remove lockPixels from bitmapshader (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Created 7 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 | « include/core/SkPixelRef.h ('k') | src/core/SkBitmapProcState.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/core/SkBitmapProcShader.cpp
diff --git a/src/core/SkBitmapProcShader.cpp b/src/core/SkBitmapProcShader.cpp
index 3f657156f4f6f1d6333584a70e88905968d55167..ded1b7200938bb97a9d6dbe94d0eccc50f213408 100644
--- a/src/core/SkBitmapProcShader.cpp
+++ b/src/core/SkBitmapProcShader.cpp
@@ -80,24 +80,37 @@ bool SkBitmapProcShader::isOpaque() const {
return fRawBitmap.isOpaque();
}
+static bool valid_for_drawing(const SkBitmap& bm) {
+ if (0 == bm.width() || 0 == bm.height()) {
+ return false; // nothing to draw
+ }
+ if (NULL == bm.pixelRef()) {
+ return false; // no pixels to read
+ }
+ if (SkBitmap::kIndex8_Config == bm.config()) {
+ // ugh, I have to lock-pixels to inspect the colortable
+ SkAutoLockPixels alp(bm);
+ if (!bm.getColorTable()) {
+ return false;
+ }
+ }
+ return true;
+}
+
bool SkBitmapProcShader::setContext(const SkBitmap& device,
const SkPaint& paint,
const SkMatrix& matrix) {
- // do this first, so we have a correct inverse matrix
- if (!this->INHERITED::setContext(device, paint, matrix)) {
+ if (!fRawBitmap.getTexture() && !valid_for_drawing(fRawBitmap)) {
return false;
}
- fState.fOrigBitmap = fRawBitmap;
- fState.fOrigBitmap.lockPixels();
- if (!fState.fOrigBitmap.getTexture() && !fState.fOrigBitmap.readyToDraw()) {
- fState.fOrigBitmap.unlockPixels();
- this->INHERITED::endContext();
+ // do this first, so we have a correct inverse matrix
+ if (!this->INHERITED::setContext(device, paint, matrix)) {
return false;
}
+ fState.fOrigBitmap = fRawBitmap;
if (!fState.chooseProcs(this->getTotalInverse(), paint)) {
- fState.fOrigBitmap.unlockPixels();
this->INHERITED::endContext();
return false;
}
@@ -147,7 +160,6 @@ bool SkBitmapProcShader::setContext(const SkBitmap& device,
}
void SkBitmapProcShader::endContext() {
- fState.fOrigBitmap.unlockPixels();
fState.endContext();
this->INHERITED::endContext();
}
« no previous file with comments | « include/core/SkPixelRef.h ('k') | src/core/SkBitmapProcState.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698