Add always-threaded SkRecord quilt tests.
Now that we're drawing tiles threaded like implside painting, remove the checks
that those lock counts are balanced. They're just not right for anyone anymore.
SkBitmaps themselves are not threadsafe (even const ones), so shallow copy them
on playback of an SkRecord. (The underlying SkPixelRefs are threadsafe.)
Simplify quilt drawing by using SkBitmap::extractSubset. No need for locking.
Bump up to 256x256 tiles. 16x16 tiles just murders performance (way too much
contention). This has the nice side effect of letting us enable a bunch more
GMs for quilt mode; they drew wrong with small tiles but exactly right with large.
BUG=171776
R=reed@google.com, mtklein@google.com
Author: mtklein@chromium.org
Review URL: https://codereview.chromium.org/371023005
diff --git a/src/core/SkCanvas.cpp b/src/core/SkCanvas.cpp
index 90c8ec8..4b1749a 100644
--- a/src/core/SkCanvas.cpp
+++ b/src/core/SkCanvas.cpp
@@ -54,47 +54,6 @@
#define dec_canvas()
#endif
-#ifdef SK_DEBUG
-#include "SkPixelRef.h"
-
-/*
- * Some pixelref subclasses can support being "locked" from another thread
- * during the lock-scope of skia calling them. In these instances, this balance
- * check will fail, but may not be indicative of a problem, so we allow a build
- * flag to disable this check.
- *
- * Potentially another fix would be to have a (debug-only) virtual or flag on
- * pixelref, which could tell us at runtime if this check is valid. That would
- * eliminate the need for this heavy-handed build check.
- */
-#ifdef SK_DISABLE_PIXELREF_LOCKCOUNT_BALANCE_CHECK
-class AutoCheckLockCountBalance {
-public:
- AutoCheckLockCountBalance(const SkBitmap&) { /* do nothing */ }
-};
-#else
-class AutoCheckLockCountBalance {
-public:
- AutoCheckLockCountBalance(const SkBitmap& bm) : fPixelRef(bm.pixelRef()) {
- fLockCount = fPixelRef ? fPixelRef->getLockCount() : 0;
- }
- ~AutoCheckLockCountBalance() {
- const int count = fPixelRef ? fPixelRef->getLockCount() : 0;
- SkASSERT(count == fLockCount);
- }
-
-private:
- const SkPixelRef* fPixelRef;
- int fLockCount;
-};
-#endif
-
-#define CHECK_LOCKCOUNT_BALANCE(bitmap) AutoCheckLockCountBalance clcb(bitmap)
-
-#else
- #define CHECK_LOCKCOUNT_BALANCE(bitmap)
-#endif
-
typedef SkTLazy<SkPaint> SkLazyPaint;
void SkCanvas::predrawNotify() {
@@ -1135,7 +1094,6 @@
}
SkDEBUGCODE(bitmap.validate();)
- CHECK_LOCKCOUNT_BALANCE(bitmap);
SkRect storage;
const SkRect* bounds = NULL;
@@ -1202,7 +1160,6 @@
return;
}
SkDEBUGCODE(bitmap.validate();)
- CHECK_LOCKCOUNT_BALANCE(bitmap);
SkPaint tmp;
if (NULL == paint) {
@@ -2011,8 +1968,6 @@
return;
}
- CHECK_LOCKCOUNT_BALANCE(bitmap);
-
SkRect storage;
const SkRect* bounds = &dst;
if (NULL == paint || paint->canComputeFastBounds()) {
diff --git a/src/core/SkRecordDraw.cpp b/src/core/SkRecordDraw.cpp
index db14910..89efb8e 100644
--- a/src/core/SkRecordDraw.cpp
+++ b/src/core/SkRecordDraw.cpp
@@ -31,6 +31,11 @@
return fCanvas->quickRejectY(r.minY, r.maxY);
}
+// FIXME: SkBitmaps are stateful, so we need to copy them to play back in multiple threads.
+static SkBitmap shallow_copy(const SkBitmap& bitmap) {
+ return bitmap;
+}
+
// NoOps draw nothing.
template <> void Draw::draw(const NoOp&) {}
@@ -49,10 +54,11 @@
DRAW(ClipRect, clipRect(r.rect, r.op, r.doAA));
DRAW(ClipRegion, clipRegion(r.region, r.op));
-DRAW(DrawBitmap, drawBitmap(r.bitmap, r.left, r.top, r.paint));
-DRAW(DrawBitmapMatrix, drawBitmapMatrix(r.bitmap, r.matrix, r.paint));
-DRAW(DrawBitmapNine, drawBitmapNine(r.bitmap, r.center, r.dst, r.paint));
-DRAW(DrawBitmapRectToRect, drawBitmapRectToRect(r.bitmap, r.src, r.dst, r.paint, r.flags));
+DRAW(DrawBitmap, drawBitmap(shallow_copy(r.bitmap), r.left, r.top, r.paint));
+DRAW(DrawBitmapMatrix, drawBitmapMatrix(shallow_copy(r.bitmap), r.matrix, r.paint));
+DRAW(DrawBitmapNine, drawBitmapNine(shallow_copy(r.bitmap), r.center, r.dst, r.paint));
+DRAW(DrawBitmapRectToRect,
+ drawBitmapRectToRect(shallow_copy(r.bitmap), r.src, r.dst, r.paint, r.flags));
DRAW(DrawDRRect, drawDRRect(r.outer, r.inner, r.paint));
DRAW(DrawOval, drawOval(r.oval, r.paint));
DRAW(DrawPaint, drawPaint(r.paint));
@@ -62,7 +68,7 @@
DRAW(DrawPosTextH, drawPosTextH(r.text, r.byteLength, r.xpos, r.y, r.paint));
DRAW(DrawRRect, drawRRect(r.rrect, r.paint));
DRAW(DrawRect, drawRect(r.rect, r.paint));
-DRAW(DrawSprite, drawSprite(r.bitmap, r.left, r.top, r.paint));
+DRAW(DrawSprite, drawSprite(shallow_copy(r.bitmap), r.left, r.top, r.paint));
DRAW(DrawText, drawText(r.text, r.byteLength, r.x, r.y, r.paint));
DRAW(DrawTextOnPath, drawTextOnPath(r.text, r.byteLength, r.path, r.matrix, r.paint));
DRAW(DrawVertices, drawVertices(r.vmode, r.vertexCount, r.vertices, r.texs, r.colors,