GrVertexWriter -> skgpu::VertexWriter
This class can now be shared with Graphite. Bug: skia:12524 Change-Id: I7841410b3e8e111a12298efe0a1898a33295873a Reviewed-on: https://skia-review.googlesource.com/c/skia/+/462556 Commit-Queue: Chris Dalton <csmartdalton@google.com> Reviewed-by: Greg Daniel <egdaniel@google.com>
This commit is contained in:
parent
c00c888db1
commit
52aee23ded
@ -215,7 +215,7 @@ DEF_PATH_TESS_BENCH(middle_out_triangulation,
|
||||
SkMatrix::I()) {
|
||||
sk_sp<const GrBuffer> buffer;
|
||||
int baseVertex;
|
||||
GrVertexWriter vertexWriter = static_cast<SkPoint*>(fTarget->makeVertexSpace(
|
||||
VertexWriter vertexWriter = static_cast<SkPoint*>(fTarget->makeVertexSpace(
|
||||
sizeof(SkPoint), kNumCubicsInChalkboard, &buffer, &baseVertex));
|
||||
int numTrianglesWritten;
|
||||
MiddleOutPolygonTriangulator::WritePathInnerFan(std::move(vertexWriter),
|
||||
|
@ -238,7 +238,6 @@ skia_gpu_sources = [
|
||||
"$_src/gpu/GrUtil.h",
|
||||
"$_src/gpu/GrVertexChunkArray.cpp",
|
||||
"$_src/gpu/GrVertexChunkArray.h",
|
||||
"$_src/gpu/GrVertexWriter.h",
|
||||
"$_src/gpu/GrVx.h",
|
||||
"$_src/gpu/GrWaitRenderTask.cpp",
|
||||
"$_src/gpu/GrWaitRenderTask.h",
|
||||
@ -255,6 +254,7 @@ skia_gpu_sources = [
|
||||
"$_src/gpu/SurfaceContext.h",
|
||||
"$_src/gpu/SurfaceFillContext.cpp",
|
||||
"$_src/gpu/SurfaceFillContext.h",
|
||||
"$_src/gpu/VertexWriter.h",
|
||||
|
||||
# Ops
|
||||
"$_src/gpu/effects/GrBezierEffect.cpp",
|
||||
|
@ -16,7 +16,7 @@
|
||||
#include "include/gpu/GrTypes.h"
|
||||
#include "include/private/SkColorData.h"
|
||||
#include "include/private/SkHalf.h"
|
||||
#include "src/gpu/GrVertexWriter.h"
|
||||
#include "src/gpu/VertexWriter.h"
|
||||
|
||||
/**
|
||||
* GrColor is 4 bytes for R, G, B, A, in a specific order defined below. Whether the color is
|
||||
@ -87,8 +87,8 @@ static inline uint64_t SkPMColor4f_toFP16(const SkPMColor4f& color) {
|
||||
|
||||
/**
|
||||
* GrVertexColor is a helper for writing colors to a vertex attribute. It stores either GrColor
|
||||
* or four half-float channels, depending on the wideColor parameter. GrVertexWriter will write
|
||||
* the correct amount of data. Note that the GP needs to have been constructed with the correct
|
||||
* or four half-float channels, depending on the wideColor parameter. VertexWriter will write the
|
||||
* correct amount of data. Note that the GP needs to have been constructed with the correct
|
||||
* attribute type for colors, to match the usage here.
|
||||
*/
|
||||
class GrVertexColor {
|
||||
@ -111,14 +111,16 @@ public:
|
||||
size_t size() const { return fWideColor ? 16 : 4; }
|
||||
|
||||
private:
|
||||
template<typename T> friend GrVertexWriter& operator<<(GrVertexWriter&, const T&);
|
||||
template <typename T>
|
||||
friend skgpu::VertexWriter& skgpu::operator<<(skgpu::VertexWriter&, const T&);
|
||||
|
||||
uint32_t fColor[4];
|
||||
bool fWideColor;
|
||||
};
|
||||
|
||||
template <>
|
||||
SK_MAYBE_UNUSED inline GrVertexWriter& operator<<(GrVertexWriter& w, const GrVertexColor& color) {
|
||||
SK_MAYBE_UNUSED inline skgpu::VertexWriter& skgpu::operator<<(skgpu::VertexWriter& w,
|
||||
const GrVertexColor& color) {
|
||||
w << color.fColor[0];
|
||||
if (color.fWideColor) {
|
||||
w << color.fColor[1]
|
||||
|
@ -24,8 +24,8 @@
|
||||
#include "src/gpu/GrResourceCache.h"
|
||||
#include "src/gpu/GrSemaphore.h"
|
||||
#include "src/gpu/GrTexture.h"
|
||||
#include "src/gpu/GrVertexWriter.h"
|
||||
#include "src/gpu/SkGr.h"
|
||||
#include "src/gpu/VertexWriter.h"
|
||||
|
||||
const int GrResourceProvider::kMinScratchTextureSize = 16;
|
||||
|
||||
@ -437,7 +437,7 @@ sk_sp<const GrGpuBuffer> GrResourceProvider::findOrMakeStaticBuffer(
|
||||
buffer->resourcePriv().setUniqueKey(uniqueKey);
|
||||
|
||||
// Map the buffer. Use a staging buffer on the heap if mapping isn't supported.
|
||||
GrVertexWriter vertexWriter = buffer->map();
|
||||
skgpu::VertexWriter vertexWriter = buffer->map();
|
||||
SkAutoTMalloc<char> stagingBuffer;
|
||||
if (!vertexWriter) {
|
||||
SkASSERT(!buffer->isMapped());
|
||||
|
@ -24,7 +24,6 @@ class GrRenderTarget;
|
||||
class GrResourceProviderPriv;
|
||||
class GrSemaphore;
|
||||
class GrSingleOwner;
|
||||
struct GrVertexWriter;
|
||||
class GrTexture;
|
||||
struct GrVkDrawableInfo;
|
||||
|
||||
@ -33,6 +32,8 @@ class SkDescriptor;
|
||||
class SkPath;
|
||||
class SkTypeface;
|
||||
|
||||
namespace skgpu { struct VertexWriter; }
|
||||
|
||||
/**
|
||||
* A factory for arbitrary resource types.
|
||||
*/
|
||||
@ -193,7 +194,7 @@ public:
|
||||
*
|
||||
* @return The buffer if successful, otherwise nullptr.
|
||||
*/
|
||||
using InitializeBufferFn = void(*)(GrVertexWriter, size_t bufferSize);
|
||||
using InitializeBufferFn = void(*)(skgpu::VertexWriter, size_t bufferSize);
|
||||
sk_sp<const GrGpuBuffer> findOrMakeStaticBuffer(GrGpuBufferType intendedType, size_t size,
|
||||
const GrUniqueKey& key, InitializeBufferFn);
|
||||
|
||||
|
@ -12,7 +12,7 @@
|
||||
#include "include/private/SkNoncopyable.h"
|
||||
#include "include/private/SkTArray.h"
|
||||
#include "src/gpu/GrBuffer.h"
|
||||
#include "src/gpu/GrVertexWriter.h"
|
||||
#include "src/gpu/VertexWriter.h"
|
||||
|
||||
class GrMeshDrawTarget;
|
||||
|
||||
@ -48,7 +48,7 @@ public:
|
||||
|
||||
// Appends 'count' contiguous vertices. These vertices are not guaranteed to be contiguous with
|
||||
// previous or future calls to appendVertices.
|
||||
SK_ALWAYS_INLINE GrVertexWriter appendVertices(int count) {
|
||||
SK_ALWAYS_INLINE skgpu::VertexWriter appendVertices(int count) {
|
||||
SkASSERT(count > 0);
|
||||
if (fCurrChunkVertexCount + count > fCurrChunkVertexCapacity && !this->allocChunk(count)) {
|
||||
SkDEBUGCODE(fLastAppendAmount = 0;)
|
||||
@ -61,7 +61,7 @@ public:
|
||||
fCurrChunkVertexWriter.makeOffset(fStride * count));
|
||||
}
|
||||
|
||||
SK_ALWAYS_INLINE GrVertexWriter appendVertex() { return this->appendVertices(1); }
|
||||
SK_ALWAYS_INLINE skgpu::VertexWriter appendVertex() { return this->appendVertices(1); }
|
||||
|
||||
// Pops the most recent 'count' contiguous vertices. Since there is no guarantee of contiguity
|
||||
// between appends, 'count' may be no larger than the most recent call to appendVertices().
|
||||
@ -82,7 +82,7 @@ private:
|
||||
const size_t fStride;
|
||||
int fMinVerticesPerChunk;
|
||||
|
||||
GrVertexWriter fCurrChunkVertexWriter;
|
||||
skgpu::VertexWriter fCurrChunkVertexWriter;
|
||||
int fCurrChunkVertexCount = 0;
|
||||
int fCurrChunkVertexCapacity = 0;
|
||||
|
||||
|
@ -5,43 +5,45 @@
|
||||
* found in the LICENSE file.
|
||||
*/
|
||||
|
||||
#ifndef GrVertexWriter_DEFINED
|
||||
#define GrVertexWriter_DEFINED
|
||||
#ifndef VertexWriter_DEFINED
|
||||
#define VertexWriter_DEFINED
|
||||
|
||||
#include "include/core/SkRect.h"
|
||||
#include "include/private/SkNx.h"
|
||||
#include "include/private/SkTemplates.h"
|
||||
#include <type_traits>
|
||||
|
||||
namespace skgpu {
|
||||
|
||||
/**
|
||||
* Helper for writing vertex data to a buffer. Usage:
|
||||
* GrVertexWriter vertices{target->makeVertexSpace(...)};
|
||||
* VertexWriter vertices{target->makeVertexSpace(...)};
|
||||
* vertices << A0 << B0 << C0 << ...;
|
||||
* vertices << A1 << B1 << C1 << ...;
|
||||
*
|
||||
* Each value must be POD (plain old data), or have a specialization of the "<<" operator.
|
||||
*/
|
||||
struct GrVertexWriter {
|
||||
struct VertexWriter {
|
||||
inline constexpr static uint32_t kIEEE_32_infinity = 0x7f800000;
|
||||
|
||||
void* fPtr;
|
||||
|
||||
GrVertexWriter() = default;
|
||||
GrVertexWriter(void* ptr) : fPtr(ptr) {}
|
||||
GrVertexWriter(const GrVertexWriter&) = delete;
|
||||
GrVertexWriter(GrVertexWriter&& that) { *this = std::move(that); }
|
||||
VertexWriter() = default;
|
||||
VertexWriter(void* ptr) : fPtr(ptr) {}
|
||||
VertexWriter(const VertexWriter&) = delete;
|
||||
VertexWriter(VertexWriter&& that) { *this = std::move(that); }
|
||||
|
||||
GrVertexWriter& operator=(const GrVertexWriter&) = delete;
|
||||
GrVertexWriter& operator=(GrVertexWriter&& that) {
|
||||
VertexWriter& operator=(const VertexWriter&) = delete;
|
||||
VertexWriter& operator=(VertexWriter&& that) {
|
||||
fPtr = that.fPtr;
|
||||
that.fPtr = nullptr;
|
||||
return *this;
|
||||
}
|
||||
|
||||
bool operator==(const GrVertexWriter& that) const { return fPtr == that.fPtr; }
|
||||
bool operator==(const VertexWriter& that) const { return fPtr == that.fPtr; }
|
||||
operator bool() const { return fPtr != nullptr; }
|
||||
|
||||
GrVertexWriter makeOffset(ptrdiff_t offsetInBytes) const {
|
||||
VertexWriter makeOffset(ptrdiff_t offsetInBytes) const {
|
||||
return {SkTAddOffset<void>(fPtr, offsetInBytes)};
|
||||
}
|
||||
|
||||
@ -83,11 +85,11 @@ struct GrVertexWriter {
|
||||
* - For any arguments where is_quad<Type>::value is true, a unique point will be written at
|
||||
* each vertex. To make a custom type be emitted as a quad, declare:
|
||||
*
|
||||
* template<> struct GrVertexWriter::is_quad<MyQuadClass> : std::true_type {};
|
||||
* template<> struct VertexWriter::is_quad<MyQuadClass> : std::true_type {};
|
||||
*
|
||||
* and define:
|
||||
*
|
||||
* MyQuadClass::writeVertex(int cornerIdx, GrVertexWriter&) const { ... }
|
||||
* MyQuadClass::writeVertex(int cornerIdx, VertexWriter&) const { ... }
|
||||
*
|
||||
* - For any arguments where is_quad<Type>::value is false, its value will be replicated at each
|
||||
* vertex.
|
||||
@ -97,7 +99,7 @@ struct GrVertexWriter {
|
||||
|
||||
template <typename T>
|
||||
struct TriStrip {
|
||||
void writeVertex(int cornerIdx, GrVertexWriter& w) const {
|
||||
void writeVertex(int cornerIdx, VertexWriter& w) const {
|
||||
switch (cornerIdx) {
|
||||
case 0: w << l << t; return;
|
||||
case 1: w << l << b; return;
|
||||
@ -119,7 +121,7 @@ struct GrVertexWriter {
|
||||
|
||||
template <typename T>
|
||||
struct TriFan {
|
||||
void writeVertex(int cornerIdx, GrVertexWriter& w) const {
|
||||
void writeVertex(int cornerIdx, VertexWriter& w) const {
|
||||
switch (cornerIdx) {
|
||||
case 0: w << l << t; return;
|
||||
case 1: w << l << b; return;
|
||||
@ -144,8 +146,6 @@ struct GrVertexWriter {
|
||||
}
|
||||
|
||||
private:
|
||||
template<typename T> friend GrVertexWriter& operator<<(GrVertexWriter&, const T&);
|
||||
|
||||
template <int kCornerIdx, typename T, typename... Args>
|
||||
std::enable_if_t<!is_quad<T>::value, void> writeQuadVertex(const T& val,
|
||||
const Args&... remainder) {
|
||||
@ -165,7 +165,7 @@ private:
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
inline GrVertexWriter& operator<<(GrVertexWriter& w, const T& val) {
|
||||
inline VertexWriter& operator<<(VertexWriter& w, const T& val) {
|
||||
static_assert(std::is_pod<T>::value, "");
|
||||
memcpy(w.fPtr, &val, sizeof(T));
|
||||
w = w.makeOffset(sizeof(T));
|
||||
@ -173,7 +173,7 @@ inline GrVertexWriter& operator<<(GrVertexWriter& w, const T& val) {
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
inline GrVertexWriter& operator<<(GrVertexWriter& w, const GrVertexWriter::Conditional<T>& val) {
|
||||
inline VertexWriter& operator<<(VertexWriter& w, const VertexWriter::Conditional<T>& val) {
|
||||
static_assert(std::is_pod<T>::value, "");
|
||||
if (val.fCondition) {
|
||||
w << val.fValue;
|
||||
@ -182,22 +182,24 @@ inline GrVertexWriter& operator<<(GrVertexWriter& w, const GrVertexWriter::Condi
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
inline GrVertexWriter& operator<<(GrVertexWriter& w, const GrVertexWriter::Skip<T>& val) {
|
||||
inline VertexWriter& operator<<(VertexWriter& w, const VertexWriter::Skip<T>& val) {
|
||||
w = w.makeOffset(sizeof(T));
|
||||
return w;
|
||||
}
|
||||
|
||||
template <>
|
||||
SK_MAYBE_UNUSED inline GrVertexWriter& operator<<(GrVertexWriter& w, const Sk4f& vector) {
|
||||
SK_MAYBE_UNUSED inline VertexWriter& operator<<(VertexWriter& w, const Sk4f& vector) {
|
||||
vector.store(w.fPtr);
|
||||
w = w.makeOffset(sizeof(vector));
|
||||
return w;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
struct GrVertexWriter::is_quad<GrVertexWriter::TriStrip<T>> : std::true_type {};
|
||||
struct VertexWriter::is_quad<VertexWriter::TriStrip<T>> : std::true_type {};
|
||||
|
||||
template <typename T>
|
||||
struct GrVertexWriter::is_quad<GrVertexWriter::TriFan<T>> : std::true_type {};
|
||||
struct VertexWriter::is_quad<VertexWriter::TriFan<T>> : std::true_type {};
|
||||
|
||||
} // namespace skgpu
|
||||
|
||||
#endif
|
@ -12,8 +12,8 @@
|
||||
#include "include/private/SkTArray.h"
|
||||
#include "src/core/SkGeometry.h"
|
||||
#include "src/core/SkPathPriv.h"
|
||||
#include "src/gpu/GrVertexWriter.h"
|
||||
#include "src/gpu/GrVx.h"
|
||||
#include "src/gpu/VertexWriter.h"
|
||||
|
||||
class SkMatrix;
|
||||
|
||||
@ -136,7 +136,7 @@ void convertCubicToQuadsConstrainToTangents(const SkPoint p[4],
|
||||
// Converts the given line to a cubic bezier.
|
||||
// NOTE: This method interpolates at 1/3 and 2/3, but if suitable in context, the cubic
|
||||
// {p0, p0, p1, p1} may also work.
|
||||
inline void writeLineAsCubic(SkPoint startPt, SkPoint endPt, GrVertexWriter* writer) {
|
||||
inline void writeLineAsCubic(SkPoint startPt, SkPoint endPt, skgpu::VertexWriter* writer) {
|
||||
using grvx::float2, skvx::bit_pun;
|
||||
float2 p0 = bit_pun<float2>(startPt);
|
||||
float2 p1 = bit_pun<float2>(endPt);
|
||||
@ -145,7 +145,7 @@ inline void writeLineAsCubic(SkPoint startPt, SkPoint endPt, GrVertexWriter* wri
|
||||
}
|
||||
|
||||
// Converts the given quadratic bezier to a cubic.
|
||||
inline void writeQuadAsCubic(const SkPoint p[3], GrVertexWriter* writer) {
|
||||
inline void writeQuadAsCubic(const SkPoint p[3], skgpu::VertexWriter* writer) {
|
||||
using grvx::float2, skvx::bit_pun;
|
||||
float2 p0 = bit_pun<float2>(p[0]);
|
||||
float2 p1 = bit_pun<float2>(p[1]);
|
||||
@ -154,7 +154,7 @@ inline void writeQuadAsCubic(const SkPoint p[3], GrVertexWriter* writer) {
|
||||
*writer << p0 << (p0*(1/3.f) + c) << (p2 * (1/3.f) + c) << p2;
|
||||
}
|
||||
inline void convertQuadToCubic(const SkPoint p[3], SkPoint out[4]) {
|
||||
GrVertexWriter writer(out);
|
||||
skgpu::VertexWriter writer(out);
|
||||
writeQuadAsCubic(p, &writer);
|
||||
}
|
||||
|
||||
|
@ -12,7 +12,7 @@
|
||||
#include "include/core/SkPoint.h"
|
||||
#include "include/core/SkPoint3.h"
|
||||
#include "include/private/SkVx.h"
|
||||
#include "src/gpu/GrVertexWriter.h"
|
||||
#include "src/gpu/VertexWriter.h"
|
||||
|
||||
enum class GrQuadAAFlags;
|
||||
|
||||
@ -67,7 +67,7 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
void writeVertex(int cornerIdx, GrVertexWriter& w) const {
|
||||
void writeVertex(int cornerIdx, skgpu::VertexWriter& w) const {
|
||||
w << this->point(cornerIdx);
|
||||
}
|
||||
|
||||
@ -169,7 +169,7 @@ private:
|
||||
Type fType = Type::kAxisAligned;
|
||||
};
|
||||
|
||||
template<> struct GrVertexWriter::is_quad<GrQuad> : std::true_type {};
|
||||
template<> struct skgpu::VertexWriter::is_quad<GrQuad> : std::true_type {};
|
||||
|
||||
// A simple struct representing the common work unit of a pair of device and local coordinates, as
|
||||
// well as the edge flags controlling anti-aliasing for the quadrilateral when drawn.
|
||||
|
@ -8,7 +8,7 @@
|
||||
#include "src/gpu/geometry/GrTriangulator.h"
|
||||
|
||||
#include "src/gpu/GrEagerVertexAllocator.h"
|
||||
#include "src/gpu/GrVertexWriter.h"
|
||||
#include "src/gpu/VertexWriter.h"
|
||||
#include "src/gpu/geometry/GrPathUtils.h"
|
||||
|
||||
#include "src/core/SkGeometry.h"
|
||||
@ -81,7 +81,7 @@ bool GrTriangulator::Comparator::sweep_lt(const SkPoint& a, const SkPoint& b) co
|
||||
}
|
||||
|
||||
static inline void* emit_vertex(Vertex* v, bool emitCoverage, void* data) {
|
||||
GrVertexWriter verts{data};
|
||||
skgpu::VertexWriter verts{data};
|
||||
verts << v->fPoint;
|
||||
|
||||
if (emitCoverage) {
|
||||
|
@ -19,7 +19,7 @@
|
||||
#include "src/gpu/GrGeometryProcessor.h"
|
||||
#include "src/gpu/GrProcessor.h"
|
||||
#include "src/gpu/GrProgramInfo.h"
|
||||
#include "src/gpu/GrVertexWriter.h"
|
||||
#include "src/gpu/VertexWriter.h"
|
||||
#include "src/gpu/geometry/GrPathUtils.h"
|
||||
#include "src/gpu/geometry/GrStyledShape.h"
|
||||
#include "src/gpu/glsl/GrGLSLFragmentShaderBuilder.h"
|
||||
@ -31,6 +31,8 @@
|
||||
#include "src/gpu/ops/GrSimpleMeshDrawOpHelperWithStencil.h"
|
||||
#include "src/gpu/v1/SurfaceDrawContext_v1.h"
|
||||
|
||||
namespace skgpu::v1 {
|
||||
|
||||
namespace {
|
||||
|
||||
struct Segment {
|
||||
@ -364,7 +366,7 @@ void create_vertices(const SegmentArray& segments,
|
||||
const SkPoint& fanPt,
|
||||
const GrVertexColor& color,
|
||||
DrawArray* draws,
|
||||
GrVertexWriter& verts,
|
||||
VertexWriter& verts,
|
||||
uint16_t* idxs,
|
||||
size_t vertexStride) {
|
||||
Draw* draw = &draws->push_back();
|
||||
@ -800,8 +802,10 @@ private:
|
||||
sk_sp<const GrBuffer> vertexBuffer;
|
||||
int firstVertex;
|
||||
|
||||
GrVertexWriter verts{target->makeVertexSpace(kVertexStride, vertexCount,
|
||||
&vertexBuffer, &firstVertex)};
|
||||
VertexWriter verts{target->makeVertexSpace(kVertexStride,
|
||||
vertexCount,
|
||||
&vertexBuffer,
|
||||
&firstVertex)};
|
||||
|
||||
if (!verts.fPtr) {
|
||||
SkDebugf("Could not allocate vertices\n");
|
||||
@ -893,23 +897,8 @@ private:
|
||||
|
||||
} // anonymous namespace
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#if GR_TEST_UTILS
|
||||
|
||||
GR_DRAW_OP_TEST_DEFINE(AAConvexPathOp) {
|
||||
SkMatrix viewMatrix = GrTest::TestMatrixInvertible(random);
|
||||
const SkPath& path = GrTest::TestPathConvex(random);
|
||||
const GrUserStencilSettings* stencilSettings = GrGetRandomStencil(random, context);
|
||||
return AAConvexPathOp::Make(context, std::move(paint), viewMatrix, path, stencilSettings);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
namespace skgpu::v1 {
|
||||
|
||||
PathRenderer::CanDrawPath AAConvexPathRenderer::onCanDrawPath(const CanDrawPathArgs& args) const {
|
||||
// This check requires convexity and known direction, since the direction is used to build
|
||||
// the geometry segments. Degenerate convex paths will fall through to some other path renderer.
|
||||
@ -939,3 +928,15 @@ bool AAConvexPathRenderer::onDrawPath(const DrawPathArgs& args) {
|
||||
}
|
||||
|
||||
} // namespace skgpu::v1
|
||||
|
||||
#if GR_TEST_UTILS
|
||||
|
||||
GR_DRAW_OP_TEST_DEFINE(AAConvexPathOp) {
|
||||
SkMatrix viewMatrix = GrTest::TestMatrixInvertible(random);
|
||||
const SkPath& path = GrTest::TestPathConvex(random);
|
||||
const GrUserStencilSettings* stencilSettings = GrGetRandomStencil(random, context);
|
||||
return skgpu::v1::AAConvexPathOp::Make(context, std::move(paint), viewMatrix, path,
|
||||
stencilSettings);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@ -20,7 +20,7 @@
|
||||
#include "src/gpu/GrProcessor.h"
|
||||
#include "src/gpu/GrProgramInfo.h"
|
||||
#include "src/gpu/GrStyle.h"
|
||||
#include "src/gpu/GrVertexWriter.h"
|
||||
#include "src/gpu/VertexWriter.h"
|
||||
#include "src/gpu/geometry/GrAAConvexTessellator.h"
|
||||
#include "src/gpu/geometry/GrPathUtils.h"
|
||||
#include "src/gpu/geometry/GrStyledShape.h"
|
||||
@ -29,6 +29,8 @@
|
||||
#include "src/gpu/v1/SurfaceDrawContext_v1.h"
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
namespace skgpu::v1 {
|
||||
|
||||
namespace {
|
||||
|
||||
static const int DEFAULT_BUFFER_SIZE = 100;
|
||||
@ -44,13 +46,13 @@ void extract_verts(const GrAAConvexTessellator& tess,
|
||||
const GrVertexColor& color,
|
||||
uint16_t firstIndex,
|
||||
uint16_t* idxs) {
|
||||
GrVertexWriter verts{vertData};
|
||||
VertexWriter verts{vertData};
|
||||
for (int i = 0; i < tess.numPts(); ++i) {
|
||||
SkPoint lc;
|
||||
if (localCoordsMatrix) {
|
||||
localCoordsMatrix->mapPoints(&lc, &tess.point(i), 1);
|
||||
}
|
||||
verts << tess.point(i) << color << GrVertexWriter::If(localCoordsMatrix, lc)
|
||||
verts << tess.point(i) << color << VertexWriter::If(localCoordsMatrix, lc)
|
||||
<< tess.coverage(i);
|
||||
}
|
||||
|
||||
@ -339,42 +341,6 @@ private:
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#if GR_TEST_UTILS
|
||||
|
||||
GR_DRAW_OP_TEST_DEFINE(AAFlatteningConvexPathOp) {
|
||||
SkMatrix viewMatrix = GrTest::TestMatrixPreservesRightAngles(random);
|
||||
const SkPath& path = GrTest::TestPathConvex(random);
|
||||
|
||||
SkStrokeRec::Style styles[3] = { SkStrokeRec::kFill_Style,
|
||||
SkStrokeRec::kStroke_Style,
|
||||
SkStrokeRec::kStrokeAndFill_Style };
|
||||
|
||||
SkStrokeRec::Style style = styles[random->nextU() % 3];
|
||||
|
||||
SkScalar strokeWidth = -1.f;
|
||||
SkPaint::Join join = SkPaint::kMiter_Join;
|
||||
SkScalar miterLimit = 0.5f;
|
||||
|
||||
if (SkStrokeRec::kFill_Style != style) {
|
||||
strokeWidth = random->nextRangeF(1.0f, 10.0f);
|
||||
if (random->nextBool()) {
|
||||
join = SkPaint::kMiter_Join;
|
||||
} else {
|
||||
join = SkPaint::kBevel_Join;
|
||||
}
|
||||
miterLimit = random->nextRangeF(0.5f, 2.0f);
|
||||
}
|
||||
const GrUserStencilSettings* stencilSettings = GrGetRandomStencil(random, context);
|
||||
return AAFlatteningConvexPathOp::Make(context, std::move(paint), viewMatrix, path, strokeWidth,
|
||||
style, join, miterLimit, stencilSettings);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
namespace skgpu::v1 {
|
||||
|
||||
PathRenderer::CanDrawPath
|
||||
AALinearizingConvexPathRenderer::onCanDrawPath(const CanDrawPathArgs& args) const {
|
||||
if (GrAAType::kCoverage != args.fAAType) {
|
||||
@ -446,3 +412,36 @@ bool AALinearizingConvexPathRenderer::onDrawPath(const DrawPathArgs& args) {
|
||||
}
|
||||
|
||||
} // namespace skgpu::v1
|
||||
|
||||
#if GR_TEST_UTILS
|
||||
|
||||
GR_DRAW_OP_TEST_DEFINE(AAFlatteningConvexPathOp) {
|
||||
SkMatrix viewMatrix = GrTest::TestMatrixPreservesRightAngles(random);
|
||||
const SkPath& path = GrTest::TestPathConvex(random);
|
||||
|
||||
SkStrokeRec::Style styles[3] = { SkStrokeRec::kFill_Style,
|
||||
SkStrokeRec::kStroke_Style,
|
||||
SkStrokeRec::kStrokeAndFill_Style };
|
||||
|
||||
SkStrokeRec::Style style = styles[random->nextU() % 3];
|
||||
|
||||
SkScalar strokeWidth = -1.f;
|
||||
SkPaint::Join join = SkPaint::kMiter_Join;
|
||||
SkScalar miterLimit = 0.5f;
|
||||
|
||||
if (SkStrokeRec::kFill_Style != style) {
|
||||
strokeWidth = random->nextRangeF(1.0f, 10.0f);
|
||||
if (random->nextBool()) {
|
||||
join = SkPaint::kMiter_Join;
|
||||
} else {
|
||||
join = SkPaint::kBevel_Join;
|
||||
}
|
||||
miterLimit = random->nextRangeF(0.5f, 2.0f);
|
||||
}
|
||||
const GrUserStencilSettings* stencilSettings = GrGetRandomStencil(random, context);
|
||||
return skgpu::v1::AAFlatteningConvexPathOp::Make(context, std::move(paint), viewMatrix, path,
|
||||
strokeWidth, style, join, miterLimit,
|
||||
stencilSettings);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@ -7,7 +7,7 @@
|
||||
|
||||
#include "src/gpu/ops/AtlasInstancedHelper.h"
|
||||
|
||||
#include "src/gpu/GrVertexWriter.h"
|
||||
#include "src/gpu/VertexWriter.h"
|
||||
#include "src/gpu/glsl/GrGLSLFragmentShaderBuilder.h"
|
||||
#include "src/gpu/glsl/GrGLSLVarying.h"
|
||||
#include "src/gpu/glsl/GrGLSLVertexGeoBuilder.h"
|
||||
@ -22,7 +22,7 @@ void AtlasInstancedHelper::appendInstanceAttribs(
|
||||
}
|
||||
}
|
||||
|
||||
void AtlasInstancedHelper::writeInstanceData(GrVertexWriter* instanceWriter,
|
||||
void AtlasInstancedHelper::writeInstanceData(VertexWriter* instanceWriter,
|
||||
const Instance* i) const {
|
||||
SkASSERT(i->fLocationInAtlas.x() >= 0);
|
||||
SkASSERT(i->fLocationInAtlas.y() >= 0);
|
||||
@ -34,8 +34,8 @@ void AtlasInstancedHelper::writeInstanceData(GrVertexWriter* instanceWriter,
|
||||
(float)i->fLocationInAtlas.y() <<
|
||||
(float)i->fPathDevIBounds.left() <<
|
||||
(float)i->fPathDevIBounds.top() <<
|
||||
GrVertexWriter::If(fShaderFlags & ShaderFlags::kCheckBounds,
|
||||
SkSize::Make(i->fPathDevIBounds.size()));
|
||||
VertexWriter::If(fShaderFlags & ShaderFlags::kCheckBounds,
|
||||
SkSize::Make(i->fPathDevIBounds.size()));
|
||||
}
|
||||
|
||||
void AtlasInstancedHelper::injectShaderCode(
|
||||
|
@ -13,8 +13,6 @@
|
||||
#include "src/gpu/GrSurfaceProxyView.h"
|
||||
#include "src/gpu/glsl/GrGLSLUniformHandler.h"
|
||||
|
||||
struct GrVertexWriter;
|
||||
|
||||
namespace skgpu::v1 {
|
||||
|
||||
// This class encapsulates all the necessary steps for an instanced GrGeometryProcessor to clip
|
||||
@ -74,7 +72,7 @@ public:
|
||||
|
||||
// Writes out the given instance data, formatted for the specific attribs that we added during
|
||||
// appendInstanceAttribs().
|
||||
void writeInstanceData(GrVertexWriter* instanceWriter, const Instance*) const;
|
||||
void writeInstanceData(VertexWriter* instanceWriter, const Instance*) const;
|
||||
|
||||
// Injects vertex code, fragment code, varyings, and uniforms to ultimately multiply
|
||||
// "args.fOutputCoverage" in the fragment shader by the atlas coverage.
|
||||
|
@ -20,8 +20,8 @@
|
||||
#include "src/gpu/GrProgramInfo.h"
|
||||
#include "src/gpu/GrRecordingContextPriv.h"
|
||||
#include "src/gpu/GrStyle.h"
|
||||
#include "src/gpu/GrVertexWriter.h"
|
||||
#include "src/gpu/SkGr.h"
|
||||
#include "src/gpu/VertexWriter.h"
|
||||
#include "src/gpu/geometry/GrQuad.h"
|
||||
#include "src/gpu/glsl/GrGLSLFragmentShaderBuilder.h"
|
||||
#include "src/gpu/glsl/GrGLSLProgramDataManager.h"
|
||||
@ -37,6 +37,8 @@ using AAMode = skgpu::v1::DashOp::AAMode;
|
||||
static const int kAAModeCnt = static_cast<int>(skgpu::v1::DashOp::AAMode::kCoverageWithMSAA) + 1;
|
||||
#endif
|
||||
|
||||
namespace skgpu::v1::DashOp {
|
||||
|
||||
namespace {
|
||||
|
||||
void calc_dash_scaling(SkScalar* parallelScale, SkScalar* perpScale,
|
||||
@ -116,7 +118,7 @@ enum DashCap {
|
||||
};
|
||||
|
||||
void setup_dashed_rect(const SkRect& rect,
|
||||
GrVertexWriter& vertices,
|
||||
VertexWriter& vertices,
|
||||
const SkMatrix& matrix,
|
||||
SkScalar offset,
|
||||
SkScalar bloatX,
|
||||
@ -139,7 +141,7 @@ void setup_dashed_rect(const SkRect& rect,
|
||||
SkScalar centerX = SkScalarHalf(endInterval);
|
||||
|
||||
vertices.writeQuad(GrQuad::MakeFromRect(rect, matrix),
|
||||
GrVertexWriter::TriStripFromRect(dashRect),
|
||||
VertexWriter::TriStripFromRect(dashRect),
|
||||
intervalLength,
|
||||
radius,
|
||||
centerX);
|
||||
@ -152,7 +154,7 @@ void setup_dashed_rect(const SkRect& rect,
|
||||
halfOffLen + startInterval - 0.5f, halfStroke - 0.5f);
|
||||
|
||||
vertices.writeQuad(GrQuad::MakeFromRect(rect, matrix),
|
||||
GrVertexWriter::TriStripFromRect(dashRect),
|
||||
VertexWriter::TriStripFromRect(dashRect),
|
||||
intervalLength,
|
||||
rectParam);
|
||||
}
|
||||
@ -561,7 +563,7 @@ private:
|
||||
}
|
||||
|
||||
QuadHelper helper(target, fProgramInfo->geomProc().vertexStride(), totalRectCount);
|
||||
GrVertexWriter vertices{ helper.vertices() };
|
||||
VertexWriter vertices{ helper.vertices() };
|
||||
if (!vertices.fPtr) {
|
||||
return;
|
||||
}
|
||||
@ -1124,90 +1126,6 @@ GrGeometryProcessor* make_dash_gp(SkArenaAlloc* arena,
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#if GR_TEST_UTILS
|
||||
|
||||
#include "src/gpu/GrDrawOpTest.h"
|
||||
|
||||
GR_DRAW_OP_TEST_DEFINE(DashOpImpl) {
|
||||
SkMatrix viewMatrix = GrTest::TestMatrixPreservesRightAngles(random);
|
||||
AAMode aaMode;
|
||||
do {
|
||||
aaMode = static_cast<AAMode>(random->nextULessThan(kAAModeCnt));
|
||||
} while (AAMode::kCoverageWithMSAA == aaMode && numSamples <= 1);
|
||||
|
||||
// We can only dash either horizontal or vertical lines
|
||||
SkPoint pts[2];
|
||||
if (random->nextBool()) {
|
||||
// vertical
|
||||
pts[0].fX = 1.f;
|
||||
pts[0].fY = random->nextF() * 10.f;
|
||||
pts[1].fX = 1.f;
|
||||
pts[1].fY = random->nextF() * 10.f;
|
||||
} else {
|
||||
// horizontal
|
||||
pts[0].fX = random->nextF() * 10.f;
|
||||
pts[0].fY = 1.f;
|
||||
pts[1].fX = random->nextF() * 10.f;
|
||||
pts[1].fY = 1.f;
|
||||
}
|
||||
|
||||
// pick random cap
|
||||
SkPaint::Cap cap = SkPaint::Cap(random->nextULessThan(SkPaint::kCapCount));
|
||||
|
||||
SkScalar intervals[2];
|
||||
|
||||
// We can only dash with the following intervals
|
||||
enum Intervals {
|
||||
kOpenOpen_Intervals ,
|
||||
kOpenClose_Intervals,
|
||||
kCloseOpen_Intervals,
|
||||
};
|
||||
|
||||
Intervals intervalType = SkPaint::kRound_Cap == cap ?
|
||||
kOpenClose_Intervals :
|
||||
Intervals(random->nextULessThan(kCloseOpen_Intervals + 1));
|
||||
static const SkScalar kIntervalMin = 0.1f;
|
||||
static const SkScalar kIntervalMinCircles = 1.f; // Must be >= to stroke width
|
||||
static const SkScalar kIntervalMax = 10.f;
|
||||
switch (intervalType) {
|
||||
case kOpenOpen_Intervals:
|
||||
intervals[0] = random->nextRangeScalar(kIntervalMin, kIntervalMax);
|
||||
intervals[1] = random->nextRangeScalar(kIntervalMin, kIntervalMax);
|
||||
break;
|
||||
case kOpenClose_Intervals: {
|
||||
intervals[0] = 0.f;
|
||||
SkScalar min = SkPaint::kRound_Cap == cap ? kIntervalMinCircles : kIntervalMin;
|
||||
intervals[1] = random->nextRangeScalar(min, kIntervalMax);
|
||||
break;
|
||||
}
|
||||
case kCloseOpen_Intervals:
|
||||
intervals[0] = random->nextRangeScalar(kIntervalMin, kIntervalMax);
|
||||
intervals[1] = 0.f;
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
// phase is 0 < sum (i0, i1)
|
||||
SkScalar phase = random->nextRangeScalar(0, intervals[0] + intervals[1]);
|
||||
|
||||
SkPaint p;
|
||||
p.setStyle(SkPaint::kStroke_Style);
|
||||
p.setStrokeWidth(SkIntToScalar(1));
|
||||
p.setStrokeCap(cap);
|
||||
p.setPathEffect(GrTest::TestDashPathEffect::Make(intervals, 2, phase));
|
||||
|
||||
GrStyle style(p);
|
||||
|
||||
return skgpu::v1::DashOp::MakeDashLineOp(context, std::move(paint), viewMatrix, pts, aaMode,
|
||||
style, GrGetRandomStencil(random, context));
|
||||
}
|
||||
|
||||
#endif // GR_TEST_UTILS
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
namespace skgpu::v1::DashOp {
|
||||
|
||||
GrOp::Owner MakeDashLineOp(GrRecordingContext* context,
|
||||
GrPaint&& paint,
|
||||
const SkMatrix& viewMatrix,
|
||||
@ -1306,3 +1224,83 @@ bool CanDrawDashLine(const SkPoint pts[2], const GrStyle& style, const SkMatrix&
|
||||
}
|
||||
|
||||
} // namespace skgpu::v1::DashOp
|
||||
|
||||
#if GR_TEST_UTILS
|
||||
|
||||
#include "src/gpu/GrDrawOpTest.h"
|
||||
|
||||
GR_DRAW_OP_TEST_DEFINE(DashOpImpl) {
|
||||
SkMatrix viewMatrix = GrTest::TestMatrixPreservesRightAngles(random);
|
||||
AAMode aaMode;
|
||||
do {
|
||||
aaMode = static_cast<AAMode>(random->nextULessThan(kAAModeCnt));
|
||||
} while (AAMode::kCoverageWithMSAA == aaMode && numSamples <= 1);
|
||||
|
||||
// We can only dash either horizontal or vertical lines
|
||||
SkPoint pts[2];
|
||||
if (random->nextBool()) {
|
||||
// vertical
|
||||
pts[0].fX = 1.f;
|
||||
pts[0].fY = random->nextF() * 10.f;
|
||||
pts[1].fX = 1.f;
|
||||
pts[1].fY = random->nextF() * 10.f;
|
||||
} else {
|
||||
// horizontal
|
||||
pts[0].fX = random->nextF() * 10.f;
|
||||
pts[0].fY = 1.f;
|
||||
pts[1].fX = random->nextF() * 10.f;
|
||||
pts[1].fY = 1.f;
|
||||
}
|
||||
|
||||
// pick random cap
|
||||
SkPaint::Cap cap = SkPaint::Cap(random->nextULessThan(SkPaint::kCapCount));
|
||||
|
||||
SkScalar intervals[2];
|
||||
|
||||
// We can only dash with the following intervals
|
||||
enum Intervals {
|
||||
kOpenOpen_Intervals ,
|
||||
kOpenClose_Intervals,
|
||||
kCloseOpen_Intervals,
|
||||
};
|
||||
|
||||
Intervals intervalType = SkPaint::kRound_Cap == cap ?
|
||||
kOpenClose_Intervals :
|
||||
Intervals(random->nextULessThan(kCloseOpen_Intervals + 1));
|
||||
static const SkScalar kIntervalMin = 0.1f;
|
||||
static const SkScalar kIntervalMinCircles = 1.f; // Must be >= to stroke width
|
||||
static const SkScalar kIntervalMax = 10.f;
|
||||
switch (intervalType) {
|
||||
case kOpenOpen_Intervals:
|
||||
intervals[0] = random->nextRangeScalar(kIntervalMin, kIntervalMax);
|
||||
intervals[1] = random->nextRangeScalar(kIntervalMin, kIntervalMax);
|
||||
break;
|
||||
case kOpenClose_Intervals: {
|
||||
intervals[0] = 0.f;
|
||||
SkScalar min = SkPaint::kRound_Cap == cap ? kIntervalMinCircles : kIntervalMin;
|
||||
intervals[1] = random->nextRangeScalar(min, kIntervalMax);
|
||||
break;
|
||||
}
|
||||
case kCloseOpen_Intervals:
|
||||
intervals[0] = random->nextRangeScalar(kIntervalMin, kIntervalMax);
|
||||
intervals[1] = 0.f;
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
// phase is 0 < sum (i0, i1)
|
||||
SkScalar phase = random->nextRangeScalar(0, intervals[0] + intervals[1]);
|
||||
|
||||
SkPaint p;
|
||||
p.setStyle(SkPaint::kStroke_Style);
|
||||
p.setStrokeWidth(SkIntToScalar(1));
|
||||
p.setStrokeCap(cap);
|
||||
p.setPathEffect(GrTest::TestDashPathEffect::Make(intervals, 2, phase));
|
||||
|
||||
GrStyle style(p);
|
||||
|
||||
return skgpu::v1::DashOp::MakeDashLineOp(context, std::move(paint), viewMatrix, pts, aaMode,
|
||||
style, GrGetRandomStencil(random, context));
|
||||
}
|
||||
|
||||
#endif // GR_TEST_UTILS
|
||||
|
@ -12,7 +12,7 @@
|
||||
#include "src/gpu/GrOpsRenderPass.h"
|
||||
#include "src/gpu/GrProgramInfo.h"
|
||||
#include "src/gpu/GrResourceProvider.h"
|
||||
#include "src/gpu/GrVertexWriter.h"
|
||||
#include "src/gpu/VertexWriter.h"
|
||||
#include "src/gpu/glsl/GrGLSLFragmentShaderBuilder.h"
|
||||
#include "src/gpu/glsl/GrGLSLVarying.h"
|
||||
#include "src/gpu/glsl/GrGLSLVertexGeoBuilder.h"
|
||||
@ -191,13 +191,13 @@ void DrawAtlasPathOp::onPrepare(GrOpFlushState* flushState) {
|
||||
SkASSERT(fProgram);
|
||||
}
|
||||
|
||||
if (GrVertexWriter instanceWriter = flushState->makeVertexSpace(
|
||||
if (VertexWriter instanceWriter = flushState->makeVertexSpace(
|
||||
fProgram->geomProc().instanceStride(), fInstanceCount, &fInstanceBuffer,
|
||||
&fBaseInstance)) {
|
||||
for (const Instance* i = fHeadInstance; i; i = i->fNext) {
|
||||
instanceWriter << SkRect::Make(i->fFillBounds)
|
||||
<< GrVertexWriter::If(fUsesLocalCoords,
|
||||
i->fLocalToDeviceIfUsingLocalCoords)
|
||||
<< VertexWriter::If(fUsesLocalCoords,
|
||||
i->fLocalToDeviceIfUsingLocalCoords)
|
||||
<< i->fColor;
|
||||
fAtlasHelper.writeInstanceData(&instanceWriter, &i->fAtlasInstance);
|
||||
}
|
||||
|
@ -16,14 +16,16 @@
|
||||
#include "src/gpu/GrGeometryProcessor.h"
|
||||
#include "src/gpu/GrOpFlushState.h"
|
||||
#include "src/gpu/GrProgramInfo.h"
|
||||
#include "src/gpu/GrVertexWriter.h"
|
||||
#include "src/gpu/SkGr.h"
|
||||
#include "src/gpu/VertexWriter.h"
|
||||
#include "src/gpu/glsl/GrGLSLColorSpaceXformHelper.h"
|
||||
#include "src/gpu/glsl/GrGLSLFragmentShaderBuilder.h"
|
||||
#include "src/gpu/glsl/GrGLSLVarying.h"
|
||||
#include "src/gpu/glsl/GrGLSLVertexGeoBuilder.h"
|
||||
#include "src/gpu/ops/GrSimpleMeshDrawOpHelper.h"
|
||||
|
||||
namespace skgpu::v1::DrawVerticesOp {
|
||||
|
||||
namespace {
|
||||
|
||||
enum class ColorArrayType {
|
||||
@ -401,7 +403,7 @@ void DrawVerticesOpImpl::onPrepareDraws(GrMeshDrawTarget* target) {
|
||||
size_t vertexStride = this->vertexStride();
|
||||
sk_sp<const GrBuffer> vertexBuffer;
|
||||
int firstVertex = 0;
|
||||
GrVertexWriter verts{
|
||||
VertexWriter verts{
|
||||
target->makeVertexSpace(vertexStride, fVertexCount, &vertexBuffer, &firstVertex)};
|
||||
if (!verts.fPtr) {
|
||||
SkDebugf("Could not allocate vertices\n");
|
||||
@ -581,8 +583,6 @@ static GrPrimitiveType SkVertexModeToGrPrimitiveType(SkVertices::VertexMode mode
|
||||
|
||||
} // anonymous namespace
|
||||
|
||||
namespace skgpu::v1::DrawVerticesOp {
|
||||
|
||||
GrOp::Owner Make(GrRecordingContext* context,
|
||||
GrPaint&& paint,
|
||||
sk_sp<SkVertices> vertices,
|
||||
|
@ -17,8 +17,8 @@
|
||||
#include "src/gpu/GrProgramInfo.h"
|
||||
#include "src/gpu/GrRecordingContextPriv.h"
|
||||
#include "src/gpu/GrResourceProvider.h"
|
||||
#include "src/gpu/GrVertexWriter.h"
|
||||
#include "src/gpu/GrVx.h"
|
||||
#include "src/gpu/VertexWriter.h"
|
||||
#include "src/gpu/geometry/GrShape.h"
|
||||
#include "src/gpu/glsl/GrGLSLFragmentShaderBuilder.h"
|
||||
#include "src/gpu/glsl/GrGLSLVarying.h"
|
||||
@ -26,6 +26,8 @@
|
||||
#include "src/gpu/ops/GrMeshDrawOp.h"
|
||||
#include "src/gpu/ops/GrSimpleMeshDrawOpHelper.h"
|
||||
|
||||
namespace skgpu::v1::FillRRectOp {
|
||||
|
||||
namespace {
|
||||
|
||||
class FillRRectOpImpl final : public GrMeshDrawOp {
|
||||
@ -515,8 +517,8 @@ void FillRRectOpImpl::onPrepareDraws(GrMeshDrawTarget* target) {
|
||||
|
||||
size_t instanceStride = fProgramInfo->geomProc().instanceStride();
|
||||
|
||||
if (GrVertexWriter instanceWrter = target->makeVertexSpace(instanceStride, fInstanceCount,
|
||||
&fInstanceBuffer, &fBaseInstance)) {
|
||||
if (VertexWriter instanceWrter = target->makeVertexSpace(instanceStride, fInstanceCount,
|
||||
&fInstanceBuffer, &fBaseInstance)) {
|
||||
SkDEBUGCODE(auto end = instanceWrter.makeOffset(instanceStride * fInstanceCount));
|
||||
for (Instance* i = fHeadInstance; i; i = i->fNext) {
|
||||
auto [l, t, r, b] = i->fRRect.rect();
|
||||
@ -538,8 +540,8 @@ void FillRRectOpImpl::onPrepareDraws(GrMeshDrawTarget* target) {
|
||||
<< m.getTranslateX() << m.getTranslateY()
|
||||
<< radiiX << radiiY
|
||||
<< GrVertexColor(i->fColor, fProcessorFlags & ProcessorFlags::kWideColor)
|
||||
<< GrVertexWriter::If(fProcessorFlags & ProcessorFlags::kHasLocalCoords,
|
||||
i->fLocalRect);
|
||||
<< VertexWriter::If(fProcessorFlags & ProcessorFlags::kHasLocalCoords,
|
||||
i->fLocalRect);
|
||||
}
|
||||
SkASSERT(instanceWrter == end);
|
||||
}
|
||||
@ -848,8 +850,6 @@ bool can_use_hw_derivatives_with_coverage(const GrShaderCaps& shaderCaps,
|
||||
|
||||
} // anonymous namespace
|
||||
|
||||
namespace skgpu::v1::FillRRectOp {
|
||||
|
||||
GrOp::Owner Make(GrRecordingContext* ctx,
|
||||
SkArenaAlloc* arena,
|
||||
GrPaint&& paint,
|
||||
|
@ -19,7 +19,7 @@
|
||||
#include "src/gpu/GrResourceProvider.h"
|
||||
#include "src/gpu/GrShaderCaps.h"
|
||||
#include "src/gpu/GrStyle.h"
|
||||
#include "src/gpu/GrVertexWriter.h"
|
||||
#include "src/gpu/VertexWriter.h"
|
||||
#include "src/gpu/glsl/GrGLSLFragmentShaderBuilder.h"
|
||||
#include "src/gpu/glsl/GrGLSLProgramDataManager.h"
|
||||
#include "src/gpu/glsl/GrGLSLUniformHandler.h"
|
||||
@ -30,13 +30,15 @@
|
||||
|
||||
#include <utility>
|
||||
|
||||
using skgpu::VertexWriter;
|
||||
|
||||
namespace {
|
||||
|
||||
static inline bool circle_stays_circle(const SkMatrix& m) { return m.isSimilarity(); }
|
||||
|
||||
// Produces TriStrip vertex data for an origin-centered rectangle from [-x, -y] to [x, y]
|
||||
static inline GrVertexWriter::TriStrip<float> origin_centered_tri_strip(float x, float y) {
|
||||
return GrVertexWriter::TriStrip<float>{ -x, -y, x, y };
|
||||
static inline VertexWriter::TriStrip<float> origin_centered_tri_strip(float x, float y) {
|
||||
return VertexWriter::TriStrip<float>{ -x, -y, x, y };
|
||||
};
|
||||
|
||||
} // namespace
|
||||
@ -1277,8 +1279,8 @@ private:
|
||||
|
||||
sk_sp<const GrBuffer> vertexBuffer;
|
||||
int firstVertex;
|
||||
GrVertexWriter vertices{target->makeVertexSpace(fProgramInfo->geomProc().vertexStride(),
|
||||
fVertCount, &vertexBuffer, &firstVertex)};
|
||||
VertexWriter vertices{target->makeVertexSpace(fProgramInfo->geomProc().vertexStride(),
|
||||
fVertCount, &vertexBuffer, &firstVertex)};
|
||||
if (!vertices.fPtr) {
|
||||
SkDebugf("Could not allocate vertices\n");
|
||||
return;
|
||||
@ -1649,8 +1651,8 @@ private:
|
||||
|
||||
sk_sp<const GrBuffer> vertexBuffer;
|
||||
int firstVertex;
|
||||
GrVertexWriter vertices{target->makeVertexSpace(fProgramInfo->geomProc().vertexStride(),
|
||||
fVertCount, &vertexBuffer, &firstVertex)};
|
||||
VertexWriter vertices{target->makeVertexSpace(fProgramInfo->geomProc().vertexStride(),
|
||||
fVertCount, &vertexBuffer, &firstVertex)};
|
||||
if (!vertices.fPtr) {
|
||||
SkDebugf("Could not allocate vertices\n");
|
||||
return;
|
||||
@ -1984,7 +1986,7 @@ private:
|
||||
}
|
||||
|
||||
QuadHelper helper(target, fProgramInfo->geomProc().vertexStride(), fEllipses.count());
|
||||
GrVertexWriter verts{helper.vertices()};
|
||||
VertexWriter verts{helper.vertices()};
|
||||
if (!verts.fPtr) {
|
||||
SkDebugf("Could not allocate vertices\n");
|
||||
return;
|
||||
@ -2017,11 +2019,11 @@ private:
|
||||
}
|
||||
|
||||
// The inner radius in the vertex data must be specified in normalized space.
|
||||
verts.writeQuad(GrVertexWriter::TriStripFromRect(
|
||||
verts.writeQuad(VertexWriter::TriStripFromRect(
|
||||
ellipse.fDevBounds.makeOutset(aaBloat, aaBloat)),
|
||||
color,
|
||||
origin_centered_tri_strip(xMaxOffset, yMaxOffset),
|
||||
GrVertexWriter::If(fUseScale, std::max(xRadius, yRadius)),
|
||||
VertexWriter::If(fUseScale, std::max(xRadius, yRadius)),
|
||||
invRadii);
|
||||
}
|
||||
fMesh = helper.mesh();
|
||||
@ -2260,7 +2262,7 @@ private:
|
||||
}
|
||||
|
||||
QuadHelper helper(target, fProgramInfo->geomProc().vertexStride(), fEllipses.count());
|
||||
GrVertexWriter verts{helper.vertices()};
|
||||
VertexWriter verts{helper.vertices()};
|
||||
if (!verts.fPtr) {
|
||||
return;
|
||||
}
|
||||
@ -2292,10 +2294,10 @@ private:
|
||||
innerCoordY = drawBounds.height() / (ellipse.fInnerYRadius * 2);
|
||||
}
|
||||
|
||||
verts.writeQuad(GrVertexWriter::TriStripFromRect(drawBounds),
|
||||
verts.writeQuad(VertexWriter::TriStripFromRect(drawBounds),
|
||||
color,
|
||||
origin_centered_tri_strip(outerCoordX, outerCoordY),
|
||||
GrVertexWriter::If(fUseScale, std::max(xRadius, yRadius)),
|
||||
VertexWriter::If(fUseScale, std::max(xRadius, yRadius)),
|
||||
origin_centered_tri_strip(innerCoordX, innerCoordY));
|
||||
}
|
||||
fMesh = helper.mesh();
|
||||
@ -2591,7 +2593,7 @@ public:
|
||||
FixedFunctionFlags fixedFunctionFlags() const override { return fHelper.fixedFunctionFlags(); }
|
||||
|
||||
private:
|
||||
static void FillInOverstrokeVerts(GrVertexWriter& verts, const SkRect& bounds, SkScalar smInset,
|
||||
static void FillInOverstrokeVerts(VertexWriter& verts, const SkRect& bounds, SkScalar smInset,
|
||||
SkScalar bigInset, SkScalar xOffset, SkScalar outerRadius,
|
||||
SkScalar innerRadius, const GrVertexColor& color) {
|
||||
SkASSERT(smInset < bigInset);
|
||||
@ -2680,7 +2682,7 @@ private:
|
||||
sk_sp<const GrBuffer> vertexBuffer;
|
||||
int firstVertex;
|
||||
|
||||
GrVertexWriter verts{target->makeVertexSpace(fProgramInfo->geomProc().vertexStride(),
|
||||
VertexWriter verts{target->makeVertexSpace(fProgramInfo->geomProc().vertexStride(),
|
||||
fVertCount, &vertexBuffer, &firstVertex)};
|
||||
if (!verts.fPtr) {
|
||||
SkDebugf("Could not allocate vertices\n");
|
||||
@ -3011,7 +3013,7 @@ private:
|
||||
fProgramInfo->geomProc().vertexStride(),
|
||||
std::move(indexBuffer), kVertsPerStandardRRect, indicesPerInstance,
|
||||
fRRects.count(), kNumRRectsInIndexBuffer);
|
||||
GrVertexWriter verts{helper.vertices()};
|
||||
VertexWriter verts{helper.vertices()};
|
||||
if (!verts.fPtr) {
|
||||
SkDebugf("Could not allocate vertices\n");
|
||||
return;
|
||||
@ -3058,7 +3060,7 @@ private:
|
||||
// shader, so can't be exactly 0
|
||||
SK_ScalarNearlyZero, yMaxOffset};
|
||||
|
||||
auto maybeScale = GrVertexWriter::If(fUseScale, std::max(rrect.fXRadius, rrect.fYRadius));
|
||||
auto maybeScale = VertexWriter::If(fUseScale, std::max(rrect.fXRadius, rrect.fYRadius));
|
||||
for (int i = 0; i < 4; ++i) {
|
||||
verts << bounds.fLeft << yCoords[i]
|
||||
<< color
|
||||
|
@ -17,14 +17,16 @@
|
||||
#include "src/gpu/GrProgramInfo.h"
|
||||
#include "src/gpu/GrResourceProvider.h"
|
||||
#include "src/gpu/GrResourceProviderPriv.h"
|
||||
#include "src/gpu/GrVertexWriter.h"
|
||||
#include "src/gpu/SkGr.h"
|
||||
#include "src/gpu/VertexWriter.h"
|
||||
#include "src/gpu/glsl/GrGLSLColorSpaceXformHelper.h"
|
||||
#include "src/gpu/glsl/GrGLSLFragmentShaderBuilder.h"
|
||||
#include "src/gpu/glsl/GrGLSLVarying.h"
|
||||
#include "src/gpu/ops/GrMeshDrawOp.h"
|
||||
#include "src/gpu/ops/GrSimpleMeshDrawOpHelper.h"
|
||||
|
||||
namespace skgpu::v1::LatticeOp {
|
||||
|
||||
namespace {
|
||||
|
||||
class LatticeGP : public GrGeometryProcessor {
|
||||
@ -247,7 +249,7 @@ private:
|
||||
|
||||
QuadHelper helper(target, kVertexStride, numRects);
|
||||
|
||||
GrVertexWriter vertices{helper.vertices()};
|
||||
VertexWriter vertices{helper.vertices()};
|
||||
if (!vertices.fPtr) {
|
||||
SkDebugf("Could not allocate vertices\n");
|
||||
return;
|
||||
@ -288,8 +290,8 @@ private:
|
||||
coords.store(&texCoords);
|
||||
|
||||
if (isScaleTranslate) {
|
||||
vertices.writeQuad(GrVertexWriter::TriStripFromRect(dstR),
|
||||
GrVertexWriter::TriStripFromRect(texCoords),
|
||||
vertices.writeQuad(VertexWriter::TriStripFromRect(dstR),
|
||||
VertexWriter::TriStripFromRect(texCoords),
|
||||
texDomain,
|
||||
patchColor);
|
||||
} else {
|
||||
@ -393,8 +395,6 @@ private:
|
||||
|
||||
} // anonymous namespace
|
||||
|
||||
namespace skgpu::v1::LatticeOp {
|
||||
|
||||
GrOp::Owner MakeNonAA(GrRecordingContext* context,
|
||||
GrPaint&& paint,
|
||||
const SkMatrix& viewMatrix,
|
||||
@ -529,8 +529,10 @@ GR_DRAW_OP_TEST_DEFINE(NonAALatticeOp) {
|
||||
std::move(proxy), origin,
|
||||
context->priv().caps()->getReadSwizzle(format, GrColorType::kRGBA_8888));
|
||||
|
||||
return NonAALatticeOp::Make(context, std::move(paint), viewMatrix, std::move(view),
|
||||
kPremul_SkAlphaType, std::move(csxf), filter, std::move(iter), dst);
|
||||
return skgpu::v1::LatticeOp::NonAALatticeOp::Make(context, std::move(paint), viewMatrix,
|
||||
std::move(view), kPremul_SkAlphaType,
|
||||
std::move(csxf), filter, std::move(iter),
|
||||
dst);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@ -242,7 +242,7 @@ void PathStencilCoverOp::onPrepare(GrOpFlushState* flushState) {
|
||||
// A single n-sided polygon is fanned by n-2 triangles. Multiple polygons with a combined
|
||||
// edge count of n are fanned by strictly fewer triangles.
|
||||
int maxTrianglesInFans = std::max(maxCombinedFanEdges - 2, 0);
|
||||
GrVertexWriter triangleVertexWriter = vertexAlloc.lock<SkPoint>(maxTrianglesInFans * 3);
|
||||
VertexWriter triangleVertexWriter = vertexAlloc.lock<SkPoint>(maxTrianglesInFans * 3);
|
||||
int fanTriangleCount = 0;
|
||||
for (auto [pathMatrix, path] : *fPathDrawList) {
|
||||
int numTrianglesWritten;
|
||||
@ -264,11 +264,10 @@ void PathStencilCoverOp::onPrepare(GrOpFlushState* flushState) {
|
||||
|
||||
if (fCoverBBoxProgram) {
|
||||
size_t instanceStride = fCoverBBoxProgram->geomProc().instanceStride();
|
||||
GrVertexWriter vertexWriter = flushState->makeVertexSpace(
|
||||
instanceStride,
|
||||
fPathCount,
|
||||
&fBBoxBuffer,
|
||||
&fBBoxBaseInstance);
|
||||
VertexWriter vertexWriter = flushState->makeVertexSpace(instanceStride,
|
||||
fPathCount,
|
||||
&fBBoxBuffer,
|
||||
&fBBoxBaseInstance);
|
||||
SkDEBUGCODE(int pathCount = 0;)
|
||||
for (auto [pathMatrix, path] : *fPathDrawList) {
|
||||
SkDEBUGCODE(auto end = vertexWriter.makeOffset(instanceStride));
|
||||
|
@ -24,6 +24,8 @@ static_assert((int)GrQuadAAFlags::kBottom == SkCanvas::kBottom_QuadAAFlag);
|
||||
static_assert((int)GrQuadAAFlags::kNone == SkCanvas::kNone_QuadAAFlags);
|
||||
static_assert((int)GrQuadAAFlags::kAll == SkCanvas::kAll_QuadAAFlags);
|
||||
|
||||
namespace skgpu::v1::QuadPerEdgeAA {
|
||||
|
||||
namespace {
|
||||
|
||||
using VertexSpec = skgpu::v1::QuadPerEdgeAA::VertexSpec;
|
||||
@ -32,7 +34,7 @@ using ColorType = skgpu::v1::QuadPerEdgeAA::ColorType;
|
||||
|
||||
// Generic WriteQuadProc that can handle any VertexSpec. It writes the 4 vertices in triangle strip
|
||||
// order, although the data per-vertex is dependent on the VertexSpec.
|
||||
void write_quad_generic(GrVertexWriter* vb,
|
||||
void write_quad_generic(VertexWriter* vb,
|
||||
const VertexSpec& spec,
|
||||
const GrQuad* deviceQuad,
|
||||
const GrQuad* localQuad,
|
||||
@ -40,7 +42,7 @@ void write_quad_generic(GrVertexWriter* vb,
|
||||
const SkPMColor4f& color,
|
||||
const SkRect& geomSubset,
|
||||
const SkRect& texSubset) {
|
||||
static constexpr auto If = GrVertexWriter::If<float>;
|
||||
static constexpr auto If = VertexWriter::If<float>;
|
||||
|
||||
SkASSERT(!spec.hasLocalCoords() || localQuad);
|
||||
|
||||
@ -84,7 +86,7 @@ void write_quad_generic(GrVertexWriter* vb,
|
||||
|
||||
// 2D (XY), no explicit coverage, vertex color, no locals, no geometry subset, no texture subsetn
|
||||
// This represents simple, solid color or shader, non-AA (or AA with cov. as alpha) rects.
|
||||
void write_2d_color(GrVertexWriter* vb,
|
||||
void write_2d_color(VertexWriter* vb,
|
||||
const VertexSpec& spec,
|
||||
const GrQuad* deviceQuad,
|
||||
const GrQuad* localQuad,
|
||||
@ -116,7 +118,7 @@ void write_2d_color(GrVertexWriter* vb,
|
||||
|
||||
// 2D (XY), no explicit coverage, UV locals, no color, no geometry subset, no texture subset
|
||||
// This represents opaque, non AA, textured rects
|
||||
void write_2d_uv(GrVertexWriter* vb,
|
||||
void write_2d_uv(VertexWriter* vb,
|
||||
const VertexSpec& spec,
|
||||
const GrQuad* deviceQuad,
|
||||
const GrQuad* localQuad,
|
||||
@ -143,7 +145,7 @@ void write_2d_uv(GrVertexWriter* vb,
|
||||
|
||||
// 2D (XY), no explicit coverage, UV locals, vertex color, no geometry or texture subsets
|
||||
// This represents transparent, non AA (or AA with cov. as alpha), textured rects
|
||||
void write_2d_color_uv(GrVertexWriter* vb,
|
||||
void write_2d_color_uv(VertexWriter* vb,
|
||||
const VertexSpec& spec,
|
||||
const GrQuad* deviceQuad,
|
||||
const GrQuad* localQuad,
|
||||
@ -175,7 +177,7 @@ void write_2d_color_uv(GrVertexWriter* vb,
|
||||
|
||||
// 2D (XY), explicit coverage, UV locals, no color, no geometry subset, no texture subset
|
||||
// This represents opaque, AA, textured rects
|
||||
void write_2d_cov_uv(GrVertexWriter* vb,
|
||||
void write_2d_cov_uv(VertexWriter* vb,
|
||||
const VertexSpec& spec,
|
||||
const GrQuad* deviceQuad,
|
||||
const GrQuad* localQuad,
|
||||
@ -209,7 +211,7 @@ void write_2d_cov_uv(GrVertexWriter* vb,
|
||||
|
||||
// 2D (XY), no explicit coverage, UV locals, no color, tex subset but no geometry subset
|
||||
// This represents opaque, non AA, textured rects with strict uv sampling
|
||||
void write_2d_uv_strict(GrVertexWriter* vb,
|
||||
void write_2d_uv_strict(VertexWriter* vb,
|
||||
const VertexSpec& spec,
|
||||
const GrQuad* deviceQuad,
|
||||
const GrQuad* localQuad,
|
||||
@ -237,7 +239,7 @@ void write_2d_uv_strict(GrVertexWriter* vb,
|
||||
|
||||
// 2D (XY), no explicit coverage, UV locals, vertex color, tex subset but no geometry subset
|
||||
// This represents transparent, non AA (or AA with cov. as alpha), textured rects with strict sample
|
||||
void write_2d_color_uv_strict(GrVertexWriter* vb,
|
||||
void write_2d_color_uv_strict(VertexWriter* vb,
|
||||
const VertexSpec& spec,
|
||||
const GrQuad* deviceQuad,
|
||||
const GrQuad* localQuad,
|
||||
@ -270,7 +272,7 @@ void write_2d_color_uv_strict(GrVertexWriter* vb,
|
||||
|
||||
// 2D (XY), explicit coverage, UV locals, no color, tex subset but no geometry subset
|
||||
// This represents opaque, AA, textured rects with strict uv sampling
|
||||
void write_2d_cov_uv_strict(GrVertexWriter* vb,
|
||||
void write_2d_cov_uv_strict(VertexWriter* vb,
|
||||
const VertexSpec& spec,
|
||||
const GrQuad* deviceQuad,
|
||||
const GrQuad* localQuad,
|
||||
@ -299,8 +301,6 @@ void write_2d_cov_uv_strict(GrVertexWriter* vb,
|
||||
|
||||
} // anonymous namespace
|
||||
|
||||
namespace skgpu::v1::QuadPerEdgeAA {
|
||||
|
||||
IndexBufferOption CalcIndexBufferOption(GrAAType aa, int numQuads) {
|
||||
if (aa == GrAAType::kCoverage) {
|
||||
return IndexBufferOption::kPictureFramed;
|
||||
|
@ -14,7 +14,7 @@
|
||||
#include "src/gpu/GrColor.h"
|
||||
#include "src/gpu/GrGeometryProcessor.h"
|
||||
#include "src/gpu/GrSamplerState.h"
|
||||
#include "src/gpu/GrVertexWriter.h"
|
||||
#include "src/gpu/VertexWriter.h"
|
||||
#include "src/gpu/geometry/GrQuad.h"
|
||||
#include "src/gpu/geometry/GrQuadUtils.h"
|
||||
#include "src/gpu/ops/TextureOp.h"
|
||||
@ -23,7 +23,7 @@ class GrCaps;
|
||||
class GrColorSpaceXform;
|
||||
class GrMeshDrawTarget;
|
||||
class GrShaderCaps;
|
||||
struct GrVertexWriter;
|
||||
struct VertexWriter;
|
||||
|
||||
namespace skgpu::v1::QuadPerEdgeAA {
|
||||
using Saturate = skgpu::v1::TextureOp::Saturate;
|
||||
@ -153,7 +153,7 @@ namespace skgpu::v1::QuadPerEdgeAA {
|
||||
// generically by branching per-quad based on the VertexSpec. However, there are several
|
||||
// specs that appear in the wild far more frequently, so they use explicit WriteQuadProcs
|
||||
// that have no branches.
|
||||
typedef void (*WriteQuadProc)(GrVertexWriter* vertices, const VertexSpec& spec,
|
||||
typedef void (*WriteQuadProc)(VertexWriter* vertices, const VertexSpec& spec,
|
||||
const GrQuad* deviceQuad, const GrQuad* localQuad,
|
||||
const float coverage[4], const SkPMColor4f& color,
|
||||
const SkRect& geomSubset, const SkRect& texSubset);
|
||||
@ -161,7 +161,7 @@ namespace skgpu::v1::QuadPerEdgeAA {
|
||||
|
||||
GrQuadUtils::TessellationHelper fAAHelper;
|
||||
VertexSpec fVertexSpec;
|
||||
GrVertexWriter fVertexWriter;
|
||||
VertexWriter fVertexWriter;
|
||||
WriteQuadProc fWriteProc;
|
||||
};
|
||||
|
||||
|
@ -14,10 +14,12 @@
|
||||
#include "src/gpu/GrOpFlushState.h"
|
||||
#include "src/gpu/GrProgramInfo.h"
|
||||
#include "src/gpu/GrResourceProvider.h"
|
||||
#include "src/gpu/GrVertexWriter.h"
|
||||
#include "src/gpu/VertexWriter.h"
|
||||
#include "src/gpu/ops/GrMeshDrawOp.h"
|
||||
#include "src/gpu/ops/GrSimpleMeshDrawOpHelperWithStencil.h"
|
||||
|
||||
namespace skgpu::v1::RegionOp {
|
||||
|
||||
namespace {
|
||||
|
||||
GrGeometryProcessor* make_gp(SkArenaAlloc* arena,
|
||||
@ -122,7 +124,7 @@ private:
|
||||
|
||||
QuadHelper helper(target, fProgramInfo->geomProc().vertexStride(), numRects);
|
||||
|
||||
GrVertexWriter vertices{helper.vertices()};
|
||||
VertexWriter vertices{helper.vertices()};
|
||||
if (!vertices.fPtr) {
|
||||
SkDebugf("Could not allocate vertices\n");
|
||||
return;
|
||||
@ -133,7 +135,7 @@ private:
|
||||
SkRegion::Iterator iter(fRegions[i].fRegion);
|
||||
while (!iter.done()) {
|
||||
SkRect rect = SkRect::Make(iter.rect());
|
||||
vertices.writeQuad(GrVertexWriter::TriStripFromRect(rect), color);
|
||||
vertices.writeQuad(VertexWriter::TriStripFromRect(rect), color);
|
||||
iter.next();
|
||||
}
|
||||
}
|
||||
@ -197,8 +199,6 @@ private:
|
||||
|
||||
} // anonymous namespace
|
||||
|
||||
namespace skgpu::v1::RegionOp {
|
||||
|
||||
GrOp::Owner Make(GrRecordingContext* context,
|
||||
GrPaint&& paint,
|
||||
const SkMatrix& viewMatrix,
|
||||
@ -243,8 +243,8 @@ GR_DRAW_OP_TEST_DEFINE(RegionOp) {
|
||||
if (numSamples > 1 && random->nextBool()) {
|
||||
aaType = GrAAType::kMSAA;
|
||||
}
|
||||
return RegionOpImpl::Make(context, std::move(paint), viewMatrix, region, aaType,
|
||||
GrGetRandomStencil(random, context));
|
||||
return skgpu::v1::RegionOp::RegionOpImpl::Make(context, std::move(paint), viewMatrix, region,
|
||||
aaType, GrGetRandomStencil(random, context));
|
||||
}
|
||||
|
||||
#endif // GR_TEST_UTILS
|
||||
|
@ -21,7 +21,7 @@
|
||||
#include "src/gpu/GrDistanceFieldGenFromVector.h"
|
||||
#include "src/gpu/GrDrawOpTest.h"
|
||||
#include "src/gpu/GrResourceProvider.h"
|
||||
#include "src/gpu/GrVertexWriter.h"
|
||||
#include "src/gpu/VertexWriter.h"
|
||||
#include "src/gpu/effects/GrBitmapTextGeoProc.h"
|
||||
#include "src/gpu/effects/GrDistanceFieldGeoProc.h"
|
||||
#include "src/gpu/geometry/GrQuad.h"
|
||||
@ -32,6 +32,8 @@
|
||||
#include "src/gpu/ops/SmallPathShapeData.h"
|
||||
#include "src/gpu/v1/SurfaceDrawContext_v1.h"
|
||||
|
||||
namespace skgpu::v1 {
|
||||
|
||||
namespace {
|
||||
|
||||
// mip levels
|
||||
@ -209,7 +211,7 @@ private:
|
||||
if (instanceCount > SK_MaxS32 / GrResourceProvider::NumVertsPerNonAAQuad()) {
|
||||
return;
|
||||
}
|
||||
GrVertexWriter vertices{ target->makeVertexSpace(
|
||||
VertexWriter vertices{target->makeVertexSpace(
|
||||
kVertexStride, GrResourceProvider::NumVertsPerNonAAQuad() * instanceCount,
|
||||
&flushInfo.fVertexBuffer, &flushInfo.fVertexOffset)};
|
||||
|
||||
@ -510,7 +512,7 @@ private:
|
||||
drawBounds, 0, shapeData);
|
||||
}
|
||||
|
||||
void writePathVertices(GrVertexWriter& vertices,
|
||||
void writePathVertices(VertexWriter& vertices,
|
||||
const GrVertexColor& color,
|
||||
const SkMatrix& ctm,
|
||||
const skgpu::v1::SmallPathShapeData* shapeData) const {
|
||||
@ -521,14 +523,14 @@ private:
|
||||
}
|
||||
|
||||
// set up texture coordinates
|
||||
auto texCoords = GrVertexWriter::TriStripFromUVs(shapeData->fAtlasLocator.getUVs());
|
||||
auto texCoords = VertexWriter::TriStripFromUVs(shapeData->fAtlasLocator.getUVs());
|
||||
|
||||
if (fUsesDistanceField && !ctm.hasPerspective()) {
|
||||
vertices.writeQuad(GrQuad::MakeFromRect(translatedBounds, ctm),
|
||||
color,
|
||||
texCoords);
|
||||
} else {
|
||||
vertices.writeQuad(GrVertexWriter::TriStripFromRect(translatedBounds),
|
||||
vertices.writeQuad(VertexWriter::TriStripFromRect(translatedBounds),
|
||||
color,
|
||||
texCoords);
|
||||
}
|
||||
@ -657,24 +659,6 @@ private:
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#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 {
|
||||
|
||||
PathRenderer::CanDrawPath SmallPathRenderer::onCanDrawPath(const CanDrawPathArgs& args) const {
|
||||
if (!args.fCaps->shaderCaps()->shaderDerivativeSupport()) {
|
||||
return CanDrawPath::kNo;
|
||||
@ -738,3 +722,17 @@ bool SmallPathRenderer::onDrawPath(const DrawPathArgs& args) {
|
||||
}
|
||||
|
||||
} // namespace skgpu::v1
|
||||
|
||||
#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 skgpu::v1::SmallPathOp::Make(context, std::move(paint), shape, viewMatrix, gammaCorrect,
|
||||
GrGetRandomStencil(random, context));
|
||||
}
|
||||
|
||||
#endif // GR_TEST_UTILS
|
||||
|
@ -18,12 +18,14 @@
|
||||
#include "src/gpu/GrOpFlushState.h"
|
||||
#include "src/gpu/GrProgramInfo.h"
|
||||
#include "src/gpu/GrResourceProvider.h"
|
||||
#include "src/gpu/GrVertexWriter.h"
|
||||
#include "src/gpu/VertexWriter.h"
|
||||
#include "src/gpu/geometry/GrQuad.h"
|
||||
#include "src/gpu/ops/FillRectOp.h"
|
||||
#include "src/gpu/ops/GrMeshDrawOp.h"
|
||||
#include "src/gpu/ops/GrSimpleMeshDrawOpHelper.h"
|
||||
|
||||
namespace skgpu::v1::StrokeRectOp {
|
||||
|
||||
namespace {
|
||||
|
||||
// We support all hairlines, bevels, and miters, but not round joins. Also, check whether the miter
|
||||
@ -559,7 +561,7 @@ private:
|
||||
|
||||
CombineResult onCombineIfPossible(GrOp* t, SkArenaAlloc*, const GrCaps&) override;
|
||||
|
||||
void generateAAStrokeRectGeometry(GrVertexWriter& vertices,
|
||||
void generateAAStrokeRectGeometry(VertexWriter& vertices,
|
||||
const SkPMColor4f& color,
|
||||
bool wideColor,
|
||||
const SkRect& devOutside,
|
||||
@ -639,7 +641,7 @@ void AAStrokeRectOp::onPrepareDraws(GrMeshDrawTarget* target) {
|
||||
PatternHelper helper(target, GrPrimitiveType::kTriangles,
|
||||
fProgramInfo->geomProc().vertexStride(), std::move(indexBuffer),
|
||||
verticesPerInstance, indicesPerInstance, instanceCount, maxQuads);
|
||||
GrVertexWriter vertices{ helper.vertices() };
|
||||
VertexWriter vertices{ helper.vertices() };
|
||||
if (!vertices.fPtr) {
|
||||
SkDebugf("Could not allocate vertices\n");
|
||||
return;
|
||||
@ -791,7 +793,7 @@ GrOp::CombineResult AAStrokeRectOp::onCombineIfPossible(GrOp* t, SkArenaAlloc*,
|
||||
return CombineResult::kMerged;
|
||||
}
|
||||
|
||||
void AAStrokeRectOp::generateAAStrokeRectGeometry(GrVertexWriter& vertices,
|
||||
void AAStrokeRectOp::generateAAStrokeRectGeometry(VertexWriter& vertices,
|
||||
const SkPMColor4f& color,
|
||||
bool wideColor,
|
||||
const SkRect& devOutside,
|
||||
@ -811,13 +813,13 @@ void AAStrokeRectOp::generateAAStrokeRectGeometry(GrVertexWriter& vertices,
|
||||
SkASSERT(stroke_dev_half_size_supported(devHalfStrokeSize));
|
||||
|
||||
auto inset_fan = [](const SkRect& r, SkScalar dx, SkScalar dy) {
|
||||
return GrVertexWriter::TriFanFromRect(r.makeInset(dx, dy));
|
||||
return VertexWriter::TriFanFromRect(r.makeInset(dx, dy));
|
||||
};
|
||||
|
||||
bool tweakAlphaForCoverage = this->compatibleWithCoverageAsAlpha(usesMSAASurface);
|
||||
|
||||
auto maybe_coverage = [tweakAlphaForCoverage](float coverage) {
|
||||
return GrVertexWriter::If(!tweakAlphaForCoverage, coverage);
|
||||
return VertexWriter::If(!tweakAlphaForCoverage, coverage);
|
||||
};
|
||||
|
||||
// How much do we inset toward the inside of the strokes?
|
||||
@ -913,19 +915,19 @@ void AAStrokeRectOp::generateAAStrokeRectGeometry(GrVertexWriter& vertices,
|
||||
}
|
||||
GrVertexColor interiorColor(tweakAlphaForCoverage ? color * interiorCoverage : color,
|
||||
wideColor);
|
||||
vertices.writeQuad(GrVertexWriter::TriFanFromRect(interiorAABoundary),
|
||||
vertices.writeQuad(VertexWriter::TriFanFromRect(interiorAABoundary),
|
||||
interiorColor,
|
||||
maybe_coverage(interiorCoverage));
|
||||
} else {
|
||||
// When the interior rect has become degenerate we smoosh to a single point
|
||||
SkASSERT(devInside.fLeft == devInside.fRight && devInside.fTop == devInside.fBottom);
|
||||
|
||||
vertices.writeQuad(GrVertexWriter::TriFanFromRect(devInside),
|
||||
vertices.writeQuad(VertexWriter::TriFanFromRect(devInside),
|
||||
innerColor,
|
||||
maybe_coverage(innerCoverage));
|
||||
|
||||
// ... unless we are degenerate, in which case we must apply the scaled coverage
|
||||
vertices.writeQuad(GrVertexWriter::TriFanFromRect(devInside),
|
||||
vertices.writeQuad(VertexWriter::TriFanFromRect(devInside),
|
||||
innerColor,
|
||||
maybe_coverage(innerCoverage));
|
||||
}
|
||||
@ -933,8 +935,6 @@ void AAStrokeRectOp::generateAAStrokeRectGeometry(GrVertexWriter& vertices,
|
||||
|
||||
} // anonymous namespace
|
||||
|
||||
namespace skgpu::v1::StrokeRectOp {
|
||||
|
||||
GrOp::Owner Make(GrRecordingContext* context,
|
||||
GrPaint&& paint,
|
||||
GrAAType aaType,
|
||||
@ -1002,7 +1002,8 @@ GR_DRAW_OP_TEST_DEFINE(NonAAStrokeRectOp) {
|
||||
if (numSamples > 1) {
|
||||
aaType = random->nextBool() ? GrAAType::kMSAA : GrAAType::kNone;
|
||||
}
|
||||
return NonAAStrokeRectOp::Make(context, std::move(paint), viewMatrix, rect, strokeRec, aaType);
|
||||
return skgpu::v1::StrokeRectOp::NonAAStrokeRectOp::Make(context, std::move(paint), viewMatrix,
|
||||
rect, strokeRec, aaType);
|
||||
}
|
||||
|
||||
GR_DRAW_OP_TEST_DEFINE(AAStrokeRectOp) {
|
||||
@ -1019,7 +1020,8 @@ GR_DRAW_OP_TEST_DEFINE(AAStrokeRectOp) {
|
||||
rec.setStrokeParams(SkPaint::kButt_Cap,
|
||||
miterStroke ? SkPaint::kMiter_Join : SkPaint::kBevel_Join, 1.f);
|
||||
SkMatrix matrix = GrTest::TestMatrixRectStaysRect(random);
|
||||
return AAStrokeRectOp::Make(context, std::move(paint), matrix, rect, rec);
|
||||
return skgpu::v1::StrokeRectOp::AAStrokeRectOp::Make(context, std::move(paint), matrix, rect,
|
||||
rec);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@ -13,7 +13,7 @@
|
||||
#include "include/private/SkTemplates.h"
|
||||
#include "src/core/SkMathPriv.h"
|
||||
#include "src/core/SkPathPriv.h"
|
||||
#include "src/gpu/GrVertexWriter.h"
|
||||
#include "src/gpu/VertexWriter.h"
|
||||
#include "src/gpu/tessellate/PathXform.h"
|
||||
|
||||
namespace skgpu {
|
||||
@ -49,8 +49,10 @@ public:
|
||||
// Writes out 3 SkPoints per triangle to "vertexWriter". Additionally writes out "pad32Count"
|
||||
// repetitions of "pad32Value" after each triangle. Set pad32Count to 0 if the triangles are
|
||||
// to be tightly packed.
|
||||
MiddleOutPolygonTriangulator(GrVertexWriter&& vertexWriter, int pad32Count,
|
||||
uint32_t pad32Value, int maxPushVertexCalls)
|
||||
MiddleOutPolygonTriangulator(VertexWriter&& vertexWriter,
|
||||
int pad32Count,
|
||||
uint32_t pad32Value,
|
||||
int maxPushVertexCalls)
|
||||
: fVertexWriter(std::move(vertexWriter))
|
||||
, fPad32Count(pad32Count)
|
||||
, fPad32Value(pad32Value) {
|
||||
@ -125,14 +127,14 @@ public:
|
||||
SkASSERT(fTop->fVertexIdxDelta == 0); // Ensure we are in the initial stack state.
|
||||
}
|
||||
|
||||
GrVertexWriter detachVertexWriter() { return std::move(fVertexWriter); }
|
||||
VertexWriter detachVertexWriter() { return std::move(fVertexWriter); }
|
||||
|
||||
static GrVertexWriter WritePathInnerFan(GrVertexWriter&& vertexWriter,
|
||||
int pad32Count,
|
||||
uint32_t pad32Value,
|
||||
const PathXform& pathXform,
|
||||
const SkPath& path,
|
||||
int* numTrianglesWritten) {
|
||||
static VertexWriter WritePathInnerFan(VertexWriter&& vertexWriter,
|
||||
int pad32Count,
|
||||
uint32_t pad32Value,
|
||||
const PathXform& pathXform,
|
||||
const SkPath& path,
|
||||
int* numTrianglesWritten) {
|
||||
MiddleOutPolygonTriangulator middleOut(std::move(vertexWriter),
|
||||
pad32Count,
|
||||
pad32Value,
|
||||
@ -190,7 +192,7 @@ private:
|
||||
}
|
||||
|
||||
constexpr static int kStackPreallocCount = 32;
|
||||
GrVertexWriter fVertexWriter;
|
||||
VertexWriter fVertexWriter;
|
||||
const int fPad32Count;
|
||||
const uint32_t fPad32Value;
|
||||
SkAutoSTMalloc<kStackPreallocCount, StackVertex> fVertexStack;
|
||||
|
@ -54,10 +54,10 @@ public:
|
||||
return;
|
||||
}
|
||||
if (numSegments_pow4 > 1) {
|
||||
if (GrVertexWriter vertexWriter = chunker->appendVertex()) {
|
||||
if (VertexWriter vertexWriter = chunker->appendVertex()) {
|
||||
fPathXform.mapQuadToCubic(&vertexWriter, p);
|
||||
vertexWriter << GrVertexWriter::If(!shaderCaps.infinitySupport(),
|
||||
GrTessellationShader::kCubicCurveType);
|
||||
vertexWriter << VertexWriter::If(!shaderCaps.infinitySupport(),
|
||||
GrTessellationShader::kCubicCurveType);
|
||||
}
|
||||
fNumFixedSegments_pow4 = std::max(numSegments_pow4, fNumFixedSegments_pow4);
|
||||
}
|
||||
@ -71,10 +71,10 @@ public:
|
||||
return;
|
||||
}
|
||||
if (numSegments_pow2 > 1) {
|
||||
if (GrVertexWriter vertexWriter = chunker->appendVertex()) {
|
||||
if (VertexWriter vertexWriter = chunker->appendVertex()) {
|
||||
fPathXform.mapConicToPatch(&vertexWriter, p, w);
|
||||
vertexWriter << GrVertexWriter::If(!shaderCaps.infinitySupport(),
|
||||
GrTessellationShader::kConicCurveType);
|
||||
vertexWriter << VertexWriter::If(!shaderCaps.infinitySupport(),
|
||||
GrTessellationShader::kConicCurveType);
|
||||
}
|
||||
fNumFixedSegments_pow4 = std::max(numSegments_pow2 * numSegments_pow2,
|
||||
fNumFixedSegments_pow4);
|
||||
@ -89,10 +89,10 @@ public:
|
||||
return;
|
||||
}
|
||||
if (numSegments_pow4 > 1) {
|
||||
if (GrVertexWriter vertexWriter = chunker->appendVertex()) {
|
||||
if (VertexWriter vertexWriter = chunker->appendVertex()) {
|
||||
fPathXform.map4Points(&vertexWriter, p);
|
||||
vertexWriter << GrVertexWriter::If(!shaderCaps.infinitySupport(),
|
||||
GrTessellationShader::kCubicCurveType);
|
||||
vertexWriter << VertexWriter::If(!shaderCaps.infinitySupport(),
|
||||
GrTessellationShader::kCubicCurveType);
|
||||
}
|
||||
fNumFixedSegments_pow4 = std::max(numSegments_pow4, fNumFixedSegments_pow4);
|
||||
}
|
||||
@ -146,14 +146,14 @@ private:
|
||||
|
||||
void writeTriangle(const GrShaderCaps& shaderCaps, GrVertexChunkBuilder* chunker, SkPoint p0,
|
||||
SkPoint p1, SkPoint p2) {
|
||||
if (GrVertexWriter vertexWriter = chunker->appendVertex()) {
|
||||
if (VertexWriter vertexWriter = chunker->appendVertex()) {
|
||||
vertexWriter << fPathXform.mapPoint(p0)
|
||||
<< fPathXform.mapPoint(p1)
|
||||
<< fPathXform.mapPoint(p2);
|
||||
// Mark this instance as a triangle by setting it to a conic with w=Inf.
|
||||
vertexWriter.fill(GrVertexWriter::kIEEE_32_infinity, 2);
|
||||
vertexWriter << GrVertexWriter::If(!shaderCaps.infinitySupport(),
|
||||
GrTessellationShader::kTriangularConicCurveType);
|
||||
vertexWriter.fill(VertexWriter::kIEEE_32_infinity, 2);
|
||||
vertexWriter << VertexWriter::If(!shaderCaps.infinitySupport(),
|
||||
GrTessellationShader::kTriangularConicCurveType);
|
||||
}
|
||||
}
|
||||
|
||||
@ -232,7 +232,7 @@ void PathCurveTessellator::prepare(GrMeshDrawTarget* target,
|
||||
|
||||
// Write out the triangles.
|
||||
if (maxTriangles) {
|
||||
GrVertexWriter vertexWriter = chunker.appendVertices(maxTriangles);
|
||||
VertexWriter vertexWriter = chunker.appendVertices(maxTriangles);
|
||||
if (!vertexWriter) {
|
||||
return;
|
||||
}
|
||||
@ -243,7 +243,7 @@ void PathCurveTessellator::prepare(GrMeshDrawTarget* target,
|
||||
// explicitly tells the shader to interpret these patches as triangles.
|
||||
int pad32Count = shaderCaps.infinitySupport() ? 2 : 3;
|
||||
uint32_t pad32Value = shaderCaps.infinitySupport()
|
||||
? GrVertexWriter::kIEEE_32_infinity
|
||||
? VertexWriter::kIEEE_32_infinity
|
||||
: sk_bit_cast<uint32_t>(GrTessellationShader::kTriangularConicCurveType);
|
||||
for (auto [pathMatrix, path] : pathDrawList) {
|
||||
int numTrianglesWritten;
|
||||
@ -284,9 +284,9 @@ void PathCurveTessellator::prepare(GrMeshDrawTarget* target,
|
||||
}
|
||||
vertexWriter.writeArray(tri->fPts, 3);
|
||||
// Mark this instance as a triangle by setting it to a conic with w=Inf.
|
||||
vertexWriter.fill(GrVertexWriter::kIEEE_32_infinity, 2);
|
||||
vertexWriter << GrVertexWriter::If(!shaderCaps.infinitySupport(),
|
||||
GrTessellationShader::kTriangularConicCurveType);
|
||||
vertexWriter.fill(VertexWriter::kIEEE_32_infinity, 2);
|
||||
vertexWriter << VertexWriter::If(!shaderCaps.infinitySupport(),
|
||||
GrTessellationShader::kTriangularConicCurveType);
|
||||
++numWritten;
|
||||
}
|
||||
SkASSERT(count == breadcrumbTriangleList->count());
|
||||
|
@ -9,8 +9,8 @@
|
||||
#define tessellate_PathTessellator_DEFINED
|
||||
|
||||
#include "src/core/SkPathPriv.h"
|
||||
#include "src/gpu/GrVertexWriter.h"
|
||||
#include "src/gpu/GrVx.h"
|
||||
#include "src/gpu/VertexWriter.h"
|
||||
#include "src/gpu/geometry/GrInnerFanTriangulator.h"
|
||||
|
||||
class SkPath;
|
||||
|
@ -147,11 +147,11 @@ public:
|
||||
SkPoint p0,
|
||||
SkPoint p1,
|
||||
SkPoint midpoint) {
|
||||
if (GrVertexWriter vertexWriter = fChunker.appendVertex()) {
|
||||
if (VertexWriter vertexWriter = fChunker.appendVertex()) {
|
||||
fPathXform.mapLineToCubic(&vertexWriter, p0, p1);
|
||||
vertexWriter << midpoint
|
||||
<< GrVertexWriter::If(!shaderCaps.infinitySupport(),
|
||||
GrTessellationShader::kCubicCurveType);
|
||||
<< VertexWriter::If(!shaderCaps.infinitySupport(),
|
||||
GrTessellationShader::kCubicCurveType);
|
||||
}
|
||||
}
|
||||
|
||||
@ -163,11 +163,11 @@ public:
|
||||
this->chopAndWriteQuadraticWedges(shaderCaps, p, midpoint);
|
||||
return;
|
||||
}
|
||||
if (GrVertexWriter vertexWriter = fChunker.appendVertex()) {
|
||||
if (VertexWriter vertexWriter = fChunker.appendVertex()) {
|
||||
fPathXform.mapQuadToCubic(&vertexWriter, p);
|
||||
vertexWriter << midpoint
|
||||
<< GrVertexWriter::If(!shaderCaps.infinitySupport(),
|
||||
GrTessellationShader::kCubicCurveType);
|
||||
<< VertexWriter::If(!shaderCaps.infinitySupport(),
|
||||
GrTessellationShader::kCubicCurveType);
|
||||
}
|
||||
fNumFixedSegments_pow4 = std::max(numSegments_pow4, fNumFixedSegments_pow4);
|
||||
}
|
||||
@ -181,11 +181,11 @@ public:
|
||||
this->chopAndWriteConicWedges(shaderCaps, {p, w}, midpoint);
|
||||
return;
|
||||
}
|
||||
if (GrVertexWriter vertexWriter = fChunker.appendVertex()) {
|
||||
if (VertexWriter vertexWriter = fChunker.appendVertex()) {
|
||||
fPathXform.mapConicToPatch(&vertexWriter, p, w);
|
||||
vertexWriter << midpoint
|
||||
<< GrVertexWriter::If(!shaderCaps.infinitySupport(),
|
||||
GrTessellationShader::kConicCurveType);
|
||||
<< VertexWriter::If(!shaderCaps.infinitySupport(),
|
||||
GrTessellationShader::kConicCurveType);
|
||||
}
|
||||
fNumFixedSegments_pow4 = std::max(numSegments_pow2 * numSegments_pow2,
|
||||
fNumFixedSegments_pow4);
|
||||
@ -199,11 +199,11 @@ public:
|
||||
this->chopAndWriteCubicWedges(shaderCaps, p, midpoint);
|
||||
return;
|
||||
}
|
||||
if (GrVertexWriter vertexWriter = fChunker.appendVertex()) {
|
||||
if (VertexWriter vertexWriter = fChunker.appendVertex()) {
|
||||
fPathXform.map4Points(&vertexWriter, p);
|
||||
vertexWriter << midpoint
|
||||
<< GrVertexWriter::If(!shaderCaps.infinitySupport(),
|
||||
GrTessellationShader::kCubicCurveType);
|
||||
<< VertexWriter::If(!shaderCaps.infinitySupport(),
|
||||
GrTessellationShader::kCubicCurveType);
|
||||
}
|
||||
fNumFixedSegments_pow4 = std::max(numSegments_pow4, fNumFixedSegments_pow4);
|
||||
}
|
||||
|
@ -9,8 +9,8 @@
|
||||
#define tessellate_PathXform_DEFINED
|
||||
|
||||
#include "include/core/SkMatrix.h"
|
||||
#include "src/gpu/GrVertexWriter.h"
|
||||
#include "src/gpu/GrVx.h"
|
||||
#include "src/gpu/VertexWriter.h"
|
||||
|
||||
namespace skgpu {
|
||||
|
||||
@ -45,23 +45,23 @@ public:
|
||||
return skvx::bit_pun<SkPoint>(this->mapPoint(skvx::bit_pun<float2>(p)));
|
||||
}
|
||||
|
||||
SK_ALWAYS_INLINE void map2Points(GrVertexWriter* writer, const SkPoint pts[2]) const {
|
||||
SK_ALWAYS_INLINE void map2Points(VertexWriter* writer, const SkPoint pts[2]) const {
|
||||
float4 p = float4::Load(pts);
|
||||
*writer << (fScale * p + (fSkew * skvx::shuffle<1,0,3,2>(p) + fTrans));
|
||||
}
|
||||
|
||||
SK_ALWAYS_INLINE void map3Points(GrVertexWriter* writer, const SkPoint pts[3]) const {
|
||||
SK_ALWAYS_INLINE void map3Points(VertexWriter* writer, const SkPoint pts[3]) const {
|
||||
*writer << this->mapPoint(pts[0]);
|
||||
this->map2Points(writer, pts + 1);
|
||||
}
|
||||
|
||||
SK_ALWAYS_INLINE void map4Points(GrVertexWriter* writer, const SkPoint pts[4]) const {
|
||||
SK_ALWAYS_INLINE void map4Points(VertexWriter* writer, const SkPoint pts[4]) const {
|
||||
this->map2Points(writer, pts);
|
||||
this->map2Points(writer, pts + 2);
|
||||
}
|
||||
|
||||
// Emits a degenerate, 4-point transformed cubic bezier equal to a line.
|
||||
SK_ALWAYS_INLINE void mapLineToCubic(GrVertexWriter* writer,
|
||||
SK_ALWAYS_INLINE void mapLineToCubic(VertexWriter* writer,
|
||||
SkPoint startPt,
|
||||
SkPoint endPt) const {
|
||||
float2 p0 = this->mapPoint(skvx::bit_pun<float2>(startPt));
|
||||
@ -71,7 +71,7 @@ public:
|
||||
}
|
||||
|
||||
// Emits a degenerate, 4-point transformed bezier equal to a quadratic.
|
||||
SK_ALWAYS_INLINE void mapQuadToCubic(GrVertexWriter* writer, const SkPoint pts[3]) const {
|
||||
SK_ALWAYS_INLINE void mapQuadToCubic(VertexWriter* writer, const SkPoint pts[3]) const {
|
||||
float2 p0 = this->mapPoint(skvx::bit_pun<float2>(pts[0]));
|
||||
float2 p1 = this->mapPoint(skvx::bit_pun<float2>(pts[1]));
|
||||
float2 p2 = this->mapPoint(skvx::bit_pun<float2>(pts[2]));
|
||||
@ -81,11 +81,11 @@ public:
|
||||
|
||||
// Writes out the 3 conic points transformed, plus a 4th point with the conic weight in x and
|
||||
// infinity in y. Infinite y flags the 4-point patch as a conic.
|
||||
SK_ALWAYS_INLINE void mapConicToPatch(GrVertexWriter* writer,
|
||||
SK_ALWAYS_INLINE void mapConicToPatch(VertexWriter* writer,
|
||||
const SkPoint pts[3],
|
||||
float w) const {
|
||||
this->map3Points(writer, pts);
|
||||
*writer << w << GrVertexWriter::kIEEE_32_infinity;
|
||||
*writer << w << VertexWriter::kIEEE_32_infinity;
|
||||
}
|
||||
|
||||
private:
|
||||
|
@ -123,12 +123,12 @@ public:
|
||||
// Draws a circle whose diameter is equal to the stroke width. We emit circles at cusp points
|
||||
// round caps, and empty strokes that are specified to be drawn as circles.
|
||||
void writeCircle(SkPoint location) {
|
||||
if (GrVertexWriter writer = fChunkBuilder.appendVertex()) {
|
||||
if (VertexWriter writer = fChunkBuilder.appendVertex()) {
|
||||
// The shader interprets an empty stroke + empty join as a special case that denotes a
|
||||
// circle, or 180-degree point stroke.
|
||||
writer.fill(location, 5);
|
||||
writer << GrVertexWriter::If(!fShaderCaps->infinitySupport(),
|
||||
GrTessellationShader::kCubicCurveType);
|
||||
writer << VertexWriter::If(!fShaderCaps->infinitySupport(),
|
||||
GrTessellationShader::kCubicCurveType);
|
||||
this->writeDynamicAttribs(&writer);
|
||||
}
|
||||
}
|
||||
@ -195,17 +195,17 @@ private:
|
||||
fDeferredCurveTypeIfUnsupportedInfinity = curveTypeIfUnsupportedInfinity;
|
||||
fHasDeferredFirstStroke = true;
|
||||
fHasLastControlPoint = true;
|
||||
} else if (GrVertexWriter writer = fChunkBuilder.appendVertex()) {
|
||||
} else if (VertexWriter writer = fChunkBuilder.appendVertex()) {
|
||||
writer.writeArray(p, 4);
|
||||
writer << fLastControlPoint
|
||||
<< GrVertexWriter::If(!fShaderCaps->infinitySupport(),
|
||||
curveTypeIfUnsupportedInfinity);
|
||||
<< VertexWriter::If(!fShaderCaps->infinitySupport(),
|
||||
curveTypeIfUnsupportedInfinity);
|
||||
this->writeDynamicAttribs(&writer);
|
||||
}
|
||||
fLastControlPoint = endControlPoint;
|
||||
}
|
||||
|
||||
SK_ALWAYS_INLINE void writeDynamicAttribs(GrVertexWriter* writer) {
|
||||
SK_ALWAYS_INLINE void writeDynamicAttribs(VertexWriter* writer) {
|
||||
if (fShaderFlags & ShaderFlags::kDynamicStroke) {
|
||||
*writer << fDynamicStroke;
|
||||
}
|
||||
|
@ -235,7 +235,7 @@ public:
|
||||
fLastControlPoint = p[0]; // Disables the join section of this patch.
|
||||
}
|
||||
|
||||
if (GrVertexWriter patchWriter = fChunkBuilder.appendVertex()) {
|
||||
if (VertexWriter patchWriter = fChunkBuilder.appendVertex()) {
|
||||
patchWriter << fLastControlPoint;
|
||||
patchWriter.writeArray(p, 4);
|
||||
this->writeDynamicAttribs(&patchWriter);
|
||||
@ -589,7 +589,7 @@ private:
|
||||
// We should never write out joins before the first curve.
|
||||
SkASSERT(fHasLastControlPoint);
|
||||
|
||||
if (GrVertexWriter patchWriter = fChunkBuilder.appendVertex()) {
|
||||
if (VertexWriter patchWriter = fChunkBuilder.appendVertex()) {
|
||||
patchWriter << fLastControlPoint << junctionPoint;
|
||||
if (joinType == JoinType::kBowtie) {
|
||||
// {prevControlPoint, [p0, p0, p0, p3]} is a reserved patch pattern that means this
|
||||
@ -609,7 +609,7 @@ private:
|
||||
fLastControlPoint = nextControlPoint;
|
||||
}
|
||||
|
||||
SK_ALWAYS_INLINE void writeDynamicAttribs(GrVertexWriter* patchWriter) {
|
||||
SK_ALWAYS_INLINE void writeDynamicAttribs(VertexWriter* patchWriter) {
|
||||
if (fShaderFlags & ShaderFlags::kDynamicStroke) {
|
||||
*patchWriter << fDynamicStroke;
|
||||
}
|
||||
|
@ -70,24 +70,24 @@ public:
|
||||
constexpr int kMaxVertexCount = (1 << kMaxFixedCountResolveLevel) + 1;
|
||||
return kMaxVertexCount * kMiddleOutVertexStride;
|
||||
}
|
||||
static void InitializeVertexBufferForMiddleOutCurves(GrVertexWriter, size_t bufferSize);
|
||||
static void InitializeVertexBufferForMiddleOutCurves(skgpu::VertexWriter, size_t bufferSize);
|
||||
|
||||
constexpr static size_t SizeOfIndexBufferForMiddleOutCurves() {
|
||||
constexpr int kMaxTriangleCount =
|
||||
NumCurveTrianglesAtResolveLevel(kMaxFixedCountResolveLevel);
|
||||
return kMaxTriangleCount * 3 * sizeof(uint16_t);
|
||||
}
|
||||
static void InitializeIndexBufferForMiddleOutCurves(GrVertexWriter, size_t bufferSize);
|
||||
static void InitializeIndexBufferForMiddleOutCurves(skgpu::VertexWriter, size_t bufferSize);
|
||||
|
||||
constexpr static int SizeOfVertexBufferForMiddleOutWedges() {
|
||||
return SizeOfVertexBufferForMiddleOutCurves() + kMiddleOutVertexStride;
|
||||
}
|
||||
static void InitializeVertexBufferForMiddleOutWedges(GrVertexWriter, size_t bufferSize);
|
||||
static void InitializeVertexBufferForMiddleOutWedges(skgpu::VertexWriter, size_t bufferSize);
|
||||
|
||||
constexpr static size_t SizeOfIndexBufferForMiddleOutWedges() {
|
||||
return SizeOfIndexBufferForMiddleOutCurves() + 3 * sizeof(uint16_t);
|
||||
}
|
||||
static void InitializeIndexBufferForMiddleOutWedges(GrVertexWriter, size_t bufferSize);
|
||||
static void InitializeIndexBufferForMiddleOutWedges(skgpu::VertexWriter, size_t bufferSize);
|
||||
|
||||
// Uses GPU tessellation shaders to linearize, triangulate, and render cubic "wedge" patches. A
|
||||
// wedge is a 5-point patch consisting of 4 cubic control points, plus an anchor point fanning
|
||||
|
@ -11,6 +11,8 @@
|
||||
#include "src/gpu/glsl/GrGLSLVertexGeoBuilder.h"
|
||||
#include "src/gpu/tessellate/WangsFormula.h"
|
||||
|
||||
using skgpu::VertexWriter;
|
||||
|
||||
namespace {
|
||||
|
||||
// Uses instanced draws to triangulate standalone closed curves with a "middle-out" topology.
|
||||
@ -179,13 +181,13 @@ GrPathTessellationShader* GrPathTessellationShader::MakeMiddleOutFixedCountShade
|
||||
return arena->make<MiddleOutShader>(shaderCaps, viewMatrix, color, patchType);
|
||||
}
|
||||
|
||||
void GrPathTessellationShader::InitializeVertexBufferForMiddleOutCurves(GrVertexWriter vertexWriter,
|
||||
void GrPathTessellationShader::InitializeVertexBufferForMiddleOutCurves(VertexWriter vertexWriter,
|
||||
size_t bufferSize) {
|
||||
SkASSERT(bufferSize >= kMiddleOutVertexStride * 2);
|
||||
SkASSERT(bufferSize % kMiddleOutVertexStride == 0);
|
||||
int vertexCount = bufferSize / kMiddleOutVertexStride;
|
||||
SkASSERT(vertexCount > 3);
|
||||
SkDEBUGCODE(GrVertexWriter end = vertexWriter.makeOffset(vertexCount * kMiddleOutVertexStride);)
|
||||
SkDEBUGCODE(VertexWriter end = vertexWriter.makeOffset(vertexCount * kMiddleOutVertexStride);)
|
||||
|
||||
// Lay out the vertices in "middle-out" order:
|
||||
//
|
||||
@ -214,7 +216,7 @@ void GrPathTessellationShader::InitializeVertexBufferForMiddleOutCurves(GrVertex
|
||||
SkASSERT(vertexWriter == end);
|
||||
}
|
||||
|
||||
void GrPathTessellationShader::InitializeVertexBufferForMiddleOutWedges(GrVertexWriter vertexWriter,
|
||||
void GrPathTessellationShader::InitializeVertexBufferForMiddleOutWedges(VertexWriter vertexWriter,
|
||||
size_t bufferSize) {
|
||||
SkASSERT(bufferSize >= kMiddleOutVertexStride);
|
||||
// Start out with the fan point. A negative resolve level indicates the fan point.
|
||||
@ -224,7 +226,8 @@ void GrPathTessellationShader::InitializeVertexBufferForMiddleOutWedges(GrVertex
|
||||
bufferSize - kMiddleOutVertexStride);
|
||||
}
|
||||
|
||||
static void fill_index_buffer_for_curves(GrVertexWriter vertexWriter, size_t bufferSize,
|
||||
static void fill_index_buffer_for_curves(VertexWriter vertexWriter,
|
||||
size_t bufferSize,
|
||||
uint16_t baseIndex) {
|
||||
SkASSERT(bufferSize % (sizeof(uint16_t) * 3) == 0);
|
||||
int triangleCount = bufferSize / (sizeof(uint16_t) * 3);
|
||||
@ -268,12 +271,12 @@ static void fill_index_buffer_for_curves(GrVertexWriter vertexWriter, size_t buf
|
||||
vertexWriter.writeArray(indexData.data(), indexData.count());
|
||||
}
|
||||
|
||||
void GrPathTessellationShader::InitializeIndexBufferForMiddleOutCurves(GrVertexWriter vertexWriter,
|
||||
void GrPathTessellationShader::InitializeIndexBufferForMiddleOutCurves(VertexWriter vertexWriter,
|
||||
size_t bufferSize) {
|
||||
fill_index_buffer_for_curves(std::move(vertexWriter), bufferSize, 0);
|
||||
}
|
||||
|
||||
void GrPathTessellationShader::InitializeIndexBufferForMiddleOutWedges(GrVertexWriter vertexWriter,
|
||||
void GrPathTessellationShader::InitializeIndexBufferForMiddleOutWedges(VertexWriter vertexWriter,
|
||||
size_t bufferSize) {
|
||||
SkASSERT(bufferSize >= sizeof(uint16_t) * 3);
|
||||
// Start out with the fan triangle.
|
||||
|
@ -118,7 +118,8 @@ public:
|
||||
// and sk_VertexID is not supported. Each vertex is a single float and each edge is composed of
|
||||
// two vertices, so the desired edge count in the buffer is presumed to be
|
||||
// "bufferSize / (sizeof(float) * 2)". The caller cannot draw more vertices than edgeCount * 2.
|
||||
static void InitializeVertexIDFallbackBuffer(GrVertexWriter vertexWriter, size_t bufferSize);
|
||||
static void InitializeVertexIDFallbackBuffer(skgpu::VertexWriter vertexWriter,
|
||||
size_t bufferSize);
|
||||
|
||||
private:
|
||||
const char* name() const override {
|
||||
|
@ -11,6 +11,8 @@
|
||||
#include "src/gpu/glsl/GrGLSLVertexGeoBuilder.h"
|
||||
#include "src/gpu/tessellate/WangsFormula.h"
|
||||
|
||||
using skgpu::VertexWriter;
|
||||
|
||||
void GrStrokeTessellationShader::InstancedImpl::onEmitCode(EmitArgs& args, GrGPArgs* gpArgs) {
|
||||
const auto& shader = args.fGeomProc.cast<GrStrokeTessellationShader>();
|
||||
SkPaint::Join joinType = shader.stroke().getJoin();
|
||||
@ -264,7 +266,7 @@ void GrStrokeTessellationShader::InstancedImpl::onEmitCode(EmitArgs& args, GrGPA
|
||||
this->emitFragmentCode(shader, args);
|
||||
}
|
||||
|
||||
void GrStrokeTessellationShader::InitializeVertexIDFallbackBuffer(GrVertexWriter vertexWriter,
|
||||
void GrStrokeTessellationShader::InitializeVertexIDFallbackBuffer(VertexWriter vertexWriter,
|
||||
size_t bufferSize) {
|
||||
SkASSERT(bufferSize % (sizeof(float) * 2) == 0);
|
||||
int edgeCount = bufferSize / (sizeof(float) * 2);
|
||||
|
@ -10,7 +10,7 @@
|
||||
|
||||
#include "src/gpu/GrGeometryProcessor.h"
|
||||
#include "src/gpu/GrProgramInfo.h"
|
||||
#include "src/gpu/GrVertexWriter.h"
|
||||
#include "src/gpu/VertexWriter.h"
|
||||
|
||||
class SkArenaAlloc;
|
||||
|
||||
@ -46,14 +46,14 @@ public:
|
||||
inline constexpr static float kTriangularConicCurveType = 2; // Conic curve with w=Infinity.
|
||||
|
||||
// Fills in a 4-point patch in such a way that the shader will recognize it as a conic.
|
||||
static void WriteConicPatch(const SkPoint pts[3], float w, GrVertexWriter* writer) {
|
||||
static void WriteConicPatch(const SkPoint pts[3], float w, skgpu::VertexWriter* writer) {
|
||||
// Write out the 3 conic points to patch[0..2], the weight to patch[3].x, and then set
|
||||
// patch[3].y as NaN to flag this patch as a conic.
|
||||
writer->writeArray(pts, 3);
|
||||
*writer << w << GrVertexWriter::kIEEE_32_infinity;
|
||||
*writer << w << skgpu::VertexWriter::kIEEE_32_infinity;
|
||||
}
|
||||
static void WriteConicPatch(const SkPoint pts[3], float w, SkPoint patch[4]) {
|
||||
GrVertexWriter writer(patch);
|
||||
skgpu::VertexWriter writer(patch);
|
||||
WriteConicPatch(pts, w, &writer);
|
||||
}
|
||||
|
||||
|
@ -122,7 +122,7 @@ DEF_TEST(GrPathUtils_findCubicConvex180Chops, r) {
|
||||
|
||||
DEF_TEST(GrPathUtils_convertToCubic, r) {
|
||||
SkPoint cubic[4];
|
||||
GrVertexWriter cubicWriter(cubic);
|
||||
skgpu::VertexWriter cubicWriter(cubic);
|
||||
GrPathUtils::writeLineAsCubic({0,0}, {3,6}, &cubicWriter);
|
||||
REPORTER_ASSERT(r, cubic[0] == SkPoint::Make(0,0));
|
||||
REPORTER_ASSERT(r, SkScalarNearlyEqual(cubic[1].fX, 1));
|
||||
|
@ -13,7 +13,7 @@
|
||||
#include "src/gpu/GrMemoryPool.h"
|
||||
#include "src/gpu/GrOpFlushState.h"
|
||||
#include "src/gpu/GrProgramInfo.h"
|
||||
#include "src/gpu/GrVertexWriter.h"
|
||||
#include "src/gpu/VertexWriter.h"
|
||||
#include "src/gpu/glsl/GrGLSLFragmentShaderBuilder.h"
|
||||
#include "src/gpu/glsl/GrGLSLVarying.h"
|
||||
#include "src/gpu/glsl/GrGLSLVertexGeoBuilder.h"
|
||||
@ -200,9 +200,9 @@ void TestRectOp::onCreateProgramInfo(const GrCaps* caps,
|
||||
|
||||
void TestRectOp::onPrepareDraws(GrMeshDrawTarget* target) {
|
||||
QuadHelper helper(target, fGP.vertexStride(), 1);
|
||||
GrVertexWriter writer{helper.vertices()};
|
||||
auto pos = GrVertexWriter::TriStripFromRect(fDrawRect);
|
||||
auto local = GrVertexWriter::TriStripFromRect(fLocalRect);
|
||||
skgpu::VertexWriter writer{helper.vertices()};
|
||||
auto pos = skgpu::VertexWriter::TriStripFromRect(fDrawRect);
|
||||
auto local = skgpu::VertexWriter::TriStripFromRect(fLocalRect);
|
||||
GrVertexColor color(fColor, fGP.wideColor());
|
||||
writer.writeQuad(pos, local, color);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user