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

Unified Diff: src/core/SkBitmapProcState.cpp

Issue 766283004: check (thread-tricky) colortable after we've copied the bitmap into a per-thread context (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 6 years 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 | « src/core/SkBitmapProcShader.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/core/SkBitmapProcState.cpp
diff --git a/src/core/SkBitmapProcState.cpp b/src/core/SkBitmapProcState.cpp
index dad0ca92b9f5b1d39f11794e1e4dfd3483953826..ab38b6b2bc1254e5ab29bd2300762de7c3f3f5cf 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;
« no previous file with comments | « src/core/SkBitmapProcShader.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698