Rename SkCustomMesh to SkMesh
Also rename associated files, types, functions, etc. Bug: skia:12720 Change-Id: Ibebb4e7071fa19c5a81cd36d567c96a42cd824f3 Reviewed-on: https://skia-review.googlesource.com/c/skia/+/538040 Commit-Queue: Brian Salomon <bsalomon@google.com> Reviewed-by: Greg Daniel <egdaniel@google.com>
This commit is contained in:
parent
0b81e99101
commit
f7082cb9fa
@ -3225,25 +3225,6 @@ generated_cc_atom(
|
||||
],
|
||||
)
|
||||
|
||||
generated_cc_atom(
|
||||
name = "custommesh_src",
|
||||
srcs = ["custommesh.cpp"],
|
||||
visibility = ["//:__subpackages__"],
|
||||
deps = [
|
||||
":gm_hdr",
|
||||
"//include/core:SkBlender_hdr",
|
||||
"//include/core:SkCanvas_hdr",
|
||||
"//include/core:SkColorSpace_hdr",
|
||||
"//include/core:SkCustomMesh_hdr",
|
||||
"//include/core:SkData_hdr",
|
||||
"//include/core:SkSurface_hdr",
|
||||
"//include/effects:SkGradientShader_hdr",
|
||||
"//include/gpu:GrDirectContext_hdr",
|
||||
"//src/core:SkCanvasPriv_hdr",
|
||||
"//src/core:SkCustomMeshPriv_hdr",
|
||||
],
|
||||
)
|
||||
|
||||
generated_cc_atom(
|
||||
name = "daa_src",
|
||||
srcs = ["daa.cpp"],
|
||||
@ -9676,3 +9657,22 @@ generated_cc_atom(
|
||||
"//include/effects:SkImageFilters_hdr",
|
||||
],
|
||||
)
|
||||
|
||||
generated_cc_atom(
|
||||
name = "mesh_src",
|
||||
srcs = ["mesh.cpp"],
|
||||
visibility = ["//:__subpackages__"],
|
||||
deps = [
|
||||
":gm_hdr",
|
||||
"//include/core:SkBlender_hdr",
|
||||
"//include/core:SkCanvas_hdr",
|
||||
"//include/core:SkColorSpace_hdr",
|
||||
"//include/core:SkData_hdr",
|
||||
"//include/core:SkMesh_hdr",
|
||||
"//include/core:SkSurface_hdr",
|
||||
"//include/effects:SkGradientShader_hdr",
|
||||
"//include/gpu:GrDirectContext_hdr",
|
||||
"//src/core:SkCanvasPriv_hdr",
|
||||
"//src/core:SkMeshPriv_hdr",
|
||||
],
|
||||
)
|
||||
|
@ -9,24 +9,24 @@
|
||||
#include "include/core/SkBlender.h"
|
||||
#include "include/core/SkCanvas.h"
|
||||
#include "include/core/SkColorSpace.h"
|
||||
#include "include/core/SkCustomMesh.h"
|
||||
#include "include/core/SkData.h"
|
||||
#include "include/core/SkMesh.h"
|
||||
#include "include/core/SkSurface.h"
|
||||
#include "include/effects/SkGradientShader.h"
|
||||
#include "include/gpu/GrDirectContext.h"
|
||||
#include "src/core/SkCanvasPriv.h"
|
||||
#include "src/core/SkCustomMeshPriv.h"
|
||||
#include "src/core/SkMeshPriv.h"
|
||||
|
||||
#include <memory>
|
||||
|
||||
namespace skiagm {
|
||||
class CustomMeshGM : public skiagm::GM {
|
||||
class MeshGM : public skiagm::GM {
|
||||
public:
|
||||
CustomMeshGM() {}
|
||||
MeshGM() {}
|
||||
|
||||
protected:
|
||||
using Attribute = SkCustomMeshSpecification::Attribute;
|
||||
using Varying = SkCustomMeshSpecification::Varying;
|
||||
using Attribute = SkMeshSpecification::Attribute;
|
||||
using Varying = SkMeshSpecification::Varying;
|
||||
|
||||
SkISize onISize() override { return {435, 1180}; }
|
||||
|
||||
@ -55,12 +55,12 @@ protected:
|
||||
return varyings.uv;
|
||||
}
|
||||
)";
|
||||
auto [spec, error] = SkCustomMeshSpecification::Make(
|
||||
SkMakeSpan(kAttributes, SK_ARRAY_COUNT(kAttributes)),
|
||||
sizeof(ColorVertex),
|
||||
SkMakeSpan(kVaryings, SK_ARRAY_COUNT(kVaryings)),
|
||||
SkString(kVS),
|
||||
SkString(kFS));
|
||||
auto[spec, error] =
|
||||
SkMeshSpecification::Make(SkMakeSpan(kAttributes, SK_ARRAY_COUNT(kAttributes)),
|
||||
sizeof(ColorVertex),
|
||||
SkMakeSpan(kVaryings, SK_ARRAY_COUNT(kVaryings)),
|
||||
SkString(kVS),
|
||||
SkString(kFS));
|
||||
if (!spec) {
|
||||
SkDebugf("%s\n", error.c_str());
|
||||
}
|
||||
@ -85,12 +85,12 @@ protected:
|
||||
return helper(varyings.vux2);
|
||||
}
|
||||
)";
|
||||
auto [spec, error] = SkCustomMeshSpecification::Make(
|
||||
SkMakeSpan(kAttributes, SK_ARRAY_COUNT(kAttributes)),
|
||||
sizeof(NoColorVertex),
|
||||
SkMakeSpan(kVaryings, SK_ARRAY_COUNT(kVaryings)),
|
||||
SkString(kVS),
|
||||
SkString(kFS));
|
||||
auto[spec, error] =
|
||||
SkMeshSpecification::Make(SkMakeSpan(kAttributes, SK_ARRAY_COUNT(kAttributes)),
|
||||
sizeof(NoColorVertex),
|
||||
SkMakeSpan(kVaryings, SK_ARRAY_COUNT(kVaryings)),
|
||||
SkString(kVS),
|
||||
SkString(kFS));
|
||||
if (!spec) {
|
||||
SkDebugf("%s\n", error.c_str());
|
||||
}
|
||||
@ -112,9 +112,9 @@ protected:
|
||||
return DrawResult::kOk;
|
||||
}
|
||||
|
||||
fColorVB = SkCustomMesh::MakeVertexBuffer(context, CpuVBAsData(fColorVB));
|
||||
fColorIndexedVB = SkCustomMesh::MakeVertexBuffer(context, CpuVBAsData(fColorIndexedVB));
|
||||
fIB[1] = SkCustomMesh::MakeIndexBuffer (context, CpuIBAsData(fIB[0]));
|
||||
fColorVB = SkMesh::MakeVertexBuffer(context, CpuVBAsData(fColorVB));
|
||||
fColorIndexedVB = SkMesh::MakeVertexBuffer(context, CpuVBAsData(fColorIndexedVB));
|
||||
fIB[1] = SkMesh::MakeIndexBuffer (context, CpuIBAsData(fIB[0]));
|
||||
if (!fColorVB || !fColorIndexedVB || !fIB[1]) {
|
||||
return DrawResult::kFail;
|
||||
}
|
||||
@ -140,47 +140,47 @@ protected:
|
||||
for (uint8_t alpha : {0xFF , 0x40})
|
||||
for (bool colors : {false, true})
|
||||
for (bool shader : {false, true}) {
|
||||
SkCustomMesh cm;
|
||||
SkMesh mesh;
|
||||
// Rather than pile onto the combinatorics we draw every other test case indexed.
|
||||
if ((i & 1) == 0) {
|
||||
if (colors) {
|
||||
cm = SkCustomMesh::Make(fSpecWithColor,
|
||||
SkCustomMesh::Mode::kTriangleStrip,
|
||||
fColorVB,
|
||||
/*vertexCount= */4,
|
||||
/*vertexOffset=*/0,
|
||||
kRect);
|
||||
mesh = SkMesh::Make(fSpecWithColor,
|
||||
SkMesh::Mode::kTriangleStrip,
|
||||
fColorVB,
|
||||
/*vertexCount= */ 4,
|
||||
/*vertexOffset=*/ 0,
|
||||
kRect);
|
||||
} else {
|
||||
cm = SkCustomMesh::Make(fSpecWithNoColor,
|
||||
SkCustomMesh::Mode::kTriangleStrip,
|
||||
fNoColorVB,
|
||||
/*vertexCount=*/4,
|
||||
kNoColorOffset,
|
||||
kRect);
|
||||
mesh = SkMesh::Make(fSpecWithNoColor,
|
||||
SkMesh::Mode::kTriangleStrip,
|
||||
fNoColorVB,
|
||||
/*vertexCount=*/4,
|
||||
kNoColorOffset,
|
||||
kRect);
|
||||
}
|
||||
} else {
|
||||
// Alternate between CPU and GPU-backend index buffers.
|
||||
auto ib = (i%4 == 0) ? fIB[0] : fIB[1];
|
||||
if (colors) {
|
||||
cm = SkCustomMesh::MakeIndexed(fSpecWithColor,
|
||||
SkCustomMesh::Mode::kTriangles,
|
||||
fColorIndexedVB,
|
||||
/*vertexCount=*/6,
|
||||
kColorIndexedOffset,
|
||||
std::move(ib),
|
||||
/*indexCount=*/6,
|
||||
kIndexOffset,
|
||||
kRect);
|
||||
mesh = SkMesh::MakeIndexed(fSpecWithColor,
|
||||
SkMesh::Mode::kTriangles,
|
||||
fColorIndexedVB,
|
||||
/*vertexCount=*/ 6,
|
||||
kColorIndexedOffset,
|
||||
std::move(ib),
|
||||
/*indexCount=*/6,
|
||||
kIndexOffset,
|
||||
kRect);
|
||||
} else {
|
||||
cm = SkCustomMesh::MakeIndexed(fSpecWithNoColor,
|
||||
SkCustomMesh::Mode::kTriangles,
|
||||
fNoColorIndexedVB,
|
||||
/*vertexCount=*/ 6,
|
||||
/*vertexOffset=*/0,
|
||||
std::move(ib),
|
||||
/*indexCount=*/6,
|
||||
kIndexOffset,
|
||||
kRect);
|
||||
mesh = SkMesh::MakeIndexed(fSpecWithNoColor,
|
||||
SkMesh::Mode::kTriangles,
|
||||
fNoColorIndexedVB,
|
||||
/*vertexCount=*/ 6,
|
||||
/*vertexOffset=*/0,
|
||||
std::move(ib),
|
||||
/*indexCount=*/6,
|
||||
kIndexOffset,
|
||||
kRect);
|
||||
}
|
||||
}
|
||||
SkPaint paint;
|
||||
@ -188,7 +188,7 @@ protected:
|
||||
paint.setShader(shader ? fShader : nullptr);
|
||||
paint.setAlpha(alpha);
|
||||
|
||||
SkCanvasPriv::DrawCustomMesh(canvas, cm, blender, paint);
|
||||
SkCanvasPriv::DrawMesh(canvas, mesh, blender, paint);
|
||||
|
||||
canvas->translate(0, 150);
|
||||
++i;
|
||||
@ -200,21 +200,21 @@ protected:
|
||||
}
|
||||
|
||||
private:
|
||||
static sk_sp<const SkData> CpuVBAsData(sk_sp<SkCustomMesh::VertexBuffer> buffer) {
|
||||
auto vb = static_cast<SkCustomMeshPriv::VB*>(buffer.get());
|
||||
static sk_sp<const SkData> CpuVBAsData(sk_sp<SkMesh::VertexBuffer> buffer) {
|
||||
auto vb = static_cast<SkMeshPriv::VB*>(buffer.get());
|
||||
SkASSERT(vb->asData());
|
||||
return vb->asData();
|
||||
}
|
||||
|
||||
static sk_sp<const SkData> CpuIBAsData(sk_sp<SkCustomMesh::IndexBuffer> buffer) {
|
||||
auto ib = static_cast<SkCustomMeshPriv::IB*>(buffer.get());
|
||||
static sk_sp<const SkData> CpuIBAsData(sk_sp<SkMesh::IndexBuffer> buffer) {
|
||||
auto ib = static_cast<SkMeshPriv::IB*>(buffer.get());
|
||||
SkASSERT(ib->asData());
|
||||
return ib->asData();
|
||||
}
|
||||
|
||||
void ensureBuffers() {
|
||||
if (!fColorVB) {
|
||||
fColorVB = SkCustomMesh::MakeVertexBuffer(
|
||||
fColorVB = SkMesh::MakeVertexBuffer(
|
||||
/*GrDirectContext*=*/nullptr,
|
||||
SkData::MakeWithoutCopy(kColorQuad, sizeof(kColorQuad)));
|
||||
}
|
||||
@ -225,8 +225,7 @@ private:
|
||||
std::memcpy(SkTAddOffset<void>(data->writable_data(), kNoColorOffset),
|
||||
kNoColorQuad,
|
||||
sizeof(kNoColorQuad));
|
||||
fNoColorVB = SkCustomMesh::MakeVertexBuffer(/*GrDirectContext*=*/nullptr,
|
||||
std::move(data));
|
||||
fNoColorVB = SkMesh::MakeVertexBuffer(/*GrDirectContext*=*/nullptr, std::move(data));
|
||||
}
|
||||
|
||||
if (!fColorIndexedVB) {
|
||||
@ -235,12 +234,12 @@ private:
|
||||
std::memcpy(SkTAddOffset<void>(data->writable_data(), kColorIndexedOffset),
|
||||
kColorIndexedQuad,
|
||||
sizeof(kColorIndexedQuad));
|
||||
fColorIndexedVB = SkCustomMesh::MakeVertexBuffer(/*GrDirectContext*=*/nullptr,
|
||||
std::move(data));
|
||||
fColorIndexedVB = SkMesh::MakeVertexBuffer(/*GrDirectContext*=*/nullptr,
|
||||
std::move(data));
|
||||
}
|
||||
|
||||
if (!fNoColorIndexedVB) {
|
||||
fNoColorIndexedVB = SkCustomMesh::MakeVertexBuffer(
|
||||
fNoColorIndexedVB = SkMesh::MakeVertexBuffer(
|
||||
/*GrDirectContext*=*/nullptr,
|
||||
SkData::MakeWithoutCopy(kNoColorIndexedQuad, sizeof(kNoColorIndexedQuad)));
|
||||
}
|
||||
@ -251,7 +250,7 @@ private:
|
||||
std::memcpy(SkTAddOffset<void>(data->writable_data(), kIndexOffset),
|
||||
kIndices,
|
||||
sizeof(kIndices));
|
||||
fIB[0] = SkCustomMesh::MakeIndexBuffer(/*GrDirectContext*=*/nullptr, std::move(data));
|
||||
fIB[0] = SkMesh::MakeIndexBuffer(/*GrDirectContext*=*/nullptr, std::move(data));
|
||||
}
|
||||
|
||||
if (!fIB[1]) {
|
||||
@ -316,27 +315,27 @@ private:
|
||||
|
||||
sk_sp<SkShader> fShader;
|
||||
|
||||
sk_sp<SkCustomMeshSpecification> fSpecWithColor;
|
||||
sk_sp<SkCustomMeshSpecification> fSpecWithNoColor;
|
||||
sk_sp<SkMeshSpecification> fSpecWithColor;
|
||||
sk_sp<SkMeshSpecification> fSpecWithNoColor;
|
||||
|
||||
// On GPU the first IB is a CPU buffer and the second is a GPU buffer.
|
||||
sk_sp<SkCustomMesh::IndexBuffer> fIB[2];
|
||||
sk_sp<SkMesh::IndexBuffer> fIB[2];
|
||||
|
||||
sk_sp<SkCustomMesh::VertexBuffer> fColorVB;
|
||||
sk_sp<SkCustomMesh::VertexBuffer> fNoColorVB;
|
||||
sk_sp<SkCustomMesh::VertexBuffer> fColorIndexedVB;
|
||||
sk_sp<SkCustomMesh::VertexBuffer> fNoColorIndexedVB;
|
||||
sk_sp<SkMesh::VertexBuffer> fColorVB;
|
||||
sk_sp<SkMesh::VertexBuffer> fNoColorVB;
|
||||
sk_sp<SkMesh::VertexBuffer> fColorIndexedVB;
|
||||
sk_sp<SkMesh::VertexBuffer> fNoColorIndexedVB;
|
||||
};
|
||||
|
||||
DEF_GM( return new CustomMeshGM; )
|
||||
DEF_GM(return new MeshGM;)
|
||||
|
||||
class CustomMeshColorSpaceGM : public skiagm::GM {
|
||||
class MeshColorSpaceGM : public skiagm::GM {
|
||||
public:
|
||||
CustomMeshColorSpaceGM() {}
|
||||
MeshColorSpaceGM() {}
|
||||
|
||||
protected:
|
||||
using Attribute = SkCustomMeshSpecification::Attribute;
|
||||
using Varying = SkCustomMeshSpecification::Varying;
|
||||
using Attribute = SkMeshSpecification::Attribute;
|
||||
using Varying = SkMeshSpecification::Varying;
|
||||
|
||||
SkISize onISize() override { return {468, 258}; }
|
||||
|
||||
@ -375,7 +374,7 @@ protected:
|
||||
cs = cs->makeColorSpin();
|
||||
}
|
||||
|
||||
auto [spec, error] = SkCustomMeshSpecification::Make(
|
||||
auto [spec, error] = SkMeshSpecification::Make(
|
||||
SkMakeSpan(kAttributes, SK_ARRAY_COUNT(kAttributes)),
|
||||
sizeof(Vertex),
|
||||
SkMakeSpan(kVaryings, SK_ARRAY_COUNT(kVaryings)),
|
||||
@ -393,8 +392,7 @@ protected:
|
||||
SkColor colors[] = {SK_ColorWHITE, SK_ColorTRANSPARENT};
|
||||
fShader = SkGradientShader::MakeLinear(pts, colors, nullptr, 2, SkTileMode::kMirror);
|
||||
|
||||
fVB = SkCustomMesh::MakeVertexBuffer(nullptr,
|
||||
SkData::MakeWithoutCopy(kQuad, sizeof(kQuad)));
|
||||
fVB = SkMesh::MakeVertexBuffer(nullptr, SkData::MakeWithoutCopy(kQuad, sizeof(kQuad)));
|
||||
}
|
||||
|
||||
SkString onShortName() override { return SkString("custommesh_cs"); }
|
||||
@ -417,20 +415,17 @@ protected:
|
||||
for (bool unpremul : {false, true}) {
|
||||
c->save();
|
||||
for (bool spin : {false, true}) {
|
||||
SkCustomMesh cm = SkCustomMesh::Make(fSpecs[SpecIndex(unpremul, spin)],
|
||||
SkCustomMesh::Mode::kTriangleStrip,
|
||||
fVB,
|
||||
/*vertexCount=*/ 4,
|
||||
/*vertexOffset=*/0,
|
||||
kRect);
|
||||
SkMesh mesh = SkMesh::Make(fSpecs[SpecIndex(unpremul, spin)],
|
||||
SkMesh::Mode::kTriangleStrip,
|
||||
fVB,
|
||||
/*vertexCount=*/ 4,
|
||||
/*vertexOffset=*/0,
|
||||
kRect);
|
||||
|
||||
SkPaint paint;
|
||||
paint.setShader(useShader ? fShader : nullptr);
|
||||
SkBlendMode mode = useShader ? SkBlendMode::kModulate : SkBlendMode::kDst;
|
||||
SkCanvasPriv::DrawCustomMesh(c,
|
||||
std::move(cm),
|
||||
SkBlender::Mode(mode),
|
||||
paint);
|
||||
SkCanvasPriv::DrawMesh(c, mesh, SkBlender::Mode(mode), paint);
|
||||
|
||||
c->translate(0, kRect.height() + 10);
|
||||
}
|
||||
@ -463,13 +458,13 @@ private:
|
||||
{{kRect.right(), kRect.bottom()}, {0, 0, 1, 1}},
|
||||
};
|
||||
|
||||
sk_sp<SkCustomMesh::VertexBuffer> fVB;
|
||||
sk_sp<SkMesh::VertexBuffer> fVB;
|
||||
|
||||
sk_sp<SkCustomMeshSpecification> fSpecs[4];
|
||||
sk_sp<SkMeshSpecification> fSpecs[4];
|
||||
|
||||
sk_sp<SkShader> fShader;
|
||||
};
|
||||
|
||||
DEF_GM( return new CustomMeshColorSpaceGM; )
|
||||
DEF_GM(return new MeshColorSpaceGM;)
|
||||
|
||||
} // namespace skiagm
|
@ -24,7 +24,7 @@ skia_core_public = [
|
||||
"$_include/core/SkContourMeasure.h",
|
||||
"$_include/core/SkCoverageMode.h",
|
||||
"$_include/core/SkCubicMap.h",
|
||||
"$_include/core/SkCustomMesh.h",
|
||||
"$_include/core/SkMesh.h",
|
||||
"$_include/core/SkData.h",
|
||||
"$_include/core/SkDataTable.h",
|
||||
"$_include/core/SkDeferredDisplayList.h",
|
||||
@ -171,8 +171,6 @@ skia_core_sources = [
|
||||
"$_src/core/SkCubicClipper.h",
|
||||
"$_src/core/SkCubicMap.cpp",
|
||||
"$_src/core/SkCubicSolver.h",
|
||||
"$_src/core/SkCustomMesh.cpp",
|
||||
"$_src/core/SkCustomMeshPriv.h",
|
||||
"$_src/core/SkData.cpp",
|
||||
"$_src/core/SkDataTable.cpp",
|
||||
"$_src/core/SkDebug.cpp",
|
||||
@ -281,6 +279,8 @@ skia_core_sources = [
|
||||
"$_src/core/SkMatrixInvert.cpp",
|
||||
"$_src/core/SkMatrixInvert.h",
|
||||
"$_src/core/SkMatrixUtils.h",
|
||||
"$_src/core/SkMesh.cpp",
|
||||
"$_src/core/SkMeshPriv.h",
|
||||
"$_src/core/SkMessageBus.h",
|
||||
"$_src/core/SkMiniRecorder.cpp",
|
||||
"$_src/core/SkMiniRecorder.h",
|
||||
|
@ -140,7 +140,6 @@ gm_sources = [
|
||||
"$_gm/croppedrects.cpp",
|
||||
"$_gm/crosscontextimage.cpp",
|
||||
"$_gm/cubicpaths.cpp",
|
||||
"$_gm/custommesh.cpp",
|
||||
"$_gm/daa.cpp",
|
||||
"$_gm/dashcircle.cpp",
|
||||
"$_gm/dashcubics.cpp",
|
||||
@ -265,6 +264,7 @@ gm_sources = [
|
||||
"$_gm/manypaths.cpp",
|
||||
"$_gm/matrixconvolution.cpp",
|
||||
"$_gm/matriximagefilter.cpp",
|
||||
"$_gm/mesh.cpp",
|
||||
"$_gm/mipmap.cpp",
|
||||
"$_gm/mixedtextblobs.cpp",
|
||||
"$_gm/mixercolorfilter.cpp",
|
||||
|
@ -484,8 +484,8 @@ skia_skgpu_v1_sources = [
|
||||
"$_src/gpu/ganesh/ops/DrawAtlasOp.h",
|
||||
"$_src/gpu/ganesh/ops/DrawAtlasPathOp.cpp",
|
||||
"$_src/gpu/ganesh/ops/DrawAtlasPathOp.h",
|
||||
"$_src/gpu/ganesh/ops/DrawCustomMeshOp.cpp",
|
||||
"$_src/gpu/ganesh/ops/DrawCustomMeshOp.h",
|
||||
"$_src/gpu/ganesh/ops/DrawMeshOp.cpp",
|
||||
"$_src/gpu/ganesh/ops/DrawMeshOp.h",
|
||||
"$_src/gpu/ganesh/ops/DrawableOp.cpp",
|
||||
"$_src/gpu/ganesh/ops/DrawableOp.h",
|
||||
"$_src/gpu/ganesh/ops/FillPathFlags.h",
|
||||
|
@ -52,7 +52,6 @@ tests_sources = [
|
||||
"$_tests/CopySurfaceTest.cpp",
|
||||
"$_tests/CubicMapTest.cpp",
|
||||
"$_tests/CullTestTest.cpp",
|
||||
"$_tests/CustomMeshTest.cpp",
|
||||
"$_tests/DashPathEffectTest.cpp",
|
||||
"$_tests/DataRefTest.cpp",
|
||||
"$_tests/DebugLayerManagerTest.cpp",
|
||||
@ -147,6 +146,7 @@ tests_sources = [
|
||||
"$_tests/MatrixTest.cpp",
|
||||
"$_tests/MemoryTest.cpp",
|
||||
"$_tests/MemsetTest.cpp",
|
||||
"$_tests/MeshTest.cpp",
|
||||
"$_tests/MessageBusTest.cpp",
|
||||
"$_tests/MetaDataTest.cpp",
|
||||
"$_tests/MipMapTest.cpp",
|
||||
|
@ -933,21 +933,6 @@ generated_cc_atom(
|
||||
],
|
||||
)
|
||||
|
||||
generated_cc_atom(
|
||||
name = "SkCustomMesh_hdr",
|
||||
hdrs = ["SkCustomMesh.h"],
|
||||
enforce_iwyu = True,
|
||||
visibility = ["//:__subpackages__"],
|
||||
deps = [
|
||||
":SkAlphaType_hdr",
|
||||
":SkRect_hdr",
|
||||
":SkRefCnt_hdr",
|
||||
":SkSpan_hdr",
|
||||
":SkString_hdr",
|
||||
":SkTypes_hdr",
|
||||
],
|
||||
)
|
||||
|
||||
generated_cc_atom(
|
||||
name = "SkAlphaType_hdr",
|
||||
hdrs = ["SkAlphaType.h"],
|
||||
@ -971,3 +956,17 @@ generated_cc_atom(
|
||||
":SkTypes_hdr",
|
||||
],
|
||||
)
|
||||
|
||||
generated_cc_atom(
|
||||
name = "SkMesh_hdr",
|
||||
hdrs = ["SkMesh.h"],
|
||||
visibility = ["//:__subpackages__"],
|
||||
deps = [
|
||||
":SkAlphaType_hdr",
|
||||
":SkRect_hdr",
|
||||
":SkRefCnt_hdr",
|
||||
":SkSpan_hdr",
|
||||
":SkString_hdr",
|
||||
":SkTypes_hdr",
|
||||
],
|
||||
)
|
||||
|
@ -59,7 +59,7 @@ class SkPixmap;
|
||||
class SkRegion;
|
||||
class SkRRect;
|
||||
struct SkRSXform;
|
||||
class SkCustomMesh;
|
||||
class SkMesh;
|
||||
class SkSpecialImage;
|
||||
class SkSurface;
|
||||
class SkSurface_Base;
|
||||
@ -1960,9 +1960,9 @@ public:
|
||||
/**
|
||||
Experimental, under active development, and subject to change without notice.
|
||||
|
||||
Draws a mesh using a user-defined specification (see SkCustomMeshSpecification).
|
||||
Draws a mesh using a user-defined specification (see SkMeshSpecification).
|
||||
|
||||
SkBlender is ignored if SkCustomMesh's specification does not output fragment shader color.
|
||||
SkBlender is ignored if SkMesh's specification does not output fragment shader color.
|
||||
Otherwise, it combines
|
||||
- the SkShader if SkPaint contains SkShader
|
||||
- or the opaque SkPaint color if SkPaint does not contain SkShader
|
||||
@ -1970,13 +1970,13 @@ public:
|
||||
|
||||
SkMaskFilter, SkPathEffect, and antialiasing on SkPaint are ignored.
|
||||
|
||||
@param cm the custom mesh vertices and compatible specification.
|
||||
@param mesh the mesh vertices and compatible specification.
|
||||
@param blender combines vertices colors with SkShader if present or SkPaint opaque color
|
||||
if not. Ignored if the custom mesh does not output color. Defaults to
|
||||
SkBlendMode::kModulate if nullptr.
|
||||
@param paint specifies the SkShader, used as SkVertices texture, may be nullptr
|
||||
*/
|
||||
void drawCustomMesh(const SkCustomMesh& cm, sk_sp<SkBlender> blender, const SkPaint& paint);
|
||||
void drawMesh(const SkMesh& mesh, sk_sp<SkBlender> blender, const SkPaint& paint);
|
||||
#endif
|
||||
|
||||
/** Draws a Coons patch: the interpolation of four cubics with shared corners,
|
||||
@ -2200,7 +2200,7 @@ protected:
|
||||
|
||||
#ifndef SK_ENABLE_EXPERIMENTAL_CUSTOM_MESH
|
||||
// Define this in protected so we can still access internally for testing.
|
||||
void drawCustomMesh(const SkCustomMesh& cm, sk_sp<SkBlender> blender, const SkPaint& paint);
|
||||
void drawMesh(const SkMesh& mesh, sk_sp<SkBlender> blender, const SkPaint& paint);
|
||||
#endif
|
||||
|
||||
// NOTE: If you are adding a new onDraw virtual to SkCanvas, PLEASE add an override to
|
||||
@ -2244,7 +2244,7 @@ protected:
|
||||
virtual void onDrawVerticesObject(const SkVertices* vertices, SkBlendMode mode,
|
||||
const SkPaint& paint);
|
||||
#ifdef SK_ENABLE_SKSL
|
||||
virtual void onDrawCustomMesh(const SkCustomMesh&, sk_sp<SkBlender>, const SkPaint&);
|
||||
virtual void onDrawMesh(const SkMesh&, sk_sp<SkBlender>, const SkPaint&);
|
||||
#endif
|
||||
virtual void onDrawAnnotation(const SkRect& rect, const char key[], SkData* value);
|
||||
virtual void onDrawShadowRec(const SkPath&, const SkDrawShadowRec&);
|
||||
|
@ -5,8 +5,8 @@
|
||||
* found in the LICENSE file.
|
||||
*/
|
||||
|
||||
#ifndef SkCustomMesh_DEFINED
|
||||
#define SkCustomMesh_DEFINED
|
||||
#ifndef SkMesh_DEFINED
|
||||
#define SkMesh_DEFINED
|
||||
|
||||
#include "include/core/SkTypes.h"
|
||||
|
||||
@ -45,7 +45,7 @@ namespace SkSL { struct Program; }
|
||||
* coordinate. If the color variant is used it will be blended with SkShader (or SkPaint color in
|
||||
* absence of a shader) using the SkBlender provided to the SkCanvas draw call.
|
||||
*/
|
||||
class SkCustomMeshSpecification : public SkNVRefCnt<SkCustomMeshSpecification> {
|
||||
class SkMeshSpecification : public SkNVRefCnt<SkMeshSpecification> {
|
||||
public:
|
||||
/** These values are enforced when creating a specification. */
|
||||
static constexpr size_t kMaxStride = 1024;
|
||||
@ -86,11 +86,11 @@ public:
|
||||
SkString name;
|
||||
};
|
||||
|
||||
~SkCustomMeshSpecification();
|
||||
~SkMeshSpecification();
|
||||
|
||||
struct Result {
|
||||
sk_sp<SkCustomMeshSpecification> specification;
|
||||
SkString error;
|
||||
sk_sp<SkMeshSpecification> specification;
|
||||
SkString error;
|
||||
};
|
||||
|
||||
/**
|
||||
@ -139,7 +139,7 @@ public:
|
||||
size_t stride() const { return fStride; }
|
||||
|
||||
private:
|
||||
friend struct SkCustomMeshSpecificationPriv;
|
||||
friend struct SkMeshSpecificationPriv;
|
||||
|
||||
enum class ColorType {
|
||||
kNone,
|
||||
@ -155,41 +155,40 @@ private:
|
||||
sk_sp<SkColorSpace> cs,
|
||||
SkAlphaType at);
|
||||
|
||||
SkCustomMeshSpecification(SkSpan<const Attribute>,
|
||||
size_t,
|
||||
SkSpan<const Varying>,
|
||||
std::unique_ptr<SkSL::Program>,
|
||||
std::unique_ptr<SkSL::Program>,
|
||||
ColorType,
|
||||
bool hasLocalCoords,
|
||||
sk_sp<SkColorSpace>,
|
||||
SkAlphaType);
|
||||
SkMeshSpecification(SkSpan<const Attribute>,
|
||||
size_t,
|
||||
SkSpan<const Varying>,
|
||||
std::unique_ptr<SkSL::Program>,
|
||||
std::unique_ptr<SkSL::Program>,
|
||||
ColorType,
|
||||
bool hasLocalCoords,
|
||||
sk_sp<SkColorSpace>,
|
||||
SkAlphaType);
|
||||
|
||||
SkCustomMeshSpecification(const SkCustomMeshSpecification&) = delete;
|
||||
SkCustomMeshSpecification(SkCustomMeshSpecification&&) = delete;
|
||||
SkMeshSpecification(const SkMeshSpecification&) = delete;
|
||||
SkMeshSpecification(SkMeshSpecification&&) = delete;
|
||||
|
||||
SkCustomMeshSpecification& operator=(const SkCustomMeshSpecification&) = delete;
|
||||
SkCustomMeshSpecification& operator=(SkCustomMeshSpecification&&) = delete;
|
||||
SkMeshSpecification& operator=(const SkMeshSpecification&) = delete;
|
||||
SkMeshSpecification& operator=(SkMeshSpecification&&) = delete;
|
||||
|
||||
const std::vector<Attribute> fAttributes;
|
||||
const std::vector<Varying> fVaryings;
|
||||
std::unique_ptr<SkSL::Program> fVS;
|
||||
std::unique_ptr<SkSL::Program> fFS;
|
||||
size_t fStride;
|
||||
uint32_t fHash;
|
||||
ColorType fColorType;
|
||||
bool fHasLocalCoords;
|
||||
sk_sp<SkColorSpace> fColorSpace;
|
||||
SkAlphaType fAlphaType;
|
||||
const std::vector<Attribute> fAttributes;
|
||||
const std::vector<Varying> fVaryings;
|
||||
std::unique_ptr<SkSL::Program> fVS;
|
||||
std::unique_ptr<SkSL::Program> fFS;
|
||||
size_t fStride;
|
||||
uint32_t fHash;
|
||||
ColorType fColorType;
|
||||
bool fHasLocalCoords;
|
||||
sk_sp<SkColorSpace> fColorSpace;
|
||||
SkAlphaType fAlphaType;
|
||||
};
|
||||
|
||||
/**
|
||||
* A vertex buffer, a topology, optionally an index buffer, and a compatible
|
||||
* SkCustomMeshSpecification.
|
||||
* A vertex buffer, a topology, optionally an index buffer, and a compatible SkMeshSpecification.
|
||||
*
|
||||
* The data in the vertex buffer is expected to contain the attributes described by the spec
|
||||
* for vertexCount vertices beginning at vertexOffset. vertexOffset must be aligned to the
|
||||
* SkCustomMeshSpecification's vertex stride. The size of the buffer must be at least vertexOffset +
|
||||
* SkMeshSpecification's vertex stride. The size of the buffer must be at least vertexOffset +
|
||||
* spec->stride()*vertexCount (even if vertex attributes contains pad at the end of the stride). If
|
||||
* the specified bounds does not contain all the points output by the spec's vertex program when
|
||||
* applied to the vertices in the custom mesh then the result is undefined.
|
||||
@ -201,22 +200,22 @@ private:
|
||||
* If Make() is used the implicit index sequence is 0, 1, 2, 3, ... and vertexCount must be at least
|
||||
* 3.
|
||||
*/
|
||||
class SkCustomMesh {
|
||||
class SkMesh {
|
||||
public:
|
||||
class IndexBuffer : public SkRefCnt {};
|
||||
class VertexBuffer : public SkRefCnt {};
|
||||
|
||||
SkCustomMesh();
|
||||
~SkCustomMesh();
|
||||
SkMesh();
|
||||
~SkMesh();
|
||||
|
||||
SkCustomMesh(const SkCustomMesh&);
|
||||
SkCustomMesh(SkCustomMesh&&);
|
||||
SkMesh(const SkMesh&);
|
||||
SkMesh(SkMesh&&);
|
||||
|
||||
SkCustomMesh& operator=(const SkCustomMesh&);
|
||||
SkCustomMesh& operator=(SkCustomMesh&&);
|
||||
SkMesh& operator=(const SkMesh&);
|
||||
SkMesh& operator=(SkMesh&&);
|
||||
|
||||
/**
|
||||
* Makes an index buffer to be used with SkCustomMeshes. The SkData is used to determine the
|
||||
* Makes an index buffer to be used with SkMeshes. The SkData is used to determine the
|
||||
* size and contents of the buffer. The buffer may be CPU- or GPU-backed depending on whether
|
||||
* GrDirectContext* is nullptr.
|
||||
*
|
||||
@ -229,7 +228,7 @@ public:
|
||||
static sk_sp<IndexBuffer> MakeIndexBuffer(GrDirectContext*, sk_sp<const SkData>);
|
||||
|
||||
/**
|
||||
* Makes a vertex buffer to be used with SkCustomMeshes. The SkData is used to determine the
|
||||
* Makes a vertex buffer to be used with SkMeshes. The SkData is used to determine the
|
||||
* size and contents of the buffer.The buffer may be CPU- or GPU-backed depending on whether
|
||||
* GrDirectContext* is nullptr.
|
||||
*
|
||||
@ -243,24 +242,24 @@ public:
|
||||
|
||||
enum class Mode { kTriangles, kTriangleStrip };
|
||||
|
||||
static SkCustomMesh Make(sk_sp<SkCustomMeshSpecification>,
|
||||
Mode,
|
||||
sk_sp<VertexBuffer>,
|
||||
size_t vertexCount,
|
||||
size_t vertexOffset,
|
||||
const SkRect& bounds);
|
||||
static SkMesh Make(sk_sp<SkMeshSpecification>,
|
||||
Mode,
|
||||
sk_sp<VertexBuffer>,
|
||||
size_t vertexCount,
|
||||
size_t vertexOffset,
|
||||
const SkRect& bounds);
|
||||
|
||||
static SkCustomMesh MakeIndexed(sk_sp<SkCustomMeshSpecification>,
|
||||
Mode,
|
||||
sk_sp<VertexBuffer>,
|
||||
size_t vertexCount,
|
||||
size_t vertexOffset,
|
||||
sk_sp<IndexBuffer>,
|
||||
size_t indexCount,
|
||||
size_t indexOffset,
|
||||
const SkRect& bounds);
|
||||
static SkMesh MakeIndexed(sk_sp<SkMeshSpecification>,
|
||||
Mode,
|
||||
sk_sp<VertexBuffer>,
|
||||
size_t vertexCount,
|
||||
size_t vertexOffset,
|
||||
sk_sp<IndexBuffer>,
|
||||
size_t indexCount,
|
||||
size_t indexOffset,
|
||||
const SkRect& bounds);
|
||||
|
||||
sk_sp<SkCustomMeshSpecification> spec() const { return fSpec; }
|
||||
sk_sp<SkMeshSpecification> spec() const { return fSpec; }
|
||||
|
||||
Mode mode() const { return fMode; }
|
||||
|
||||
@ -279,11 +278,11 @@ public:
|
||||
bool isValid() const;
|
||||
|
||||
private:
|
||||
friend struct SkCustomMeshPriv;
|
||||
friend struct SkMeshPriv;
|
||||
|
||||
bool validate() const;
|
||||
|
||||
sk_sp<SkCustomMeshSpecification> fSpec;
|
||||
sk_sp<SkMeshSpecification> fSpec;
|
||||
|
||||
sk_sp<VertexBuffer> fVB;
|
||||
sk_sp<IndexBuffer> fIB;
|
@ -20,12 +20,12 @@ enum class ProgramKind : int8_t {
|
||||
kVertex,
|
||||
kGraphiteFragment,
|
||||
kGraphiteVertex,
|
||||
kRuntimeColorFilter, // Runtime effect only suitable as SkColorFilter
|
||||
kRuntimeShader, // " " " " " SkShader
|
||||
kRuntimeBlender, // " " " " " SkBlender
|
||||
kPrivateRuntimeShader, // Runtime shader with public restrictions lifted
|
||||
kCustomMeshVertex, // Vertex portion of a custom mesh
|
||||
kCustomMeshFragment, // Fragment " " " " "
|
||||
kRuntimeColorFilter, // Runtime effect only suitable as SkColorFilter
|
||||
kRuntimeShader, // " " " " " SkShader
|
||||
kRuntimeBlender, // " " " " " SkBlender
|
||||
kPrivateRuntimeShader, // Runtime shader with public restrictions lifted
|
||||
kMeshVertex, // Vertex portion of a custom mesh
|
||||
kMeshFragment, // Fragment " " " " "
|
||||
kGeneric,
|
||||
};
|
||||
|
||||
|
10
public.bzl
10
public.bzl
@ -50,7 +50,7 @@ SKIA_PUBLIC_HDRS = [
|
||||
"include/core/SkContourMeasure.h",
|
||||
"include/core/SkCoverageMode.h",
|
||||
"include/core/SkCubicMap.h",
|
||||
"include/core/SkCustomMesh.h",
|
||||
"include/core/SkMesh.h",
|
||||
"include/core/SkData.h",
|
||||
"include/core/SkDataTable.h",
|
||||
"include/core/SkDeferredDisplayList.h",
|
||||
@ -418,8 +418,8 @@ BASE_SRCS_ALL = [
|
||||
"src/core/SkCubicClipper.h",
|
||||
"src/core/SkCubicMap.cpp",
|
||||
"src/core/SkCubicSolver.h",
|
||||
"src/core/SkCustomMesh.cpp",
|
||||
"src/core/SkCustomMeshPriv.h",
|
||||
"src/core/SkMesh.cpp",
|
||||
"src/core/SkMeshPriv.h",
|
||||
"src/core/SkData.cpp",
|
||||
"src/core/SkDataTable.cpp",
|
||||
"src/core/SkDebug.cpp",
|
||||
@ -1150,8 +1150,8 @@ BASE_SRCS_ALL = [
|
||||
"src/gpu/ganesh/ops/DrawAtlasOp.h",
|
||||
"src/gpu/ganesh/ops/DrawAtlasPathOp.cpp",
|
||||
"src/gpu/ganesh/ops/DrawAtlasPathOp.h",
|
||||
"src/gpu/ganesh/ops/DrawCustomMeshOp.cpp",
|
||||
"src/gpu/ganesh/ops/DrawCustomMeshOp.h",
|
||||
"src/gpu/ganesh/ops/DrawMeshOp.cpp",
|
||||
"src/gpu/ganesh/ops/DrawMeshOp.h",
|
||||
"src/gpu/ganesh/ops/DrawableOp.cpp",
|
||||
"src/gpu/ganesh/ops/DrawableOp.h",
|
||||
"src/gpu/ganesh/ops/FillPathFlags.h",
|
||||
|
@ -50,7 +50,6 @@ cc_library(
|
||||
":SkCpu_src",
|
||||
":SkCubicClipper_src",
|
||||
":SkCubicMap_src",
|
||||
":SkCustomMesh_src",
|
||||
":SkDataTable_src",
|
||||
":SkData_src",
|
||||
":SkDebug_src",
|
||||
@ -111,6 +110,7 @@ cc_library(
|
||||
":SkMatrixImageFilter_src",
|
||||
":SkMatrixInvert_src",
|
||||
":SkMatrix_src",
|
||||
":SkMesh_src",
|
||||
":SkMiniRecorder_src",
|
||||
":SkMipmapAccessor_src",
|
||||
":SkMipmap_src",
|
||||
@ -998,7 +998,6 @@ generated_cc_atom(
|
||||
":SkCanvasPriv_hdr",
|
||||
":SkClipStack_hdr",
|
||||
":SkColorFilterBase_hdr",
|
||||
":SkCustomMeshPriv_hdr",
|
||||
":SkDraw_hdr",
|
||||
":SkGlyphRun_hdr",
|
||||
":SkImageFilterCache_hdr",
|
||||
@ -1007,6 +1006,7 @@ generated_cc_atom(
|
||||
":SkMSAN_hdr",
|
||||
":SkMatrixPriv_hdr",
|
||||
":SkMatrixUtils_hdr",
|
||||
":SkMeshPriv_hdr",
|
||||
":SkPaintPriv_hdr",
|
||||
":SkRasterClip_hdr",
|
||||
":SkSpecialImage_hdr",
|
||||
@ -5554,13 +5554,13 @@ generated_cc_atom(
|
||||
)
|
||||
|
||||
generated_cc_atom(
|
||||
name = "SkCustomMeshPriv_hdr",
|
||||
hdrs = ["SkCustomMeshPriv.h"],
|
||||
name = "SkMeshPriv_hdr",
|
||||
hdrs = ["SkMeshPriv.h"],
|
||||
visibility = ["//:__subpackages__"],
|
||||
deps = [
|
||||
":SkSLTypeShared_hdr",
|
||||
"//include/core:SkCustomMesh_hdr",
|
||||
"//include/core:SkData_hdr",
|
||||
"//include/core:SkMesh_hdr",
|
||||
"//include/gpu:GrDirectContext_hdr",
|
||||
"//include/private/gpu/ganesh:GrTypesPriv_hdr",
|
||||
"//src/gpu/ganesh:GrDirectContextPriv_hdr",
|
||||
@ -5571,17 +5571,17 @@ generated_cc_atom(
|
||||
)
|
||||
|
||||
generated_cc_atom(
|
||||
name = "SkCustomMesh_src",
|
||||
srcs = ["SkCustomMesh.cpp"],
|
||||
name = "SkMesh_src",
|
||||
srcs = ["SkMesh.cpp"],
|
||||
enforce_iwyu = True,
|
||||
visibility = ["//:__subpackages__"],
|
||||
deps = [
|
||||
":SkCustomMeshPriv_hdr",
|
||||
":SkMeshPriv_hdr",
|
||||
":SkSafeMath_hdr",
|
||||
"//include/core:SkColorSpace_hdr",
|
||||
"//include/core:SkCustomMesh_hdr",
|
||||
"//include/core:SkData_hdr",
|
||||
"//include/core:SkMath_hdr",
|
||||
"//include/core:SkMesh_hdr",
|
||||
"//include/private:SkOpts_spi_hdr",
|
||||
"//include/private:SkSLProgramElement_hdr",
|
||||
"//include/private:SkSLProgramKind_hdr",
|
||||
|
@ -542,7 +542,7 @@ void SkBitmapDevice::drawVertices(const SkVertices* vertices,
|
||||
}
|
||||
|
||||
#ifdef SK_ENABLE_SKSL
|
||||
void SkBitmapDevice::drawCustomMesh(const SkCustomMesh&, sk_sp<SkBlender>, const SkPaint&) {
|
||||
void SkBitmapDevice::drawMesh(const SkMesh&, sk_sp<SkBlender>, const SkPaint&) {
|
||||
// TODO: Implement
|
||||
}
|
||||
#endif
|
||||
|
@ -31,7 +31,7 @@ class SkSurface;
|
||||
class SkSurfaceProps;
|
||||
struct SkPoint;
|
||||
#ifdef SK_ENABLE_SKSL
|
||||
class SkCustomMesh;
|
||||
class SkMesh;
|
||||
#endif
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
class SkBitmapDevice : public SkBaseDevice {
|
||||
@ -89,7 +89,7 @@ protected:
|
||||
|
||||
void drawVertices(const SkVertices*, sk_sp<SkBlender>, const SkPaint&, bool) override;
|
||||
#ifdef SK_ENABLE_SKSL
|
||||
void drawCustomMesh(const SkCustomMesh&, sk_sp<SkBlender>, const SkPaint&) override;
|
||||
void drawMesh(const SkMesh&, sk_sp<SkBlender>, const SkPaint&) override;
|
||||
#endif
|
||||
|
||||
void drawAtlas(const SkRSXform[], const SkRect[], const SkColor[], int count, sk_sp<SkBlender>,
|
||||
|
@ -26,7 +26,6 @@
|
||||
#include "src/core/SkCanvasPriv.h"
|
||||
#include "src/core/SkClipStack.h"
|
||||
#include "src/core/SkColorFilterBase.h"
|
||||
#include "src/core/SkCustomMeshPriv.h"
|
||||
#include "src/core/SkDraw.h"
|
||||
#include "src/core/SkGlyphRun.h"
|
||||
#include "src/core/SkImageFilterCache.h"
|
||||
@ -35,6 +34,7 @@
|
||||
#include "src/core/SkMSAN.h"
|
||||
#include "src/core/SkMatrixPriv.h"
|
||||
#include "src/core/SkMatrixUtils.h"
|
||||
#include "src/core/SkMeshPriv.h"
|
||||
#include "src/core/SkPaintPriv.h"
|
||||
#include "src/core/SkRasterClip.h"
|
||||
#include "src/core/SkSpecialImage.h"
|
||||
@ -1818,15 +1818,13 @@ void SkCanvas::drawVertices(const SkVertices* vertices, SkBlendMode mode, const
|
||||
}
|
||||
|
||||
#ifdef SK_ENABLE_SKSL
|
||||
void SkCanvas::drawCustomMesh(const SkCustomMesh& cm,
|
||||
sk_sp<SkBlender> blender,
|
||||
const SkPaint& paint) {
|
||||
void SkCanvas::drawMesh(const SkMesh& mesh, sk_sp<SkBlender> blender, const SkPaint& paint) {
|
||||
TRACE_EVENT0("skia", TRACE_FUNC);
|
||||
RETURN_ON_FALSE(cm.isValid());
|
||||
RETURN_ON_FALSE(mesh.isValid());
|
||||
if (!blender) {
|
||||
blender = SkBlender::Mode(SkBlendMode::kModulate);
|
||||
}
|
||||
this->onDrawCustomMesh(std::move(cm), std::move(blender), paint);
|
||||
this->onDrawMesh(mesh, std::move(blender), paint);
|
||||
}
|
||||
#endif
|
||||
|
||||
@ -2507,18 +2505,16 @@ void SkCanvas::onDrawVerticesObject(const SkVertices* vertices, SkBlendMode bmod
|
||||
}
|
||||
|
||||
#ifdef SK_ENABLE_SKSL
|
||||
void SkCanvas::onDrawCustomMesh(const SkCustomMesh& cm,
|
||||
sk_sp<SkBlender> blender,
|
||||
const SkPaint& paint) {
|
||||
void SkCanvas::onDrawMesh(const SkMesh& mesh, sk_sp<SkBlender> blender, const SkPaint& paint) {
|
||||
SkPaint simplePaint = clean_paint_for_drawVertices(paint);
|
||||
|
||||
if (this->internalQuickReject(cm.bounds(), simplePaint)) {
|
||||
if (this->internalQuickReject(mesh.bounds(), simplePaint)) {
|
||||
return;
|
||||
}
|
||||
|
||||
auto layer = this->aboutToDraw(this, simplePaint, nullptr);
|
||||
if (layer) {
|
||||
this->topDevice()->drawCustomMesh(std::move(cm), std::move(blender), paint);
|
||||
this->topDevice()->drawMesh(mesh, std::move(blender), paint);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
@ -102,11 +102,11 @@ void SkCanvasPriv::GetDstClipAndMatrixCounts(const SkCanvas::ImageSetEntry set[]
|
||||
}
|
||||
|
||||
#ifdef SK_ENABLE_SKSL
|
||||
void SkCanvasPriv::DrawCustomMesh(SkCanvas* canvas,
|
||||
const SkCustomMesh& cm,
|
||||
sk_sp<SkBlender> blender,
|
||||
const SkPaint& paint) {
|
||||
canvas->drawCustomMesh(cm, std::move(blender), paint);
|
||||
void SkCanvasPriv::DrawMesh(SkCanvas* canvas,
|
||||
const SkMesh& mesh,
|
||||
sk_sp<SkBlender> blender,
|
||||
const SkPaint& paint) {
|
||||
canvas->drawMesh(mesh, std::move(blender), paint);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -93,10 +93,10 @@ public:
|
||||
rec->fExperimentalBackdropScale = scale;
|
||||
}
|
||||
|
||||
static void DrawCustomMesh(SkCanvas*,
|
||||
const SkCustomMesh& cm,
|
||||
sk_sp<SkBlender> blender,
|
||||
const SkPaint& paint);
|
||||
static void DrawMesh(SkCanvas*,
|
||||
const SkMesh& mesh,
|
||||
sk_sp<SkBlender> blender,
|
||||
const SkPaint& paint);
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -23,7 +23,7 @@
|
||||
|
||||
class SkBitmap;
|
||||
class SkColorSpace;
|
||||
class SkCustomMesh;
|
||||
class SkMesh;
|
||||
struct SkDrawShadowRec;
|
||||
class SkGlyphRun;
|
||||
class SkGlyphRunList;
|
||||
@ -284,7 +284,7 @@ protected:
|
||||
const SkPaint&,
|
||||
bool skipColorXform = false) = 0;
|
||||
#ifdef SK_ENABLE_SKSL
|
||||
virtual void drawCustomMesh(const SkCustomMesh& cm, sk_sp<SkBlender>, const SkPaint&) = 0;
|
||||
virtual void drawMesh(const SkMesh& mesh, sk_sp<SkBlender>, const SkPaint&) = 0;
|
||||
#endif
|
||||
virtual void drawShadow(const SkPath&, const SkDrawShadowRec&);
|
||||
|
||||
@ -549,7 +549,7 @@ protected:
|
||||
void drawDevice(SkBaseDevice*, const SkSamplingOptions&, const SkPaint&) override {}
|
||||
void drawVertices(const SkVertices*, sk_sp<SkBlender>, const SkPaint&, bool) override {}
|
||||
#ifdef SK_ENABLE_SKSL
|
||||
void drawCustomMesh(const SkCustomMesh&, sk_sp<SkBlender>, const SkPaint&) override {}
|
||||
void drawMesh(const SkMesh&, sk_sp<SkBlender>, const SkPaint&) override {}
|
||||
#endif
|
||||
|
||||
void drawFilteredImage(const skif::Mapping&, SkSpecialImage* src, const SkImageFilter*,
|
||||
|
@ -5,7 +5,7 @@
|
||||
* found in the LICENSE file.
|
||||
*/
|
||||
|
||||
#include "include/core/SkCustomMesh.h"
|
||||
#include "include/core/SkMesh.h"
|
||||
|
||||
#ifdef SK_ENABLE_SKSL
|
||||
#include "include/core/SkColorSpace.h"
|
||||
@ -14,7 +14,7 @@
|
||||
#include "include/private/SkOpts_spi.h"
|
||||
#include "include/private/SkSLProgramElement.h"
|
||||
#include "include/private/SkSLProgramKind.h"
|
||||
#include "src/core/SkCustomMeshPriv.h"
|
||||
#include "src/core/SkMeshPriv.h"
|
||||
#include "src/core/SkSafeMath.h"
|
||||
#include "src/sksl/SkSLAnalysis.h"
|
||||
#include "src/sksl/SkSLBuiltinTypes.h"
|
||||
@ -32,11 +32,11 @@
|
||||
#include <type_traits>
|
||||
#include <utility>
|
||||
|
||||
using Attribute = SkCustomMeshSpecification::Attribute;
|
||||
using Varying = SkCustomMeshSpecification::Varying;
|
||||
using Attribute = SkMeshSpecification::Attribute;
|
||||
using Varying = SkMeshSpecification::Varying;
|
||||
|
||||
using IndexBuffer = SkCustomMesh::IndexBuffer;
|
||||
using VertexBuffer = SkCustomMesh::VertexBuffer;
|
||||
using IndexBuffer = SkMesh::IndexBuffer;
|
||||
using VertexBuffer = SkMesh::VertexBuffer;
|
||||
|
||||
#define RETURN_FAILURE(...) return Result{nullptr, SkStringPrintf(__VA_ARGS__)}
|
||||
|
||||
@ -57,7 +57,7 @@ static bool has_main(const SkSL::Program& p) {
|
||||
return false;
|
||||
}
|
||||
|
||||
using ColorType = SkCustomMeshSpecificationPriv::ColorType;
|
||||
using ColorType = SkMeshSpecificationPriv::ColorType;
|
||||
|
||||
static std::tuple<ColorType, bool>
|
||||
get_fs_color_type_and_local_coords(const SkSL::Program& fsProgram) {
|
||||
@ -67,7 +67,7 @@ get_fs_color_type_and_local_coords(const SkSL::Program& fsProgram) {
|
||||
const SkSL::FunctionDeclaration& decl = defn.declaration();
|
||||
if (decl.isMain()) {
|
||||
|
||||
SkCustomMeshSpecificationPriv::ColorType ct;
|
||||
SkMeshSpecificationPriv::ColorType ct;
|
||||
SkASSERT(decl.parameters().size() == 1 || decl.parameters().size() == 2);
|
||||
if (decl.parameters().size() == 1) {
|
||||
ct = ColorType::kNone;
|
||||
@ -147,35 +147,35 @@ std::tuple<bool, SkString>
|
||||
check_vertex_offsets_and_stride(SkSpan<const Attribute> attributes,
|
||||
size_t stride) {
|
||||
// Vulkan 1.0 has a minimum maximum attribute count of 2048.
|
||||
static_assert(SkCustomMeshSpecification::kMaxStride <= 2048);
|
||||
static_assert(SkMeshSpecification::kMaxStride <= 2048);
|
||||
// ES 2 has a max of 8.
|
||||
static_assert(SkCustomMeshSpecification::kMaxAttributes <= 8);
|
||||
static_assert(SkMeshSpecification::kMaxAttributes <= 8);
|
||||
// Four bytes alignment is required by Metal.
|
||||
static_assert(SkCustomMeshSpecification::kStrideAlignment >= 4);
|
||||
static_assert(SkCustomMeshSpecification::kOffsetAlignment >= 4);
|
||||
static_assert(SkMeshSpecification::kStrideAlignment >= 4);
|
||||
static_assert(SkMeshSpecification::kOffsetAlignment >= 4);
|
||||
// ES2 has a minimum maximum of 8. We may need one for a broken gl_FragCoord workaround and
|
||||
// one for local coords.
|
||||
static_assert(SkCustomMeshSpecification::kMaxVaryings <= 6);
|
||||
static_assert(SkMeshSpecification::kMaxVaryings <= 6);
|
||||
|
||||
if (attributes.empty()) {
|
||||
RETURN_ERROR("At least 1 attribute is required.");
|
||||
}
|
||||
if (attributes.size() > SkCustomMeshSpecification::kMaxAttributes) {
|
||||
if (attributes.size() > SkMeshSpecification::kMaxAttributes) {
|
||||
RETURN_ERROR("A maximum of %zu attributes is allowed.",
|
||||
SkCustomMeshSpecification::kMaxAttributes);
|
||||
SkMeshSpecification::kMaxAttributes);
|
||||
}
|
||||
static_assert(SkIsPow2(SkCustomMeshSpecification::kStrideAlignment));
|
||||
if (stride == 0 || stride & (SkCustomMeshSpecification::kStrideAlignment - 1)) {
|
||||
static_assert(SkIsPow2(SkMeshSpecification::kStrideAlignment));
|
||||
if (stride == 0 || stride & (SkMeshSpecification::kStrideAlignment - 1)) {
|
||||
RETURN_ERROR("Vertex stride must be a non-zero multiple of %zu.",
|
||||
SkCustomMeshSpecification::kStrideAlignment);
|
||||
SkMeshSpecification::kStrideAlignment);
|
||||
}
|
||||
if (stride > SkCustomMeshSpecification::kMaxStride) {
|
||||
RETURN_ERROR("Stride cannot exceed %zu.", SkCustomMeshSpecification::kMaxStride);
|
||||
if (stride > SkMeshSpecification::kMaxStride) {
|
||||
RETURN_ERROR("Stride cannot exceed %zu.", SkMeshSpecification::kMaxStride);
|
||||
}
|
||||
for (const auto& a : attributes) {
|
||||
if (a.offset & (SkCustomMeshSpecification::kOffsetAlignment - 1)) {
|
||||
if (a.offset & (SkMeshSpecification::kOffsetAlignment - 1)) {
|
||||
RETURN_ERROR("Attribute offset must be a multiple of %zu.",
|
||||
SkCustomMeshSpecification::kOffsetAlignment);
|
||||
SkMeshSpecification::kOffsetAlignment);
|
||||
}
|
||||
// This equivalent to vertexAttributeAccessBeyondStride==VK_FALSE in
|
||||
// VK_KHR_portability_subset. First check is to avoid overflow in second check.
|
||||
@ -186,35 +186,36 @@ check_vertex_offsets_and_stride(SkSpan<const Attribute> attributes,
|
||||
RETURN_SUCCESS;
|
||||
}
|
||||
|
||||
SkCustomMeshSpecification::Result SkCustomMeshSpecification::Make(
|
||||
SkSpan<const Attribute> attributes,
|
||||
size_t vertexStride,
|
||||
SkSpan<const Varying> varyings,
|
||||
const SkString& vs,
|
||||
const SkString& fs) {
|
||||
return Make(attributes, vertexStride, varyings, vs, fs,
|
||||
SkColorSpace::MakeSRGB(), kPremul_SkAlphaType);
|
||||
SkMeshSpecification::Result SkMeshSpecification::Make(SkSpan<const Attribute> attributes,
|
||||
size_t vertexStride,
|
||||
SkSpan<const Varying> varyings,
|
||||
const SkString& vs,
|
||||
const SkString& fs) {
|
||||
return Make(attributes,
|
||||
vertexStride,
|
||||
varyings,
|
||||
vs,
|
||||
fs,
|
||||
SkColorSpace::MakeSRGB(),
|
||||
kPremul_SkAlphaType);
|
||||
}
|
||||
|
||||
SkCustomMeshSpecification::Result SkCustomMeshSpecification::Make(
|
||||
SkSpan<const Attribute> attributes,
|
||||
size_t vertexStride,
|
||||
SkSpan<const Varying> varyings,
|
||||
const SkString& vs,
|
||||
const SkString& fs,
|
||||
sk_sp<SkColorSpace> cs) {
|
||||
return Make(attributes, vertexStride, varyings, vs, fs,
|
||||
std::move(cs), kPremul_SkAlphaType);
|
||||
SkMeshSpecification::Result SkMeshSpecification::Make(SkSpan<const Attribute> attributes,
|
||||
size_t vertexStride,
|
||||
SkSpan<const Varying> varyings,
|
||||
const SkString& vs,
|
||||
const SkString& fs,
|
||||
sk_sp<SkColorSpace> cs) {
|
||||
return Make(attributes, vertexStride, varyings, vs, fs, std::move(cs), kPremul_SkAlphaType);
|
||||
}
|
||||
|
||||
SkCustomMeshSpecification::Result SkCustomMeshSpecification::Make(
|
||||
SkSpan<const Attribute> attributes,
|
||||
size_t vertexStride,
|
||||
SkSpan<const Varying> varyings,
|
||||
const SkString& vs,
|
||||
const SkString& fs,
|
||||
sk_sp<SkColorSpace> cs,
|
||||
SkAlphaType at) {
|
||||
SkMeshSpecification::Result SkMeshSpecification::Make(SkSpan<const Attribute> attributes,
|
||||
size_t vertexStride,
|
||||
SkSpan<const Varying> varyings,
|
||||
const SkString& vs,
|
||||
const SkString& fs,
|
||||
sk_sp<SkColorSpace> cs,
|
||||
SkAlphaType at) {
|
||||
SkString attributesStruct("struct Attributes {\n");
|
||||
for (const auto& a : attributes) {
|
||||
attributesStruct.appendf(" %s %s;\n", attribute_type_string(a.type), a.name.c_str());
|
||||
@ -249,7 +250,7 @@ SkCustomMeshSpecification::Result SkCustomMeshSpecification::Make(
|
||||
at);
|
||||
}
|
||||
|
||||
SkCustomMeshSpecification::Result SkCustomMeshSpecification::MakeFromSourceWithStructs(
|
||||
SkMeshSpecification::Result SkMeshSpecification::MakeFromSourceWithStructs(
|
||||
SkSpan<const Attribute> attributes,
|
||||
size_t stride,
|
||||
SkSpan<const Varying> varyings,
|
||||
@ -281,7 +282,7 @@ SkCustomMeshSpecification::Result SkCustomMeshSpecification::MakeFromSourceWithS
|
||||
SkSL::Program::Settings settings;
|
||||
settings.fEnforceES2Restrictions = true;
|
||||
std::unique_ptr<SkSL::Program> vsProgram = compiler->convertProgram(
|
||||
SkSL::ProgramKind::kCustomMeshVertex,
|
||||
SkSL::ProgramKind::kMeshVertex,
|
||||
std::string(vs.c_str()),
|
||||
settings);
|
||||
if (!vsProgram) {
|
||||
@ -295,7 +296,7 @@ SkCustomMeshSpecification::Result SkCustomMeshSpecification::MakeFromSourceWithS
|
||||
}
|
||||
|
||||
std::unique_ptr<SkSL::Program> fsProgram = compiler->convertProgram(
|
||||
SkSL::ProgramKind::kCustomMeshFragment,
|
||||
SkSL::ProgramKind::kMeshFragment,
|
||||
std::string(fs.c_str()),
|
||||
settings);
|
||||
|
||||
@ -323,29 +324,29 @@ SkCustomMeshSpecification::Result SkCustomMeshSpecification::MakeFromSourceWithS
|
||||
}
|
||||
}
|
||||
|
||||
return {sk_sp<SkCustomMeshSpecification>(new SkCustomMeshSpecification(attributes,
|
||||
stride,
|
||||
varyings,
|
||||
std::move(vsProgram),
|
||||
std::move(fsProgram),
|
||||
ct,
|
||||
hasLocalCoords,
|
||||
std::move(cs),
|
||||
at)),
|
||||
/*error=*/ {}};
|
||||
return {sk_sp<SkMeshSpecification>(new SkMeshSpecification(attributes,
|
||||
stride,
|
||||
varyings,
|
||||
std::move(vsProgram),
|
||||
std::move(fsProgram),
|
||||
ct,
|
||||
hasLocalCoords,
|
||||
std::move(cs),
|
||||
at)),
|
||||
/*error=*/{}};
|
||||
}
|
||||
|
||||
SkCustomMeshSpecification::~SkCustomMeshSpecification() = default;
|
||||
SkMeshSpecification::~SkMeshSpecification() = default;
|
||||
|
||||
SkCustomMeshSpecification::SkCustomMeshSpecification(SkSpan<const Attribute> attributes,
|
||||
size_t stride,
|
||||
SkSpan<const Varying> varyings,
|
||||
std::unique_ptr<SkSL::Program> vs,
|
||||
std::unique_ptr<SkSL::Program> fs,
|
||||
ColorType ct,
|
||||
bool hasLocalCoords,
|
||||
sk_sp<SkColorSpace> cs,
|
||||
SkAlphaType at)
|
||||
SkMeshSpecification::SkMeshSpecification(SkSpan<const Attribute> attributes,
|
||||
size_t stride,
|
||||
SkSpan<const Varying> varyings,
|
||||
std::unique_ptr<SkSL::Program> vs,
|
||||
std::unique_ptr<SkSL::Program> fs,
|
||||
ColorType ct,
|
||||
bool hasLocalCoords,
|
||||
sk_sp<SkColorSpace> cs,
|
||||
SkAlphaType at)
|
||||
: fAttributes(attributes.begin(), attributes.end())
|
||||
, fVaryings(varyings.begin(), varyings.end())
|
||||
, fVS(std::move(vs))
|
||||
@ -375,67 +376,67 @@ SkCustomMeshSpecification::SkCustomMeshSpecification(SkSpan<const Attribute>
|
||||
fHash = SkOpts::hash_fn(&atInt, sizeof(atInt), fHash);
|
||||
}
|
||||
|
||||
SkCustomMesh::SkCustomMesh() = default;
|
||||
SkCustomMesh::~SkCustomMesh() = default;
|
||||
SkMesh::SkMesh() = default;
|
||||
SkMesh::~SkMesh() = default;
|
||||
|
||||
SkCustomMesh::SkCustomMesh(const SkCustomMesh&) = default;
|
||||
SkCustomMesh::SkCustomMesh(SkCustomMesh&&) = default;
|
||||
SkMesh::SkMesh(const SkMesh&) = default;
|
||||
SkMesh::SkMesh(SkMesh&&) = default;
|
||||
|
||||
SkCustomMesh& SkCustomMesh::operator=(const SkCustomMesh&) = default;
|
||||
SkCustomMesh& SkCustomMesh::operator=(SkCustomMesh&&) = default;
|
||||
SkMesh& SkMesh::operator=(const SkMesh&) = default;
|
||||
SkMesh& SkMesh::operator=(SkMesh&&) = default;
|
||||
|
||||
sk_sp<IndexBuffer> SkCustomMesh::MakeIndexBuffer(GrDirectContext* dc, sk_sp<const SkData> data) {
|
||||
sk_sp<IndexBuffer> SkMesh::MakeIndexBuffer(GrDirectContext* dc, sk_sp<const SkData> data) {
|
||||
if (!data) {
|
||||
return nullptr;
|
||||
}
|
||||
if (!dc) {
|
||||
return SkCustomMeshPriv::CpuIndexBuffer::Make(std::move(data));
|
||||
return SkMeshPriv::CpuIndexBuffer::Make(std::move(data));
|
||||
}
|
||||
#if SK_SUPPORT_GPU
|
||||
return SkCustomMeshPriv::GpuIndexBuffer::Make(dc, std::move(data));
|
||||
return SkMeshPriv::GpuIndexBuffer::Make(dc, std::move(data));
|
||||
#endif
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
sk_sp<VertexBuffer> SkCustomMesh::MakeVertexBuffer(GrDirectContext* dc, sk_sp<const SkData> data) {
|
||||
sk_sp<VertexBuffer> SkMesh::MakeVertexBuffer(GrDirectContext* dc, sk_sp<const SkData> data) {
|
||||
if (!data) {
|
||||
return nullptr;
|
||||
}
|
||||
if (!dc) {
|
||||
return SkCustomMeshPriv::CpuVertexBuffer::Make(std::move(data));
|
||||
return SkMeshPriv::CpuVertexBuffer::Make(std::move(data));
|
||||
}
|
||||
#if SK_SUPPORT_GPU
|
||||
return SkCustomMeshPriv::GpuVertexBuffer::Make(dc, std::move(data));
|
||||
return SkMeshPriv::GpuVertexBuffer::Make(dc, std::move(data));
|
||||
#endif
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
SkCustomMesh SkCustomMesh::Make(sk_sp<SkCustomMeshSpecification> spec,
|
||||
Mode mode,
|
||||
sk_sp<VertexBuffer> vb,
|
||||
size_t vertexCount,
|
||||
size_t vertexOffset,
|
||||
const SkRect& bounds) {
|
||||
SkCustomMesh cm;
|
||||
SkMesh SkMesh::Make(sk_sp<SkMeshSpecification> spec,
|
||||
Mode mode,
|
||||
sk_sp<VertexBuffer> vb,
|
||||
size_t vertexCount,
|
||||
size_t vertexOffset,
|
||||
const SkRect& bounds) {
|
||||
SkMesh cm;
|
||||
cm.fSpec = std::move(spec);
|
||||
cm.fMode = mode;
|
||||
cm.fVB = std::move(vb);
|
||||
cm.fVCount = vertexCount;
|
||||
cm.fVOffset = vertexOffset;
|
||||
cm.fBounds = bounds;
|
||||
return cm.validate() ? cm : SkCustomMesh{};
|
||||
return cm.validate() ? cm : SkMesh{};
|
||||
}
|
||||
|
||||
SkCustomMesh SkCustomMesh::MakeIndexed(sk_sp<SkCustomMeshSpecification> spec,
|
||||
Mode mode,
|
||||
sk_sp<VertexBuffer> vb,
|
||||
size_t vertexCount,
|
||||
size_t vertexOffset,
|
||||
sk_sp<IndexBuffer> ib,
|
||||
size_t indexCount,
|
||||
size_t indexOffset,
|
||||
const SkRect& bounds) {
|
||||
SkCustomMesh cm;
|
||||
SkMesh SkMesh::MakeIndexed(sk_sp<SkMeshSpecification> spec,
|
||||
Mode mode,
|
||||
sk_sp<VertexBuffer> vb,
|
||||
size_t vertexCount,
|
||||
size_t vertexOffset,
|
||||
sk_sp<IndexBuffer> ib,
|
||||
size_t indexCount,
|
||||
size_t indexOffset,
|
||||
const SkRect& bounds) {
|
||||
SkMesh cm;
|
||||
cm.fSpec = std::move(spec);
|
||||
cm.fMode = mode;
|
||||
cm.fVB = std::move(vb);
|
||||
@ -445,24 +446,24 @@ SkCustomMesh SkCustomMesh::MakeIndexed(sk_sp<SkCustomMeshSpecification> spec,
|
||||
cm.fICount = indexCount;
|
||||
cm.fIOffset = indexOffset;
|
||||
cm.fBounds = bounds;
|
||||
return cm.validate() ? cm : SkCustomMesh{};
|
||||
return cm.validate() ? cm : SkMesh{};
|
||||
}
|
||||
|
||||
bool SkCustomMesh::isValid() const {
|
||||
bool SkMesh::isValid() const {
|
||||
bool valid = SkToBool(fSpec);
|
||||
SkASSERT(valid == this->validate());
|
||||
return valid;
|
||||
}
|
||||
|
||||
static size_t min_vcount_for_mode(SkCustomMesh::Mode mode) {
|
||||
static size_t min_vcount_for_mode(SkMesh::Mode mode) {
|
||||
switch (mode) {
|
||||
case SkCustomMesh::Mode::kTriangles: return 3;
|
||||
case SkCustomMesh::Mode::kTriangleStrip: return 3;
|
||||
case SkMesh::Mode::kTriangles: return 3;
|
||||
case SkMesh::Mode::kTriangleStrip: return 3;
|
||||
}
|
||||
SkUNREACHABLE;
|
||||
}
|
||||
|
||||
bool SkCustomMesh::validate() const {
|
||||
bool SkMesh::validate() const {
|
||||
if (!fSpec) {
|
||||
return false;
|
||||
}
|
||||
@ -475,8 +476,8 @@ bool SkCustomMesh::validate() const {
|
||||
return false;
|
||||
}
|
||||
|
||||
auto vb = static_cast<SkCustomMeshPriv::VB*>(fVB.get());
|
||||
auto ib = static_cast<SkCustomMeshPriv::IB*>(fIB.get());
|
||||
auto vb = static_cast<SkMeshPriv::VB*>(fVB.get());
|
||||
auto ib = static_cast<SkMeshPriv::IB*>(fIB.get());
|
||||
|
||||
SkSafeMath sm;
|
||||
size_t vsize = sm.mul(fSpec->stride(), fVCount);
|
||||
@ -512,4 +513,4 @@ bool SkCustomMesh::validate() const {
|
||||
return sm.ok();
|
||||
}
|
||||
|
||||
#endif //SK_ENABLE_SKSL
|
||||
#endif // SK_ENABLE_SKSL
|
@ -5,10 +5,10 @@
|
||||
* found in the LICENSE file.
|
||||
*/
|
||||
|
||||
#ifndef SkCustomMeshPriv_DEFINED
|
||||
#define SkCustomMeshPriv_DEFINED
|
||||
#ifndef SkMeshPriv_DEFINED
|
||||
#define SkMeshPriv_DEFINED
|
||||
|
||||
#include "include/core/SkCustomMesh.h"
|
||||
#include "include/core/SkMesh.h"
|
||||
|
||||
#ifdef SK_ENABLE_SKSL
|
||||
#include "include/core/SkData.h"
|
||||
@ -23,34 +23,32 @@
|
||||
#include "src/gpu/ganesh/GrResourceProvider.h"
|
||||
#endif
|
||||
|
||||
struct SkCustomMeshSpecificationPriv {
|
||||
using Varying = SkCustomMeshSpecification::Varying;
|
||||
using Attribute = SkCustomMeshSpecification::Attribute;
|
||||
using ColorType = SkCustomMeshSpecification::ColorType;
|
||||
struct SkMeshSpecificationPriv {
|
||||
using Varying = SkMeshSpecification::Varying;
|
||||
using Attribute = SkMeshSpecification::Attribute;
|
||||
using ColorType = SkMeshSpecification::ColorType;
|
||||
|
||||
static SkSpan<const Varying> Varyings(const SkCustomMeshSpecification& spec) {
|
||||
static SkSpan<const Varying> Varyings(const SkMeshSpecification& spec) {
|
||||
return SkMakeSpan(spec.fVaryings);
|
||||
}
|
||||
|
||||
static const SkSL::Program* VS(const SkCustomMeshSpecification& spec) { return spec.fVS.get(); }
|
||||
static const SkSL::Program* FS(const SkCustomMeshSpecification& spec) { return spec.fFS.get(); }
|
||||
static const SkSL::Program* VS(const SkMeshSpecification& spec) { return spec.fVS.get(); }
|
||||
static const SkSL::Program* FS(const SkMeshSpecification& spec) { return spec.fFS.get(); }
|
||||
|
||||
static int Hash(const SkCustomMeshSpecification& spec) { return spec.fHash; }
|
||||
static int Hash(const SkMeshSpecification& spec) { return spec.fHash; }
|
||||
|
||||
static ColorType GetColorType(const SkCustomMeshSpecification& spec) { return spec.fColorType; }
|
||||
static bool HasColors(const SkCustomMeshSpecification& spec) {
|
||||
static ColorType GetColorType(const SkMeshSpecification& spec) { return spec.fColorType; }
|
||||
static bool HasColors(const SkMeshSpecification& spec) {
|
||||
return GetColorType(spec) != ColorType::kNone;
|
||||
}
|
||||
|
||||
static SkColorSpace* ColorSpace(const SkCustomMeshSpecification& spec) {
|
||||
static SkColorSpace* ColorSpace(const SkMeshSpecification& spec) {
|
||||
return spec.fColorSpace.get();
|
||||
}
|
||||
|
||||
static SkAlphaType AlphaType(const SkCustomMeshSpecification& spec) { return spec.fAlphaType; }
|
||||
static SkAlphaType AlphaType(const SkMeshSpecification& spec) { return spec.fAlphaType; }
|
||||
|
||||
static bool HasLocalCoords(const SkCustomMeshSpecification& spec) {
|
||||
return spec.fHasLocalCoords;
|
||||
}
|
||||
static bool HasLocalCoords(const SkMeshSpecification& spec) { return spec.fHasLocalCoords; }
|
||||
|
||||
static SkSLType VaryingTypeAsSLType(Varying::Type type) {
|
||||
switch (type) {
|
||||
@ -89,7 +87,7 @@ struct SkCustomMeshSpecificationPriv {
|
||||
}
|
||||
};
|
||||
|
||||
struct SkCustomMeshPriv {
|
||||
struct SkMeshPriv {
|
||||
class Buffer {
|
||||
public:
|
||||
virtual ~Buffer() = 0;
|
||||
@ -108,8 +106,8 @@ struct SkCustomMeshPriv {
|
||||
virtual size_t size() const = 0;
|
||||
};
|
||||
|
||||
class IB : public Buffer, public SkCustomMesh::IndexBuffer {};
|
||||
class VB : public Buffer, public SkCustomMesh::VertexBuffer {};
|
||||
class IB : public Buffer, public SkMesh::IndexBuffer {};
|
||||
class VB : public Buffer, public SkMesh::VertexBuffer {};
|
||||
|
||||
template <typename Base> class CpuBuffer final : public Base {
|
||||
public:
|
||||
@ -152,26 +150,22 @@ struct SkCustomMeshPriv {
|
||||
#endif // SK_SUPPORT_GPU
|
||||
};
|
||||
|
||||
inline SkCustomMeshPriv::Buffer::~Buffer() = default;
|
||||
inline SkMeshPriv::Buffer::~Buffer() = default;
|
||||
|
||||
template <typename Base>
|
||||
sk_sp<Base> SkCustomMeshPriv::CpuBuffer<Base>::Make(sk_sp<const SkData> data) {
|
||||
template <typename Base> sk_sp<Base> SkMeshPriv::CpuBuffer<Base>::Make(sk_sp<const SkData> data) {
|
||||
SkASSERT(data);
|
||||
|
||||
auto result = new CpuBuffer<Base>;
|
||||
result->fData = std::move(data);
|
||||
return sk_sp<Base>(result);
|
||||
}
|
||||
#if SK_SUPPORT_GPU
|
||||
|
||||
template <typename Base, GrGpuBufferType Type>
|
||||
SkCustomMeshPriv::GpuBuffer<Base, Type>::~GpuBuffer() {
|
||||
template <typename Base, GrGpuBufferType Type> SkMeshPriv::GpuBuffer<Base, Type>::~GpuBuffer() {
|
||||
GrResourceCache::ReturnResourceFromThread(std::move(fBuffer), fContextID);
|
||||
}
|
||||
|
||||
template <typename Base, GrGpuBufferType Type>
|
||||
sk_sp<Base> SkCustomMeshPriv::GpuBuffer<Base, Type>::Make(GrDirectContext* dc,
|
||||
sk_sp<const SkData> data) {
|
||||
sk_sp<Base> SkMeshPriv::GpuBuffer<Base, Type>::Make(GrDirectContext* dc,sk_sp<const SkData> data) {
|
||||
SkASSERT(dc);
|
||||
SkASSERT(data);
|
||||
|
@ -156,7 +156,7 @@ cc_library(
|
||||
"//src/gpu/ganesh/ops:DefaultPathRenderer_src",
|
||||
"//src/gpu/ganesh/ops:DrawAtlasOp_src",
|
||||
"//src/gpu/ganesh/ops:DrawAtlasPathOp_src",
|
||||
"//src/gpu/ganesh/ops:DrawCustomMeshOp_src",
|
||||
"//src/gpu/ganesh/ops:DrawMeshOp_src",
|
||||
"//src/gpu/ganesh/ops:DrawableOp_src",
|
||||
"//src/gpu/ganesh/ops:FillRRectOp_src",
|
||||
"//src/gpu/ganesh/ops:FillRectOp_src",
|
||||
|
@ -1303,8 +1303,8 @@ generated_cc_atom(
|
||||
)
|
||||
|
||||
generated_cc_atom(
|
||||
name = "DrawCustomMeshOp_hdr",
|
||||
hdrs = ["DrawCustomMeshOp.h"],
|
||||
name = "DrawMeshOp_hdr",
|
||||
hdrs = ["DrawMeshOp.h"],
|
||||
visibility = ["//:__subpackages__"],
|
||||
deps = [
|
||||
":GrOp_hdr",
|
||||
@ -1315,16 +1315,16 @@ generated_cc_atom(
|
||||
)
|
||||
|
||||
generated_cc_atom(
|
||||
name = "DrawCustomMeshOp_src",
|
||||
srcs = ["DrawCustomMeshOp.cpp"],
|
||||
name = "DrawMeshOp_src",
|
||||
srcs = ["DrawMeshOp.cpp"],
|
||||
visibility = ["//:__subpackages__"],
|
||||
deps = [
|
||||
":DrawCustomMeshOp_hdr",
|
||||
":DrawMeshOp_hdr",
|
||||
":GrSimpleMeshDrawOpHelper_hdr",
|
||||
"//include/core:SkCustomMesh_hdr",
|
||||
"//include/core:SkData_hdr",
|
||||
"//include/core:SkMesh_hdr",
|
||||
"//src/core:SkArenaAlloc_hdr",
|
||||
"//src/core:SkCustomMeshPriv_hdr",
|
||||
"//src/core:SkMeshPriv_hdr",
|
||||
"//src/core:SkVerticesPriv_hdr",
|
||||
"//src/gpu:BufferWriter_hdr",
|
||||
"//src/gpu:KeyBuilder_hdr",
|
||||
|
@ -5,12 +5,12 @@
|
||||
* found in the LICENSE file.
|
||||
*/
|
||||
|
||||
#include "src/gpu/ganesh/ops/DrawCustomMeshOp.h"
|
||||
#include "src/gpu/ganesh/ops/DrawMeshOp.h"
|
||||
|
||||
#include "include/core/SkCustomMesh.h"
|
||||
#include "include/core/SkData.h"
|
||||
#include "include/core/SkMesh.h"
|
||||
#include "src/core/SkArenaAlloc.h"
|
||||
#include "src/core/SkCustomMeshPriv.h"
|
||||
#include "src/core/SkMeshPriv.h"
|
||||
#include "src/core/SkVerticesPriv.h"
|
||||
#include "src/gpu/BufferWriter.h"
|
||||
#include "src/gpu/KeyBuilder.h"
|
||||
@ -27,38 +27,38 @@
|
||||
|
||||
namespace {
|
||||
|
||||
GrPrimitiveType primitive_type(SkCustomMesh::Mode mode) {
|
||||
GrPrimitiveType primitive_type(SkMesh::Mode mode) {
|
||||
switch (mode) {
|
||||
case SkCustomMesh::Mode::kTriangles: return GrPrimitiveType::kTriangles;
|
||||
case SkCustomMesh::Mode::kTriangleStrip: return GrPrimitiveType::kTriangleStrip;
|
||||
case SkMesh::Mode::kTriangles: return GrPrimitiveType::kTriangles;
|
||||
case SkMesh::Mode::kTriangleStrip: return GrPrimitiveType::kTriangleStrip;
|
||||
}
|
||||
SkUNREACHABLE;
|
||||
}
|
||||
|
||||
class CustomMeshGP : public GrGeometryProcessor {
|
||||
class MeshGP : public GrGeometryProcessor {
|
||||
public:
|
||||
static GrGeometryProcessor* Make(SkArenaAlloc* arena,
|
||||
sk_sp<SkCustomMeshSpecification> spec,
|
||||
sk_sp<SkMeshSpecification> spec,
|
||||
sk_sp<GrColorSpaceXform> colorSpaceXform,
|
||||
const SkMatrix& viewMatrix,
|
||||
const std::optional<SkPMColor4f>& color,
|
||||
bool needsLocalCoords) {
|
||||
return arena->make([&](void* ptr) {
|
||||
return new (ptr) CustomMeshGP(std::move(spec),
|
||||
std::move(colorSpaceXform),
|
||||
viewMatrix,
|
||||
std::move(color),
|
||||
needsLocalCoords);
|
||||
return new (ptr) MeshGP(std::move(spec),
|
||||
std::move(colorSpaceXform),
|
||||
viewMatrix,
|
||||
std::move(color),
|
||||
needsLocalCoords);
|
||||
});
|
||||
}
|
||||
|
||||
const char* name() const override { return "CustomMeshGP"; }
|
||||
const char* name() const override { return "MeshGP"; }
|
||||
|
||||
void addToKey(const GrShaderCaps& caps, skgpu::KeyBuilder* b) const override {
|
||||
b->add32(SkCustomMeshSpecificationPriv::Hash(*fSpec), "custom mesh spec hash");
|
||||
b->add32(SkMeshSpecificationPriv::Hash(*fSpec), "custom mesh spec hash");
|
||||
b->add32(ProgramImpl::ComputeMatrixKey(caps, fViewMatrix), "view matrix key");
|
||||
if (SkCustomMeshSpecificationPriv::GetColorType(*fSpec) !=
|
||||
SkCustomMeshSpecificationPriv::ColorType::kNone) {
|
||||
if (SkMeshSpecificationPriv::GetColorType(*fSpec) !=
|
||||
SkMeshSpecificationPriv::ColorType::kNone) {
|
||||
b->add32(GrColorSpaceXform::XformKey(fColorSpaceXform.get()), "colorspace xform key");
|
||||
}
|
||||
}
|
||||
@ -73,7 +73,7 @@ private:
|
||||
void setData(const GrGLSLProgramDataManager& pdman,
|
||||
const GrShaderCaps& shaderCaps,
|
||||
const GrGeometryProcessor& geomProc) override {
|
||||
const auto& cmgp = geomProc.cast<CustomMeshGP>();
|
||||
const auto& cmgp = geomProc.cast<MeshGP>();
|
||||
SetTransform(pdman, shaderCaps, fViewMatrixUniform, cmgp.fViewMatrix, &fViewMatrix);
|
||||
fColorSpaceHelper.setData(pdman, cmgp.fColorSpaceXform.get());
|
||||
if (fColorUniform.isValid()) {
|
||||
@ -143,7 +143,7 @@ private:
|
||||
};
|
||||
|
||||
void onEmitCode(EmitArgs& args, GrGPArgs* gpArgs) override {
|
||||
const CustomMeshGP& cmgp = args.fGeomProc.cast<CustomMeshGP>();
|
||||
const MeshGP& cmgp = args.fGeomProc.cast<MeshGP>();
|
||||
GrGLSLVertexBuilder* vertBuilder = args.fVertBuilder;
|
||||
GrGLSLFPFragmentBuilder* fragBuilder = args.fFragBuilder;
|
||||
GrGLSLVaryingHandler* varyingHandler = args.fVaryingHandler;
|
||||
@ -156,7 +156,7 @@ private:
|
||||
|
||||
// Define the user's vert function.
|
||||
SkString userVertName = vertBuilder->getMangledFunctionName("custom_mesh_vs");
|
||||
const SkSL::Program* customVS = SkCustomMeshSpecificationPriv::VS(*cmgp.fSpec);
|
||||
const SkSL::Program* customVS = SkMeshSpecificationPriv::VS(*cmgp.fSpec);
|
||||
MeshCallbacks vsCallbacks(this, vertBuilder, userVertName.c_str(), *customVS->fContext);
|
||||
SkSL::PipelineStage::ConvertProgram(*customVS,
|
||||
/*sampleCoords=*/"",
|
||||
@ -183,9 +183,9 @@ private:
|
||||
|
||||
// Unpack the varyings from the struct into individual varyings.
|
||||
std::vector<GrGLSLVarying> varyings;
|
||||
varyings.reserve(SkCustomMeshSpecificationPriv::Varyings(*cmgp.fSpec).size());
|
||||
for (const auto& v : SkCustomMeshSpecificationPriv::Varyings(*cmgp.fSpec)) {
|
||||
varyings.emplace_back(SkCustomMeshSpecificationPriv::VaryingTypeAsSLType(v.type));
|
||||
varyings.reserve(SkMeshSpecificationPriv::Varyings(*cmgp.fSpec).size());
|
||||
for (const auto& v : SkMeshSpecificationPriv::Varyings(*cmgp.fSpec)) {
|
||||
varyings.emplace_back(SkMeshSpecificationPriv::VaryingTypeAsSLType(v.type));
|
||||
varyingHandler->addVarying(v.name.c_str(), &varyings.back());
|
||||
vertBuilder->codeAppendf("%s = varyings.%s;",
|
||||
varyings.back().vsOut(),
|
||||
@ -208,7 +208,7 @@ private:
|
||||
|
||||
// Define the user's frag function.
|
||||
SkString userFragName = fragBuilder->getMangledFunctionName("custom_mesh_fs");
|
||||
const SkSL::Program* customFS = SkCustomMeshSpecificationPriv::FS(*cmgp.fSpec);
|
||||
const SkSL::Program* customFS = SkMeshSpecificationPriv::FS(*cmgp.fSpec);
|
||||
MeshCallbacks fsCallbacks(this, fragBuilder, userFragName.c_str(), *customFS->fContext);
|
||||
SkSL::PipelineStage::ConvertProgram(*customFS,
|
||||
/*sampleCoords=*/"",
|
||||
@ -220,13 +220,13 @@ private:
|
||||
fragBuilder->codeAppendf("%s varyings;",
|
||||
fsCallbacks.getMangledName("Varyings").c_str());
|
||||
i = 0;
|
||||
for (const auto& varying : SkCustomMeshSpecificationPriv::Varyings(*cmgp.fSpec)) {
|
||||
for (const auto& varying : SkMeshSpecificationPriv::Varyings(*cmgp.fSpec)) {
|
||||
fragBuilder->codeAppendf("varyings.%s = %s;",
|
||||
varying.name.c_str(),
|
||||
varyings[i++].vsOut());
|
||||
}
|
||||
SkCustomMeshSpecificationPriv::ColorType meshColorType =
|
||||
SkCustomMeshSpecificationPriv::GetColorType(*cmgp.fSpec);
|
||||
SkMeshSpecificationPriv::ColorType meshColorType =
|
||||
SkMeshSpecificationPriv::GetColorType(*cmgp.fSpec);
|
||||
const char* uniformColorName = nullptr;
|
||||
if (cmgp.fColor != SK_PMColor4fILLEGAL) {
|
||||
fColorUniform = uniformHandler->addUniform(nullptr,
|
||||
@ -236,11 +236,10 @@ private:
|
||||
&uniformColorName);
|
||||
}
|
||||
SkString localCoordAssignment;
|
||||
if (SkCustomMeshSpecificationPriv::HasLocalCoords(*cmgp.fSpec) &&
|
||||
cmgp.fNeedsLocalCoords) {
|
||||
if (SkMeshSpecificationPriv::HasLocalCoords(*cmgp.fSpec) && cmgp.fNeedsLocalCoords) {
|
||||
localCoordAssignment = "float2 local =";
|
||||
}
|
||||
if (meshColorType == SkCustomMeshSpecificationPriv::ColorType::kNone) {
|
||||
if (meshColorType == SkMeshSpecificationPriv::ColorType::kNone) {
|
||||
fragBuilder->codeAppendf("%s %s(varyings);",
|
||||
localCoordAssignment.c_str(),
|
||||
userFragName.c_str());
|
||||
@ -250,10 +249,10 @@ private:
|
||||
fColorSpaceHelper.emitCode(uniformHandler,
|
||||
cmgp.fColorSpaceXform.get(),
|
||||
kFragment_GrShaderFlag);
|
||||
if (meshColorType == SkCustomMeshSpecificationPriv::ColorType::kFloat4) {
|
||||
if (meshColorType == SkMeshSpecificationPriv::ColorType::kFloat4) {
|
||||
fragBuilder->codeAppendf("float4 color;");
|
||||
} else {
|
||||
SkASSERT(meshColorType == SkCustomMeshSpecificationPriv::ColorType::kHalf4);
|
||||
SkASSERT(meshColorType == SkMeshSpecificationPriv::ColorType::kHalf4);
|
||||
fragBuilder->codeAppendf("half4 color;");
|
||||
}
|
||||
|
||||
@ -268,7 +267,7 @@ private:
|
||||
fragBuilder->codeAppendf("%s = %s;", args.fOutputColor, xformedColor.c_str());
|
||||
}
|
||||
if (cmgp.fNeedsLocalCoords) {
|
||||
if (SkCustomMeshSpecificationPriv::HasLocalCoords(*cmgp.fSpec)) {
|
||||
if (SkMeshSpecificationPriv::HasLocalCoords(*cmgp.fSpec)) {
|
||||
gpArgs->fLocalCoordVar = GrShaderVar("local", SkSLType::kFloat2);
|
||||
gpArgs->fLocalCoordShader = kFragment_GrShaderType;
|
||||
} else {
|
||||
@ -287,11 +286,11 @@ private:
|
||||
GrGLSLColorSpaceXformHelper fColorSpaceHelper;
|
||||
};
|
||||
|
||||
CustomMeshGP(sk_sp<SkCustomMeshSpecification> spec,
|
||||
sk_sp<GrColorSpaceXform> colorSpaceXform,
|
||||
const SkMatrix& viewMatrix,
|
||||
const std::optional<SkPMColor4f>& color,
|
||||
bool needsLocalCoords)
|
||||
MeshGP(sk_sp<SkMeshSpecification> spec,
|
||||
sk_sp<GrColorSpaceXform> colorSpaceXform,
|
||||
const SkMatrix& viewMatrix,
|
||||
const std::optional<SkPMColor4f>& color,
|
||||
bool needsLocalCoords)
|
||||
: INHERITED(kVerticesGP_ClassID)
|
||||
, fSpec(std::move(spec))
|
||||
, fViewMatrix(viewMatrix)
|
||||
@ -301,46 +300,46 @@ private:
|
||||
for (const auto& srcAttr : fSpec->attributes()) {
|
||||
fAttributes.emplace_back(
|
||||
srcAttr.name.c_str(),
|
||||
SkCustomMeshSpecificationPriv::AttrTypeAsVertexAttribType(srcAttr.type),
|
||||
SkCustomMeshSpecificationPriv::AttrTypeAsSLType(srcAttr.type),
|
||||
SkMeshSpecificationPriv::AttrTypeAsVertexAttribType(srcAttr.type),
|
||||
SkMeshSpecificationPriv::AttrTypeAsSLType(srcAttr.type),
|
||||
srcAttr.offset);
|
||||
}
|
||||
this->setVertexAttributes(fAttributes.data(), fAttributes.size(), fSpec->stride());
|
||||
}
|
||||
|
||||
sk_sp<SkCustomMeshSpecification> fSpec;
|
||||
std::vector<Attribute> fAttributes;
|
||||
SkMatrix fViewMatrix;
|
||||
SkPMColor4f fColor;
|
||||
sk_sp<GrColorSpaceXform> fColorSpaceXform;
|
||||
bool fNeedsLocalCoords;
|
||||
sk_sp<SkMeshSpecification> fSpec;
|
||||
std::vector<Attribute> fAttributes;
|
||||
SkMatrix fViewMatrix;
|
||||
SkPMColor4f fColor;
|
||||
sk_sp<GrColorSpaceXform> fColorSpaceXform;
|
||||
bool fNeedsLocalCoords;
|
||||
|
||||
using INHERITED = GrGeometryProcessor;
|
||||
};
|
||||
|
||||
class CustomMeshOp final : public GrMeshDrawOp {
|
||||
class MeshOp final : public GrMeshDrawOp {
|
||||
private:
|
||||
using Helper = GrSimpleMeshDrawOpHelper;
|
||||
|
||||
public:
|
||||
DEFINE_OP_CLASS_ID
|
||||
|
||||
CustomMeshOp(GrProcessorSet*,
|
||||
const SkPMColor4f&,
|
||||
const SkCustomMesh&,
|
||||
GrAAType,
|
||||
sk_sp<GrColorSpaceXform>,
|
||||
const SkMatrixProvider&);
|
||||
MeshOp(GrProcessorSet*,
|
||||
const SkPMColor4f&,
|
||||
const SkMesh&,
|
||||
GrAAType,
|
||||
sk_sp<GrColorSpaceXform>,
|
||||
const SkMatrixProvider&);
|
||||
|
||||
CustomMeshOp(GrProcessorSet*,
|
||||
const SkPMColor4f&,
|
||||
sk_sp<SkVertices>,
|
||||
const GrPrimitiveType*,
|
||||
GrAAType,
|
||||
sk_sp<GrColorSpaceXform>,
|
||||
const SkMatrixProvider&);
|
||||
MeshOp(GrProcessorSet*,
|
||||
const SkPMColor4f&,
|
||||
sk_sp<SkVertices>,
|
||||
const GrPrimitiveType*,
|
||||
GrAAType,
|
||||
sk_sp<GrColorSpaceXform>,
|
||||
const SkMatrixProvider&);
|
||||
|
||||
const char* name() const override { return "CustomMeshOp"; }
|
||||
const char* name() const override { return "MeshOp"; }
|
||||
|
||||
void visitProxies(const GrVisitProxyFunc& func) const override {
|
||||
if (fProgramInfo) {
|
||||
@ -377,20 +376,20 @@ private:
|
||||
CombineResult onCombineIfPossible(GrOp* t, SkArenaAlloc*, const GrCaps&) override;
|
||||
|
||||
/**
|
||||
* Built either from a SkCustomMesh or a SkVertices. In the former case the data is owned
|
||||
* Built either from a SkMesh or a SkVertices. In the former case the data is owned
|
||||
* by Mesh and in the latter it is not. Meshes made from SkVertices can contain a SkMatrix
|
||||
* to enable CPU-based transformation but Meshes made from SkCustomMesh cannot.
|
||||
* to enable CPU-based transformation but Meshes made from SkMesh cannot.
|
||||
*/
|
||||
class Mesh {
|
||||
public:
|
||||
Mesh() = delete;
|
||||
Mesh(const SkCustomMesh& cm);
|
||||
Mesh(const SkMesh& mesh);
|
||||
Mesh(sk_sp<SkVertices>, const SkMatrix& viewMatrix);
|
||||
Mesh(const Mesh&) = delete;
|
||||
Mesh(Mesh&& m);
|
||||
|
||||
Mesh& operator=(const Mesh&) = delete;
|
||||
Mesh& operator=(Mesh&&) = delete; // not used by SkSTArray but could be implemented.
|
||||
Mesh& operator=(Mesh&&) = delete; // not used by SkSTArray but could be implemented.
|
||||
|
||||
~Mesh();
|
||||
|
||||
@ -400,46 +399,46 @@ private:
|
||||
if (this->isFromVertices()) {
|
||||
return {};
|
||||
}
|
||||
return {fCMData.vb->asGpuBuffer(), fCMData.voffset};
|
||||
return {fMeshData.vb->asGpuBuffer(), fMeshData.voffset};
|
||||
}
|
||||
|
||||
std::tuple<sk_sp<const GrGpuBuffer>, size_t> gpuIB() const {
|
||||
if (this->isFromVertices() || !fCMData.ib) {
|
||||
if (this->isFromVertices() || !fMeshData.ib) {
|
||||
return {};
|
||||
}
|
||||
return {fCMData.ib->asGpuBuffer(), fCMData.ioffset};
|
||||
return {fMeshData.ib->asGpuBuffer(), fMeshData.ioffset};
|
||||
}
|
||||
|
||||
void writeVertices(skgpu::VertexWriter& writer,
|
||||
const SkCustomMeshSpecification& spec,
|
||||
const SkMeshSpecification& spec,
|
||||
bool transform) const;
|
||||
|
||||
int vertexCount() const {
|
||||
return this->isFromVertices() ? fVertices->priv().vertexCount() : fCMData.vcount;
|
||||
return this->isFromVertices() ? fVertices->priv().vertexCount() : fMeshData.vcount;
|
||||
}
|
||||
|
||||
const uint16_t* indices() const {
|
||||
if (this->isFromVertices()) {
|
||||
return fVertices->priv().indices();
|
||||
}
|
||||
if (!fCMData.ib) {
|
||||
if (!fMeshData.ib) {
|
||||
return nullptr;
|
||||
}
|
||||
auto data = fCMData.ib->asData();
|
||||
auto data = fMeshData.ib->asData();
|
||||
if (!data) {
|
||||
return nullptr;
|
||||
}
|
||||
return SkTAddOffset<const uint16_t>(data->data(), fCMData.ioffset);
|
||||
return SkTAddOffset<const uint16_t>(data->data(), fMeshData.ioffset);
|
||||
}
|
||||
|
||||
int indexCount() const {
|
||||
return this->isFromVertices() ? fVertices->priv().indexCount() : fCMData.icount;
|
||||
return this->isFromVertices() ? fVertices->priv().indexCount() : fMeshData.icount;
|
||||
}
|
||||
|
||||
private:
|
||||
struct CMData {
|
||||
sk_sp<const SkCustomMeshPriv::VB> vb;
|
||||
sk_sp<const SkCustomMeshPriv::IB> ib;
|
||||
struct MeshData {
|
||||
sk_sp<const SkMeshPriv::VB> vb;
|
||||
sk_sp<const SkMeshPriv::IB> ib;
|
||||
|
||||
size_t vcount = 0;
|
||||
size_t icount = 0;
|
||||
@ -452,63 +451,63 @@ private:
|
||||
|
||||
union {
|
||||
SkMatrix fViewMatrix;
|
||||
CMData fCMData;
|
||||
MeshData fMeshData;
|
||||
};
|
||||
};
|
||||
|
||||
Helper fHelper;
|
||||
sk_sp<SkCustomMeshSpecification> fSpecification;
|
||||
bool fIgnoreSpecColor = false;
|
||||
GrPrimitiveType fPrimitiveType;
|
||||
SkSTArray<1, Mesh> fMeshes;
|
||||
sk_sp<GrColorSpaceXform> fColorSpaceXform;
|
||||
SkPMColor4f fColor; // Used if no color from spec or analysis overrides.
|
||||
SkMatrix fViewMatrix;
|
||||
int fVertexCount;
|
||||
int fIndexCount;
|
||||
GrSimpleMesh* fMesh = nullptr;
|
||||
GrProgramInfo* fProgramInfo = nullptr;
|
||||
Helper fHelper;
|
||||
sk_sp<SkMeshSpecification> fSpecification;
|
||||
bool fIgnoreSpecColor = false;
|
||||
GrPrimitiveType fPrimitiveType;
|
||||
SkSTArray<1, Mesh> fMeshes;
|
||||
sk_sp<GrColorSpaceXform> fColorSpaceXform;
|
||||
SkPMColor4f fColor; // Used if no color from spec or analysis overrides.
|
||||
SkMatrix fViewMatrix;
|
||||
int fVertexCount;
|
||||
int fIndexCount;
|
||||
GrSimpleMesh* fMesh = nullptr;
|
||||
GrProgramInfo* fProgramInfo = nullptr;
|
||||
|
||||
using INHERITED = GrMeshDrawOp;
|
||||
};
|
||||
|
||||
CustomMeshOp::Mesh::Mesh(const SkCustomMesh& cm) {
|
||||
new (&fCMData) CMData();
|
||||
fCMData.vb = sk_ref_sp(static_cast<SkCustomMeshPriv::VB*>(cm.vertexBuffer().get()));
|
||||
if (cm.indexBuffer()) {
|
||||
fCMData.ib = sk_ref_sp(static_cast<SkCustomMeshPriv::IB*>(cm.indexBuffer().get()));
|
||||
MeshOp::Mesh::Mesh(const SkMesh& mesh) {
|
||||
new (&fMeshData) MeshData();
|
||||
fMeshData.vb = sk_ref_sp(static_cast<SkMeshPriv::VB*>(mesh.vertexBuffer().get()));
|
||||
if (mesh.indexBuffer()) {
|
||||
fMeshData.ib = sk_ref_sp(static_cast<SkMeshPriv::IB*>(mesh.indexBuffer().get()));
|
||||
}
|
||||
fCMData.vcount = cm.vertexCount();
|
||||
fCMData.voffset = cm.vertexOffset();
|
||||
fCMData.icount = cm.indexCount();
|
||||
fCMData.ioffset = cm.indexOffset();
|
||||
fMeshData.vcount = mesh.vertexCount();
|
||||
fMeshData.voffset = mesh.vertexOffset();
|
||||
fMeshData.icount = mesh.indexCount();
|
||||
fMeshData.ioffset = mesh.indexOffset();
|
||||
}
|
||||
|
||||
CustomMeshOp::Mesh::Mesh(sk_sp<SkVertices> vertices, const SkMatrix& viewMatrix)
|
||||
MeshOp::Mesh::Mesh(sk_sp<SkVertices> vertices, const SkMatrix& viewMatrix)
|
||||
: fVertices(std::move(vertices)), fViewMatrix(viewMatrix) {
|
||||
SkASSERT(fVertices);
|
||||
}
|
||||
|
||||
CustomMeshOp::Mesh::Mesh(Mesh&& that) {
|
||||
MeshOp::Mesh::Mesh(Mesh&& that) {
|
||||
fVertices = std::move(that.fVertices);
|
||||
if (fVertices) {
|
||||
fViewMatrix = that.fViewMatrix;
|
||||
// 'that' is now not-a-vertices. Make sure it can be safely destroyed.
|
||||
new (&that.fCMData) CMData();
|
||||
new (&that.fMeshData) MeshData();
|
||||
} else {
|
||||
fCMData = std::move(that.fCMData);
|
||||
fMeshData = std::move(that.fMeshData);
|
||||
}
|
||||
}
|
||||
|
||||
CustomMeshOp::Mesh::~Mesh() {
|
||||
MeshOp::Mesh::~Mesh() {
|
||||
if (!this->isFromVertices()) {
|
||||
fCMData.~CMData();
|
||||
fMeshData.~MeshData();
|
||||
}
|
||||
}
|
||||
|
||||
void CustomMeshOp::Mesh::writeVertices(skgpu::VertexWriter& writer,
|
||||
const SkCustomMeshSpecification& spec,
|
||||
bool transform) const {
|
||||
void MeshOp::Mesh::writeVertices(skgpu::VertexWriter& writer,
|
||||
const SkMeshSpecification& spec,
|
||||
bool transform) const {
|
||||
SkASSERT(!transform || this->isFromVertices());
|
||||
if (this->isFromVertices()) {
|
||||
int vertexCount = fVertices->priv().vertexCount();
|
||||
@ -519,49 +518,49 @@ void CustomMeshOp::Mesh::writeVertices(skgpu::VertexWriter& writer,
|
||||
fViewMatrix.mapPoints(&pos, 1);
|
||||
}
|
||||
writer << pos;
|
||||
if (SkCustomMeshSpecificationPriv::HasColors(spec)) {
|
||||
if (SkMeshSpecificationPriv::HasColors(spec)) {
|
||||
SkASSERT(fVertices->priv().hasColors());
|
||||
writer << fVertices->priv().colors()[i];
|
||||
}
|
||||
if (SkCustomMeshSpecificationPriv::HasLocalCoords(spec)) {
|
||||
if (SkMeshSpecificationPriv::HasLocalCoords(spec)) {
|
||||
SkASSERT(fVertices->priv().hasTexCoords());
|
||||
writer << fVertices->priv().texCoords()[i];
|
||||
}
|
||||
}
|
||||
} else {
|
||||
sk_sp<const SkData> data = fCMData.vb->asData();
|
||||
sk_sp<const SkData> data = fMeshData.vb->asData();
|
||||
if (data) {
|
||||
auto vdata = static_cast<const char*>(data->data()) + fCMData.voffset;
|
||||
writer << skgpu::VertexWriter::Array(vdata, spec.stride() * fCMData.vcount);
|
||||
auto vdata = static_cast<const char*>(data->data()) + fMeshData.voffset;
|
||||
writer << skgpu::VertexWriter::Array(vdata, spec.stride()*fMeshData.vcount);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
CustomMeshOp::CustomMeshOp(GrProcessorSet* processorSet,
|
||||
const SkPMColor4f& color,
|
||||
const SkCustomMesh& cm,
|
||||
GrAAType aaType,
|
||||
sk_sp<GrColorSpaceXform> colorSpaceXform,
|
||||
const SkMatrixProvider& matrixProvider)
|
||||
MeshOp::MeshOp(GrProcessorSet* processorSet,
|
||||
const SkPMColor4f& color,
|
||||
const SkMesh& mesh,
|
||||
GrAAType aaType,
|
||||
sk_sp<GrColorSpaceXform> colorSpaceXform,
|
||||
const SkMatrixProvider& matrixProvider)
|
||||
: INHERITED(ClassID())
|
||||
, fHelper(processorSet, aaType)
|
||||
, fPrimitiveType(primitive_type(cm.mode()))
|
||||
, fPrimitiveType(primitive_type(mesh.mode()))
|
||||
, fColorSpaceXform(std::move(colorSpaceXform))
|
||||
, fColor(color)
|
||||
, fViewMatrix(matrixProvider.localToDevice()) {
|
||||
fMeshes.emplace_back(cm);
|
||||
fMeshes.emplace_back(mesh);
|
||||
|
||||
fSpecification = cm.spec();
|
||||
fSpecification = mesh.spec();
|
||||
|
||||
fVertexCount = fMeshes.back().vertexCount();
|
||||
fIndexCount = fMeshes.back().indexCount();
|
||||
|
||||
this->setTransformedBounds(cm.bounds(), fViewMatrix, HasAABloat::kNo, IsHairline::kNo);
|
||||
this->setTransformedBounds(mesh.bounds(), fViewMatrix, HasAABloat::kNo, IsHairline::kNo);
|
||||
}
|
||||
|
||||
static sk_sp<SkCustomMeshSpecification> make_vertices_spec(bool hasColors, bool hasTex) {
|
||||
using Attribute = SkCustomMeshSpecification::Attribute;
|
||||
using Varying = SkCustomMeshSpecification::Varying;
|
||||
static sk_sp<SkMeshSpecification> make_vertices_spec(bool hasColors, bool hasTex) {
|
||||
using Attribute = SkMeshSpecification::Attribute;
|
||||
using Varying = SkMeshSpecification::Varying;
|
||||
std::vector<Attribute> attributes;
|
||||
attributes.reserve(3);
|
||||
attributes.push_back({Attribute::Type::kFloat2, 0, SkString{"pos"}});
|
||||
@ -594,7 +593,7 @@ static sk_sp<SkCustomMeshSpecification> make_vertices_spec(bool hasColors, bool
|
||||
}
|
||||
vs += "return a.pos;\n}";
|
||||
fs += "}";
|
||||
auto [spec, error] = SkCustomMeshSpecification::Make(
|
||||
auto [spec, error] = SkMeshSpecification::Make(
|
||||
SkMakeSpan(attributes),
|
||||
size,
|
||||
SkMakeSpan(varyings),
|
||||
@ -604,13 +603,13 @@ static sk_sp<SkCustomMeshSpecification> make_vertices_spec(bool hasColors, bool
|
||||
return spec;
|
||||
}
|
||||
|
||||
CustomMeshOp::CustomMeshOp(GrProcessorSet* processorSet,
|
||||
const SkPMColor4f& color,
|
||||
sk_sp<SkVertices> vertices,
|
||||
const GrPrimitiveType* overridePrimitiveType,
|
||||
GrAAType aaType,
|
||||
sk_sp<GrColorSpaceXform> colorSpaceXform,
|
||||
const SkMatrixProvider& matrixProvider)
|
||||
MeshOp::MeshOp(GrProcessorSet* processorSet,
|
||||
const SkPMColor4f& color,
|
||||
sk_sp<SkVertices> vertices,
|
||||
const GrPrimitiveType* overridePrimitiveType,
|
||||
GrAAType aaType,
|
||||
sk_sp<GrColorSpaceXform> colorSpaceXform,
|
||||
const SkMatrixProvider& matrixProvider)
|
||||
: INHERITED(ClassID())
|
||||
, fHelper(processorSet, aaType)
|
||||
, fColorSpaceXform(std::move(colorSpaceXform))
|
||||
@ -670,16 +669,16 @@ CustomMeshOp::CustomMeshOp(GrProcessorSet* processorSet,
|
||||
}
|
||||
|
||||
#if GR_TEST_UTILS
|
||||
SkString CustomMeshOp::onDumpInfo() const { return {}; }
|
||||
SkString MeshOp::onDumpInfo() const { return {}; }
|
||||
#endif
|
||||
|
||||
GrDrawOp::FixedFunctionFlags CustomMeshOp::fixedFunctionFlags() const {
|
||||
GrDrawOp::FixedFunctionFlags MeshOp::fixedFunctionFlags() const {
|
||||
return fHelper.fixedFunctionFlags();
|
||||
}
|
||||
|
||||
GrProcessorSet::Analysis CustomMeshOp::finalize(const GrCaps& caps,
|
||||
const GrAppliedClip* clip,
|
||||
GrClampType clampType) {
|
||||
GrProcessorSet::Analysis MeshOp::finalize(const GrCaps& caps,
|
||||
const GrAppliedClip* clip,
|
||||
GrClampType clampType) {
|
||||
GrProcessorAnalysisColor gpColor;
|
||||
gpColor.setToUnknown();
|
||||
auto result = fHelper.finalizeProcessors(caps,
|
||||
@ -693,29 +692,29 @@ GrProcessorSet::Analysis CustomMeshOp::finalize(const GrCaps& caps,
|
||||
return result;
|
||||
}
|
||||
|
||||
GrGeometryProcessor* CustomMeshOp::makeGP(SkArenaAlloc* arena) {
|
||||
GrGeometryProcessor* MeshOp::makeGP(SkArenaAlloc* arena) {
|
||||
std::optional<SkPMColor4f> color;
|
||||
if (fIgnoreSpecColor || !SkCustomMeshSpecificationPriv::HasColors(*fSpecification)) {
|
||||
if (fIgnoreSpecColor || !SkMeshSpecificationPriv::HasColors(*fSpecification)) {
|
||||
color.emplace(fColor);
|
||||
}
|
||||
// Check if we're pre-transforming the vertices on the CPU.
|
||||
const SkMatrix& vm = fViewMatrix == SkMatrix::InvalidMatrix() ? SkMatrix::I() : fViewMatrix;
|
||||
return CustomMeshGP::Make(arena,
|
||||
fSpecification,
|
||||
fColorSpaceXform,
|
||||
vm,
|
||||
color,
|
||||
fHelper.usesLocalCoords());
|
||||
return MeshGP::Make(arena,
|
||||
fSpecification,
|
||||
fColorSpaceXform,
|
||||
vm,
|
||||
color,
|
||||
fHelper.usesLocalCoords());
|
||||
}
|
||||
|
||||
void CustomMeshOp::onCreateProgramInfo(const GrCaps* caps,
|
||||
SkArenaAlloc* arena,
|
||||
const GrSurfaceProxyView& writeView,
|
||||
bool usesMSAASurface,
|
||||
GrAppliedClip&& appliedClip,
|
||||
const GrDstProxyView& dstProxyView,
|
||||
GrXferBarrierFlags renderPassXferBarriers,
|
||||
GrLoadOp colorLoadOp) {
|
||||
void MeshOp::onCreateProgramInfo(const GrCaps* caps,
|
||||
SkArenaAlloc* arena,
|
||||
const GrSurfaceProxyView& writeView,
|
||||
bool usesMSAASurface,
|
||||
GrAppliedClip&& appliedClip,
|
||||
const GrDstProxyView& dstProxyView,
|
||||
GrXferBarrierFlags renderPassXferBarriers,
|
||||
GrLoadOp colorLoadOp) {
|
||||
fProgramInfo = fHelper.createProgramInfo(caps,
|
||||
arena,
|
||||
writeView,
|
||||
@ -728,7 +727,7 @@ void CustomMeshOp::onCreateProgramInfo(const GrCaps* caps,
|
||||
colorLoadOp);
|
||||
}
|
||||
|
||||
void CustomMeshOp::onPrepareDraws(GrMeshDrawTarget* target) {
|
||||
void MeshOp::onPrepareDraws(GrMeshDrawTarget* target) {
|
||||
size_t vertexStride = fSpecification->stride();
|
||||
sk_sp<const GrBuffer> vertexBuffer;
|
||||
int firstVertex;
|
||||
@ -800,7 +799,7 @@ void CustomMeshOp::onPrepareDraws(GrMeshDrawTarget* target) {
|
||||
}
|
||||
}
|
||||
|
||||
void CustomMeshOp::onExecute(GrOpFlushState* flushState, const SkRect& chainBounds) {
|
||||
void MeshOp::onExecute(GrOpFlushState* flushState, const SkRect& chainBounds) {
|
||||
if (!fProgramInfo) {
|
||||
this->createProgramInfo(flushState);
|
||||
}
|
||||
@ -814,8 +813,8 @@ void CustomMeshOp::onExecute(GrOpFlushState* flushState, const SkRect& chainBoun
|
||||
flushState->drawMesh(*fMesh);
|
||||
}
|
||||
|
||||
GrOp::CombineResult CustomMeshOp::onCombineIfPossible(GrOp* t, SkArenaAlloc*, const GrCaps& caps) {
|
||||
auto that = t->cast<CustomMeshOp>();
|
||||
GrOp::CombineResult MeshOp::onCombineIfPossible(GrOp* t, SkArenaAlloc*, const GrCaps& caps) {
|
||||
auto that = t->cast<MeshOp>();
|
||||
|
||||
// Check for a combinable primitive type.
|
||||
if (!(fPrimitiveType == GrPrimitiveType::kTriangles ||
|
||||
@ -835,12 +834,12 @@ GrOp::CombineResult CustomMeshOp::onCombineIfPossible(GrOp* t, SkArenaAlloc*, co
|
||||
return CombineResult::kCannotCombine;
|
||||
}
|
||||
|
||||
if (SkCustomMeshSpecificationPriv::Hash(*this->fSpecification) !=
|
||||
SkCustomMeshSpecificationPriv::Hash(*that->fSpecification)) {
|
||||
if (SkMeshSpecificationPriv::Hash(*this->fSpecification) !=
|
||||
SkMeshSpecificationPriv::Hash(*that->fSpecification)) {
|
||||
return CombineResult::kCannotCombine;
|
||||
}
|
||||
|
||||
if (!SkCustomMeshSpecificationPriv::HasColors(*fSpecification) && fColor != that->fColor) {
|
||||
if (!SkMeshSpecificationPriv::HasColors(*fSpecification) && fColor != that->fColor) {
|
||||
return CombineResult::kCannotCombine;
|
||||
}
|
||||
|
||||
@ -856,7 +855,7 @@ GrOp::CombineResult CustomMeshOp::onCombineIfPossible(GrOp* t, SkArenaAlloc*, co
|
||||
// If we use local coords and the local coords come from positions then we can't pre-
|
||||
// transform the positions on the CPU.
|
||||
if (fHelper.usesLocalCoords() &&
|
||||
!SkCustomMeshSpecificationPriv::HasLocalCoords(*fSpecification)) {
|
||||
!SkMeshSpecificationPriv::HasLocalCoords(*fSpecification)) {
|
||||
return CombineResult::kCannotCombine;
|
||||
}
|
||||
// We only support two-component position attributes. This means we would not get
|
||||
@ -881,20 +880,20 @@ GrOp::CombineResult CustomMeshOp::onCombineIfPossible(GrOp* t, SkArenaAlloc*, co
|
||||
|
||||
} // anonymous namespace
|
||||
|
||||
namespace skgpu::v1::DrawCustomMeshOp {
|
||||
namespace skgpu::v1::DrawMeshOp {
|
||||
|
||||
GrOp::Owner Make(GrRecordingContext* context,
|
||||
GrPaint&& paint,
|
||||
const SkCustomMesh& cm,
|
||||
const SkMesh& mesh,
|
||||
const SkMatrixProvider& matrixProvider,
|
||||
GrAAType aaType,
|
||||
sk_sp<GrColorSpaceXform> colorSpaceXform) {
|
||||
return GrSimpleMeshDrawOpHelper::FactoryHelper<CustomMeshOp>(context,
|
||||
std::move(paint),
|
||||
std::move(cm),
|
||||
aaType,
|
||||
std::move(colorSpaceXform),
|
||||
matrixProvider);
|
||||
return GrSimpleMeshDrawOpHelper::FactoryHelper<MeshOp>(context,
|
||||
std::move(paint),
|
||||
mesh,
|
||||
aaType,
|
||||
std::move(colorSpaceXform),
|
||||
matrixProvider);
|
||||
}
|
||||
|
||||
GrOp::Owner Make(GrRecordingContext* context,
|
||||
@ -904,13 +903,13 @@ GrOp::Owner Make(GrRecordingContext* context,
|
||||
const SkMatrixProvider& matrixProvider,
|
||||
GrAAType aaType,
|
||||
sk_sp<GrColorSpaceXform> colorSpaceXform) {
|
||||
return GrSimpleMeshDrawOpHelper::FactoryHelper<CustomMeshOp>(context,
|
||||
std::move(paint),
|
||||
std::move(vertices),
|
||||
overridePrimitiveType,
|
||||
aaType,
|
||||
std::move(colorSpaceXform),
|
||||
matrixProvider);
|
||||
return GrSimpleMeshDrawOpHelper::FactoryHelper<MeshOp>(context,
|
||||
std::move(paint),
|
||||
std::move(vertices),
|
||||
overridePrimitiveType,
|
||||
aaType,
|
||||
std::move(colorSpaceXform),
|
||||
matrixProvider);
|
||||
}
|
||||
|
||||
} // namespace skgpu::v1::DrawCustomMeshOp
|
||||
} // namespace skgpu::v1::DrawMeshOp
|
@ -5,8 +5,8 @@
|
||||
* found in the LICENSE file.
|
||||
*/
|
||||
|
||||
#ifndef DrawCustomMeshOp_DEFINED
|
||||
#define DrawCustomMeshOp_DEFINED
|
||||
#ifndef DrawMeshOp_DEFINED
|
||||
#define DrawMeshOp_DEFINED
|
||||
|
||||
#include "include/core/SkCanvas.h"
|
||||
#include "include/core/SkRefCnt.h"
|
||||
@ -16,13 +16,13 @@
|
||||
class GrColorSpaceXform;
|
||||
class GrPaint;
|
||||
class GrRecordingContext;
|
||||
class SkCustomMesh;
|
||||
class SkMesh;
|
||||
class SkMatrixProvider;
|
||||
|
||||
namespace skgpu::v1::DrawCustomMeshOp {
|
||||
namespace skgpu::v1::DrawMeshOp {
|
||||
GrOp::Owner Make(GrRecordingContext*,
|
||||
GrPaint&&,
|
||||
const SkCustomMesh&,
|
||||
const SkMesh&,
|
||||
const SkMatrixProvider&,
|
||||
GrAAType,
|
||||
sk_sp<GrColorSpaceXform>);
|
||||
@ -34,6 +34,6 @@ GrOp::Owner Make(GrRecordingContext*,
|
||||
const SkMatrixProvider&,
|
||||
GrAAType,
|
||||
sk_sp<GrColorSpaceXform>);
|
||||
} // namespace skgpu::v1::DrawCustomMeshOp
|
||||
} // namespace skgpu::v1::DrawMeshOp
|
||||
|
||||
#endif // DrawCustomMeshOp_DEFINED
|
||||
#endif // DrawMeshOp_DEFINED
|
@ -105,11 +105,11 @@ generated_cc_atom(
|
||||
"//include/private/chromium:SkChromeRemoteGlyphCache_hdr",
|
||||
"//src/core:SkCanvasPriv_hdr",
|
||||
"//src/core:SkClipStack_hdr",
|
||||
"//src/core:SkCustomMeshPriv_hdr",
|
||||
"//src/core:SkDraw_hdr",
|
||||
"//src/core:SkImageFilterCache_hdr",
|
||||
"//src/core:SkImageFilter_Base_hdr",
|
||||
"//src/core:SkLatticeIter_hdr",
|
||||
"//src/core:SkMeshPriv_hdr",
|
||||
"//src/core:SkPictureData_hdr",
|
||||
"//src/core:SkRRectPriv_hdr",
|
||||
"//src/core:SkRasterClip_hdr",
|
||||
@ -273,13 +273,13 @@ generated_cc_atom(
|
||||
"//include/utils:SkShadowUtils_hdr",
|
||||
"//src/core:SkAutoPixmapStorage_hdr",
|
||||
"//src/core:SkConvertPixels_hdr",
|
||||
"//src/core:SkCustomMeshPriv_hdr",
|
||||
"//src/core:SkDrawProcs_hdr",
|
||||
"//src/core:SkDrawShadowInfo_hdr",
|
||||
"//src/core:SkGlyphRunPainter_hdr",
|
||||
"//src/core:SkLatticeIter_hdr",
|
||||
"//src/core:SkMatrixPriv_hdr",
|
||||
"//src/core:SkMatrixProvider_hdr",
|
||||
"//src/core:SkMeshPriv_hdr",
|
||||
"//src/core:SkRRectPriv_hdr",
|
||||
"//src/gpu/ganesh:GrAppliedClip_hdr",
|
||||
"//src/gpu/ganesh:GrAttachment_hdr",
|
||||
@ -312,7 +312,7 @@ generated_cc_atom(
|
||||
"//src/gpu/ganesh/geometry:GrStyledShape_hdr",
|
||||
"//src/gpu/ganesh/ops:ClearOp_hdr",
|
||||
"//src/gpu/ganesh/ops:DrawAtlasOp_hdr",
|
||||
"//src/gpu/ganesh/ops:DrawCustomMeshOp_hdr",
|
||||
"//src/gpu/ganesh/ops:DrawMeshOp_hdr",
|
||||
"//src/gpu/ganesh/ops:DrawableOp_hdr",
|
||||
"//src/gpu/ganesh/ops:FillRRectOp_hdr",
|
||||
"//src/gpu/ganesh/ops:FillRectOp_hdr",
|
||||
|
@ -21,11 +21,11 @@
|
||||
#include "include/private/chromium/GrSlug.h"
|
||||
#include "src/core/SkCanvasPriv.h"
|
||||
#include "src/core/SkClipStack.h"
|
||||
#include "src/core/SkCustomMeshPriv.h"
|
||||
#include "src/core/SkDraw.h"
|
||||
#include "src/core/SkImageFilterCache.h"
|
||||
#include "src/core/SkImageFilter_Base.h"
|
||||
#include "src/core/SkLatticeIter.h"
|
||||
#include "src/core/SkMeshPriv.h"
|
||||
#include "src/core/SkPictureData.h"
|
||||
#include "src/core/SkRRectPriv.h"
|
||||
#include "src/core/SkRasterClip.h"
|
||||
@ -882,12 +882,10 @@ void Device::drawVertices(const SkVertices* vertices,
|
||||
skipColorXform);
|
||||
}
|
||||
|
||||
void Device::drawCustomMesh(const SkCustomMesh& customMesh,
|
||||
sk_sp<SkBlender> blender,
|
||||
const SkPaint& paint) {
|
||||
void Device::drawMesh(const SkMesh& mesh, sk_sp<SkBlender> blender, const SkPaint& paint) {
|
||||
ASSERT_SINGLE_OWNER
|
||||
GR_CREATE_TRACE_MARKER_CONTEXT("skgpu::v1::Device", "drawCustomMesh", fContext.get());
|
||||
SkASSERT(customMesh.isValid());
|
||||
GR_CREATE_TRACE_MARKER_CONTEXT("skgpu::v1::Device", "drawMesh", fContext.get());
|
||||
SkASSERT(mesh.isValid());
|
||||
|
||||
GrPaint grPaint;
|
||||
if (!init_vertices_paint(fContext.get(),
|
||||
@ -895,14 +893,11 @@ void Device::drawCustomMesh(const SkCustomMesh& customMesh,
|
||||
paint,
|
||||
this->asMatrixProvider(),
|
||||
std::move(blender),
|
||||
SkCustomMeshSpecificationPriv::HasColors(*customMesh.spec()),
|
||||
SkMeshSpecificationPriv::HasColors(*mesh.spec()),
|
||||
&grPaint)) {
|
||||
return;
|
||||
}
|
||||
fSurfaceDrawContext->drawCustomMesh(this->clip(),
|
||||
std::move(grPaint),
|
||||
this->asMatrixProvider(),
|
||||
customMesh);
|
||||
fSurfaceDrawContext->drawMesh(this->clip(), std::move(grPaint), this->asMatrixProvider(), mesh);
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
@ -117,7 +117,7 @@ public:
|
||||
void drawPath(const SkPath& path, const SkPaint& paint, bool pathIsMutable) override;
|
||||
|
||||
void drawVertices(const SkVertices*, sk_sp<SkBlender>, const SkPaint&, bool) override;
|
||||
void drawCustomMesh(const SkCustomMesh&, sk_sp<SkBlender>, const SkPaint&) override;
|
||||
void drawMesh(const SkMesh&, sk_sp<SkBlender>, const SkPaint&) override;
|
||||
void drawShadow(const SkPath&, const SkDrawShadowRec&) override;
|
||||
void drawAtlas(const SkRSXform[], const SkRect[], const SkColor[], int count, sk_sp<SkBlender>,
|
||||
const SkPaint&) override;
|
||||
|
@ -19,13 +19,13 @@
|
||||
#include "include/utils/SkShadowUtils.h"
|
||||
#include "src/core/SkAutoPixmapStorage.h"
|
||||
#include "src/core/SkConvertPixels.h"
|
||||
#include "src/core/SkCustomMeshPriv.h"
|
||||
#include "src/core/SkDrawProcs.h"
|
||||
#include "src/core/SkDrawShadowInfo.h"
|
||||
#include "src/core/SkGlyphRunPainter.h"
|
||||
#include "src/core/SkLatticeIter.h"
|
||||
#include "src/core/SkMatrixPriv.h"
|
||||
#include "src/core/SkMatrixProvider.h"
|
||||
#include "src/core/SkMeshPriv.h"
|
||||
#include "src/core/SkRRectPriv.h"
|
||||
#include "src/gpu/ganesh/GrAppliedClip.h"
|
||||
#include "src/gpu/ganesh/GrAttachment.h"
|
||||
@ -58,7 +58,7 @@
|
||||
#include "src/gpu/ganesh/geometry/GrStyledShape.h"
|
||||
#include "src/gpu/ganesh/ops/ClearOp.h"
|
||||
#include "src/gpu/ganesh/ops/DrawAtlasOp.h"
|
||||
#include "src/gpu/ganesh/ops/DrawCustomMeshOp.h"
|
||||
#include "src/gpu/ganesh/ops/DrawMeshOp.h"
|
||||
#include "src/gpu/ganesh/ops/DrawableOp.h"
|
||||
#include "src/gpu/ganesh/ops/FillRRectOp.h"
|
||||
#include "src/gpu/ganesh/ops/FillRectOp.h"
|
||||
@ -910,40 +910,40 @@ void SurfaceDrawContext::drawVertices(const GrClip* clip,
|
||||
SkASSERT(vertices);
|
||||
auto xform = skipColorXform ? nullptr : this->colorInfo().refColorSpaceXformFromSRGB();
|
||||
GrAAType aaType = fCanUseDynamicMSAA ? GrAAType::kMSAA : this->chooseAAType(GrAA::kNo);
|
||||
GrOp::Owner op = DrawCustomMeshOp::Make(fContext,
|
||||
std::move(paint),
|
||||
std::move(vertices),
|
||||
overridePrimType,
|
||||
matrixProvider,
|
||||
aaType,
|
||||
std::move(xform));
|
||||
GrOp::Owner op = DrawMeshOp::Make(fContext,
|
||||
std::move(paint),
|
||||
std::move(vertices),
|
||||
overridePrimType,
|
||||
matrixProvider,
|
||||
aaType,
|
||||
std::move(xform));
|
||||
this->addDrawOp(clip, std::move(op));
|
||||
}
|
||||
|
||||
void SurfaceDrawContext::drawCustomMesh(const GrClip* clip,
|
||||
GrPaint&& paint,
|
||||
const SkMatrixProvider& matrixProvider,
|
||||
const SkCustomMesh& cm) {
|
||||
void SurfaceDrawContext::drawMesh(const GrClip* clip,
|
||||
GrPaint&& paint,
|
||||
const SkMatrixProvider& matrixProvider,
|
||||
const SkMesh& mesh) {
|
||||
ASSERT_SINGLE_OWNER
|
||||
RETURN_IF_ABANDONED
|
||||
SkDEBUGCODE(this->validate();)
|
||||
GR_CREATE_TRACE_MARKER_CONTEXT("SurfaceDrawContext", "drawCustomMesh", fContext);
|
||||
GR_CREATE_TRACE_MARKER_CONTEXT("SurfaceDrawContext", "drawMesh", fContext);
|
||||
|
||||
AutoCheckFlush acf(this->drawingManager());
|
||||
|
||||
SkASSERT(cm.isValid());
|
||||
SkASSERT(mesh.isValid());
|
||||
|
||||
auto xform = GrColorSpaceXform::Make(SkCustomMeshSpecificationPriv::ColorSpace(*cm.spec()),
|
||||
SkCustomMeshSpecificationPriv::AlphaType(*cm.spec()),
|
||||
auto xform = GrColorSpaceXform::Make(SkMeshSpecificationPriv::ColorSpace(*mesh.spec()),
|
||||
SkMeshSpecificationPriv::AlphaType(*mesh.spec()),
|
||||
this->colorInfo().colorSpace(),
|
||||
this->colorInfo().alphaType());
|
||||
GrAAType aaType = fCanUseDynamicMSAA ? GrAAType::kMSAA : this->chooseAAType(GrAA::kNo);
|
||||
GrOp::Owner op = DrawCustomMeshOp::Make(fContext,
|
||||
std::move(paint),
|
||||
std::move(cm),
|
||||
matrixProvider,
|
||||
aaType,
|
||||
std::move(xform));
|
||||
GrOp::Owner op = DrawMeshOp::Make(fContext,
|
||||
std::move(paint),
|
||||
mesh,
|
||||
matrixProvider,
|
||||
aaType,
|
||||
std::move(xform));
|
||||
this->addDrawOp(clip, std::move(op));
|
||||
}
|
||||
|
||||
|
@ -380,12 +380,12 @@ public:
|
||||
*
|
||||
* @param paint describes how to color pixels.
|
||||
* @param matrixProvider provides the transformation matrix
|
||||
* @param cm the custom mesh to draw.
|
||||
* @param mesh the mesh to draw.
|
||||
*/
|
||||
void drawCustomMesh(const GrClip*,
|
||||
GrPaint&& paint,
|
||||
const SkMatrixProvider& matrixProvider,
|
||||
const SkCustomMesh& cm);
|
||||
void drawMesh(const GrClip*,
|
||||
GrPaint&& paint,
|
||||
const SkMatrixProvider& matrixProvider,
|
||||
const SkMesh& mesh);
|
||||
|
||||
/**
|
||||
* Draws textured sprites from an atlas with a paint. This currently does not support AA for the
|
||||
|
@ -127,7 +127,7 @@ private:
|
||||
|
||||
void drawDrawable(SkCanvas*, SkDrawable*, const SkMatrix*) override {}
|
||||
void drawVertices(const SkVertices*, sk_sp<SkBlender>, const SkPaint&, bool) override {}
|
||||
void drawCustomMesh(const SkCustomMesh&, sk_sp<SkBlender>, const SkPaint&) override {}
|
||||
void drawMesh(const SkMesh&, sk_sp<SkBlender>, const SkPaint&) override {}
|
||||
void drawShadow(const SkPath&, const SkDrawShadowRec&) override {}
|
||||
void onDrawGlyphRunList(
|
||||
SkCanvas*, const SkGlyphRunList&, const SkPaint&, const SkPaint&) override {}
|
||||
|
@ -973,11 +973,11 @@ void SkPDFDevice::drawVertices(const SkVertices*, sk_sp<SkBlender>, const SkPain
|
||||
// TODO: implement drawVertices
|
||||
}
|
||||
|
||||
void SkPDFDevice::drawCustomMesh(const SkCustomMesh&, sk_sp<SkBlender>, const SkPaint&) {
|
||||
void SkPDFDevice::drawMesh(const SkMesh&, sk_sp<SkBlender>, const SkPaint&) {
|
||||
if (this->hasEmptyClip()) {
|
||||
return;
|
||||
}
|
||||
// TODO: implement drawCustomMesh
|
||||
// TODO: implement drawMesh
|
||||
}
|
||||
|
||||
void SkPDFDevice::drawFormXObject(SkPDFIndirectReference xObject, SkDynamicMemoryWStream* content) {
|
||||
|
@ -89,7 +89,7 @@ public:
|
||||
const SkPaint& initialPaint,
|
||||
const SkPaint& drawingPaint) override;
|
||||
void drawVertices(const SkVertices*, sk_sp<SkBlender>, const SkPaint&, bool) override;
|
||||
void drawCustomMesh(const SkCustomMesh&, sk_sp<SkBlender>, const SkPaint&) override;
|
||||
void drawMesh(const SkMesh&, sk_sp<SkBlender>, const SkPaint&) override;
|
||||
|
||||
// PDF specific methods.
|
||||
void drawSprite(const SkBitmap& bitmap, int x, int y,
|
||||
|
@ -346,8 +346,8 @@ const ParsedModule& Compiler::moduleForProgramKind(ProgramKind kind) {
|
||||
case ProgramKind::kRuntimeShader: return this->loadPublicModule(); break;
|
||||
case ProgramKind::kRuntimeBlender: return this->loadPublicModule(); break;
|
||||
case ProgramKind::kPrivateRuntimeShader: return this->loadPrivateRTShaderModule(); break;
|
||||
case ProgramKind::kCustomMeshVertex: return this->loadPublicModule(); break;
|
||||
case ProgramKind::kCustomMeshFragment: return this->loadPublicModule(); break;
|
||||
case ProgramKind::kMeshVertex: return this->loadPublicModule(); break;
|
||||
case ProgramKind::kMeshFragment: return this->loadPublicModule(); break;
|
||||
case ProgramKind::kGeneric: return this->loadPublicModule(); break;
|
||||
}
|
||||
SkUNREACHABLE;
|
||||
|
@ -119,8 +119,8 @@ struct ProgramConfig {
|
||||
kind == ProgramKind::kRuntimeShader ||
|
||||
kind == ProgramKind::kRuntimeBlender ||
|
||||
kind == ProgramKind::kPrivateRuntimeShader ||
|
||||
kind == ProgramKind::kCustomMeshVertex ||
|
||||
kind == ProgramKind::kCustomMeshFragment);
|
||||
kind == ProgramKind::kMeshVertex ||
|
||||
kind == ProgramKind::kMeshFragment);
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -364,8 +364,8 @@ void PipelineStageCodeGenerator::writeFunction(const FunctionDefinition& f) {
|
||||
// obscure bug.
|
||||
const FunctionDeclaration& decl = f.declaration();
|
||||
if (decl.isMain() &&
|
||||
fProgram.fConfig->fKind != SkSL::ProgramKind::kCustomMeshVertex &&
|
||||
fProgram.fConfig->fKind != SkSL::ProgramKind::kCustomMeshFragment) {
|
||||
fProgram.fConfig->fKind != SkSL::ProgramKind::kMeshVertex &&
|
||||
fProgram.fConfig->fKind != SkSL::ProgramKind::kMeshFragment) {
|
||||
fCastReturnsToHalf = true;
|
||||
}
|
||||
|
||||
|
@ -100,8 +100,8 @@ static bool check_parameters(const Context& context,
|
||||
|
||||
if (isMain) {
|
||||
if (ProgramConfig::IsRuntimeEffect(context.fConfig->fKind) &&
|
||||
context.fConfig->fKind != ProgramKind::kCustomMeshFragment &&
|
||||
context.fConfig->fKind != ProgramKind::kCustomMeshVertex) {
|
||||
context.fConfig->fKind != ProgramKind::kMeshFragment &&
|
||||
context.fConfig->fKind != ProgramKind::kMeshVertex) {
|
||||
// We verify that the signature is fully correct later. For now, if this is a
|
||||
// runtime effect of any flavor, a float2 param is supposed to be the coords, and a
|
||||
// half4/float parameter is supposed to be the input or destination color:
|
||||
@ -230,7 +230,7 @@ static bool check_main_signature(const Context& context, Position pos, const Typ
|
||||
}
|
||||
break;
|
||||
}
|
||||
case ProgramKind::kCustomMeshVertex: {
|
||||
case ProgramKind::kMeshVertex: {
|
||||
// float2 main(Attributes, out Varyings)
|
||||
if (!returnType.matches(*context.fTypes.fFloat2)) {
|
||||
errors.error(pos, "'main' must return: 'vec2' or 'float2'");
|
||||
@ -242,7 +242,7 @@ static bool check_main_signature(const Context& context, Position pos, const Typ
|
||||
}
|
||||
break;
|
||||
}
|
||||
case ProgramKind::kCustomMeshFragment: {
|
||||
case ProgramKind::kMeshFragment: {
|
||||
// float2 main(Varyings) -or- float2 main(Varyings, out half4|float4]) -or-
|
||||
// void main(Varyings) -or- void main(Varyings, out half4|float4])
|
||||
if (!returnType.matches(*context.fTypes.fFloat2) &&
|
||||
|
@ -108,8 +108,8 @@ void VarDeclaration::ErrorCheck(const Context& context,
|
||||
"variables of type '" + baseType->displayName() + "' must be uniform");
|
||||
}
|
||||
if (modifiers.fFlags & Modifiers::kUniform_Flag &&
|
||||
(context.fConfig->fKind == ProgramKind::kCustomMeshVertex ||
|
||||
context.fConfig->fKind == ProgramKind::kCustomMeshFragment)) {
|
||||
(context.fConfig->fKind == ProgramKind::kMeshVertex ||
|
||||
context.fConfig->fKind == ProgramKind::kMeshFragment)) {
|
||||
context.fErrors->error(pos, "uniforms are not permitted in custom mesh shaders");
|
||||
}
|
||||
if (modifiers.fLayout.fFlags & Layout::kColor_Flag) {
|
||||
|
@ -59,7 +59,7 @@
|
||||
#include <utility>
|
||||
|
||||
#if SK_SUPPORT_GPU
|
||||
class SkCustomMesh;
|
||||
class SkMesh;
|
||||
#endif
|
||||
class SkBlender;
|
||||
class SkVertices;
|
||||
@ -1141,7 +1141,7 @@ void SkSVGDevice::drawVertices(const SkVertices*, sk_sp<SkBlender>, const SkPain
|
||||
}
|
||||
|
||||
#ifdef SK_ENABLE_SKSL
|
||||
void SkSVGDevice::drawCustomMesh(const SkCustomMesh&, sk_sp<SkBlender>, const SkPaint&) {
|
||||
void SkSVGDevice::drawMesh(const SkMesh&, sk_sp<SkBlender>, const SkPaint&) {
|
||||
// todo
|
||||
}
|
||||
#endif
|
||||
|
@ -34,7 +34,7 @@ struct SkPoint;
|
||||
struct SkRect;
|
||||
struct SkSamplingOptions;
|
||||
#ifdef SK_ENABLE_SKSL
|
||||
class SkCustomMesh;
|
||||
class SkMesh;
|
||||
#endif
|
||||
|
||||
class SkSVGDevice final : public SkClipStackDevice {
|
||||
@ -63,7 +63,7 @@ protected:
|
||||
const SkPaint& drawingPaint) override;
|
||||
void drawVertices(const SkVertices*, sk_sp<SkBlender>, const SkPaint&, bool) override;
|
||||
#ifdef SK_ENABLE_SKSL
|
||||
void drawCustomMesh(const SkCustomMesh&, sk_sp<SkBlender>, const SkPaint&) override;
|
||||
void drawMesh(const SkMesh&, sk_sp<SkBlender>, const SkPaint&) override;
|
||||
#endif
|
||||
private:
|
||||
SkSVGDevice(const SkISize& size, std::unique_ptr<SkXMLWriter>, uint32_t);
|
||||
|
@ -1146,7 +1146,7 @@ void SkXPSDevice::drawVertices(const SkVertices*, sk_sp<SkBlender>, const SkPain
|
||||
//TODO
|
||||
}
|
||||
|
||||
void SkXPSDevice::drawCustomMesh(const SkCustomMesh&, sk_sp<SkBlender>, const SkPaint&) {
|
||||
void SkXPSDevice::drawMesh(const SkMesh&, sk_sp<SkBlender>, const SkPaint&) {
|
||||
// TODO
|
||||
}
|
||||
|
||||
|
@ -95,7 +95,7 @@ protected:
|
||||
void onDrawGlyphRunList(
|
||||
SkCanvas*, const SkGlyphRunList&, const SkPaint&, const SkPaint&) override;
|
||||
void drawVertices(const SkVertices*, sk_sp<SkBlender>, const SkPaint&, bool) override;
|
||||
void drawCustomMesh(const SkCustomMesh&, sk_sp<SkBlender>, const SkPaint&) override;
|
||||
void drawMesh(const SkMesh&, sk_sp<SkBlender>, const SkPaint&) override;
|
||||
void drawDevice(SkBaseDevice*, const SkSamplingOptions&, const SkPaint&) override;
|
||||
|
||||
private:
|
||||
|
@ -1456,17 +1456,6 @@ generated_cc_atom(
|
||||
],
|
||||
)
|
||||
|
||||
generated_cc_atom(
|
||||
name = "CustomMeshTest_src",
|
||||
srcs = ["CustomMeshTest.cpp"],
|
||||
visibility = ["//:__subpackages__"],
|
||||
deps = [
|
||||
":Test_hdr",
|
||||
"//include/core:SkCanvas_hdr",
|
||||
"//include/core:SkCustomMesh_hdr",
|
||||
],
|
||||
)
|
||||
|
||||
generated_cc_atom(
|
||||
name = "DMSAATest_src",
|
||||
srcs = ["DMSAATest.cpp"],
|
||||
@ -7242,3 +7231,14 @@ generated_cc_atom(
|
||||
"//src/core:SkEnumBitMask_hdr",
|
||||
],
|
||||
)
|
||||
|
||||
generated_cc_atom(
|
||||
name = "MeshTest_src",
|
||||
srcs = ["MeshTest.cpp"],
|
||||
visibility = ["//:__subpackages__"],
|
||||
deps = [
|
||||
":Test_hdr",
|
||||
"//include/core:SkCanvas_hdr",
|
||||
"//include/core:SkMesh_hdr",
|
||||
],
|
||||
)
|
||||
|
@ -6,19 +6,19 @@
|
||||
*/
|
||||
|
||||
#include "include/core/SkCanvas.h"
|
||||
#include "include/core/SkCustomMesh.h"
|
||||
#include "include/core/SkMesh.h"
|
||||
#include "tests/Test.h"
|
||||
|
||||
using Attribute = SkCustomMeshSpecification::Attribute;
|
||||
using Varying = SkCustomMeshSpecification::Varying;
|
||||
using Attribute = SkMeshSpecification::Attribute;
|
||||
using Varying = SkMeshSpecification::Varying;
|
||||
|
||||
static const char* attr_type_str(const Attribute::Type type) {
|
||||
switch (type) {
|
||||
case Attribute::Type::kFloat: return "float";
|
||||
case Attribute::Type::kFloat2: return "float2";
|
||||
case Attribute::Type::kFloat3: return "float3";
|
||||
case Attribute::Type::kFloat4: return "float4";
|
||||
case Attribute::Type::kUByte4_unorm: return "ubyte4_unorm";
|
||||
case Attribute::Type::kFloat: return "float";
|
||||
case Attribute::Type::kFloat2: return "float2";
|
||||
case Attribute::Type::kFloat3: return "float3";
|
||||
case Attribute::Type::kFloat4: return "float4";
|
||||
case Attribute::Type::kUByte4_unorm: return "ubyte4_unorm";
|
||||
}
|
||||
SkUNREACHABLE;
|
||||
}
|
||||
@ -47,10 +47,7 @@ static SkString make_description(SkSpan<const Attribute> attributes,
|
||||
result.appendf("Attributes (count=%zu, stride=%zu):\n", attributes.size(), stride);
|
||||
for (size_t i = 0; i < std::min(kMax, attributes.size()); ++i) {
|
||||
const auto& a = attributes[i];
|
||||
result.appendf(" {%-10s, %3zu, \"%s\"}\n",
|
||||
attr_type_str(a.type),
|
||||
a.offset,
|
||||
a.name.c_str());
|
||||
result.appendf(" {%-10s, %3zu, \"%s\"}\n", attr_type_str(a.type), a.offset, a.name.c_str());
|
||||
}
|
||||
if (kMax < attributes.size()) {
|
||||
result.append(" ...\n");
|
||||
@ -76,7 +73,7 @@ static bool check_for_failure(skiatest::Reporter* r,
|
||||
SkSpan<const Varying> varyings,
|
||||
const SkString& vs,
|
||||
const SkString& fs) {
|
||||
auto [spec, error] = SkCustomMeshSpecification::Make(attributes, stride, varyings, vs, fs);
|
||||
auto [spec, error] = SkMeshSpecification::Make(attributes, stride, varyings, vs, fs);
|
||||
SkString description;
|
||||
if (!spec) {
|
||||
return true;
|
||||
@ -93,7 +90,7 @@ static bool check_for_success(skiatest::Reporter* r,
|
||||
SkSpan<const Varying> varyings,
|
||||
const SkString& vs,
|
||||
const SkString& fs) {
|
||||
auto [spec, error] = SkCustomMeshSpecification::Make(attributes, stride, varyings, vs, fs);
|
||||
auto [spec, error] = SkMeshSpecification::Make(attributes, stride, varyings, vs, fs);
|
||||
if (spec) {
|
||||
REPORTER_ASSERT(r, error.isEmpty());
|
||||
return true;
|
||||
@ -513,7 +510,7 @@ static void test_empty_varying_name(skiatest::Reporter* r) {
|
||||
kValidFSes[0]);
|
||||
}
|
||||
|
||||
DEF_TEST(CustomMeshSpec, reporter) {
|
||||
DEF_TEST(MeshSpec, reporter) {
|
||||
struct X {};
|
||||
test_good(reporter);
|
||||
test_bad_sig(reporter);
|
Loading…
Reference in New Issue
Block a user