• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright 2018 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 #include "include/core/SkDeferredDisplayList.h"
9 
10 #include "include/core/SkRefCnt.h"
11 #include "include/core/SkTypes.h"
12 #include "src/base/SkArenaAlloc.h"
13 
14 #include <utility>
15 
16 class SkSurfaceCharacterization;
17 
18 #if defined(SK_GANESH)
19 #include "src/gpu/ganesh/GrDirectContextPriv.h"
20 #include "src/gpu/ganesh/GrRenderTargetProxy.h"
21 #include "src/gpu/ganesh/GrRenderTask.h"
22 #endif
23 
SkDeferredDisplayList(const SkSurfaceCharacterization & characterization,sk_sp<GrRenderTargetProxy> targetProxy,sk_sp<LazyProxyData> lazyProxyData)24 SkDeferredDisplayList::SkDeferredDisplayList(const SkSurfaceCharacterization& characterization,
25                                              sk_sp<GrRenderTargetProxy> targetProxy,
26                                              sk_sp<LazyProxyData> lazyProxyData)
27         : fCharacterization(characterization)
28 #if defined(SK_GANESH)
29         , fArenas(true)
30         , fTargetProxy(std::move(targetProxy))
31         , fLazyProxyData(std::move(lazyProxyData))
32 #endif
33 {
34 #if defined(SK_GANESH)
35     SkASSERT(fTargetProxy->isDDLTarget());
36 #endif
37 }
38 
~SkDeferredDisplayList()39 SkDeferredDisplayList::~SkDeferredDisplayList() {
40 #if defined(SK_GANESH) && defined(SK_DEBUG)
41     for (auto& renderTask : fRenderTasks) {
42         SkASSERT(renderTask->unique());
43     }
44 #endif
45 }
46 
47 //-------------------------------------------------------------------------------------------------
48 #if defined(SK_GANESH)
49 
ProgramIterator(GrDirectContext * dContext,SkDeferredDisplayList * ddl)50 SkDeferredDisplayList::ProgramIterator::ProgramIterator(GrDirectContext* dContext,
51                                                         SkDeferredDisplayList* ddl)
52     : fDContext(dContext)
53     , fProgramData(ddl->programData())
54     , fIndex(0) {
55 }
56 
~ProgramIterator()57 SkDeferredDisplayList::ProgramIterator::~ProgramIterator() {}
58 
compile()59 bool SkDeferredDisplayList::ProgramIterator::compile() {
60     if (!fDContext || fIndex < 0 || fIndex >= (int) fProgramData.size()) {
61         return false;
62     }
63 
64     return fDContext->priv().compile(fProgramData[fIndex].desc(), fProgramData[fIndex].info());
65 }
66 
done() const67 bool SkDeferredDisplayList::ProgramIterator::done() const {
68     return fIndex >= (int) fProgramData.size();
69 }
70 
next()71 void SkDeferredDisplayList::ProgramIterator::next() {
72     ++fIndex;
73 }
74 
75 #endif
76