Use SkSpan to clean up GrOnFlushCallbackObject API

Also adjust the OpsTask terminology to the broader RenderTask term.

Change-Id: I8549e74a3e2f6b2caf765103f31243b776823c16
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/332724
Commit-Queue: Adlai Holler <adlai@google.com>
Reviewed-by: Robert Phillips <robertphillips@google.com>
This commit is contained in:
Adlai Holler 2020-11-11 08:51:25 -05:00 committed by Skia Commit-Bot
parent 5acf6a857b
commit 9902cff102
11 changed files with 28 additions and 37 deletions

View File

@ -233,8 +233,7 @@ bool GrDrawingManager::flush(
fDAG.gatherIDs(&fFlushingRenderTaskIDs);
for (GrOnFlushCallbackObject* onFlushCBObject : fOnFlushCBObjects) {
onFlushCBObject->preFlush(&onFlushProvider, fFlushingRenderTaskIDs.begin(),
fFlushingRenderTaskIDs.count());
onFlushCBObject->preFlush(&onFlushProvider, fFlushingRenderTaskIDs);
}
for (const auto& onFlushRenderTask : fOnFlushRenderTasks) {
onFlushRenderTask->makeClosed(*fContext->priv().caps());
@ -339,8 +338,7 @@ bool GrDrawingManager::flush(
flushed = false;
}
for (GrOnFlushCallbackObject* onFlushCBObject : fOnFlushCBObjects) {
onFlushCBObject->postFlush(fTokenTracker.nextTokenToFlush(), fFlushingRenderTaskIDs.begin(),
fFlushingRenderTaskIDs.count());
onFlushCBObject->postFlush(fTokenTracker.nextTokenToFlush(), fFlushingRenderTaskIDs);
flushed = true;
}
if (flushed) {

View File

@ -10,6 +10,7 @@
#include "include/core/SkRefCnt.h"
#include "include/private/SkTArray.h"
#include "src/core/SkSpan.h"
#include "src/gpu/GrDeferredUpload.h"
#include "src/gpu/GrOpFlushState.h"
#include "src/gpu/GrResourceProvider.h"
@ -31,19 +32,18 @@ public:
/*
* The preFlush callback allows subsystems (e.g., text, path renderers) to create atlases
* for a specific flush. All the GrOpsTask IDs required for the flush are passed into the
* for a specific flush. All the GrRenderTask IDs required for the flush are passed into the
* callback.
*/
virtual void preFlush(GrOnFlushResourceProvider*, const uint32_t* opsTaskIDs,
int numOpsTaskIDs) = 0;
virtual void preFlush(GrOnFlushResourceProvider*, SkSpan<const uint32_t> renderTaskIDs) = 0;
/**
* Called once flushing is complete and all opsTasks indicated by preFlush have been executed
* Called once flushing is complete and all renderTasks indicated by preFlush have been executed
* and released. startTokenForNextFlush can be used to track resources used in the current
* flush.
*/
virtual void postFlush(GrDeferredUploadToken startTokenForNextFlush,
const uint32_t* opsTaskIDs, int numOpsTaskIDs) {}
SkSpan<const uint32_t> renderTaskIDs) {}
/**
* Tells the callback owner to hold onto this object when freeing GPU resources.

View File

@ -223,7 +223,7 @@ std::unique_ptr<GrFragmentProcessor> GrCoverageCountingPathRenderer::makeClipPro
}
void GrCoverageCountingPathRenderer::preFlush(
GrOnFlushResourceProvider* onFlushRP, const uint32_t* opsTaskIDs, int numOpsTaskIDs) {
GrOnFlushResourceProvider* onFlushRP, SkSpan<const uint32_t> taskIDs) {
using DoCopiesToA8Coverage = GrCCDrawPathsOp::DoCopiesToA8Coverage;
SkASSERT(!fFlushing);
SkASSERT(fFlushingPaths.empty());
@ -246,9 +246,9 @@ void GrCoverageCountingPathRenderer::preFlush(
// Move the per-opsTask paths that are about to be flushed from fPendingPaths to fFlushingPaths,
// and count them up so we can preallocate buffers.
fFlushingPaths.reserve_back(numOpsTaskIDs);
for (int i = 0; i < numOpsTaskIDs; ++i) {
auto iter = fPendingPaths.find(opsTaskIDs[i]);
fFlushingPaths.reserve_back(taskIDs.count());
for (uint32_t taskID : taskIDs) {
auto iter = fPendingPaths.find(taskID);
if (fPendingPaths.end() == iter) {
continue; // No paths on this opsTask.
}
@ -311,8 +311,8 @@ void GrCoverageCountingPathRenderer::preFlush(
}
}
void GrCoverageCountingPathRenderer::postFlush(GrDeferredUploadToken, const uint32_t* opsTaskIDs,
int numOpsTaskIDs) {
void GrCoverageCountingPathRenderer::postFlush(GrDeferredUploadToken,
SkSpan<const uint32_t> /* taskIDs */) {
SkASSERT(fFlushing);
if (!fFlushingPaths.empty()) {

View File

@ -67,9 +67,8 @@ public:
const SkPath& deviceSpacePath, const SkIRect& accessRect, const GrCaps& caps);
// GrOnFlushCallbackObject overrides.
void preFlush(GrOnFlushResourceProvider*, const uint32_t* opsTaskIDs,
int numOpsTaskIDs) override;
void postFlush(GrDeferredUploadToken, const uint32_t* opsTaskIDs, int numOpsTaskIDs) override;
void preFlush(GrOnFlushResourceProvider*, SkSpan<const uint32_t> taskIDs) override;
void postFlush(GrDeferredUploadToken, SkSpan<const uint32_t> taskIDs) override;
void purgeCacheEntriesOlderThan(GrProxyProvider*, const GrStdSteadyClock::time_point&);

View File

@ -48,16 +48,14 @@ public:
// GrOnFlushCallbackObject overrides
void preFlush(GrOnFlushResourceProvider* onFlushRP,
const uint32_t* /* opsTaskIDs */,
int /* numOpsTaskIDs */) override {
SkSpan<const uint32_t> /* taskIDs */) override {
if (fAtlas) {
fAtlas->instantiate(onFlushRP);
}
}
void postFlush(GrDeferredUploadToken startTokenForNextFlush,
const uint32_t* /* opsTaskIDs */,
int /* numOpsTaskIDs */) override {
SkSpan<const uint32_t> /* taskIDs */) override {
if (fAtlas) {
fAtlas->compact(startTokenForNextFlush);
}

View File

@ -361,7 +361,7 @@ void GrTessellationPathRenderer::onStencilPath(const StencilPathArgs& args) {
}
void GrTessellationPathRenderer::preFlush(GrOnFlushResourceProvider* onFlushRP,
const uint32_t* opsTaskIDs, int numOpsTaskIDs) {
SkSpan<const uint32_t> /* taskIDs */) {
if (!fAtlas.drawBounds().isEmpty()) {
this->renderAtlas(onFlushRP);
fAtlas.reset(kAtlasInitialSize, *onFlushRP->caps());

View File

@ -54,8 +54,7 @@ public:
CanDrawPath onCanDrawPath(const CanDrawPathArgs&) const override;
bool onDrawPath(const DrawPathArgs&) override;
void onStencilPath(const StencilPathArgs&) override;
void preFlush(GrOnFlushResourceProvider*, const uint32_t* opsTaskIDs,
int numOpsTaskIDs) override;
void preFlush(GrOnFlushResourceProvider*, SkSpan<const uint32_t> taskIDs) override;
private:
void initAtlasFlags(GrRecordingContext*);

View File

@ -83,7 +83,7 @@ public:
// GrOnFlushCallbackObject overrides
void preFlush(GrOnFlushResourceProvider* onFlushRP, const uint32_t*, int) override {
void preFlush(GrOnFlushResourceProvider* onFlushRP, SkSpan<const uint32_t>) override {
for (int i = 0; i < kMaskFormatCount; ++i) {
if (fAtlases[i]) {
fAtlases[i]->instantiate(onFlushRP);
@ -91,8 +91,7 @@ public:
}
}
void postFlush(GrDeferredUploadToken startTokenForNextFlush,
const uint32_t* opsTaskIDs, int numOpsTaskIDs) override {
void postFlush(GrDeferredUploadToken startTokenForNextFlush, SkSpan<const uint32_t>) override {
for (int i = 0; i < kMaskFormatCount; ++i) {
if (fAtlases[i]) {
fAtlases[i]->compact(startTokenForNextFlush);

View File

@ -323,8 +323,7 @@ protected:
int lastCopyAtlasID() const { return fLastCopyAtlasID; }
int lastRenderedAtlasID() const { return fLastRenderedAtlasID; }
void preFlush(GrOnFlushResourceProvider*, const uint32_t* opsTaskIDs,
int numOpsTaskIDs) override {
void preFlush(GrOnFlushResourceProvider*, SkSpan<const uint32_t>) override {
fLastRenderedAtlasID = fLastCopyAtlasID = 0;
const GrCCPerFlushResources* resources = fCCPR->testingOnly_getCurrentFlushResources();
@ -340,7 +339,7 @@ protected:
}
}
void postFlush(GrDeferredUploadToken, const uint32_t*, int) override {}
void postFlush(GrDeferredUploadToken, SkSpan<const uint32_t>) override {}
private:
sk_sp<GrCoverageCountingPathRenderer> fCCPR;

View File

@ -40,12 +40,12 @@ public:
REPORTER_ASSERT(fReporter, fHasClipTexture);
}
void preFlush(GrOnFlushResourceProvider*, const uint32_t*, int) override {
void preFlush(GrOnFlushResourceProvider*, SkSpan<const uint32_t>) override {
REPORTER_ASSERT(fReporter, !fHasOpTexture);
REPORTER_ASSERT(fReporter, !fHasClipTexture);
}
void postFlush(GrDeferredUploadToken, const uint32_t* opsTaskIDs, int numOpsTaskIDs) override {
void postFlush(GrDeferredUploadToken, SkSpan<const uint32_t>) override {
REPORTER_ASSERT(fReporter, fHasOpTexture);
REPORTER_ASSERT(fReporter, fHasClipTexture);
}

View File

@ -366,12 +366,11 @@ public:
* This callback creates the atlas and updates the AtlasedRectOps to read from it
*/
void preFlush(GrOnFlushResourceProvider* resourceProvider,
const uint32_t* opsTaskIDs,
int numOpsTaskIDs) override {
SkSpan<const uint32_t> renderTaskIDs) override {
// Until MDB is landed we will most-likely only have one opsTask.
SkTDArray<LinkedListHeader*> lists;
for (int i = 0; i < numOpsTaskIDs; ++i) {
if (LinkedListHeader* list = this->getList(opsTaskIDs[i])) {
for (uint32_t taskID : renderTaskIDs) {
if (LinkedListHeader* list = this->getList(taskID)) {
lists.push_back(list);
}
}