aboutsummaryrefslogtreecommitdiffhomepage
path: root/tools/DDLTileHelper.h
diff options
context:
space:
mode:
authorGravatar Robert Phillips <robertphillips@google.com>2018-05-29 16:13:26 -0400
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2018-05-30 10:12:08 +0000
commit96601084b3f7b108c1faf12a2ea12eb7ea8688a0 (patch)
tree222f8ec851bd0156b32a382f458226170f7b33c0 /tools/DDLTileHelper.h
parent16f558ddeed33c816f3d3dad03997b2ea523c5b9 (diff)
Add DDL to SKPBench
Most of this CL is just repackaging the promise image and tile code from ViaDDL for reuse by SKPBench. Change-Id: Ie5003c36fe85cc5be9639552f9488b8e92dcdbbf Reviewed-on: https://skia-review.googlesource.com/129805 Reviewed-by: Chris Dalton <csmartdalton@google.com> Reviewed-by: Greg Daniel <egdaniel@google.com> Commit-Queue: Robert Phillips <robertphillips@google.com>
Diffstat (limited to 'tools/DDLTileHelper.h')
-rw-r--r--tools/DDLTileHelper.h80
1 files changed, 80 insertions, 0 deletions
diff --git a/tools/DDLTileHelper.h b/tools/DDLTileHelper.h
new file mode 100644
index 0000000000..fa6f8115bc
--- /dev/null
+++ b/tools/DDLTileHelper.h
@@ -0,0 +1,80 @@
+/*
+ * Copyright 2018 Google Inc.
+ *
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#ifndef DDLTileHelper_DEFINED
+#define DDLTileHelper_DEFINED
+
+#include "SkRect.h"
+#include "SkRefCnt.h"
+#include "SkSurfaceCharacterization.h"
+
+#if SK_SUPPORT_GPU
+
+class DDLPromiseImageHelper;
+class SkCanvas;
+class SkData;
+class SkDeferredDisplayList;
+class SkPicture;
+class SkSurface;
+class SkSurfaceCharacterization;
+
+class DDLTileHelper {
+public:
+ // TileData class encapsulates the information and behavior for a single tile/thread in
+ // a DDL rendering.
+ class TileData {
+ public:
+ TileData(sk_sp<SkSurface>, const SkIRect& clip);
+
+ // This method can be invoked in parallel
+ // In each thread we will reconvert the compressedPictureData into an SkPicture
+ // replacing each image-index with a promise image.
+ void createTileSpecificSKP(SkData* compressedPictureData,
+ const DDLPromiseImageHelper& helper);
+
+ // This method can be invoked in parallel
+ // Create the per-tile DDL from the per-tile SKP
+ void createDDL();
+
+ // This method operates serially and replays the recorded DDL into the tile surface.
+ void draw();
+
+ // This method also operates serially and composes the results of replaying the DDL into
+ // the final destination surface.
+ void compose(SkCanvas* dst);
+
+ void reset();
+
+ private:
+ sk_sp<SkSurface> fSurface;
+ SkSurfaceCharacterization fCharacterization;
+ SkIRect fClip; // in the device space of the dest canvas
+ sk_sp<SkPicture> fReconstitutedPicture;
+ SkTArray<sk_sp<SkImage>> fPromiseImages; // All the promise images in the
+ // reconstituted picture
+ std::unique_ptr<SkDeferredDisplayList> fDisplayList;
+ };
+
+ DDLTileHelper(SkCanvas* canvas, const SkIRect& viewport, int numDivisions);
+
+ void createSKPPerTile(SkData* compressedPictureData, const DDLPromiseImageHelper& helper);
+
+ void createDDLsInParallel();
+
+ void drawAllTilesAndFlush(GrContext*, bool flush);
+
+ void composeAllTiles(SkCanvas* dstCanvas);
+
+ void resetAllTiles();
+
+private:
+ int fNumDivisions; // number of tiles along a side
+ SkTArray<TileData> fTiles;
+};
+
+#endif
+#endif