aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/core/SkBitmapProcShader.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/core/SkBitmapProcShader.cpp')
-rw-r--r--src/core/SkBitmapProcShader.cpp30
1 files changed, 21 insertions, 9 deletions
diff --git a/src/core/SkBitmapProcShader.cpp b/src/core/SkBitmapProcShader.cpp
index 3f657156f4..ded1b72009 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();
}