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

Unified Diff: dm/DMQuiltTask.cpp

Issue 689673003: SkTaskGroup::batch(fn, args, N) (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: pun fn pointers Created 6 years, 2 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 | « no previous file | include/core/SkMultiPictureDraw.h » ('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 3d7daf27eb0003e07670ed370dc8703da52c753a..92bb6110ac098d0d2759b8d30d4af04fc6aeddab 100644
--- a/dm/DMQuiltTask.cpp
+++ b/dm/DMQuiltTask.cpp
@@ -25,32 +25,22 @@ static int tiles_needed(int fullDimension, int tileDimension) {
return (fullDimension + tileDimension - 1) / tileDimension;
}
-class Tile : public SkRunnable {
-public:
- Tile(int x, int y, const SkPicture& picture, SkBitmap* quilt)
- : fX(x * FLAGS_quiltTile)
- , fY(y * FLAGS_quiltTile)
- , fPicture(picture)
- , fQuilt(quilt) {}
-
- virtual void run() SK_OVERRIDE {
- SkBitmap tile;
- fQuilt->extractSubset(&tile, SkIRect::MakeXYWH(fX, fY, FLAGS_quiltTile, FLAGS_quiltTile));
- SkCanvas tileCanvas(tile);
-
- tileCanvas.translate(SkIntToScalar(-fX), SkIntToScalar(-fY));
- fPicture.playback(&tileCanvas);
- tileCanvas.flush();
-
- delete this;
- }
-
-private:
- const int fX, fY;
- const SkPicture& fPicture;
- SkBitmap* fQuilt;
+struct DrawTileArgs {
+ int x, y;
+ const SkPicture* picture;
+ SkBitmap* quilt;
};
+static void draw_tile(DrawTileArgs* arg) {
+ const DrawTileArgs& a = *arg;
+ SkBitmap tile;
+ a.quilt->extractSubset(&tile, SkIRect::MakeXYWH(a.x, a.y, FLAGS_quiltTile, FLAGS_quiltTile));
+ SkCanvas tileCanvas(tile);
+ tileCanvas.translate(SkIntToScalar(-a.x), SkIntToScalar(-a.y));
+ a.picture->playback(&tileCanvas);
+ tileCanvas.flush();
+}
+
void QuiltTask::draw() {
SkAutoTDelete<SkBBHFactory> factory;
switch (fBBH) {
@@ -88,13 +78,17 @@ void QuiltTask::draw() {
canvas.flush();
} else {
// Draw tiles in parallel into the same bitmap, simulating aggressive impl-side painting.
- SkTaskGroup tg;
- 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.
- tg.add(new Tile(x, y, *recorded, &full));
+ int xTiles = tiles_needed(full.width(), FLAGS_quiltTile),
+ yTiles = tiles_needed(full.height(), FLAGS_quiltTile);
+ SkTDArray<DrawTileArgs> args;
+ args.setCount(xTiles*yTiles);
+ for (int y = 0; y < yTiles; y++) {
+ for (int x = 0; x < xTiles; x++) {
+ DrawTileArgs arg = { x*FLAGS_quiltTile, y*FLAGS_quiltTile, recorded, &full };
+ args[y*xTiles + x] = arg;
}
}
+ SkTaskGroup().batch(draw_tile, args.begin(), args.count());
}
if (!BitmapsEqual(full, fReference)) {
« no previous file with comments | « no previous file | include/core/SkMultiPictureDraw.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698