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