Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Commit 1cec4d5

Browse files
rphilliSkia Commit-Bot
authored andcommitted
Add a program iterator to SkDeferredDisplayList
Bug: skia:9455 Change-Id: I201218174b5d6efb72f7c06766a49f6711325bd5 Reviewed-on: https://skia-review.googlesource.com/c/skia/+/272530 Commit-Queue: Robert Phillips <[email protected]> Reviewed-by: Brian Salomon <[email protected]>
1 parent 9642b31 commit 1cec4d5

File tree

4 files changed

+58
-3
lines changed

4 files changed

+58
-3
lines changed

RELEASE_NOTES.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@ This file includes a list of high level updates for each milestone release.
77
Milestone 82
88

99
<Insert new notes here- top is most recent.>
10+
* Made SkDeferredDisplayList.h officially part of the public API (i.e., moved it to
11+
include/core). Also added a ProgramIterator to SkDeferredDisplayList which allows
12+
clients to pre-compile some of the shaders the DDL requires.
13+
1014
* Added two new helper methods to SkSurfaceCharacterization: createBackendFormat and
1115
createFBO0. These make it easier for clients to create new surface characterizations that
1216
differ only a little from an existing surface characterization.

include/core/SkDeferredDisplayList.h

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,26 @@ class SkDeferredDisplayList {
3535
return fCharacterization;
3636
}
3737

38+
#if SK_SUPPORT_GPU
39+
/**
40+
* Iterate through the programs required by the DDL.
41+
*/
42+
class SK_API ProgramIterator {
43+
public:
44+
ProgramIterator(GrContext*, SkDeferredDisplayList*);
45+
~ProgramIterator();
46+
47+
void compile();
48+
bool done() const;
49+
void next();
50+
51+
private:
52+
GrContext* fContext;
53+
const SkTArray<GrRecordingContext::ProgramData>& fProgramData;
54+
int fIndex;
55+
};
56+
#endif
57+
3858
// Provides access to functions that aren't part of the public API.
3959
SkDeferredDisplayListPriv priv();
4060
const SkDeferredDisplayListPriv priv() const;

src/core/SkDeferredDisplayList.cpp

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
class SkSurfaceCharacterization;
1515

1616
#if SK_SUPPORT_GPU
17+
#include "src/gpu/GrContextPriv.h"
1718
#include "src/gpu/GrRenderTask.h"
1819
#include "src/gpu/ccpr/GrCCPerOpsTaskPaths.h"
1920
#endif
@@ -28,3 +29,33 @@ SkDeferredDisplayList::SkDeferredDisplayList(const SkSurfaceCharacterization& ch
2829
}
2930

3031
SkDeferredDisplayList::~SkDeferredDisplayList() {}
32+
33+
//-------------------------------------------------------------------------------------------------
34+
#if SK_SUPPORT_GPU
35+
36+
SkDeferredDisplayList::ProgramIterator::ProgramIterator(GrContext* context,
37+
SkDeferredDisplayList* ddl)
38+
: fContext(context)
39+
, fProgramData(ddl->programData())
40+
, fIndex(0) {
41+
}
42+
43+
SkDeferredDisplayList::ProgramIterator::~ProgramIterator() {}
44+
45+
void SkDeferredDisplayList::ProgramIterator::compile() {
46+
if (!fContext || fIndex < 0 || fIndex >= (int) fProgramData.size()) {
47+
return;
48+
}
49+
50+
fContext->priv().compile(fProgramData[fIndex].desc(), fProgramData[fIndex].info());
51+
}
52+
53+
bool SkDeferredDisplayList::ProgramIterator::done() const {
54+
return fIndex >= (int) fProgramData.size();
55+
}
56+
57+
void SkDeferredDisplayList::ProgramIterator::next() {
58+
++fIndex;
59+
}
60+
61+
#endif

tools/DDLTileHelper.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -164,11 +164,11 @@ void DDLTileHelper::createDDLsInParallel() {
164164
// replay the DDL into a surface to make the tile image
165165
// compose the tile image into the main canvas
166166
static void do_gpu_stuff(GrContext* context, DDLTileHelper::TileData* tile) {
167-
auto& programData = tile->ddl()->priv().programData();
168167

169168
// TODO: schedule program compilation as their own tasks
170-
for (auto& programDatum : programData) {
171-
context->priv().compile(programDatum.desc(), programDatum.info());
169+
SkDeferredDisplayList::ProgramIterator iter(context, tile->ddl());
170+
for (; !iter.done(); iter.next()) {
171+
iter.compile();
172172
}
173173

174174
tile->draw(context);

0 commit comments

Comments
 (0)