diff options
author | 2014-12-04 08:06:17 -0800 | |
---|---|---|
committer | 2014-12-04 08:06:18 -0800 | |
commit | 89dee4298e79b69ef2f1ec045c90ffacff9cabec (patch) | |
tree | 883d878319c76a54aaeaed9d4165170bcba512a8 /src/core/SkBitmapProcState.cpp | |
parent | c88cedaf8806cc9afa36497dc93eb0d1c329fb6c (diff) |
check (thread-tricky) colortable after we've copied the bitmap into a per-thread context
BUG=skia:
Review URL: https://codereview.chromium.org/766283004
Diffstat (limited to 'src/core/SkBitmapProcState.cpp')
-rw-r--r-- | src/core/SkBitmapProcState.cpp | 24 |
1 files changed, 23 insertions, 1 deletions
diff --git a/src/core/SkBitmapProcState.cpp b/src/core/SkBitmapProcState.cpp index dad0ca92b9..ab38b6b2bc 100644 --- a/src/core/SkBitmapProcState.cpp +++ b/src/core/SkBitmapProcState.cpp @@ -324,8 +324,30 @@ SkBitmapProcState::~SkBitmapProcState() { SkDELETE(fBitmapFilter); } +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 (bm.getTexture()) { + // we can handle texture (ugh) since lockPixels will perform a read-back + return true; + } + if (kIndex_8_SkColorType == bm.colorType()) { + SkAutoLockPixels alp(bm); // but we need to call it before getColorTable() is safe. + if (!bm.getColorTable()) { + return false; + } + } + return true; +} + bool SkBitmapProcState::chooseProcs(const SkMatrix& inv, const SkPaint& paint) { - SkASSERT(fOrigBitmap.width() && fOrigBitmap.height()); + if (!valid_for_drawing(fOrigBitmap)) { + return false; + } fBitmap = NULL; fInvMatrix = inv; |