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

Unified Diff: dm/DMQuiltTask.cpp

Issue 371023005: Add always-threaded SkRecord quilt tests. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: bigger tile -> more GMs can quilt Created 6 years, 5 months 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 | « dm/DMQuiltTask.h ('k') | gm/bigmatrix.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: dm/DMQuiltTask.cpp
diff --git a/dm/DMQuiltTask.cpp b/dm/DMQuiltTask.cpp
index 44c4341a7d79de5475c92b7116fa0ef09d84b8da..960ca86747b3dec47eb3e54500b761f7c7ffc106 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();
« no previous file with comments | « dm/DMQuiltTask.h ('k') | gm/bigmatrix.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698