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>
14class 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
22SkDeferredDisplayList::SkDeferredDisplayList(const SkSurfaceCharacterization& characterization,
23 sk_sp<LazyProxyData> lazyProxyData)
24 : fCharacterization(characterization)
25#if SK_SUPPORT_GPU
26 , fLazyProxyData(std::move(lazyProxyData))
27#endif
28{
29}
30
31SkDeferredDisplayList::~SkDeferredDisplayList() {
32#if SK_SUPPORT_GPU && defined(SK_DEBUG)
33 for (auto& renderTask : fRenderTasks) {
34 SkASSERT(renderTask->unique());
35 }
36#endif
37}
38
39//-------------------------------------------------------------------------------------------------
40#if SK_SUPPORT_GPU
41
42SkDeferredDisplayList::ProgramIterator::ProgramIterator(GrContext* context,
43 SkDeferredDisplayList* ddl)
44 : fContext(context)
45 , fProgramData(ddl->programData())
46 , fIndex(0) {
47}
48
49SkDeferredDisplayList::ProgramIterator::~ProgramIterator() {}
50
51void SkDeferredDisplayList::ProgramIterator::compile() {
52 if (!fContext || fIndex < 0 || fIndex >= (int) fProgramData.size()) {
53 return;
54 }
55
56 fContext->priv().compile(fProgramData[fIndex].desc(), fProgramData[fIndex].info());
57}
58
59bool SkDeferredDisplayList::ProgramIterator::done() const {
60 return fIndex >= (int) fProgramData.size();
61}
62
63void SkDeferredDisplayList::ProgramIterator::next() {
64 ++fIndex;
65}
66
67#endif
68