aboutsummaryrefslogtreecommitdiffhomepage
path: root/include/core/SkDeferredDisplayListRecorder.h
diff options
context:
space:
mode:
authorGravatar Robert Phillips <robertphillips@google.com>2017-08-30 12:06:35 -0400
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2017-08-30 19:25:47 +0000
commitad8a43f7698071f00ce024a935b0bc04a4b19a41 (patch)
treee9d501a363e4ec0f9ff42a15dd0c1c7c717b15e7 /include/core/SkDeferredDisplayListRecorder.h
parentf1942de288ad593b1348029aefaad2cf99ad57ea (diff)
DeferredDisplayList API proposal
Chrome would like to perform cpu-side preprocessing for gpu draws in parallel. They do not want to go through a picture (since they have their own display list format). The general idea is that we add a new SkDeferredDisplayListRecorder class to perform all of Ganesh's cpu-side preprocessing ahead of time and in parallel. The SkDDLRecorder operates like SkPictureRecorder. The user can get an SkCanvas from the SkDDLRecorder and feed it draw operations. Once finished, the user calls 'detach' to get an SkDeferredDisplayList. All the work up to and including the 'detach' call can be done in parallel and will not touch the GPU. To actually get pixels the client must call SkSurface::draw(SkDDL) on an SkSurface that is "compatible" with the surface characterization initially given to the SkDDLMaker. The surface characterization contains the minimum amount of information Ganesh needs to know about the ultimate destination in order to perform its cpu-side work (i.e., caps, width, height, config). Change-Id: I75faa483ab5a6b779c8de56ea56b9d90b990f43a Reviewed-on: https://skia-review.googlesource.com/30140 Reviewed-by: Brian Salomon <bsalomon@google.com> Commit-Queue: Robert Phillips <robertphillips@google.com>
Diffstat (limited to 'include/core/SkDeferredDisplayListRecorder.h')
-rw-r--r--include/core/SkDeferredDisplayListRecorder.h52
1 files changed, 52 insertions, 0 deletions
diff --git a/include/core/SkDeferredDisplayListRecorder.h b/include/core/SkDeferredDisplayListRecorder.h
new file mode 100644
index 0000000000..185adfa99b
--- /dev/null
+++ b/include/core/SkDeferredDisplayListRecorder.h
@@ -0,0 +1,52 @@
+/*
+ * Copyright 2017 Google Inc.
+ *
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#ifndef SkDeferredDisplayListMaker_DEFINED
+#define SkDeferredDisplayListMaker_DEFINED
+
+#include "SkRefCnt.h"
+
+#include "../private/SkDeferredDisplayList.h"
+#include "../private/SkSurfaceCharacterization.h"
+
+class SkCanvas;
+class SkSurface; // TODO: remove
+
+/*
+ * This class is intended to be used as:
+ * Get an SkSurfaceCharacterization from the ultimate intended gpu-backed destination SkSurface
+ * Create one of these (an SkDDLMaker) on the stack
+ * Get the canvas and render into it
+ * Snap off and hold on to an SkDeferredDisplayList
+ * Once your app actually needs the pixels, call SkSurface::draw(SkDeferredDisplayList*)
+ *
+ * This class never accesses the GPU but performs all the cpu work it can. It
+ * is thread-safe (i.e., one can break a scene into tiles and perform their cpu-side
+ * work in parallel ahead of time).
+ */
+class SkDeferredDisplayListRecorder {
+public:
+ SkDeferredDisplayListRecorder(const SkSurfaceCharacterization&);
+
+ const SkSurfaceCharacterization& characterization() const {
+ return fCharacterization;
+ }
+
+ // The backing canvas will become invalid (and this entry point will return
+ // null) once 'detach' is called.
+ // Note: ownership of the SkCanvas is not transfered via this call.
+ SkCanvas* getCanvas();
+
+ std::unique_ptr<SkDeferredDisplayList> detach();
+
+private:
+ SkSurfaceCharacterization fCharacterization;
+
+ sk_sp<SkSurface> fSurface; // temporary until we have a real implementation
+};
+
+#endif