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/core/SkArenaAlloc.h" |
13 | #include <utility> |
14 | class SkSurfaceCharacterization; |
15 | |
16 | #if SK_SUPPORT_GPU |
17 | #include "src/gpu/GrContextPriv.h" |
18 | #include "src/gpu/GrRenderTask.h" |
19 | #include "src/gpu/ccpr/GrCCPerOpsTaskPaths.h" |
20 | #endif |
21 | |
22 | SkDeferredDisplayList::SkDeferredDisplayList(const SkSurfaceCharacterization& characterization, |
23 | sk_sp<GrRenderTargetProxy> targetProxy, |
24 | sk_sp<LazyProxyData> lazyProxyData) |
25 | : fCharacterization(characterization) |
26 | #if SK_SUPPORT_GPU |
27 | , fTargetProxy(std::move(targetProxy)) |
28 | , fLazyProxyData(std::move(lazyProxyData)) |
29 | #endif |
30 | { |
31 | } |
32 | |
33 | SkDeferredDisplayList::~SkDeferredDisplayList() { |
34 | #if SK_SUPPORT_GPU && defined(SK_DEBUG) |
35 | for (auto& renderTask : fRenderTasks) { |
36 | SkASSERT(renderTask->unique()); |
37 | } |
38 | #endif |
39 | } |
40 | |
41 | //------------------------------------------------------------------------------------------------- |
42 | #if SK_SUPPORT_GPU |
43 | |
44 | SkDeferredDisplayList::ProgramIterator::ProgramIterator(GrDirectContext* dContext, |
45 | SkDeferredDisplayList* ddl) |
46 | : fDContext(dContext) |
47 | , fProgramData(ddl->programData()) |
48 | , fIndex(0) { |
49 | } |
50 | |
51 | SkDeferredDisplayList::ProgramIterator::~ProgramIterator() {} |
52 | |
53 | bool SkDeferredDisplayList::ProgramIterator::compile() { |
54 | if (!fDContext || fIndex < 0 || fIndex >= (int) fProgramData.size()) { |
55 | return false; |
56 | } |
57 | |
58 | return fDContext->priv().compile(fProgramData[fIndex].desc(), fProgramData[fIndex].info()); |
59 | } |
60 | |
61 | bool SkDeferredDisplayList::ProgramIterator::done() const { |
62 | return fIndex >= (int) fProgramData.size(); |
63 | } |
64 | |
65 | void SkDeferredDisplayList::ProgramIterator::next() { |
66 | ++fIndex; |
67 | } |
68 | |
69 | #endif |
70 |