Move GrTextureOp to skgpu::v1 namespace
Bug: skia:11837
Change-Id: Ie99b1c512885404351d6917bbea751d99a2ca23e
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/442797
Reviewed-by: Michael Ludwig <michaelludwig@google.com>
Commit-Queue: Robert Phillips <robertphillips@google.com>
diff --git a/gn/gpu.gni b/gn/gpu.gni
index 039b45b..33d69a0 100644
--- a/gn/gpu.gni
+++ b/gn/gpu.gni
@@ -554,8 +554,6 @@
"$_src/gpu/ops/GrSmallPathShapeData.h",
"$_src/gpu/ops/GrStrokeRectOp.cpp",
"$_src/gpu/ops/GrStrokeRectOp.h",
- "$_src/gpu/ops/GrTextureOp.cpp",
- "$_src/gpu/ops/GrTextureOp.h",
"$_src/gpu/ops/OpsTask.cpp",
"$_src/gpu/ops/OpsTask.h",
"$_src/gpu/ops/PathInnerTriangulateOp.cpp",
@@ -572,6 +570,8 @@
"$_src/gpu/ops/StrokeTessellateOp.h",
"$_src/gpu/ops/TessellationPathRenderer.cpp",
"$_src/gpu/ops/TessellationPathRenderer.h",
+ "$_src/gpu/ops/TextureOp.cpp",
+ "$_src/gpu/ops/TextureOp.h",
"$_src/gpu/ops/TriangulatingPathRenderer.cpp",
"$_src/gpu/ops/TriangulatingPathRenderer.h",
diff --git a/src/gpu/ops/GrQuadPerEdgeAA.cpp b/src/gpu/ops/GrQuadPerEdgeAA.cpp
index 6e62009..52bc12e 100644
--- a/src/gpu/ops/GrQuadPerEdgeAA.cpp
+++ b/src/gpu/ops/GrQuadPerEdgeAA.cpp
@@ -771,7 +771,7 @@
}
private:
- using Saturate = GrTextureOp::Saturate;
+ using Saturate = skgpu::v1::TextureOp::Saturate;
QuadPerEdgeAAGeometryProcessor(const VertexSpec& spec)
: INHERITED(kQuadPerEdgeAAGeometryProcessor_ClassID)
diff --git a/src/gpu/ops/GrQuadPerEdgeAA.h b/src/gpu/ops/GrQuadPerEdgeAA.h
index ffcaf8c..cd8eab7 100644
--- a/src/gpu/ops/GrQuadPerEdgeAA.h
+++ b/src/gpu/ops/GrQuadPerEdgeAA.h
@@ -17,7 +17,7 @@
#include "src/gpu/GrVertexWriter.h"
#include "src/gpu/geometry/GrQuad.h"
#include "src/gpu/geometry/GrQuadUtils.h"
-#include "src/gpu/ops/GrTextureOp.h"
+#include "src/gpu/ops/TextureOp.h"
class GrCaps;
class GrColorSpaceXform;
@@ -26,7 +26,7 @@
struct GrVertexWriter;
namespace GrQuadPerEdgeAA {
- using Saturate = GrTextureOp::Saturate;
+ using Saturate = skgpu::v1::TextureOp::Saturate;
enum class CoverageMode { kNone, kWithPosition, kWithColor };
enum class Subset : bool { kNo = false, kYes = true };
diff --git a/src/gpu/ops/GrTextureOp.cpp b/src/gpu/ops/TextureOp.cpp
similarity index 89%
rename from src/gpu/ops/GrTextureOp.cpp
rename to src/gpu/ops/TextureOp.cpp
index 78e5969..4e11cc2 100644
--- a/src/gpu/ops/GrTextureOp.cpp
+++ b/src/gpu/ops/TextureOp.cpp
@@ -41,10 +41,8 @@
#include "src/gpu/ops/GrMeshDrawOp.h"
#include "src/gpu/ops/GrQuadPerEdgeAA.h"
#include "src/gpu/ops/GrSimpleMeshDrawOpHelper.h"
-#include "src/gpu/ops/GrTextureOp.h"
-#if SK_GPU_V1
+#include "src/gpu/ops/TextureOp.h"
#include "src/gpu/v1/SurfaceDrawContext_v1.h"
-#endif
namespace {
@@ -54,7 +52,7 @@
// Extracts lengths of vertical and horizontal edges of axis-aligned quad. "width" is the edge
// between v0 and v2 (or v1 and v3), "height" is the edge between v0 and v1 (or v2 and v3).
-static SkSize axis_aligned_quad_size(const GrQuad& quad) {
+SkSize axis_aligned_quad_size(const GrQuad& quad) {
SkASSERT(quad.quadType() == GrQuad::Type::kAxisAligned);
// Simplification of regular edge length equation, since it's axis aligned and can avoid sqrt
float dw = sk_float_abs(quad.x(2) - quad.x(0)) + sk_float_abs(quad.y(2) - quad.y(0));
@@ -62,8 +60,8 @@
return {dw, dh};
}
-static std::tuple<bool /* filter */,
- bool /* mipmap */>
+std::tuple<bool /* filter */,
+ bool /* mipmap */>
filter_and_mm_have_effect(const GrQuad& srcQuad, const GrQuad& dstQuad) {
// If not axis-aligned in src or dst, then always say it has an effect
if (srcQuad.quadType() != GrQuad::Type::kAxisAligned ||
@@ -107,8 +105,8 @@
float fInvH; // 1 / height of texture, or 1.0 for tex rects, X -1 if bottom-left origin
float fYOffset; // 0 for top-left origin, height of [normalized] tex if bottom-left
};
-static NormalizationParams proxy_normalization_params(const GrSurfaceProxy* proxy,
- GrSurfaceOrigin origin) {
+NormalizationParams proxy_normalization_params(const GrSurfaceProxy* proxy,
+ GrSurfaceOrigin origin) {
// Whether or not the proxy is instantiated, this is the size its texture will be, so we can
// normalize the src coordinates up front.
SkISize dimensions = proxy->backingStoreDimensions();
@@ -133,9 +131,9 @@
// so a sufficiently large rect is returned even if the quad ends up batched with an op that uses
// subsets overall. When there is a subset it will be inset based on the filter mode. Normalization
// and y-flipping are applied as indicated by NormalizationParams.
-static SkRect normalize_and_inset_subset(GrSamplerState::Filter filter,
- const NormalizationParams& params,
- const SkRect* subsetRect) {
+SkRect normalize_and_inset_subset(GrSamplerState::Filter filter,
+ const NormalizationParams& params,
+ const SkRect* subsetRect) {
static constexpr SkRect kLargeRect = {-100000, -100000, 1000000, 1000000};
if (!subsetRect) {
// Either the quad has no subset constraint and is batched with a subset constrained op
@@ -169,8 +167,8 @@
}
// Normalizes logical src coords and corrects for origin
-static void normalize_src_quad(const NormalizationParams& params,
- GrQuad* srcQuad) {
+void normalize_src_quad(const NormalizationParams& params,
+ GrQuad* srcQuad) {
// The src quad should not have any perspective
SkASSERT(!srcQuad->hasPerspective());
skvx::Vec<4, float> xs = srcQuad->x4f() * params.fIW;
@@ -179,12 +177,10 @@
ys.store(srcQuad->ys());
}
-#if SK_GPU_V1
-
// Count the number of proxy runs in the entry set. This usually is already computed by
// SkGpuDevice, but when the BatchLengthLimiter chops the set up it must determine a new proxy count
// for each split.
-static int proxy_run_count(const GrTextureSetEntry set[], int count) {
+int proxy_run_count(const GrTextureSetEntry set[], int count) {
int actualProxyRunCount = 0;
const GrSurfaceProxy* lastProxy = nullptr;
for (int i = 0; i < count; ++i) {
@@ -195,10 +191,9 @@
}
return actualProxyRunCount;
}
-#endif
-static bool safe_to_ignore_subset_rect(GrAAType aaType, GrSamplerState::Filter filter,
- const DrawQuad& quad, const SkRect& subsetRect) {
+bool safe_to_ignore_subset_rect(GrAAType aaType, GrSamplerState::Filter filter,
+ const DrawQuad& quad, const SkRect& subsetRect) {
// If both the device and local quad are both axis-aligned, and filtering is off, the local quad
// can push all the way up to the edges of the the subset rect and the sampler shouldn't
// overshoot. Unfortunately, antialiasing adds enough jitter that we can only rely on this in
@@ -227,21 +222,23 @@
* Op that implements GrTextureOp::Make. It draws textured quads. Each quad can modulate against a
* the texture by color. The blend with the destination is always src-over. The edges are non-AA.
*/
-class TextureOp final : public GrMeshDrawOp {
+class TextureOpImpl final : public GrMeshDrawOp {
public:
+ using Saturate = skgpu::v1::TextureOp::Saturate;
+
static GrOp::Owner Make(GrRecordingContext* context,
GrSurfaceProxyView proxyView,
sk_sp<GrColorSpaceXform> textureXform,
GrSamplerState::Filter filter,
GrSamplerState::MipmapMode mm,
const SkPMColor4f& color,
- GrTextureOp::Saturate saturate,
+ Saturate saturate,
GrAAType aaType,
DrawQuad* quad,
const SkRect* subset) {
- return GrOp::Make<TextureOp>(context, std::move(proxyView), std::move(textureXform),
- filter, mm, color, saturate, aaType, quad, subset);
+ return GrOp::Make<TextureOpImpl>(context, std::move(proxyView), std::move(textureXform),
+ filter, mm, color, saturate, aaType, quad, subset);
}
static GrOp::Owner Make(GrRecordingContext* context,
@@ -250,20 +247,20 @@
int proxyRunCnt,
GrSamplerState::Filter filter,
GrSamplerState::MipmapMode mm,
- GrTextureOp::Saturate saturate,
+ Saturate saturate,
GrAAType aaType,
SkCanvas::SrcRectConstraint constraint,
const SkMatrix& viewMatrix,
sk_sp<GrColorSpaceXform> textureColorSpaceXform) {
// Allocate size based on proxyRunCnt, since that determines number of ViewCountPairs.
SkASSERT(proxyRunCnt <= cnt);
- return GrOp::MakeWithExtraMemory<TextureOp>(
+ return GrOp::MakeWithExtraMemory<TextureOpImpl>(
context, sizeof(ViewCountPair) * (proxyRunCnt - 1),
set, cnt, proxyRunCnt, filter, mm, saturate, aaType, constraint,
viewMatrix, std::move(textureColorSpaceXform));
}
- ~TextureOp() override {
+ ~TextureOpImpl() override {
for (unsigned p = 1; p < fMetadata.fProxyCount; ++p) {
fViewCountPairs[p].~ViewCountPair();
}
@@ -355,7 +352,7 @@
GrSamplerState::Filter filter,
GrSamplerState::MipmapMode mm,
GrQuadPerEdgeAA::Subset subset,
- GrTextureOp::Saturate saturate)
+ Saturate saturate)
: fSwizzle(swizzle)
, fProxyCount(1)
, fTotalQuadCount(1)
@@ -389,9 +386,7 @@
GrAAType aaType() const { return static_cast<GrAAType>(fAAType); }
ColorType colorType() const { return static_cast<ColorType>(fColorType); }
Subset subset() const { return static_cast<Subset>(fSubset); }
- GrTextureOp::Saturate saturate() const {
- return static_cast<GrTextureOp::Saturate>(fSaturate);
- }
+ Saturate saturate() const { return static_cast<Saturate>(fSaturate); }
static_assert(GrSamplerState::kFilterCount <= 4);
static_assert(kGrAATypeCount <= 4);
@@ -437,15 +432,15 @@
}
};
// If subsetRect is not null it will be used to apply a strict src rect-style constraint.
- TextureOp(GrSurfaceProxyView proxyView,
- sk_sp<GrColorSpaceXform> textureColorSpaceXform,
- GrSamplerState::Filter filter,
- GrSamplerState::MipmapMode mm,
- const SkPMColor4f& color,
- GrTextureOp::Saturate saturate,
- GrAAType aaType,
- DrawQuad* quad,
- const SkRect* subsetRect)
+ TextureOpImpl(GrSurfaceProxyView proxyView,
+ sk_sp<GrColorSpaceXform> textureColorSpaceXform,
+ GrSamplerState::Filter filter,
+ GrSamplerState::MipmapMode mm,
+ const SkPMColor4f& color,
+ Saturate saturate,
+ GrAAType aaType,
+ DrawQuad* quad,
+ const SkRect* subsetRect)
: INHERITED(ClassID())
, fQuads(1, true /* includes locals */)
, fTextureColorSpaceXform(std::move(textureColorSpaceXform))
@@ -485,16 +480,16 @@
fViewCountPairs[0] = {proxyView.detachProxy(), quadCount};
}
- TextureOp(GrTextureSetEntry set[],
- int cnt,
- int proxyRunCnt,
- const GrSamplerState::Filter filter,
- const GrSamplerState::MipmapMode mm,
- const GrTextureOp::Saturate saturate,
- const GrAAType aaType,
- const SkCanvas::SrcRectConstraint constraint,
- const SkMatrix& viewMatrix,
- sk_sp<GrColorSpaceXform> textureColorSpaceXform)
+ TextureOpImpl(GrTextureSetEntry set[],
+ int cnt,
+ int proxyRunCnt,
+ const GrSamplerState::Filter filter,
+ const GrSamplerState::MipmapMode mm,
+ const Saturate saturate,
+ const GrAAType aaType,
+ const SkCanvas::SrcRectConstraint constraint,
+ const SkMatrix& viewMatrix,
+ sk_sp<GrColorSpaceXform> textureColorSpaceXform)
: INHERITED(ClassID())
, fQuads(cnt, true /* includes locals */)
, fTextureColorSpaceXform(std::move(textureColorSpaceXform))
@@ -717,7 +712,10 @@
renderPassXferBarriers, colorLoadOp);
}
- static void FillInVertices(const GrCaps& caps, TextureOp* texOp, Desc* desc, char* vertexData) {
+ static void FillInVertices(const GrCaps& caps,
+ TextureOpImpl* texOp,
+ Desc* desc,
+ char* vertexData) {
SkASSERT(vertexData);
SkDEBUGCODE(int totQuadsSeen = 0;)
@@ -725,7 +723,7 @@
SkDEBUGCODE(const size_t vertexSize = desc->fVertexSpec.vertexSize());
GrQuadPerEdgeAA::Tessellator tessellator(desc->fVertexSpec, vertexData);
- for (const auto& op : ChainRange<TextureOp>(texOp)) {
+ for (const auto& op : ChainRange<TextureOpImpl>(texOp)) {
auto iter = op.fQuads.iterator();
for (unsigned p = 0; p < op.fMetadata.fProxyCount; ++p) {
const int quadCnt = op.fViewCountPairs[p].fQuadCnt;
@@ -761,7 +759,7 @@
static int validate_op(GrTextureType textureType,
GrAAType aaType,
GrSwizzle swizzle,
- const TextureOp* op) {
+ const TextureOpImpl* op) {
SkASSERT(op->fMetadata.fSwizzle == swizzle);
int quadCount = 0;
@@ -786,12 +784,12 @@
for (const GrOp* tmp = this->prevInChain(); tmp; tmp = tmp->prevInChain()) {
quadCount += validate_op(textureType, aaType, swizzle,
- static_cast<const TextureOp*>(tmp));
+ static_cast<const TextureOpImpl*>(tmp));
}
for (const GrOp* tmp = this->nextInChain(); tmp; tmp = tmp->nextInChain()) {
quadCount += validate_op(textureType, aaType, swizzle,
- static_cast<const TextureOp*>(tmp));
+ static_cast<const TextureOpImpl*>(tmp));
}
SkASSERT(quadCount == this->numChainedQuads());
@@ -816,7 +814,7 @@
desc->fNumTotalQuads = 0;
int maxQuadsPerMesh = 0;
- for (const auto& op : ChainRange<TextureOp>(this)) {
+ for (const auto& op : ChainRange<TextureOpImpl>(this)) {
if (op.fQuads.deviceQuadType() > quadType) {
quadType = op.fQuads.deviceQuadType();
}
@@ -869,11 +867,11 @@
int numChainedQuads = this->totNumQuads();
for (const GrOp* tmp = this->prevInChain(); tmp; tmp = tmp->prevInChain()) {
- numChainedQuads += ((const TextureOp*)tmp)->totNumQuads();
+ numChainedQuads += ((const TextureOpImpl*)tmp)->totNumQuads();
}
for (const GrOp* tmp = this->nextInChain(); tmp; tmp = tmp->nextInChain()) {
- numChainedQuads += ((const TextureOp*)tmp)->totNumQuads();
+ numChainedQuads += ((const TextureOpImpl*)tmp)->totNumQuads();
}
return numChainedQuads;
@@ -939,7 +937,7 @@
int totQuadsSeen = 0;
SkDEBUGCODE(int numDraws = 0;)
- for (const auto& op : ChainRange<TextureOp>(this)) {
+ for (const auto& op : ChainRange<TextureOpImpl>(this)) {
for (unsigned p = 0; p < op.fMetadata.fProxyCount; ++p) {
const int quadCnt = op.fViewCountPairs[p].fQuadCnt;
SkASSERT(numDraws < fDesc->fNumProxies);
@@ -962,14 +960,14 @@
fMetadata.fAAType = static_cast<uint16_t>(GrAAType::kCoverage);
for (GrOp* tmp = this->prevInChain(); tmp; tmp = tmp->prevInChain()) {
- TextureOp* tex = static_cast<TextureOp*>(tmp);
+ auto tex = static_cast<TextureOpImpl*>(tmp);
SkASSERT(tex->fMetadata.aaType() == GrAAType::kCoverage ||
tex->fMetadata.aaType() == GrAAType::kNone);
tex->fMetadata.fAAType = static_cast<uint16_t>(GrAAType::kCoverage);
}
for (GrOp* tmp = this->nextInChain(); tmp; tmp = tmp->nextInChain()) {
- TextureOp* tex = static_cast<TextureOp*>(tmp);
+ auto tex = static_cast<TextureOpImpl*>(tmp);
SkASSERT(tex->fMetadata.aaType() == GrAAType::kCoverage ||
tex->fMetadata.aaType() == GrAAType::kNone);
tex->fMetadata.fAAType = static_cast<uint16_t>(GrAAType::kCoverage);
@@ -978,7 +976,7 @@
CombineResult onCombineIfPossible(GrOp* t, SkArenaAlloc*, const GrCaps& caps) override {
TRACE_EVENT0("skia.gpu", TRACE_FUNC);
- auto* that = t->cast<TextureOp>();
+ auto that = t->cast<TextureOpImpl>();
SkDEBUGCODE(this->validate();)
SkDEBUGCODE(that->validate();)
@@ -1120,24 +1118,26 @@
} // anonymous namespace
+namespace skgpu::v1 {
+
#if GR_TEST_UTILS
-uint32_t GrTextureOp::ClassID() {
- return TextureOp::ClassID();
+uint32_t TextureOp::ClassID() {
+ return TextureOpImpl::ClassID();
}
#endif
-GrOp::Owner GrTextureOp::Make(GrRecordingContext* context,
- GrSurfaceProxyView proxyView,
- SkAlphaType alphaType,
- sk_sp<GrColorSpaceXform> textureXform,
- GrSamplerState::Filter filter,
- GrSamplerState::MipmapMode mm,
- const SkPMColor4f& color,
- Saturate saturate,
- SkBlendMode blendMode,
- GrAAType aaType,
- DrawQuad* quad,
- const SkRect* subset) {
+GrOp::Owner TextureOp::Make(GrRecordingContext* context,
+ GrSurfaceProxyView proxyView,
+ SkAlphaType alphaType,
+ sk_sp<GrColorSpaceXform> textureXform,
+ GrSamplerState::Filter filter,
+ GrSamplerState::MipmapMode mm,
+ const SkPMColor4f& color,
+ Saturate saturate,
+ SkBlendMode blendMode,
+ GrAAType aaType,
+ DrawQuad* quad,
+ const SkRect* subset) {
// Apply optimizations that are valid whether or not using GrTextureOp or GrFillRectOp
if (subset && subset->contains(proxyView.proxy()->backingStoreBoundsRect())) {
// No need for a shader-based subset if hardware clamping achieves the same effect
@@ -1155,8 +1155,8 @@
}
if (blendMode == SkBlendMode::kSrcOver) {
- return TextureOp::Make(context, std::move(proxyView), std::move(textureXform), filter, mm,
- color, saturate, aaType, std::move(quad), subset);
+ return TextureOpImpl::Make(context, std::move(proxyView), std::move(textureXform), filter,
+ mm, color, saturate, aaType, std::move(quad), subset);
} else {
// Emulate complex blending using GrFillRectOp
GrSamplerState samplerState(GrSamplerState::WrapMode::kClamp, filter, mm);
@@ -1181,7 +1181,7 @@
}
fp = GrColorSpaceXformEffect::Make(std::move(fp), std::move(textureXform));
fp = GrBlendFragmentProcessor::Make(std::move(fp), nullptr, SkBlendMode::kModulate);
- if (saturate == GrTextureOp::Saturate::kYes) {
+ if (saturate == Saturate::kYes) {
fp = GrFragmentProcessor::ClampOutput(std::move(fp));
}
paint.setColorFragmentProcessor(std::move(fp));
@@ -1189,18 +1189,16 @@
}
}
-#if SK_GPU_V1
-
// A helper class that assists in breaking up bulk API quad draws into manageable chunks.
-class GrTextureOp::BatchSizeLimiter {
+class TextureOp::BatchSizeLimiter {
public:
- BatchSizeLimiter(skgpu::v1::SurfaceDrawContext* sdc,
+ BatchSizeLimiter(SurfaceDrawContext* sdc,
const GrClip* clip,
GrRecordingContext* rContext,
int numEntries,
GrSamplerState::Filter filter,
GrSamplerState::MipmapMode mm,
- GrTextureOp::Saturate saturate,
+ Saturate saturate,
SkCanvas::SrcRectConstraint constraint,
const SkMatrix& viewMatrix,
sk_sp<GrColorSpaceXform> textureColorSpaceXform)
@@ -1218,17 +1216,17 @@
void createOp(GrTextureSetEntry set[], int clumpSize, GrAAType aaType) {
int clumpProxyCount = proxy_run_count(&set[fNumClumped], clumpSize);
- GrOp::Owner op = TextureOp::Make(fContext,
- &set[fNumClumped],
- clumpSize,
- clumpProxyCount,
- fFilter,
- fMipmapMode,
- fSaturate,
- aaType,
- fConstraint,
- fViewMatrix,
- fTextureColorSpaceXform);
+ GrOp::Owner op = TextureOpImpl::Make(fContext,
+ &set[fNumClumped],
+ clumpSize,
+ clumpProxyCount,
+ fFilter,
+ fMipmapMode,
+ fSaturate,
+ aaType,
+ fConstraint,
+ fViewMatrix,
+ fTextureColorSpaceXform);
fSDC->addDrawOp(fClip, std::move(op));
fNumLeft -= clumpSize;
@@ -1239,38 +1237,38 @@
int baseIndex() const { return fNumClumped; }
private:
- skgpu::v1::SurfaceDrawContext* fSDC;
- const GrClip* fClip;
- GrRecordingContext* fContext;
- GrSamplerState::Filter fFilter;
- GrSamplerState::MipmapMode fMipmapMode;
- GrTextureOp::Saturate fSaturate;
- SkCanvas::SrcRectConstraint fConstraint;
- const SkMatrix& fViewMatrix;
- sk_sp<GrColorSpaceXform> fTextureColorSpaceXform;
+ SurfaceDrawContext* fSDC;
+ const GrClip* fClip;
+ GrRecordingContext* fContext;
+ GrSamplerState::Filter fFilter;
+ GrSamplerState::MipmapMode fMipmapMode;
+ Saturate fSaturate;
+ SkCanvas::SrcRectConstraint fConstraint;
+ const SkMatrix& fViewMatrix;
+ sk_sp<GrColorSpaceXform> fTextureColorSpaceXform;
- int fNumLeft;
- int fNumClumped = 0; // also the offset for the start of the next clump
+ int fNumLeft;
+ int fNumClumped = 0; // also the offset for the start of the next clump
};
// Greedily clump quad draws together until the index buffer limit is exceeded.
-void GrTextureOp::AddTextureSetOps(skgpu::v1::SurfaceDrawContext* sdc,
- const GrClip* clip,
- GrRecordingContext* context,
- GrTextureSetEntry set[],
- int cnt,
- int proxyRunCnt,
- GrSamplerState::Filter filter,
- GrSamplerState::MipmapMode mm,
- Saturate saturate,
- SkBlendMode blendMode,
- GrAAType aaType,
- SkCanvas::SrcRectConstraint constraint,
- const SkMatrix& viewMatrix,
- sk_sp<GrColorSpaceXform> textureColorSpaceXform) {
+void TextureOp::AddTextureSetOps(SurfaceDrawContext* sdc,
+ const GrClip* clip,
+ GrRecordingContext* context,
+ GrTextureSetEntry set[],
+ int cnt,
+ int proxyRunCnt,
+ GrSamplerState::Filter filter,
+ GrSamplerState::MipmapMode mm,
+ Saturate saturate,
+ SkBlendMode blendMode,
+ GrAAType aaType,
+ SkCanvas::SrcRectConstraint constraint,
+ const SkMatrix& viewMatrix,
+ sk_sp<GrColorSpaceXform> textureColorSpaceXform) {
// Ensure that the index buffer limits are lower than the proxy and quad count limits of
// the op's metadata so we don't need to worry about overflow.
- SkDEBUGCODE(TextureOp::ValidateResourceLimits();)
+ SkDEBUGCODE(TextureOpImpl::ValidateResourceLimits();)
SkASSERT(proxy_run_count(set, cnt) == proxyRunCnt);
// First check if we can support batches as a single op
@@ -1313,8 +1311,8 @@
// needed to clump things together.
if (cnt <= std::min(GrResourceProvider::MaxNumNonAAQuads(),
GrResourceProvider::MaxNumAAQuads())) {
- auto op = TextureOp::Make(context, set, cnt, proxyRunCnt, filter, mm, saturate, aaType,
- constraint, viewMatrix, std::move(textureColorSpaceXform));
+ auto op = TextureOpImpl::Make(context, set, cnt, proxyRunCnt, filter, mm, saturate, aaType,
+ constraint, viewMatrix, std::move(textureColorSpaceXform));
sdc->addDrawOp(clip, std::move(op));
return;
}
@@ -1381,14 +1379,15 @@
}
}
}
-#endif
+
+} // namespace skgpu::v1
#if GR_TEST_UTILS
#include "include/gpu/GrRecordingContext.h"
#include "src/gpu/GrProxyProvider.h"
#include "src/gpu/GrRecordingContextPriv.h"
-GR_DRAW_OP_TEST_DEFINE(TextureOp) {
+GR_DRAW_OP_TEST_DEFINE(TextureOpImpl) {
SkISize dims;
dims.fHeight = random->nextULessThan(90) + 10;
dims.fWidth = random->nextULessThan(90) + 10;
@@ -1433,7 +1432,8 @@
aaFlags |= random->nextBool() ? GrQuadAAFlags::kRight : GrQuadAAFlags::kNone;
aaFlags |= random->nextBool() ? GrQuadAAFlags::kBottom : GrQuadAAFlags::kNone;
bool useSubset = random->nextBool();
- auto saturate = random->nextBool() ? GrTextureOp::Saturate::kYes : GrTextureOp::Saturate::kNo;
+ auto saturate = random->nextBool() ? skgpu::v1::TextureOp::Saturate::kYes
+ : skgpu::v1::TextureOp::Saturate::kNo;
GrSurfaceProxyView proxyView(
std::move(proxy), origin,
context->priv().caps()->getReadSwizzle(format, GrColorType::kRGBA_8888));
@@ -1441,9 +1441,10 @@
random->nextRangeU(kUnknown_SkAlphaType + 1, kLastEnum_SkAlphaType));
DrawQuad quad = {GrQuad::MakeFromRect(rect, viewMatrix), GrQuad(srcRect), aaFlags};
- return GrTextureOp::Make(context, std::move(proxyView), alphaType, std::move(texXform), filter,
- mm, color, saturate, SkBlendMode::kSrcOver, aaType, &quad,
- useSubset ? &srcRect : nullptr);
+ return skgpu::v1::TextureOp::Make(context, std::move(proxyView), alphaType,
+ std::move(texXform), filter, mm, color, saturate,
+ SkBlendMode::kSrcOver, aaType, &quad,
+ useSubset ? &srcRect : nullptr);
}
-#endif
+#endif // GR_TEST_UTILS
diff --git a/src/gpu/ops/GrTextureOp.h b/src/gpu/ops/TextureOp.h
similarity index 94%
rename from src/gpu/ops/GrTextureOp.h
rename to src/gpu/ops/TextureOp.h
index 76c70d8..d976c90 100644
--- a/src/gpu/ops/GrTextureOp.h
+++ b/src/gpu/ops/TextureOp.h
@@ -4,8 +4,8 @@
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
-#ifndef GrTextureOp_DEFINED
-#define GrTextureOp_DEFINED
+#ifndef TextureOp_DEFINED
+#define TextureOp_DEFINED
#include "include/core/SkCanvas.h"
#include "include/core/SkRefCnt.h"
@@ -18,13 +18,16 @@
class GrClip;
class GrColorSpaceXform;
class GrDrawOp;
-namespace skgpu { namespace v1 { class SurfaceDrawContext; }}
class GrTextureProxy;
struct GrTextureSetEntry;
struct SkRect;
class SkMatrix;
-class GrTextureOp {
+namespace skgpu::v1 {
+
+class SurfaceDrawContext;
+
+class TextureOp {
public:
/**
@@ -85,4 +88,6 @@
class BatchSizeLimiter;
};
-#endif // GrTextureOp_DEFINED
+} // namespace skgpu::v1
+
+#endif // TextureOp_DEFINED
diff --git a/src/gpu/v1/SurfaceDrawContext.cpp b/src/gpu/v1/SurfaceDrawContext.cpp
index 6ae69eb..147e2df 100644
--- a/src/gpu/v1/SurfaceDrawContext.cpp
+++ b/src/gpu/v1/SurfaceDrawContext.cpp
@@ -65,7 +65,7 @@
#include "src/gpu/ops/GrRegionOp.h"
#include "src/gpu/ops/GrShadowRRectOp.h"
#include "src/gpu/ops/GrStrokeRectOp.h"
-#include "src/gpu/ops/GrTextureOp.h"
+#include "src/gpu/ops/TextureOp.h"
#include "src/gpu/text/GrSDFTControl.h"
#include "src/gpu/text/GrTextBlobCache.h"
#include "src/gpu/v1/PathRenderer.h"
@@ -714,14 +714,14 @@
const GrClip* finalClip = opt == QuadOptimization::kClipApplied ? nullptr : clip;
GrAAType aaType = this->chooseAAType(aa);
auto clampType = GrColorTypeClampType(this->colorInfo().colorType());
- auto saturate = clampType == GrClampType::kManual ? GrTextureOp::Saturate::kYes
- : GrTextureOp::Saturate::kNo;
+ auto saturate = clampType == GrClampType::kManual ? TextureOp::Saturate::kYes
+ : TextureOp::Saturate::kNo;
// Use the provided subset, although hypothetically we could detect that the cropped local
// quad is sufficiently inside the subset and the constraint could be dropped.
this->addDrawOp(finalClip,
- GrTextureOp::Make(fContext, std::move(proxyView), srcAlphaType,
- std::move(textureXform), filter, mm, color, saturate,
- blendMode, aaType, quad, subset));
+ TextureOp::Make(fContext, std::move(proxyView), srcAlphaType,
+ std::move(textureXform), filter, mm, color, saturate,
+ blendMode, aaType, quad, subset));
}
}
@@ -967,10 +967,10 @@
AutoCheckFlush acf(this->drawingManager());
GrAAType aaType = this->chooseAAType(aa);
auto clampType = GrColorTypeClampType(this->colorInfo().colorType());
- auto saturate = clampType == GrClampType::kManual ? GrTextureOp::Saturate::kYes
- : GrTextureOp::Saturate::kNo;
- GrTextureOp::AddTextureSetOps(this, clip, fContext, set, cnt, proxyRunCnt, filter, mm, saturate,
- mode, aaType, constraint, viewMatrix, std::move(texXform));
+ auto saturate = clampType == GrClampType::kManual ? TextureOp::Saturate::kYes
+ : TextureOp::Saturate::kNo;
+ TextureOp::AddTextureSetOps(this, clip, fContext, set, cnt, proxyRunCnt, filter, mm, saturate,
+ mode, aaType, constraint, viewMatrix, std::move(texXform));
}
void SurfaceDrawContext::drawVertices(const GrClip* clip,
diff --git a/tests/BulkRectTest.cpp b/tests/BulkRectTest.cpp
index 7a8c035..8fabae1 100644
--- a/tests/BulkRectTest.cpp
+++ b/tests/BulkRectTest.cpp
@@ -12,7 +12,7 @@
#include "src/gpu/GrProxyProvider.h"
#include "src/gpu/GrResourceProvider.h"
#include "src/gpu/ops/GrFillRectOp.h"
-#include "src/gpu/ops/GrTextureOp.h"
+#include "src/gpu/ops/TextureOp.h"
#include "src/gpu/v1/SurfaceDrawContext_v1.h"
#include "tests/Test.h"
@@ -147,35 +147,35 @@
quad.fLocal = GrQuad(set[i].fSrcRect);
quad.fEdgeFlags = set[i].fAAFlags;
- GrOp::Owner op = GrTextureOp::Make(dContext,
- set[i].fProxyView,
- set[i].fSrcAlphaType,
- nullptr,
- GrSamplerState::Filter::kNearest,
- GrSamplerState::MipmapMode::kNone,
- set[i].fColor,
- GrTextureOp::Saturate::kYes,
- blendMode,
- overallAA,
- &quad,
- nullptr);
+ GrOp::Owner op = skgpu::v1::TextureOp::Make(dContext,
+ set[i].fProxyView,
+ set[i].fSrcAlphaType,
+ nullptr,
+ GrSamplerState::Filter::kNearest,
+ GrSamplerState::MipmapMode::kNone,
+ set[i].fColor,
+ skgpu::v1::TextureOp::Saturate::kYes,
+ blendMode,
+ overallAA,
+ &quad,
+ nullptr);
sdc->addDrawOp(nullptr, std::move(op));
}
} else {
- GrTextureOp::AddTextureSetOps(sdc.get(),
- nullptr,
- dContext,
- set,
- requestedTotNumQuads,
- requestedTotNumQuads, // We alternate so proxyCnt == cnt
- GrSamplerState::Filter::kNearest,
- GrSamplerState::MipmapMode::kNone,
- GrTextureOp::Saturate::kYes,
- blendMode,
- overallAA,
- SkCanvas::kStrict_SrcRectConstraint,
- SkMatrix::I(),
- nullptr);
+ skgpu::v1::TextureOp::AddTextureSetOps(sdc.get(),
+ nullptr,
+ dContext,
+ set,
+ requestedTotNumQuads,
+ requestedTotNumQuads, // We alternate so proxyCnt == cnt
+ GrSamplerState::Filter::kNearest,
+ GrSamplerState::MipmapMode::kNone,
+ skgpu::v1::TextureOp::Saturate::kYes,
+ blendMode,
+ overallAA,
+ SkCanvas::kStrict_SrcRectConstraint,
+ SkMatrix::I(),
+ nullptr);
}
auto opsTask = sdc->testingOnly_PeekLastOpsTask();
@@ -190,7 +190,7 @@
// from being merged back into fewer ops.
expectedNumOps = requestedTotNumQuads;
}
- uint32_t expectedOpID = blendMode == SkBlendMode::kSrcOver ? GrTextureOp::ClassID()
+ uint32_t expectedOpID = blendMode == SkBlendMode::kSrcOver ? skgpu::v1::TextureOp::ClassID()
: GrFillRectOp::ClassID();
for (int i = 0; i < actualNumOps; ++i) {
const GrOp* tmp = opsTask->getChain(i);
diff --git a/tests/TextureOpTest.cpp b/tests/TextureOpTest.cpp
index 4bc9253..7d74484 100644
--- a/tests/TextureOpTest.cpp
+++ b/tests/TextureOpTest.cpp
@@ -12,8 +12,8 @@
#include "src/gpu/GrProxyProvider.h"
#include "src/gpu/GrRecordingContextPriv.h"
#include "src/gpu/geometry/GrQuad.h"
-#include "src/gpu/ops/GrTextureOp.h"
#include "src/gpu/ops/OpsTask.h"
+#include "src/gpu/ops/TextureOp.h"
#include "tests/Test.h"
class OpsTaskTestingAccess {
@@ -57,19 +57,19 @@
quad.fLocal = GrQuad(rect);
quad.fEdgeFlags = isAA ? GrQuadAAFlags::kAll : GrQuadAAFlags::kNone;
- return GrTextureOp::Make(dContext,
- proxyView,
- kPremul_SkAlphaType,
- nullptr,
- GrSamplerState::Filter::kNearest,
- GrSamplerState::MipmapMode::kNone,
- {1.f, 1.f, 1.f, 1.f},
- GrTextureOp::Saturate::kYes,
- SkBlendMode::kSrcOver,
- isAA ? GrAAType::kCoverage
- : GrAAType::kNone,
- &quad,
- nullptr);
+ return skgpu::v1::TextureOp::Make(dContext,
+ proxyView,
+ kPremul_SkAlphaType,
+ nullptr,
+ GrSamplerState::Filter::kNearest,
+ GrSamplerState::MipmapMode::kNone,
+ {1.f, 1.f, 1.f, 1.f},
+ skgpu::v1::TextureOp::Saturate::kYes,
+ SkBlendMode::kSrcOver,
+ isAA ? GrAAType::kCoverage
+ : GrAAType::kNone,
+ &quad,
+ nullptr);
}
// This unit test exercises the crbug.com/1112259 case.
diff --git a/tools/gpu/GrTest.cpp b/tools/gpu/GrTest.cpp
index 4cb5735..054111a 100644
--- a/tools/gpu/GrTest.cpp
+++ b/tools/gpu/GrTest.cpp
@@ -61,7 +61,7 @@
DRAW_OP_TEST_EXTERN(RRectOp);
DRAW_OP_TEST_EXTERN(ShadowRRectOp);
DRAW_OP_TEST_EXTERN(SmallPathOp);
-DRAW_OP_TEST_EXTERN(TextureOp);
+DRAW_OP_TEST_EXTERN(TextureOpImpl);
DRAW_OP_TEST_EXTERN(TriangulatingPathOp);
void GrDrawRandomOp(SkRandom* random, skgpu::v1::SurfaceDrawContext* sdc, GrPaint&& paint) {
@@ -92,7 +92,7 @@
DRAW_OP_TEST_ENTRY(RRectOp),
DRAW_OP_TEST_ENTRY(ShadowRRectOp),
DRAW_OP_TEST_ENTRY(SmallPathOp),
- DRAW_OP_TEST_ENTRY(TextureOp),
+ DRAW_OP_TEST_ENTRY(TextureOpImpl),
DRAW_OP_TEST_ENTRY(TriangulatingPathOp),
};