Move GrAtlasRenderTask to gpu/ops and skgpu::v1 namespace

Bug: skia:11837
Change-Id: I29352c0e2c9e987b28be983c3d519a88b589baf1
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/442022
Reviewed-by: Chris Dalton <csmartdalton@google.com>
Commit-Queue: Robert Phillips <robertphillips@google.com>
This commit is contained in:
Robert Phillips 2021-08-25 16:39:14 -04:00 committed by SkCQ
parent fbb905e70f
commit fdafc0cbe4
5 changed files with 44 additions and 37 deletions

View File

@ -503,6 +503,8 @@ skia_skgpu_v1_sources = [
"$_src/gpu/ops/AALinearizingConvexPathRenderer.h", "$_src/gpu/ops/AALinearizingConvexPathRenderer.h",
"$_src/gpu/ops/AtlasPathRenderer.cpp", "$_src/gpu/ops/AtlasPathRenderer.cpp",
"$_src/gpu/ops/AtlasPathRenderer.h", "$_src/gpu/ops/AtlasPathRenderer.h",
"$_src/gpu/ops/AtlasRenderTask.cpp",
"$_src/gpu/ops/AtlasRenderTask.h",
"$_src/gpu/ops/DashLinePathRenderer.cpp", "$_src/gpu/ops/DashLinePathRenderer.cpp",
"$_src/gpu/ops/DashLinePathRenderer.h", "$_src/gpu/ops/DashLinePathRenderer.h",
"$_src/gpu/ops/DefaultPathRenderer.cpp", "$_src/gpu/ops/DefaultPathRenderer.cpp",
@ -573,10 +575,6 @@ skia_skgpu_v1_sources = [
"$_src/gpu/ops/TriangulatingPathRenderer.cpp", "$_src/gpu/ops/TriangulatingPathRenderer.cpp",
"$_src/gpu/ops/TriangulatingPathRenderer.h", "$_src/gpu/ops/TriangulatingPathRenderer.h",
# tessellate
"$_src/gpu/tessellate/GrAtlasRenderTask.cpp",
"$_src/gpu/tessellate/GrAtlasRenderTask.h",
# v1 # v1
"$_src/gpu/v1/ClipStack.cpp", "$_src/gpu/v1/ClipStack.cpp",
"$_src/gpu/v1/ClipStack.h", "$_src/gpu/v1/ClipStack.h",

View File

@ -14,9 +14,9 @@
#include "src/gpu/GrVx.h" #include "src/gpu/GrVx.h"
#include "src/gpu/effects/GrModulateAtlasCoverageEffect.h" #include "src/gpu/effects/GrModulateAtlasCoverageEffect.h"
#include "src/gpu/geometry/GrStyledShape.h" #include "src/gpu/geometry/GrStyledShape.h"
#include "src/gpu/ops/AtlasRenderTask.h"
#include "src/gpu/ops/GrDrawAtlasPathOp.h" #include "src/gpu/ops/GrDrawAtlasPathOp.h"
#include "src/gpu/ops/TessellationPathRenderer.h" #include "src/gpu/ops/TessellationPathRenderer.h"
#include "src/gpu/tessellate/GrAtlasRenderTask.h"
#include "src/gpu/tessellate/shaders/GrTessellationShader.h" #include "src/gpu/tessellate/shaders/GrTessellationShader.h"
#include "src/gpu/v1/SurfaceDrawContext_v1.h" #include "src/gpu/v1/SurfaceDrawContext_v1.h"
@ -63,10 +63,10 @@ bool is_visible(const SkRect& pathDevBounds, const SkIRect& clipBounds) {
// Ensures the atlas dependencies are set up such that each atlas will be totally out of service // Ensures the atlas dependencies are set up such that each atlas will be totally out of service
// before we render the next one in line. This means there will only ever be one atlas active at a // before we render the next one in line. This means there will only ever be one atlas active at a
// time and that they can all share the same texture. // time and that they can all share the same texture.
void validate_atlas_dependencies(const SkTArray<sk_sp<GrAtlasRenderTask>>& atlasTasks) { void validate_atlas_dependencies(const SkTArray<sk_sp<skgpu::v1::AtlasRenderTask>>& atlasTasks) {
for (int i = atlasTasks.count() - 1; i >= 1; --i) { for (int i = atlasTasks.count() - 1; i >= 1; --i) {
GrAtlasRenderTask* atlasTask = atlasTasks[i].get(); auto atlasTask = atlasTasks[i].get();
GrAtlasRenderTask* previousAtlasTask = atlasTasks[i - 1].get(); auto previousAtlasTask = atlasTasks[i - 1].get();
// Double check that atlasTask depends on every dependent of its previous atlas. If this // Double check that atlasTask depends on every dependent of its previous atlas. If this
// fires it might mean previousAtlasTask gained a new dependent after atlasTask came into // fires it might mean previousAtlasTask gained a new dependent after atlasTask came into
// service (maybe by an op that hadn't yet been added to an opsTask when we registered the // service (maybe by an op that hadn't yet been added to an opsTask when we registered the
@ -223,8 +223,8 @@ bool AtlasPathRenderer::addPathToAtlas(GrRecordingContext* rContext,
!fAtlasRenderTasks.back()->addPath(viewMatrix, path, devIBounds->topLeft(), widthInAtlas, !fAtlasRenderTasks.back()->addPath(viewMatrix, path, devIBounds->topLeft(), widthInAtlas,
heightInAtlas, *transposedInAtlas, locationInAtlas)) { heightInAtlas, *transposedInAtlas, locationInAtlas)) {
// We either don't have an atlas yet or the current one is full. Try to replace it. // We either don't have an atlas yet or the current one is full. Try to replace it.
GrAtlasRenderTask* currentAtlasTask = (!fAtlasRenderTasks.empty()) auto currentAtlasTask = (!fAtlasRenderTasks.empty()) ? fAtlasRenderTasks.back().get()
? fAtlasRenderTasks.back().get() : nullptr; : nullptr;
if (currentAtlasTask && if (currentAtlasTask &&
drawRefsAtlasCallback && drawRefsAtlasCallback &&
drawRefsAtlasCallback(currentAtlasTask->atlasProxy())) { drawRefsAtlasCallback(currentAtlasTask->atlasProxy())) {
@ -237,9 +237,9 @@ bool AtlasPathRenderer::addPathToAtlas(GrRecordingContext* rContext,
kAtlasAlpha8Type, GrDynamicAtlas::InternalMultisample::kYes, kAtlasAlpha8Type, GrDynamicAtlas::InternalMultisample::kYes,
SkISize{fAtlasInitialSize, fAtlasInitialSize}, fAtlasMaxSize, SkISize{fAtlasInitialSize, fAtlasInitialSize}, fAtlasMaxSize,
*rContext->priv().caps(), kAtlasAlgorithm); *rContext->priv().caps(), kAtlasAlgorithm);
auto newAtlasTask = sk_make_sp<GrAtlasRenderTask>(rContext, auto newAtlasTask = sk_make_sp<AtlasRenderTask>(rContext,
sk_make_sp<GrArenas>(), sk_make_sp<GrArenas>(),
std::move(dynamicAtlas)); std::move(dynamicAtlas));
rContext->priv().drawingManager()->addAtlasTask(newAtlasTask, currentAtlasTask); rContext->priv().drawingManager()->addAtlasTask(newAtlasTask, currentAtlasTask);
SkAssertResult(newAtlasTask->addPath(viewMatrix, path, devIBounds->topLeft(), widthInAtlas, SkAssertResult(newAtlasTask->addPath(viewMatrix, path, devIBounds->topLeft(), widthInAtlas,
heightInAtlas, *transposedInAtlas, locationInAtlas)); heightInAtlas, *transposedInAtlas, locationInAtlas));
@ -403,7 +403,7 @@ void AtlasPathRenderer::preFlush(GrOnFlushResourceProvider* onFlushRP,
GrTexture* firstAtlasTexture = fAtlasRenderTasks[0]->atlasProxy()->peekTexture(); GrTexture* firstAtlasTexture = fAtlasRenderTasks[0]->atlasProxy()->peekTexture();
SkASSERT(firstAtlasTexture); SkASSERT(firstAtlasTexture);
for (int i = 1; i < fAtlasRenderTasks.count(); ++i) { for (int i = 1; i < fAtlasRenderTasks.count(); ++i) {
GrAtlasRenderTask* atlasTask = fAtlasRenderTasks[i].get(); auto atlasTask = fAtlasRenderTasks[i].get();
if (atlasTask->atlasProxy()->backingStoreDimensions() == firstAtlasTexture->dimensions()) { if (atlasTask->atlasProxy()->backingStoreDimensions() == firstAtlasTexture->dimensions()) {
atlasTask->instantiate(onFlushRP, sk_ref_sp(firstAtlasTexture)); atlasTask->instantiate(onFlushRP, sk_ref_sp(firstAtlasTexture));
} else { } else {

View File

@ -16,12 +16,13 @@
#include "src/gpu/GrOnFlushResourceProvider.h" #include "src/gpu/GrOnFlushResourceProvider.h"
#include "src/gpu/v1/PathRenderer.h" #include "src/gpu/v1/PathRenderer.h"
class GrAtlasRenderTask;
class GrOp; class GrOp;
class GrRecordingContext; class GrRecordingContext;
namespace skgpu::v1 { namespace skgpu::v1 {
class AtlasRenderTask;
// Draws paths by first rendering their coverage mask into an offscreen atlas. // Draws paths by first rendering their coverage mask into an offscreen atlas.
class AtlasPathRenderer final : public PathRenderer, public GrOnFlushCallbackObject { class AtlasPathRenderer final : public PathRenderer, public GrOnFlushCallbackObject {
public: public:
@ -94,7 +95,7 @@ private:
// A collection of all atlases we've created and used since the last flush. We instantiate these // A collection of all atlases we've created and used since the last flush. We instantiate these
// at flush time during preFlush(). // at flush time during preFlush().
SkSTArray<4, sk_sp<GrAtlasRenderTask>> fAtlasRenderTasks; SkSTArray<4, sk_sp<AtlasRenderTask>> fAtlasRenderTasks;
// This simple cache remembers the locations of cacheable path masks in the most recent atlas. // This simple cache remembers the locations of cacheable path masks in the most recent atlas.
// Its main motivation is for clip paths. // Its main motivation is for clip paths.

View File

@ -5,7 +5,7 @@
* found in the LICENSE file. * found in the LICENSE file.
*/ */
#include "src/gpu/tessellate/GrAtlasRenderTask.h" #include "src/gpu/ops/AtlasRenderTask.h"
#include "src/core/SkBlendModePriv.h" #include "src/core/SkBlendModePriv.h"
#include "src/core/SkIPoint16.h" #include "src/core/SkIPoint16.h"
@ -15,9 +15,11 @@
#include "src/gpu/ops/GrFillRectOp.h" #include "src/gpu/ops/GrFillRectOp.h"
#include "src/gpu/ops/PathStencilCoverOp.h" #include "src/gpu/ops/PathStencilCoverOp.h"
GrAtlasRenderTask::GrAtlasRenderTask(GrRecordingContext* rContext, namespace skgpu::v1 {
sk_sp<GrArenas> arenas,
std::unique_ptr<GrDynamicAtlas> dynamicAtlas) AtlasRenderTask::AtlasRenderTask(GrRecordingContext* rContext,
sk_sp<GrArenas> arenas,
std::unique_ptr<GrDynamicAtlas> dynamicAtlas)
: OpsTask(rContext->priv().drawingManager(), : OpsTask(rContext->priv().drawingManager(),
dynamicAtlas->writeView(*rContext->priv().caps()), dynamicAtlas->writeView(*rContext->priv().caps()),
rContext->priv().auditTrail(), rContext->priv().auditTrail(),
@ -25,9 +27,9 @@ GrAtlasRenderTask::GrAtlasRenderTask(GrRecordingContext* rContext,
, fDynamicAtlas(std::move(dynamicAtlas)) { , fDynamicAtlas(std::move(dynamicAtlas)) {
} }
bool GrAtlasRenderTask::addPath(const SkMatrix& viewMatrix, const SkPath& path, bool AtlasRenderTask::addPath(const SkMatrix& viewMatrix, const SkPath& path,
SkIPoint pathDevTopLeft, int widthInAtlas, int heightInAtlas, SkIPoint pathDevTopLeft, int widthInAtlas, int heightInAtlas,
bool transposedInAtlas, SkIPoint16* locationInAtlas) { bool transposedInAtlas, SkIPoint16* locationInAtlas) {
SkASSERT(!this->isClosed()); SkASSERT(!this->isClosed());
SkASSERT(this->isEmpty()); SkASSERT(this->isEmpty());
SkASSERT(!fDynamicAtlas->isInstantiated()); // Paths can't be added after instantiate(). SkASSERT(!fDynamicAtlas->isInstantiated()); // Paths can't be added after instantiate().
@ -56,8 +58,8 @@ bool GrAtlasRenderTask::addPath(const SkMatrix& viewMatrix, const SkPath& path,
return true; return true;
} }
GrRenderTask::ExpectedOutcome GrAtlasRenderTask::onMakeClosed(GrRecordingContext* rContext, GrRenderTask::ExpectedOutcome AtlasRenderTask::onMakeClosed(GrRecordingContext* rContext,
SkIRect* targetUpdateBounds) { SkIRect* targetUpdateBounds) {
// We don't add our ops until now, at which point we know the atlas is done being built. // We don't add our ops until now, at which point we know the atlas is done being built.
SkASSERT(this->isEmpty()); SkASSERT(this->isEmpty());
SkASSERT(!fDynamicAtlas->isInstantiated()); // Instantiation happens after makeClosed(). SkASSERT(!fDynamicAtlas->isInstantiated()); // Instantiation happens after makeClosed().
@ -144,9 +146,9 @@ GrRenderTask::ExpectedOutcome GrAtlasRenderTask::onMakeClosed(GrRecordingContext
return ExpectedOutcome::kTargetUnchanged; return ExpectedOutcome::kTargetUnchanged;
} }
void GrAtlasRenderTask::stencilAtlasRect(GrRecordingContext* rContext, const SkRect& rect, void AtlasRenderTask::stencilAtlasRect(GrRecordingContext* rContext, const SkRect& rect,
const SkPMColor4f& color, const SkPMColor4f& color,
const GrUserStencilSettings* stencil) { const GrUserStencilSettings* stencil) {
GrPaint paint; GrPaint paint;
paint.setColor4f(color); paint.setColor4f(color);
paint.setXPFactory(SkBlendMode_AsXPFactory(SkBlendMode::kSrc)); paint.setXPFactory(SkBlendMode_AsXPFactory(SkBlendMode::kSrc));
@ -156,7 +158,7 @@ void GrAtlasRenderTask::stencilAtlasRect(GrRecordingContext* rContext, const SkR
this->addAtlasDrawOp(std::move(op), *rContext->priv().caps()); this->addAtlasDrawOp(std::move(op), *rContext->priv().caps());
} }
void GrAtlasRenderTask::addAtlasDrawOp(GrOp::Owner op, const GrCaps& caps) { void AtlasRenderTask::addAtlasDrawOp(GrOp::Owner op, const GrCaps& caps) {
SkASSERT(!this->isClosed()); SkASSERT(!this->isClosed());
auto drawOp = static_cast<GrDrawOp*>(op.get()); auto drawOp = static_cast<GrDrawOp*>(op.get());
@ -171,7 +173,7 @@ void GrAtlasRenderTask::addAtlasDrawOp(GrOp::Owner op, const GrCaps& caps) {
this->recordOp(std::move(op), true/*usesMSAA*/, processorAnalysis, nullptr, nullptr, caps); this->recordOp(std::move(op), true/*usesMSAA*/, processorAnalysis, nullptr, nullptr, caps);
} }
bool GrAtlasRenderTask::onExecute(GrOpFlushState* flushState) { bool AtlasRenderTask::onExecute(GrOpFlushState* flushState) {
if (!this->OpsTask::onExecute(flushState)) { if (!this->OpsTask::onExecute(flushState)) {
return false; return false;
} }
@ -186,3 +188,5 @@ bool GrAtlasRenderTask::onExecute(GrOpFlushState* flushState) {
} }
return true; return true;
} }
} // namespace skgpu::v1

View File

@ -5,8 +5,8 @@
* found in the LICENSE file. * found in the LICENSE file.
*/ */
#ifndef GrAtlasRenderTask_DEFINED #ifndef AtlasRenderTask_DEFINED
#define GrAtlasRenderTask_DEFINED #define AtlasRenderTask_DEFINED
#include "include/core/SkPath.h" #include "include/core/SkPath.h"
#include "src/core/SkTBlockList.h" #include "src/core/SkTBlockList.h"
@ -16,17 +16,19 @@
struct SkIPoint16; struct SkIPoint16;
namespace skgpu::v1 {
// Represents a GrRenderTask that draws paths into an atlas. This task gets added the DAG and left // Represents a GrRenderTask that draws paths into an atlas. This task gets added the DAG and left
// open, lays out its atlas while future tasks call addPath(), and finally adds its internal draw // open, lays out its atlas while future tasks call addPath(), and finally adds its internal draw
// ops during onMakeClosed(). // ops during onMakeClosed().
// //
// The atlas texture does not get instantiated automatically. It is the creator's responsibility to // The atlas texture does not get instantiated automatically. It is the creator's responsibility to
// call instantiate() at flush time. // call instantiate() at flush time.
class GrAtlasRenderTask : public skgpu::v1::OpsTask { class AtlasRenderTask : public OpsTask {
public: public:
GrAtlasRenderTask(GrRecordingContext*, AtlasRenderTask(GrRecordingContext*,
sk_sp<GrArenas>, sk_sp<GrArenas>,
std::unique_ptr<GrDynamicAtlas>); std::unique_ptr<GrDynamicAtlas>);
const GrTextureProxy* atlasProxy() const { return fDynamicAtlas->textureProxy(); } const GrTextureProxy* atlasProxy() const { return fDynamicAtlas->textureProxy(); }
GrSurfaceProxyView readView(const GrCaps& caps) const { return fDynamicAtlas->readView(caps); } GrSurfaceProxyView readView(const GrCaps& caps) const { return fDynamicAtlas->readView(caps); }
@ -87,4 +89,6 @@ private:
AtlasPathList fEvenOddPathList; AtlasPathList fEvenOddPathList;
}; };
#endif } // namespace skgpu::v1
#endif // AtlasRenderTask_DEFINED