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:
parent
fbb905e70f
commit
fdafc0cbe4
@ -503,6 +503,8 @@ skia_skgpu_v1_sources = [
|
||||
"$_src/gpu/ops/AALinearizingConvexPathRenderer.h",
|
||||
"$_src/gpu/ops/AtlasPathRenderer.cpp",
|
||||
"$_src/gpu/ops/AtlasPathRenderer.h",
|
||||
"$_src/gpu/ops/AtlasRenderTask.cpp",
|
||||
"$_src/gpu/ops/AtlasRenderTask.h",
|
||||
"$_src/gpu/ops/DashLinePathRenderer.cpp",
|
||||
"$_src/gpu/ops/DashLinePathRenderer.h",
|
||||
"$_src/gpu/ops/DefaultPathRenderer.cpp",
|
||||
@ -573,10 +575,6 @@ skia_skgpu_v1_sources = [
|
||||
"$_src/gpu/ops/TriangulatingPathRenderer.cpp",
|
||||
"$_src/gpu/ops/TriangulatingPathRenderer.h",
|
||||
|
||||
# tessellate
|
||||
"$_src/gpu/tessellate/GrAtlasRenderTask.cpp",
|
||||
"$_src/gpu/tessellate/GrAtlasRenderTask.h",
|
||||
|
||||
# v1
|
||||
"$_src/gpu/v1/ClipStack.cpp",
|
||||
"$_src/gpu/v1/ClipStack.h",
|
||||
|
@ -14,9 +14,9 @@
|
||||
#include "src/gpu/GrVx.h"
|
||||
#include "src/gpu/effects/GrModulateAtlasCoverageEffect.h"
|
||||
#include "src/gpu/geometry/GrStyledShape.h"
|
||||
#include "src/gpu/ops/AtlasRenderTask.h"
|
||||
#include "src/gpu/ops/GrDrawAtlasPathOp.h"
|
||||
#include "src/gpu/ops/TessellationPathRenderer.h"
|
||||
#include "src/gpu/tessellate/GrAtlasRenderTask.h"
|
||||
#include "src/gpu/tessellate/shaders/GrTessellationShader.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
|
||||
// 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.
|
||||
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) {
|
||||
GrAtlasRenderTask* atlasTask = atlasTasks[i].get();
|
||||
GrAtlasRenderTask* previousAtlasTask = atlasTasks[i - 1].get();
|
||||
auto atlasTask = atlasTasks[i].get();
|
||||
auto previousAtlasTask = atlasTasks[i - 1].get();
|
||||
// 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
|
||||
// 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,
|
||||
heightInAtlas, *transposedInAtlas, locationInAtlas)) {
|
||||
// We either don't have an atlas yet or the current one is full. Try to replace it.
|
||||
GrAtlasRenderTask* currentAtlasTask = (!fAtlasRenderTasks.empty())
|
||||
? fAtlasRenderTasks.back().get() : nullptr;
|
||||
auto currentAtlasTask = (!fAtlasRenderTasks.empty()) ? fAtlasRenderTasks.back().get()
|
||||
: nullptr;
|
||||
if (currentAtlasTask &&
|
||||
drawRefsAtlasCallback &&
|
||||
drawRefsAtlasCallback(currentAtlasTask->atlasProxy())) {
|
||||
@ -237,9 +237,9 @@ bool AtlasPathRenderer::addPathToAtlas(GrRecordingContext* rContext,
|
||||
kAtlasAlpha8Type, GrDynamicAtlas::InternalMultisample::kYes,
|
||||
SkISize{fAtlasInitialSize, fAtlasInitialSize}, fAtlasMaxSize,
|
||||
*rContext->priv().caps(), kAtlasAlgorithm);
|
||||
auto newAtlasTask = sk_make_sp<GrAtlasRenderTask>(rContext,
|
||||
sk_make_sp<GrArenas>(),
|
||||
std::move(dynamicAtlas));
|
||||
auto newAtlasTask = sk_make_sp<AtlasRenderTask>(rContext,
|
||||
sk_make_sp<GrArenas>(),
|
||||
std::move(dynamicAtlas));
|
||||
rContext->priv().drawingManager()->addAtlasTask(newAtlasTask, currentAtlasTask);
|
||||
SkAssertResult(newAtlasTask->addPath(viewMatrix, path, devIBounds->topLeft(), widthInAtlas,
|
||||
heightInAtlas, *transposedInAtlas, locationInAtlas));
|
||||
@ -403,7 +403,7 @@ void AtlasPathRenderer::preFlush(GrOnFlushResourceProvider* onFlushRP,
|
||||
GrTexture* firstAtlasTexture = fAtlasRenderTasks[0]->atlasProxy()->peekTexture();
|
||||
SkASSERT(firstAtlasTexture);
|
||||
for (int i = 1; i < fAtlasRenderTasks.count(); ++i) {
|
||||
GrAtlasRenderTask* atlasTask = fAtlasRenderTasks[i].get();
|
||||
auto atlasTask = fAtlasRenderTasks[i].get();
|
||||
if (atlasTask->atlasProxy()->backingStoreDimensions() == firstAtlasTexture->dimensions()) {
|
||||
atlasTask->instantiate(onFlushRP, sk_ref_sp(firstAtlasTexture));
|
||||
} else {
|
||||
|
@ -16,12 +16,13 @@
|
||||
#include "src/gpu/GrOnFlushResourceProvider.h"
|
||||
#include "src/gpu/v1/PathRenderer.h"
|
||||
|
||||
class GrAtlasRenderTask;
|
||||
class GrOp;
|
||||
class GrRecordingContext;
|
||||
|
||||
namespace skgpu::v1 {
|
||||
|
||||
class AtlasRenderTask;
|
||||
|
||||
// Draws paths by first rendering their coverage mask into an offscreen atlas.
|
||||
class AtlasPathRenderer final : public PathRenderer, public GrOnFlushCallbackObject {
|
||||
public:
|
||||
@ -94,7 +95,7 @@ private:
|
||||
|
||||
// A collection of all atlases we've created and used since the last flush. We instantiate these
|
||||
// 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.
|
||||
// Its main motivation is for clip paths.
|
||||
|
@ -5,7 +5,7 @@
|
||||
* 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/SkIPoint16.h"
|
||||
@ -15,9 +15,11 @@
|
||||
#include "src/gpu/ops/GrFillRectOp.h"
|
||||
#include "src/gpu/ops/PathStencilCoverOp.h"
|
||||
|
||||
GrAtlasRenderTask::GrAtlasRenderTask(GrRecordingContext* rContext,
|
||||
sk_sp<GrArenas> arenas,
|
||||
std::unique_ptr<GrDynamicAtlas> dynamicAtlas)
|
||||
namespace skgpu::v1 {
|
||||
|
||||
AtlasRenderTask::AtlasRenderTask(GrRecordingContext* rContext,
|
||||
sk_sp<GrArenas> arenas,
|
||||
std::unique_ptr<GrDynamicAtlas> dynamicAtlas)
|
||||
: OpsTask(rContext->priv().drawingManager(),
|
||||
dynamicAtlas->writeView(*rContext->priv().caps()),
|
||||
rContext->priv().auditTrail(),
|
||||
@ -25,9 +27,9 @@ GrAtlasRenderTask::GrAtlasRenderTask(GrRecordingContext* rContext,
|
||||
, fDynamicAtlas(std::move(dynamicAtlas)) {
|
||||
}
|
||||
|
||||
bool GrAtlasRenderTask::addPath(const SkMatrix& viewMatrix, const SkPath& path,
|
||||
SkIPoint pathDevTopLeft, int widthInAtlas, int heightInAtlas,
|
||||
bool transposedInAtlas, SkIPoint16* locationInAtlas) {
|
||||
bool AtlasRenderTask::addPath(const SkMatrix& viewMatrix, const SkPath& path,
|
||||
SkIPoint pathDevTopLeft, int widthInAtlas, int heightInAtlas,
|
||||
bool transposedInAtlas, SkIPoint16* locationInAtlas) {
|
||||
SkASSERT(!this->isClosed());
|
||||
SkASSERT(this->isEmpty());
|
||||
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;
|
||||
}
|
||||
|
||||
GrRenderTask::ExpectedOutcome GrAtlasRenderTask::onMakeClosed(GrRecordingContext* rContext,
|
||||
SkIRect* targetUpdateBounds) {
|
||||
GrRenderTask::ExpectedOutcome AtlasRenderTask::onMakeClosed(GrRecordingContext* rContext,
|
||||
SkIRect* targetUpdateBounds) {
|
||||
// We don't add our ops until now, at which point we know the atlas is done being built.
|
||||
SkASSERT(this->isEmpty());
|
||||
SkASSERT(!fDynamicAtlas->isInstantiated()); // Instantiation happens after makeClosed().
|
||||
@ -144,9 +146,9 @@ GrRenderTask::ExpectedOutcome GrAtlasRenderTask::onMakeClosed(GrRecordingContext
|
||||
return ExpectedOutcome::kTargetUnchanged;
|
||||
}
|
||||
|
||||
void GrAtlasRenderTask::stencilAtlasRect(GrRecordingContext* rContext, const SkRect& rect,
|
||||
const SkPMColor4f& color,
|
||||
const GrUserStencilSettings* stencil) {
|
||||
void AtlasRenderTask::stencilAtlasRect(GrRecordingContext* rContext, const SkRect& rect,
|
||||
const SkPMColor4f& color,
|
||||
const GrUserStencilSettings* stencil) {
|
||||
GrPaint paint;
|
||||
paint.setColor4f(color);
|
||||
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());
|
||||
}
|
||||
|
||||
void GrAtlasRenderTask::addAtlasDrawOp(GrOp::Owner op, const GrCaps& caps) {
|
||||
void AtlasRenderTask::addAtlasDrawOp(GrOp::Owner op, const GrCaps& caps) {
|
||||
SkASSERT(!this->isClosed());
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
bool GrAtlasRenderTask::onExecute(GrOpFlushState* flushState) {
|
||||
bool AtlasRenderTask::onExecute(GrOpFlushState* flushState) {
|
||||
if (!this->OpsTask::onExecute(flushState)) {
|
||||
return false;
|
||||
}
|
||||
@ -186,3 +188,5 @@ bool GrAtlasRenderTask::onExecute(GrOpFlushState* flushState) {
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
} // namespace skgpu::v1
|
@ -5,8 +5,8 @@
|
||||
* found in the LICENSE file.
|
||||
*/
|
||||
|
||||
#ifndef GrAtlasRenderTask_DEFINED
|
||||
#define GrAtlasRenderTask_DEFINED
|
||||
#ifndef AtlasRenderTask_DEFINED
|
||||
#define AtlasRenderTask_DEFINED
|
||||
|
||||
#include "include/core/SkPath.h"
|
||||
#include "src/core/SkTBlockList.h"
|
||||
@ -16,17 +16,19 @@
|
||||
|
||||
struct SkIPoint16;
|
||||
|
||||
namespace skgpu::v1 {
|
||||
|
||||
// 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
|
||||
// ops during onMakeClosed().
|
||||
//
|
||||
// The atlas texture does not get instantiated automatically. It is the creator's responsibility to
|
||||
// call instantiate() at flush time.
|
||||
class GrAtlasRenderTask : public skgpu::v1::OpsTask {
|
||||
class AtlasRenderTask : public OpsTask {
|
||||
public:
|
||||
GrAtlasRenderTask(GrRecordingContext*,
|
||||
sk_sp<GrArenas>,
|
||||
std::unique_ptr<GrDynamicAtlas>);
|
||||
AtlasRenderTask(GrRecordingContext*,
|
||||
sk_sp<GrArenas>,
|
||||
std::unique_ptr<GrDynamicAtlas>);
|
||||
|
||||
const GrTextureProxy* atlasProxy() const { return fDynamicAtlas->textureProxy(); }
|
||||
GrSurfaceProxyView readView(const GrCaps& caps) const { return fDynamicAtlas->readView(caps); }
|
||||
@ -87,4 +89,6 @@ private:
|
||||
AtlasPathList fEvenOddPathList;
|
||||
};
|
||||
|
||||
#endif
|
||||
} // namespace skgpu::v1
|
||||
|
||||
#endif // AtlasRenderTask_DEFINED
|
Loading…
Reference in New Issue
Block a user