• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright 2017 Google Inc.
3  *
4  * Use of this source code is governed by a BSD-style license that can be
5  * found in the LICENSE file.
6  */
7 
8 #ifndef SkDeferredDisplayList_DEFINED
9 #define SkDeferredDisplayList_DEFINED
10 
11 #include "include/core/SkRefCnt.h"
12 #include "include/core/SkSurfaceCharacterization.h"
13 #include "include/core/SkTypes.h"
14 
15 class SkDeferredDisplayListPriv;
16 
17 #if SK_SUPPORT_GPU
18 #include "include/private/SkTArray.h"
19 #include <map>
20 class GrRenderTask;
21 class GrRenderTargetProxy;
22 struct GrCCPerOpListPaths;
23 #endif
24 
25 /*
26  * This class contains pre-processed gpu operations that can be replayed into
27  * an SkSurface via draw(SkDeferredDisplayList*).
28  *
29  * TODO: we probably need to expose this class so users can query it for memory usage.
30  */
31 class SkDeferredDisplayList {
32 public:
33 
34 #if SK_SUPPORT_GPU
35     // This object is the source from which the lazy proxy backing the DDL will pull its backing
36     // texture when the DDL is replayed. It has to be separately ref counted bc the lazy proxy
37     // can outlive the DDL.
38     class SK_API LazyProxyData : public SkRefCnt {
39     public:
40         // Upon being replayed - this field will be filled in (by the DrawingManager) with the proxy
41         // backing the destination SkSurface. Note that, since there is no good place to clear it
42         // it can become a dangling pointer.
43         GrRenderTargetProxy*     fReplayDest = nullptr;
44     };
45 #else
46     class SK_API LazyProxyData : public SkRefCnt {};
47 #endif
48 
49     SK_API SkDeferredDisplayList(const SkSurfaceCharacterization& characterization,
50                                  sk_sp<LazyProxyData>);
51     SK_API ~SkDeferredDisplayList();
52 
characterization()53     SK_API const SkSurfaceCharacterization& characterization() const {
54         return fCharacterization;
55     }
56 
57     // Provides access to functions that aren't part of the public API.
58     SkDeferredDisplayListPriv priv();
59     const SkDeferredDisplayListPriv priv() const;
60 
61 private:
62     friend class GrDrawingManager; // for access to 'fRenderTasks' and 'fLazyProxyData'
63     friend class SkDeferredDisplayListRecorder; // for access to 'fLazyProxyData'
64     friend class SkDeferredDisplayListPriv;
65 
66     const SkSurfaceCharacterization fCharacterization;
67 
68 #if SK_SUPPORT_GPU
69     // This needs to match the same type in GrCoverageCountingPathRenderer.h
70     using PendingPathsMap = std::map<uint32_t, sk_sp<GrCCPerOpListPaths>>;
71 
72     SkTArray<sk_sp<GrRenderTask>>   fRenderTasks;
73     PendingPathsMap                 fPendingPaths;  // This is the path data from CCPR.
74 #endif
75     sk_sp<LazyProxyData>            fLazyProxyData;
76 };
77 
78 #endif
79