Move Software and Small PathRenderers to skgpu::v1 namespace
Bug: skia:11837
Change-Id: Ia34f1840aaa7360ea9a3ca40fef5cb96b68c6ca3
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/439781
Commit-Queue: Robert Phillips <robertphillips@google.com>
Reviewed-by: Michael Ludwig <michaelludwig@google.com>
diff --git a/gn/gpu.gni b/gn/gpu.gni
index 0f28944..de3d240 100644
--- a/gn/gpu.gni
+++ b/gn/gpu.gni
@@ -508,8 +508,6 @@
"$_src/gpu/GrPathRenderer.h",
"$_src/gpu/GrPathRendererChain.cpp",
"$_src/gpu/GrPathRendererChain.h",
- "$_src/gpu/GrSoftwarePathRenderer.cpp",
- "$_src/gpu/GrSoftwarePathRenderer.h",
"$_src/gpu/GrStencilClip.h",
"$_src/gpu/GrStencilMaskHelper.cpp",
"$_src/gpu/GrStencilMaskHelper.h",
@@ -566,14 +564,16 @@
"$_src/gpu/ops/GrSimpleMeshDrawOpHelper.h",
"$_src/gpu/ops/GrSimpleMeshDrawOpHelperWithStencil.cpp",
"$_src/gpu/ops/GrSimpleMeshDrawOpHelperWithStencil.h",
- "$_src/gpu/ops/GrSmallPathRenderer.cpp",
- "$_src/gpu/ops/GrSmallPathRenderer.h",
"$_src/gpu/ops/GrStrokeRectOp.cpp",
"$_src/gpu/ops/GrStrokeRectOp.h",
"$_src/gpu/ops/GrTextureOp.cpp",
"$_src/gpu/ops/GrTextureOp.h",
"$_src/gpu/ops/GrTriangulatingPathRenderer.cpp",
"$_src/gpu/ops/GrTriangulatingPathRenderer.h",
+ "$_src/gpu/ops/SmallPathRenderer.cpp",
+ "$_src/gpu/ops/SmallPathRenderer.h",
+ "$_src/gpu/ops/SoftwarePathRenderer.cpp",
+ "$_src/gpu/ops/SoftwarePathRenderer.h",
# tessellate
"$_src/gpu/tessellate/GrAtlasRenderTask.cpp",
diff --git a/src/gpu/GrDrawingManager.cpp b/src/gpu/GrDrawingManager.cpp
index 9298588..2809a23 100644
--- a/src/gpu/GrDrawingManager.cpp
+++ b/src/gpu/GrDrawingManager.cpp
@@ -45,7 +45,7 @@
#if SK_GPU_V1
#include "src/gpu/GrOpsTask.h"
-#include "src/gpu/GrSoftwarePathRenderer.h"
+#include "src/gpu/ops/SoftwarePathRenderer.h"
#endif
///////////////////////////////////////////////////////////////////////////////////////////////////
@@ -965,9 +965,8 @@
GrPathRenderer* GrDrawingManager::getSoftwarePathRenderer() {
if (!fSoftwarePathRenderer) {
- fSoftwarePathRenderer.reset(
- new GrSoftwarePathRenderer(fContext->priv().proxyProvider(),
- fOptionsForPathRendererChain.fAllowPathMaskCaching));
+ fSoftwarePathRenderer.reset(new skgpu::v1::SoftwarePathRenderer(
+ fContext->priv().proxyProvider(), fOptionsForPathRendererChain.fAllowPathMaskCaching));
}
return fSoftwarePathRenderer.get();
}
diff --git a/src/gpu/GrDrawingManager.h b/src/gpu/GrDrawingManager.h
index af02f8c..df8280c 100644
--- a/src/gpu/GrDrawingManager.h
+++ b/src/gpu/GrDrawingManager.h
@@ -36,11 +36,11 @@
class GrRenderTask;
class GrResourceAllocator;
class GrSemaphore;
-class GrSoftwarePathRenderer;
class GrSurfaceProxyView;
class GrTessellationPathRenderer;
class GrTextureResolveRenderTask;
class SkDeferredDisplayList;
+namespace skgpu { namespace v1 { class SoftwarePathRenderer; }}
class GrDrawingManager {
public:
@@ -205,31 +205,31 @@
static const int kNumPixelGeometries = 5; // The different pixel geometries
static const int kNumDFTOptions = 2; // DFT or no DFT
- GrRecordingContext* fContext;
+ GrRecordingContext* fContext;
// This cache is used by both the vertex and index pools. It reuses memory across multiple
// flushes.
sk_sp<GrBufferAllocPool::CpuBufferCache> fCpuBufferCache;
- SkTArray<sk_sp<GrRenderTask>> fDAG;
- GrOpsTask* fActiveOpsTask = nullptr;
+ SkTArray<sk_sp<GrRenderTask>> fDAG;
+ GrOpsTask* fActiveOpsTask = nullptr;
// These are the IDs of the opsTask currently being flushed (in internalFlush). They are
// only stored here to prevent memory thrashing.
- SkSTArray<8, uint32_t, true> fFlushingRenderTaskIDs;
+ SkSTArray<8, uint32_t, true> fFlushingRenderTaskIDs;
// These are the new renderTasks generated by the onFlush CBs
- SkSTArray<4, sk_sp<GrRenderTask>> fOnFlushRenderTasks;
+ SkSTArray<4, sk_sp<GrRenderTask>> fOnFlushRenderTasks;
#if SK_GPU_V1
- GrPathRendererChain::Options fOptionsForPathRendererChain;
- std::unique_ptr<GrPathRendererChain> fPathRendererChain;
- sk_sp<GrSoftwarePathRenderer> fSoftwarePathRenderer;
+ GrPathRendererChain::Options fOptionsForPathRendererChain;
+ std::unique_ptr<GrPathRendererChain> fPathRendererChain;
+ sk_sp<skgpu::v1::SoftwarePathRenderer> fSoftwarePathRenderer;
#endif
- GrTokenTracker fTokenTracker;
- bool fFlushing = false;
- const bool fReduceOpsTaskSplitting;
+ GrTokenTracker fTokenTracker;
+ bool fFlushing = false;
+ const bool fReduceOpsTaskSplitting;
- SkTArray<GrOnFlushCallbackObject*> fOnFlushCBObjects;
+ SkTArray<GrOnFlushCallbackObject*> fOnFlushCBObjects;
struct SurfaceIDKeyTraits {
static uint32_t GetInvalidKey() {
diff --git a/src/gpu/GrPathRendererChain.cpp b/src/gpu/GrPathRendererChain.cpp
index ea259dc..8190b97 100644
--- a/src/gpu/GrPathRendererChain.cpp
+++ b/src/gpu/GrPathRendererChain.cpp
@@ -22,8 +22,8 @@
#include "src/gpu/ops/GrAtlasPathRenderer.h"
#include "src/gpu/ops/GrDashLinePathRenderer.h"
#include "src/gpu/ops/GrDefaultPathRenderer.h"
-#include "src/gpu/ops/GrSmallPathRenderer.h"
#include "src/gpu/ops/GrTriangulatingPathRenderer.h"
+#include "src/gpu/ops/SmallPathRenderer.h"
#include "src/gpu/tessellate/GrTessellationPathRenderer.h"
GrPathRendererChain::GrPathRendererChain(GrRecordingContext* context, const Options& options) {
@@ -48,7 +48,7 @@
}
}
if (options.fGpuPathRenderers & GpuPathRenderers::kSmall) {
- fChain.push_back(sk_make_sp<GrSmallPathRenderer>());
+ fChain.push_back(sk_make_sp<skgpu::v1::SmallPathRenderer>());
}
if (options.fGpuPathRenderers & GpuPathRenderers::kTriangulating) {
fChain.push_back(sk_make_sp<GrTriangulatingPathRenderer>());
diff --git a/src/gpu/ops/GrSmallPathRenderer.h b/src/gpu/ops/GrSmallPathRenderer.h
deleted file mode 100644
index 0d8615b..0000000
--- a/src/gpu/ops/GrSmallPathRenderer.h
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
- * Copyright 2014 Google Inc.
- *
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-#ifndef GrSmallPathRenderer_DEFINED
-#define GrSmallPathRenderer_DEFINED
-
-#include "src/gpu/GrPathRenderer.h"
-#include "src/gpu/ops/GrOp.h"
-
-class GrDrawOp;
-class GrRecordingContext;
-class GrStyledShape;
-
-class GrSmallPathRenderer : public GrPathRenderer {
-public:
- GrSmallPathRenderer();
- ~GrSmallPathRenderer() override;
-
- const char* name() const final { return "Small"; }
-
- static GrOp::Owner createOp_TestingOnly(GrRecordingContext*,
- GrPaint&&,
- const GrStyledShape&,
- const SkMatrix& viewMatrix,
- bool gammaCorrect,
- const GrUserStencilSettings*);
-
-private:
- class SmallPathOp;
-
- StencilSupport onGetStencilSupport(const GrStyledShape&) const override {
- return GrPathRenderer::kNoSupport_StencilSupport;
- }
-
- CanDrawPath onCanDrawPath(const CanDrawPathArgs&) const override;
-
- bool onDrawPath(const DrawPathArgs&) override;
-
- using INHERITED = GrPathRenderer;
-};
-
-#endif
diff --git a/src/gpu/ops/GrSmallPathRenderer.cpp b/src/gpu/ops/SmallPathRenderer.cpp
similarity index 96%
rename from src/gpu/ops/GrSmallPathRenderer.cpp
rename to src/gpu/ops/SmallPathRenderer.cpp
index ab55b23..a8b8f3b 100644
--- a/src/gpu/ops/GrSmallPathRenderer.cpp
+++ b/src/gpu/ops/SmallPathRenderer.cpp
@@ -6,7 +6,7 @@
* found in the LICENSE file.
*/
-#include "src/gpu/ops/GrSmallPathRenderer.h"
+#include "src/gpu/ops/SmallPathRenderer.h"
#include "include/core/SkPaint.h"
#include "src/core/SkAutoPixmapStorage.h"
@@ -32,6 +32,8 @@
#include "src/gpu/ops/GrSmallPathShapeData.h"
#include "src/gpu/v1/SurfaceDrawContext_v1.h"
+namespace {
+
// mip levels
static constexpr SkScalar kIdealMinMIP = 12;
static constexpr SkScalar kMaxMIP = 162;
@@ -40,62 +42,12 @@
static constexpr SkScalar kMinSize = SK_ScalarHalf;
static constexpr SkScalar kMaxSize = 2*kMaxMIP;
-GrSmallPathRenderer::GrSmallPathRenderer() {}
-
-GrSmallPathRenderer::~GrSmallPathRenderer() {}
-
-GrPathRenderer::CanDrawPath GrSmallPathRenderer::onCanDrawPath(const CanDrawPathArgs& args) const {
- if (!args.fCaps->shaderCaps()->shaderDerivativeSupport()) {
- return CanDrawPath::kNo;
- }
- // If the shape has no key then we won't get any reuse.
- if (!args.fShape->hasUnstyledKey()) {
- return CanDrawPath::kNo;
- }
- // This only supports filled paths, however, the caller may apply the style to make a filled
- // path and try again.
- if (!args.fShape->style().isSimpleFill()) {
- return CanDrawPath::kNo;
- }
- // This does non-inverse coverage-based antialiased fills.
- if (GrAAType::kCoverage != args.fAAType) {
- return CanDrawPath::kNo;
- }
- // TODO: Support inverse fill
- if (args.fShape->inverseFilled()) {
- return CanDrawPath::kNo;
- }
-
- SkScalar scaleFactors[2] = { 1, 1 };
- // TODO: handle perspective distortion
- if (!args.fViewMatrix->hasPerspective() && !args.fViewMatrix->getMinMaxScales(scaleFactors)) {
- return CanDrawPath::kNo;
- }
- // For affine transformations, too much shear can produce artifacts.
- if (!scaleFactors[0] || scaleFactors[1]/scaleFactors[0] > 4) {
- return CanDrawPath::kNo;
- }
- // Only support paths with bounds within kMaxDim by kMaxDim,
- // scaled to have bounds within kMaxSize by kMaxSize.
- // The goal is to accelerate rendering of lots of small paths that may be scaling.
- SkRect bounds = args.fShape->styledBounds();
- SkScalar minDim = std::min(bounds.width(), bounds.height());
- SkScalar maxDim = std::max(bounds.width(), bounds.height());
- SkScalar minSize = minDim * SkScalarAbs(scaleFactors[0]);
- SkScalar maxSize = maxDim * SkScalarAbs(scaleFactors[1]);
- if (maxDim > kMaxDim || kMinSize > minSize || maxSize > kMaxSize) {
- return CanDrawPath::kNo;
- }
-
- return CanDrawPath::kYes;
-}
-
////////////////////////////////////////////////////////////////////////////////
// padding around path bounds to allow for antialiased pixels
static const int kAntiAliasPad = 1;
-class GrSmallPathRenderer::SmallPathOp final : public GrMeshDrawOp {
+class SmallPathOp final : public GrMeshDrawOp {
private:
using Helper = GrSimpleMeshDrawOpHelperWithStencil;
@@ -694,9 +646,77 @@
using INHERITED = GrMeshDrawOp;
};
-bool GrSmallPathRenderer::onDrawPath(const DrawPathArgs& args) {
+} // anonymous namespace
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+
+#if GR_TEST_UTILS
+
+GR_DRAW_OP_TEST_DEFINE(SmallPathOp) {
+ SkMatrix viewMatrix = GrTest::TestMatrix(random);
+ bool gammaCorrect = random->nextBool();
+
+ // This path renderer only allows fill styles.
+ GrStyledShape shape(GrTest::TestPath(random), GrStyle::SimpleFill());
+ return SmallPathOp::Make(context, std::move(paint), shape, viewMatrix,
+ gammaCorrect, GrGetRandomStencil(random, context));
+}
+
+#endif // GR_TEST_UTILS
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+
+namespace skgpu::v1 {
+
+GrPathRenderer::CanDrawPath SmallPathRenderer::onCanDrawPath(const CanDrawPathArgs& args) const {
+ if (!args.fCaps->shaderCaps()->shaderDerivativeSupport()) {
+ return CanDrawPath::kNo;
+ }
+ // If the shape has no key then we won't get any reuse.
+ if (!args.fShape->hasUnstyledKey()) {
+ return CanDrawPath::kNo;
+ }
+ // This only supports filled paths, however, the caller may apply the style to make a filled
+ // path and try again.
+ if (!args.fShape->style().isSimpleFill()) {
+ return CanDrawPath::kNo;
+ }
+ // This does non-inverse coverage-based antialiased fills.
+ if (GrAAType::kCoverage != args.fAAType) {
+ return CanDrawPath::kNo;
+ }
+ // TODO: Support inverse fill
+ if (args.fShape->inverseFilled()) {
+ return CanDrawPath::kNo;
+ }
+
+ SkScalar scaleFactors[2] = { 1, 1 };
+ // TODO: handle perspective distortion
+ if (!args.fViewMatrix->hasPerspective() && !args.fViewMatrix->getMinMaxScales(scaleFactors)) {
+ return CanDrawPath::kNo;
+ }
+ // For affine transformations, too much shear can produce artifacts.
+ if (!scaleFactors[0] || scaleFactors[1]/scaleFactors[0] > 4) {
+ return CanDrawPath::kNo;
+ }
+ // Only support paths with bounds within kMaxDim by kMaxDim,
+ // scaled to have bounds within kMaxSize by kMaxSize.
+ // The goal is to accelerate rendering of lots of small paths that may be scaling.
+ SkRect bounds = args.fShape->styledBounds();
+ SkScalar minDim = std::min(bounds.width(), bounds.height());
+ SkScalar maxDim = std::max(bounds.width(), bounds.height());
+ SkScalar minSize = minDim * SkScalarAbs(scaleFactors[0]);
+ SkScalar maxSize = maxDim * SkScalarAbs(scaleFactors[1]);
+ if (maxDim > kMaxDim || kMinSize > minSize || maxSize > kMaxSize) {
+ return CanDrawPath::kNo;
+ }
+
+ return CanDrawPath::kYes;
+}
+
+bool SmallPathRenderer::onDrawPath(const DrawPathArgs& args) {
GR_AUDIT_TRAIL_AUTO_FRAME(args.fContext->priv().auditTrail(),
- "GrSmallPathRenderer::onDrawPath");
+ "SmallPathRenderer::onDrawPath");
// we've already bailed on inverse filled paths, so this is safe
SkASSERT(!args.fShape->isEmpty());
@@ -710,32 +730,4 @@
return true;
}
-///////////////////////////////////////////////////////////////////////////////////////////////////
-
-#if GR_TEST_UTILS
-
-GrOp::Owner GrSmallPathRenderer::createOp_TestingOnly(
- GrRecordingContext* context,
- GrPaint&& paint,
- const GrStyledShape& shape,
- const SkMatrix& viewMatrix,
- bool gammaCorrect,
- const GrUserStencilSettings* stencil) {
- return GrSmallPathRenderer::SmallPathOp::Make(context, std::move(paint), shape, viewMatrix,
- gammaCorrect, stencil);
-}
-
-GR_DRAW_OP_TEST_DEFINE(SmallPathOp) {
- SkMatrix viewMatrix = GrTest::TestMatrix(random);
- bool gammaCorrect = random->nextBool();
-
- // This path renderer only allows fill styles.
- GrStyledShape shape(GrTest::TestPath(random), GrStyle::SimpleFill());
- return GrSmallPathRenderer::createOp_TestingOnly(
- context,
- std::move(paint), shape, viewMatrix,
- gammaCorrect,
- GrGetRandomStencil(random, context));
-}
-
-#endif
+} // namespace skgpu::v1
diff --git a/src/gpu/ops/SmallPathRenderer.h b/src/gpu/ops/SmallPathRenderer.h
new file mode 100644
index 0000000..cb93b34
--- /dev/null
+++ b/src/gpu/ops/SmallPathRenderer.h
@@ -0,0 +1,39 @@
+/*
+ * Copyright 2014 Google Inc.
+ *
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#ifndef SmallPathRenderer_DEFINED
+#define SmallPathRenderer_DEFINED
+
+#include "src/gpu/GrPathRenderer.h"
+
+class GrDrawOp;
+class GrRecordingContext;
+class GrStyledShape;
+
+namespace skgpu::v1 {
+
+class SmallPathRenderer final : public GrPathRenderer {
+public:
+ SmallPathRenderer() = default;
+
+ const char* name() const override { return "Small"; }
+
+private:
+ StencilSupport onGetStencilSupport(const GrStyledShape&) const override {
+ return GrPathRenderer::kNoSupport_StencilSupport;
+ }
+
+ CanDrawPath onCanDrawPath(const CanDrawPathArgs&) const override;
+
+ bool onDrawPath(const DrawPathArgs&) override;
+
+ using INHERITED = GrPathRenderer;
+};
+
+} // namespace skgpu::v1
+
+#endif // SmallPathRenderer_DEFINED
diff --git a/src/gpu/GrSoftwarePathRenderer.cpp b/src/gpu/ops/SoftwarePathRenderer.cpp
similarity index 86%
rename from src/gpu/GrSoftwarePathRenderer.cpp
rename to src/gpu/ops/SoftwarePathRenderer.cpp
index 3e0a79f..9c8b8a6 100644
--- a/src/gpu/GrSoftwarePathRenderer.cpp
+++ b/src/gpu/ops/SoftwarePathRenderer.cpp
@@ -5,7 +5,7 @@
* found in the LICENSE file.
*/
-#include "src/gpu/GrSoftwarePathRenderer.h"
+#include "src/gpu/ops/SoftwarePathRenderer.h"
#include "include/gpu/GrDirectContext.h"
#include "include/private/SkSemaphore.h"
@@ -28,22 +28,36 @@
#include "src/gpu/ops/GrDrawOp.h"
#include "src/gpu/v1/SurfaceDrawContext_v1.h"
-////////////////////////////////////////////////////////////////////////////////
-GrPathRenderer::CanDrawPath
-GrSoftwarePathRenderer::onCanDrawPath(const CanDrawPathArgs& args) const {
- // Pass on any style that applies. The caller will apply the style if a suitable renderer is
- // not found and try again with the new GrStyledShape.
- if (!args.fShape->style().applies() && SkToBool(fProxyProvider) &&
- (args.fAAType == GrAAType::kCoverage || args.fAAType == GrAAType::kNone)) {
- // This is the fallback renderer for when a path is too complicated for the GPU ones.
- return CanDrawPath::kAsBackup;
- }
- return CanDrawPath::kNo;
-}
+namespace {
-////////////////////////////////////////////////////////////////////////////////
-static bool get_unclipped_shape_dev_bounds(const GrStyledShape& shape, const SkMatrix& matrix,
- SkIRect* devBounds) {
+/**
+ * Payload class for use with GrTDeferredProxyUploader. The software path renderer only draws
+ * a single path into the mask texture. This stores all of the information needed by the worker
+ * thread's call to drawShape (see below, in onDrawPath).
+ */
+class SoftwarePathData {
+public:
+ SoftwarePathData(const SkIRect& maskBounds, const SkMatrix& viewMatrix,
+ const GrStyledShape& shape, GrAA aa)
+ : fMaskBounds(maskBounds)
+ , fViewMatrix(viewMatrix)
+ , fShape(shape)
+ , fAA(aa) {}
+
+ const SkIRect& getMaskBounds() const { return fMaskBounds; }
+ const SkMatrix* getViewMatrix() const { return &fViewMatrix; }
+ const GrStyledShape& getShape() const { return fShape; }
+ GrAA getAA() const { return fAA; }
+
+private:
+ SkIRect fMaskBounds;
+ SkMatrix fViewMatrix;
+ GrStyledShape fShape;
+ GrAA fAA;
+};
+
+bool get_unclipped_shape_dev_bounds(const GrStyledShape& shape, const SkMatrix& matrix,
+ SkIRect* devBounds) {
SkRect shapeBounds = shape.styledBounds();
if (shapeBounds.isEmpty()) {
return false;
@@ -67,15 +81,51 @@
return true;
}
+GrSurfaceProxyView make_deferred_mask_texture_view(GrRecordingContext* rContext,
+ SkBackingFit fit,
+ SkISize dimensions) {
+ GrProxyProvider* proxyProvider = rContext->priv().proxyProvider();
+ const GrCaps* caps = rContext->priv().caps();
+
+ const GrBackendFormat format = caps->getDefaultBackendFormat(GrColorType::kAlpha_8,
+ GrRenderable::kNo);
+
+ GrSwizzle swizzle = caps->getReadSwizzle(format, GrColorType::kAlpha_8);
+
+ auto proxy =
+ proxyProvider->createProxy(format, dimensions, GrRenderable::kNo, 1, GrMipmapped::kNo,
+ fit, SkBudgeted::kYes, GrProtected::kNo);
+ return {std::move(proxy), kTopLeft_GrSurfaceOrigin, swizzle};
+}
+
+
+} // anonymous namespace
+
+namespace skgpu::v1 {
+
+////////////////////////////////////////////////////////////////////////////////
+GrPathRenderer::CanDrawPath SoftwarePathRenderer::onCanDrawPath(const CanDrawPathArgs& args) const {
+ // Pass on any style that applies. The caller will apply the style if a suitable renderer is
+ // not found and try again with the new GrStyledShape.
+ if (!args.fShape->style().applies() && SkToBool(fProxyProvider) &&
+ (args.fAAType == GrAAType::kCoverage || args.fAAType == GrAAType::kNone)) {
+ // This is the fallback renderer for when a path is too complicated for the GPU ones.
+ return CanDrawPath::kAsBackup;
+ }
+ return CanDrawPath::kNo;
+}
+
+////////////////////////////////////////////////////////////////////////////////
+
// Gets the shape bounds, the clip bounds, and the intersection (if any). Returns false if there
// is no intersection.
-bool GrSoftwarePathRenderer::GetShapeAndClipBounds(skgpu::v1::SurfaceDrawContext* sdc,
- const GrClip* clip,
- const GrStyledShape& shape,
- const SkMatrix& matrix,
- SkIRect* unclippedDevShapeBounds,
- SkIRect* clippedDevShapeBounds,
- SkIRect* devClipBounds) {
+bool SoftwarePathRenderer::GetShapeAndClipBounds(SurfaceDrawContext* sdc,
+ const GrClip* clip,
+ const GrStyledShape& shape,
+ const SkMatrix& matrix,
+ SkIRect* unclippedDevShapeBounds,
+ SkIRect* clippedDevShapeBounds,
+ SkIRect* devClipBounds) {
// compute bounds as intersection of rt size, clip, and path
*devClipBounds = clip ? clip->getConservativeBounds()
: SkIRect::MakeWH(sdc->width(), sdc->height());
@@ -94,24 +144,24 @@
////////////////////////////////////////////////////////////////////////////////
-void GrSoftwarePathRenderer::DrawNonAARect(skgpu::v1::SurfaceDrawContext* sdc,
- GrPaint&& paint,
- const GrUserStencilSettings& userStencilSettings,
- const GrClip* clip,
- const SkMatrix& viewMatrix,
- const SkRect& rect,
- const SkMatrix& localMatrix) {
+void SoftwarePathRenderer::DrawNonAARect(SurfaceDrawContext* sdc,
+ GrPaint&& paint,
+ const GrUserStencilSettings& userStencilSettings,
+ const GrClip* clip,
+ const SkMatrix& viewMatrix,
+ const SkRect& rect,
+ const SkMatrix& localMatrix) {
sdc->stencilRect(clip, &userStencilSettings, std::move(paint), GrAA::kNo,
viewMatrix, rect, &localMatrix);
}
-void GrSoftwarePathRenderer::DrawAroundInvPath(skgpu::v1::SurfaceDrawContext* sdc,
- GrPaint&& paint,
- const GrUserStencilSettings& userStencilSettings,
- const GrClip* clip,
- const SkMatrix& viewMatrix,
- const SkIRect& devClipBounds,
- const SkIRect& devPathBounds) {
+void SoftwarePathRenderer::DrawAroundInvPath(SurfaceDrawContext* sdc,
+ GrPaint&& paint,
+ const GrUserStencilSettings& userStencilSettings,
+ const GrClip* clip,
+ const SkMatrix& viewMatrix,
+ const SkIRect& devClipBounds,
+ const SkIRect& devPathBounds) {
SkMatrix invert;
if (!viewMatrix.invert(&invert)) {
return;
@@ -144,9 +194,9 @@
}
}
-void GrSoftwarePathRenderer::DrawToTargetWithShapeMask(
+void SoftwarePathRenderer::DrawToTargetWithShapeMask(
GrSurfaceProxyView view,
- skgpu::v1::SurfaceDrawContext* sdc,
+ SurfaceDrawContext* sdc,
GrPaint&& paint,
const GrUserStencilSettings& userStencilSettings,
const GrClip* clip,
@@ -175,58 +225,11 @@
dstRect, invert);
}
-static GrSurfaceProxyView make_deferred_mask_texture_view(GrRecordingContext* rContext,
- SkBackingFit fit,
- SkISize dimensions) {
- GrProxyProvider* proxyProvider = rContext->priv().proxyProvider();
- const GrCaps* caps = rContext->priv().caps();
-
- const GrBackendFormat format = caps->getDefaultBackendFormat(GrColorType::kAlpha_8,
- GrRenderable::kNo);
-
- GrSwizzle swizzle = caps->getReadSwizzle(format, GrColorType::kAlpha_8);
-
- auto proxy =
- proxyProvider->createProxy(format, dimensions, GrRenderable::kNo, 1, GrMipmapped::kNo,
- fit, SkBudgeted::kYes, GrProtected::kNo);
- return {std::move(proxy), kTopLeft_GrSurfaceOrigin, swizzle};
-}
-
-namespace {
-
-/**
- * Payload class for use with GrTDeferredProxyUploader. The software path renderer only draws
- * a single path into the mask texture. This stores all of the information needed by the worker
- * thread's call to drawShape (see below, in onDrawPath).
- */
-class SoftwarePathData {
-public:
- SoftwarePathData(const SkIRect& maskBounds, const SkMatrix& viewMatrix,
- const GrStyledShape& shape, GrAA aa)
- : fMaskBounds(maskBounds)
- , fViewMatrix(viewMatrix)
- , fShape(shape)
- , fAA(aa) {}
-
- const SkIRect& getMaskBounds() const { return fMaskBounds; }
- const SkMatrix* getViewMatrix() const { return &fViewMatrix; }
- const GrStyledShape& getShape() const { return fShape; }
- GrAA getAA() const { return fAA; }
-
-private:
- SkIRect fMaskBounds;
- SkMatrix fViewMatrix;
- GrStyledShape fShape;
- GrAA fAA;
-};
-
-} // namespace
-
////////////////////////////////////////////////////////////////////////////////
// return true on success; false on failure
-bool GrSoftwarePathRenderer::onDrawPath(const DrawPathArgs& args) {
+bool SoftwarePathRenderer::onDrawPath(const DrawPathArgs& args) {
GR_AUDIT_TRAIL_AUTO_FRAME(args.fContext->priv().auditTrail(),
- "GrSoftwarePathRenderer::onDrawPath");
+ "SoftwarePathRenderer::onDrawPath");
if (!fProxyProvider) {
return false;
@@ -395,3 +398,5 @@
return true;
}
+
+} // namespace skgpu::v1
diff --git a/src/gpu/GrSoftwarePathRenderer.h b/src/gpu/ops/SoftwarePathRenderer.h
similarity index 79%
rename from src/gpu/GrSoftwarePathRenderer.h
rename to src/gpu/ops/SoftwarePathRenderer.h
index a9752b0..169bcdd 100644
--- a/src/gpu/GrSoftwarePathRenderer.h
+++ b/src/gpu/ops/SoftwarePathRenderer.h
@@ -5,28 +5,30 @@
* found in the LICENSE file.
*/
-#ifndef GrSoftwarePathRenderer_DEFINED
-#define GrSoftwarePathRenderer_DEFINED
+#ifndef SoftwarePathRenderer_DEFINED
+#define SoftwarePathRenderer_DEFINED
#include "src/gpu/GrPathRenderer.h"
#include "src/gpu/GrSurfaceProxyView.h"
class GrProxyProvider;
+namespace skgpu::v1 {
+
/**
* This class uses the software side to render a path to an SkBitmap and
* then uploads the result to the gpu
*/
-class GrSoftwarePathRenderer : public GrPathRenderer {
+class SoftwarePathRenderer final : public GrPathRenderer {
public:
- const char* name() const final { return "SW"; }
+ const char* name() const override { return "SW"; }
- GrSoftwarePathRenderer(GrProxyProvider* proxyProvider, bool allowCaching)
+ SoftwarePathRenderer(GrProxyProvider* proxyProvider, bool allowCaching)
: fProxyProvider(proxyProvider)
, fAllowCaching(allowCaching) {
}
- static bool GetShapeAndClipBounds(skgpu::v1::SurfaceDrawContext*,
+ static bool GetShapeAndClipBounds(SurfaceDrawContext*,
const GrClip*,
const GrStyledShape&,
const SkMatrix& viewMatrix,
@@ -35,14 +37,14 @@
SkIRect* devClipBounds);
private:
- static void DrawNonAARect(skgpu::v1::SurfaceDrawContext*,
+ static void DrawNonAARect(SurfaceDrawContext*,
GrPaint&&,
const GrUserStencilSettings&,
const GrClip*,
const SkMatrix& viewMatrix,
const SkRect& rect,
const SkMatrix& localMatrix);
- static void DrawAroundInvPath(skgpu::v1::SurfaceDrawContext*,
+ static void DrawAroundInvPath(SurfaceDrawContext*,
GrPaint&&,
const GrUserStencilSettings&,
const GrClip*,
@@ -54,7 +56,7 @@
// space. The 'viewMatrix' will be used to ensure the correct local coords are provided to
// any fragment processors in the paint.
static void DrawToTargetWithShapeMask(GrSurfaceProxyView,
- skgpu::v1::SurfaceDrawContext*,
+ SurfaceDrawContext*,
GrPaint&&,
const GrUserStencilSettings&,
const GrClip*,
@@ -71,10 +73,12 @@
bool onDrawPath(const DrawPathArgs&) override;
private:
- GrProxyProvider* fProxyProvider;
- bool fAllowCaching;
+ GrProxyProvider* fProxyProvider;
+ bool fAllowCaching;
using INHERITED = GrPathRenderer;
};
-#endif
+} // namespace skgpu::v1
+
+#endif // SoftwarePathRenderer_DEFINED
diff --git a/tests/PathRendererCacheTests.cpp b/tests/PathRendererCacheTests.cpp
index df472e6..92343ad 100644
--- a/tests/PathRendererCacheTests.cpp
+++ b/tests/PathRendererCacheTests.cpp
@@ -13,11 +13,11 @@
#include "src/gpu/GrDirectContextPriv.h"
#include "src/gpu/GrRecordingContextPriv.h"
#include "src/gpu/GrResourceCache.h"
-#include "src/gpu/GrSoftwarePathRenderer.h"
#include "src/gpu/GrStyle.h"
#include "src/gpu/effects/GrPorterDuffXferProcessor.h"
#include "src/gpu/geometry/GrStyledShape.h"
#include "src/gpu/ops/GrTriangulatingPathRenderer.h"
+#include "src/gpu/ops/SoftwarePathRenderer.h"
#include "src/gpu/v1/SurfaceDrawContext_v1.h"
static SkPath create_concave_path() {
@@ -155,7 +155,7 @@
// Test that deleting the original path invalidates the textures cached by the SW path renderer
DEF_GPUTEST(SoftwarePathRendererCacheTest, reporter, /* options */) {
auto createPR = [](GrRecordingContext* rContext) {
- return new GrSoftwarePathRenderer(rContext->priv().proxyProvider(), true);
+ return new skgpu::v1::SoftwarePathRenderer(rContext->priv().proxyProvider(), true);
};
// Software path renderer creates a mask texture and renders with a non-AA rect, but the flush