aboutsummaryrefslogtreecommitdiffhomepage
path: root/dm
diff options
context:
space:
mode:
authorGravatar mtklein <mtklein@chromium.org>2014-07-07 10:41:04 -0700
committerGravatar Commit bot <commit-bot@chromium.org>2014-07-07 10:41:04 -0700
commit7cdc1ee11545a10708e857adf1d4a94a2f1e2a48 (patch)
tree47918c0d3c042076a4eeb061eef782e27143ad71 /dm
parentd312a04ffacb8e86a2d2eb37985b154ab4e9d3c6 (diff)
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
Diffstat (limited to 'dm')
-rw-r--r--dm/DMCpuGMTask.cpp3
-rw-r--r--dm/DMQuiltTask.cpp50
-rw-r--r--dm/DMQuiltTask.h13
3 files changed, 33 insertions, 33 deletions
diff --git a/dm/DMCpuGMTask.cpp b/dm/DMCpuGMTask.cpp
index d45da5166c..2252a1d137 100644
--- a/dm/DMCpuGMTask.cpp
+++ b/dm/DMCpuGMTask.cpp
@@ -39,7 +39,8 @@ void CpuGMTask::draw() {
SPAWN(PipeTask, fGMFactory(NULL), bitmap, PipeTask::kCrossProcess_Mode);
SPAWN(PipeTask, fGMFactory(NULL), bitmap, PipeTask::kSharedAddress_Mode);
- SPAWN(QuiltTask, fGMFactory(NULL), bitmap);
+ SPAWN(QuiltTask, fGMFactory(NULL), bitmap, QuiltTask::kNormal_Mode);
+ SPAWN(QuiltTask, fGMFactory(NULL), bitmap, QuiltTask::kSkRecord_Mode);
SPAWN(ReplayTask, fGMFactory(NULL), bitmap, ReplayTask::kNormal_Mode);
SPAWN(ReplayTask, fGMFactory(NULL), bitmap, ReplayTask::kRTree_Mode);
diff --git a/dm/DMQuiltTask.cpp b/dm/DMQuiltTask.cpp
index 44c4341a7d..960ca86747 100644
--- a/dm/DMQuiltTask.cpp
+++ b/dm/DMQuiltTask.cpp
@@ -7,14 +7,17 @@
#include "SkThreadPool.h"
DEFINE_bool(quilt, true, "If true, draw into a quilt of small tiles and compare.");
-DEFINE_int32(quiltTile, 16, "Dimension of (square) quilt tile.");
+DEFINE_int32(quiltTile, 256, "Dimension of (square) quilt tile.");
DEFINE_bool(quiltThreaded, false, "If true, draw quilt tiles with multiple threads.");
+static const char* kSuffixes[] = { "quilt", "quilt_skr" };
+
namespace DM {
-QuiltTask::QuiltTask(const Task& parent, skiagm::GM* gm, SkBitmap reference)
+QuiltTask::QuiltTask(const Task& parent, skiagm::GM* gm, SkBitmap reference, QuiltTask::Mode mode)
: CpuTask(parent)
- , fName(UnderJoin(parent.name().c_str(), "quilt"))
+ , fMode(mode)
+ , fName(UnderJoin(parent.name().c_str(), kSuffixes[mode]))
, fGM(gm)
, fReference(reference)
{}
@@ -25,62 +28,51 @@ static int tiles_needed(int fullDimension, int tileDimension) {
class Tile : public SkRunnable {
public:
- Tile(int x, int y, SkColorType colorType,
- const SkPicture& picture, SkCanvas* canvas, SkMutex* mutex)
- : fX(x)
- , fY(y)
- , fColorType(colorType)
+ Tile(int x, int y, const SkPicture& picture, SkBitmap* quilt)
+ : fX(x * FLAGS_quiltTile)
+ , fY(y * FLAGS_quiltTile)
, fPicture(picture)
- , fCanvas(canvas)
- , fMutex(mutex) {}
+ , fQuilt(quilt) {}
virtual void run() SK_OVERRIDE {
SkBitmap tile;
- tile.allocPixels(SkImageInfo::Make(FLAGS_quiltTile, FLAGS_quiltTile,
- fColorType, kPremul_SkAlphaType));
+ fQuilt->extractSubset(&tile, SkIRect::MakeXYWH(fX, fY, FLAGS_quiltTile, FLAGS_quiltTile));
SkCanvas tileCanvas(tile);
- const SkScalar xOffset = SkIntToScalar(fX * tile.width()),
- yOffset = SkIntToScalar(fY * tile.height());
- tileCanvas.translate(-xOffset, -yOffset);
+ tileCanvas.translate(SkIntToScalar(-fX), SkIntToScalar(-fY));
fPicture.draw(&tileCanvas);
tileCanvas.flush();
- {
- SkAutoMutexAcquire lock(fMutex);
- fCanvas->drawBitmap(tile, xOffset, yOffset, NULL);
- }
-
delete this;
}
private:
const int fX, fY;
- const SkColorType fColorType;
const SkPicture& fPicture;
- SkCanvas* fCanvas;
- SkMutex* fMutex; // Guards fCanvas.
+ SkBitmap* fQuilt;
};
void QuiltTask::draw() {
- SkAutoTUnref<SkPicture> recorded(RecordPicture(fGM.get()));
+ SkAutoTUnref<SkPicture> recorded(
+ RecordPicture(fGM.get(), NULL/*bbh factory*/, kSkRecord_Mode == fMode));
SkBitmap full;
AllocatePixels(fReference, &full);
- SkCanvas fullCanvas(full);
- SkMutex mutex; // Guards fullCanvas.
- SkThreadPool pool(FLAGS_quiltThreaded ? SkThreadPool::kThreadPerCore : 0);
+ int threads = 0;
+ if (kSkRecord_Mode == fMode || FLAGS_quiltThreaded) {
+ threads = SkThreadPool::kThreadPerCore;
+ }
+ SkThreadPool pool(threads);
for (int y = 0; y < tiles_needed(full.height(), FLAGS_quiltTile); y++) {
for (int x = 0; x < tiles_needed(full.width(), FLAGS_quiltTile); x++) {
// Deletes itself when done.
- pool.add(new Tile(x, y, fReference.colorType(), *recorded, &fullCanvas, &mutex));
+ pool.add(new Tile(x, y, *recorded, &full));
}
}
pool.wait();
- fullCanvas.flush();
if (!BitmapsEqual(full, fReference)) {
this->fail();
diff --git a/dm/DMQuiltTask.h b/dm/DMQuiltTask.h
index 56f322f067..5f6566237d 100644
--- a/dm/DMQuiltTask.h
+++ b/dm/DMQuiltTask.h
@@ -14,15 +14,22 @@ namespace DM {
class QuiltTask : public CpuTask {
public:
- QuiltTask(const Task& parent, // QuiltTask must be a child task. Pass its parent here.
- skiagm::GM*, // GM to run through a picture. Takes ownership.
- SkBitmap reference); // Bitmap to compare picture replay results to.
+ enum Mode {
+ kNormal_Mode,
+ kSkRecord_Mode,
+ };
+
+ QuiltTask(const Task& parent, // QuiltTask must be a child task. Pass its parent here.
+ skiagm::GM*, // GM to run through a picture. Takes ownership.
+ SkBitmap reference, // Bitmap to compare picture replay results to.
+ Mode mode);
virtual void draw() SK_OVERRIDE;
virtual bool shouldSkip() const SK_OVERRIDE;
virtual SkString name() const SK_OVERRIDE { return fName; }
private:
+ const Mode fMode;
const SkString fName;
SkAutoTDelete<skiagm::GM> fGM;
const SkBitmap fReference;