Skip to content

Commit

Permalink
Add some documentation to the mesh_updates GM
Browse files Browse the repository at this point in the history
I had to look at this when filing the associated bug and added some dox.

Bug: b/391615517
Change-Id: I3b37b80eb378c058635f0e0b363150ab4edbb9d1
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/941076
Commit-Queue: Robert Phillips <[email protected]>
Reviewed-by: Jim Van Verth <[email protected]>
  • Loading branch information
rphilli authored and SkCQ committed Jan 22, 2025
1 parent 6532b64 commit 73a5aec
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions gm/mesh.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -683,7 +683,11 @@ class MeshUpdateGM : public skiagm::GM {
using Attribute = SkMeshSpecification::Attribute;
using Varying = SkMeshSpecification::Varying;

SkISize getISize() override { return {270, 490}; }
static constexpr int kWidth = 270;
static constexpr int kHeight = 490;
static constexpr int kVerticalPadding = 10;

SkISize getISize() override { return {kWidth, kHeight}; }

void onOnceBeforeDraw() override {
static const Attribute kAttributes[]{
Expand Down Expand Up @@ -726,6 +730,8 @@ class MeshUpdateGM : public skiagm::GM {

SkString getName() const override { return SkString("mesh_updates"); }

// The top 4 rows are CPU buffers - the bottom 4 rows are GPU buffers
// Within each set of 4, the top 3 rows are vertex updates while the 4th row is an index update.
DrawResult onDraw(SkCanvas* canvas, SkString* error) override {
canvas->clear(SK_ColorBLACK);

Expand All @@ -743,7 +749,7 @@ class MeshUpdateGM : public skiagm::GM {
SkPaint paint;
paint.setShader(fShader);

SkRect r = SkRect::MakeXYWH(10.f, 10.f, 50.f, 50.f);
const SkRect r = SkRect::MakeXYWH(10.f, 10.f, 50.f, 50.f);

// We test updating CPU and GPU buffers.
for (bool gpuBuffer : {false, true}) {
Expand Down Expand Up @@ -802,7 +808,7 @@ class MeshUpdateGM : public skiagm::GM {

canvas->drawMesh(result.mesh, SkBlender::Mode(SkBlendMode::kDst), paint);

canvas->translate(0, r.height() + 10);
canvas->translate(0, r.height() + kVerticalPadding);
}

// Now test updating an IB.
Expand Down Expand Up @@ -867,7 +873,7 @@ class MeshUpdateGM : public skiagm::GM {

canvas->drawMesh(result.mesh, SkBlender::Mode(SkBlendMode::kDst), paint);
}
canvas->translate(0, r.height() + 10);
canvas->translate(0, r.height() + kVerticalPadding);
}

return DrawResult::kOk;
Expand Down

0 comments on commit 73a5aec

Please sign in to comment.