From b3d7031f362c37c27e058f421973bfcdc704d23c Mon Sep 17 00:00:00 2001 From: blakdragan7 Date: Fri, 6 Sep 2024 23:20:09 +0000 Subject: [PATCH] removed skia from a few gms the start of skia removal from GMs Diffs= 63a88a1ce removed skia from a few gms (#8076) Co-authored-by: Jonathon Copeland --- .rive_head | 2 +- tests/gm/batchedconvexpaths.cpp | 6 +++--- tests/gm/beziers.cpp | 34 ++++++++++++++++----------------- tests/gm/convexpaths.cpp | 16 ++++++++-------- tests/gm/emptypath.cpp | 32 +++++++++++++++---------------- 5 files changed, 43 insertions(+), 47 deletions(-) diff --git a/.rive_head b/.rive_head index 69ed3605..f8bb7f46 100644 --- a/.rive_head +++ b/.rive_head @@ -1 +1 @@ -177921a515956eacd9858eb210c7a85af71c8f6c +63a88a1ceb4fab4d50b7cd40b7a579221bde3196 diff --git a/tests/gm/batchedconvexpaths.cpp b/tests/gm/batchedconvexpaths.cpp index 155a798a..02d12017 100644 --- a/tests/gm/batchedconvexpaths.cpp +++ b/tests/gm/batchedconvexpaths.cpp @@ -9,7 +9,7 @@ #include "gm.hpp" #include "gmutils.hpp" #include "rive/renderer.hpp" -#include "skia/include/core/SkColor.h" +#include "rive/math/math_types.hpp" using namespace rivegm; using namespace rive; @@ -20,7 +20,7 @@ class BatchedConvexPathsGM : public GM BatchedConvexPathsGM() : GM(512, 512, "batchedconvexpaths") {} private: - ColorInt clearColor() const override { return SK_ColorBLACK; } + ColorInt clearColor() const override { return 0xFF000000; } void onDraw(Renderer* canvas) override { @@ -33,7 +33,7 @@ class BatchedConvexPathsGM : public GM path->moveTo(1, 0); for (float j = 1; j < numPoints; j += 3) { - constexpr float k2PI = SK_ScalarPI * 2; + constexpr float k2PI = math::PI * 2; path->cubicTo(cosf(j / numPoints * k2PI), sinf(j / numPoints * k2PI), cosf((j + 1) / numPoints * k2PI), diff --git a/tests/gm/beziers.cpp b/tests/gm/beziers.cpp index f9c864f4..4d38c9a5 100644 --- a/tests/gm/beziers.cpp +++ b/tests/gm/beziers.cpp @@ -8,8 +8,7 @@ #include "gm.hpp" #include "gmutils.hpp" -#include "include/utils/SkRandom.h" -#include "rive/renderer.hpp" +#include "common/rand.hpp" using namespace rivegm; using namespace rive; @@ -18,42 +17,41 @@ using namespace rive; #define H 400 #define N 10 -constexpr SkScalar SH = SkIntToScalar(H); +constexpr float SH = H; -static Path rnd_quad(RenderPaint* paint, SkRandom& rand) +static Path rnd_quad(RenderPaint* paint, Rand& rand) { - auto a = rand.nextRangeScalar(0, W), b = rand.nextRangeScalar(0, H); + auto a = rand.f32(0, W), b = rand.f32(0, H); PathBuilder builder; builder.moveTo(a, b); for (int x = 0; x < 2; ++x) { - auto c = rand.nextRangeScalar(W / 4.f, W), d = rand.nextRangeScalar(0, H), - e = rand.nextRangeScalar(0, W), f = rand.nextRangeScalar(H / 4.f, H); + auto c = rand.f32(W / 4.f, W), d = rand.f32(0, H), e = rand.f32(0, W), + f = rand.f32(H / 4.f, H); builder.quadTo(c, d, e, f); } - paint->color(rand.nextU()); - SkScalar width = rand.nextRangeScalar(1, 5); + paint->color(rand.u32()); + float width = rand.f32(1, 5); width *= width; paint->thickness(width); return builder.detach(); } -static Path rnd_cubic(RenderPaint* paint, SkRandom& rand) +static Path rnd_cubic(RenderPaint* paint, Rand& rand) { - auto a = rand.nextRangeScalar(0, W), b = rand.nextRangeScalar(0, H); + auto a = rand.f32(0, W), b = rand.f32(0, H); PathBuilder builder; builder.moveTo(a, b); for (int x = 0; x < 2; ++x) { - auto c = rand.nextRangeScalar(W / 4.f, W), d = rand.nextRangeScalar(0, H), - e = rand.nextRangeScalar(0, W), f = rand.nextRangeScalar(H / 4.f, H), - g = rand.nextRangeScalar(W / 4.f, W), h = rand.nextRangeScalar(H / 4.f, H); + auto c = rand.f32(W / 4.f, W), d = rand.f32(0, H), e = rand.f32(0, W), + f = rand.f32(H / 4.f, H), g = rand.f32(W / 4.f, W), h = rand.f32(H / 4.f, H); builder.cubicTo(c, d, e, f, g, h); } - paint->color(rand.nextU()); - SkScalar width = rand.nextRangeScalar(1, 5); + paint->color(rand.u32()); + float width = rand.f32(1, 5); width *= width; paint->thickness(width); return builder.detach(); @@ -69,9 +67,9 @@ class BeziersGM : public GM { Paint paint; paint->style(RenderPaintStyle::stroke); - paint->thickness(SkIntToScalar(9) / 2); + paint->thickness(9.0f / 2.0f); - SkRandom rand; + Rand rand; for (int i = 0; i < N; i++) { canvas->drawPath(rnd_quad(paint, rand), paint); diff --git a/tests/gm/convexpaths.cpp b/tests/gm/convexpaths.cpp index 3cc91672..ee72d933 100644 --- a/tests/gm/convexpaths.cpp +++ b/tests/gm/convexpaths.cpp @@ -9,7 +9,7 @@ #include "gm.hpp" #include "gmutils.hpp" #include "rive/renderer.hpp" -#include "skia/include/utils/SkRandom.h" +#include "common/rand.hpp" using namespace rivegm; using namespace rive; @@ -25,7 +25,7 @@ class SkDoOnce bool alreadyDone() const { return fDidOnce; } void accomplished() { - SkASSERT(!fDidOnce); + assert(!fDidOnce); fDidOnce = true; } @@ -69,19 +69,19 @@ class ConvexPathsGM : public GM b.moveTo(0, 0); for (int i = 1; i < kPtsPerSide; ++i) { // skip the first point due to moveTo. - b.lineTo(kLength * SkIntToScalar(i) / kPtsPerSide, 0); + b.lineTo(kLength * (float)(i) / kPtsPerSide, 0); } for (int i = 0; i < kPtsPerSide; ++i) { - b.lineTo(kLength, kLength * SkIntToScalar(i) / kPtsPerSide); + b.lineTo(kLength, kLength * (float)(i) / kPtsPerSide); } for (int i = kPtsPerSide; i > 0; --i) { - b.lineTo(kLength * SkIntToScalar(i) / kPtsPerSide, kLength); + b.lineTo(kLength * (float)(i) / kPtsPerSide, kLength); } for (int i = kPtsPerSide; i > 0; --i) { - b.lineTo(0, kLength * SkIntToScalar(i) / kPtsPerSide); + b.lineTo(0, kLength * (float)(i) / kPtsPerSide); } fPaths.push_back(b.detach()); @@ -192,7 +192,7 @@ class ConvexPathsGM : public GM this->makePaths(); Paint paint; - SkRandom rand; + Rand rand; renderer->translate(20, 20); // As we've added more paths this has gotten pretty big. Scale the whole thing down. @@ -203,7 +203,7 @@ class ConvexPathsGM : public GM renderer->save(); // position the path, and make it at off-integer coords. renderer->translate(200.0f * (i % 5) + 1.0f / 10, 200.0f * (int)(i / 5) + 9.0f / 10); - ColorInt color = rand.nextU(); + ColorInt color = rand.u32(); color |= 0xff000000; paint->color(color); #if 0 // This hitting on 32bit Linux builds for some paths. Temporarily disabling while it is diff --git a/tests/gm/emptypath.cpp b/tests/gm/emptypath.cpp index d23a9a6a..26d67c57 100644 --- a/tests/gm/emptypath.cpp +++ b/tests/gm/emptypath.cpp @@ -9,14 +9,12 @@ #include "gm.hpp" #include "gmutils.hpp" #include "rive/renderer.hpp" -#include "skia/include/core/SkPoint.h" -#include "skia/include/utils/SkRandom.h" using namespace rivegm; using namespace rive; static constexpr int kPtsCount = 3; -static constexpr SkPoint kPts[kPtsCount] = { +static constexpr Vec2D kPts[kPtsCount] = { {40, 40}, {80, 40}, {120, 40}, @@ -25,9 +23,9 @@ static constexpr SkPoint kPts[kPtsCount] = { static Path make_path_move() { PathBuilder builder; - for (SkPoint p : kPts) + for (Vec2D p : kPts) { - builder.moveTo(p.x(), p.y()); + builder.moveTo(p.x, p.y); } return builder.detach(); } @@ -35,9 +33,9 @@ static Path make_path_move() static Path make_path_move_close() { PathBuilder builder; - for (SkPoint p : kPts) + for (Vec2D p : kPts) { - builder.moveTo(p.x(), p.y()).close(); + builder.moveTo(p.x, p.y).close(); } return builder.detach(); } @@ -45,9 +43,9 @@ static Path make_path_move_close() static Path make_path_move_line() { PathBuilder builder; - for (SkPoint p : kPts) + for (Vec2D p : kPts) { - builder.moveTo(p.x(), p.y()).lineTo(p.x(), p.y()); + builder.moveTo(p.x, p.y).lineTo(p.x, p.y); } return builder.detach(); } @@ -55,11 +53,11 @@ static Path make_path_move_line() static Path make_path_move_mix() { return PathBuilder() - .moveTo(kPts[0].x(), kPts[0].y()) - .moveTo(kPts[1].x(), kPts[1].y()) + .moveTo(kPts[0].x, kPts[0].y) + .moveTo(kPts[1].x, kPts[1].y) .close() - .moveTo(kPts[2].x(), kPts[2].y()) - .lineTo(kPts[2].x(), kPts[2].y()) + .moveTo(kPts[2].x, kPts[2].y) + .lineTo(kPts[2].x, kPts[2].y) .detach(); } @@ -94,10 +92,10 @@ class EmptyStrokeGM : public GM { for (int i = 0; i < 3; ++i) { - renderer->drawPath(PathBuilder::Oval({kPts[i].x() - 3.5f, - kPts[i].y() - 3.5f, - kPts[i].x() + 3.5f, - kPts[i].y() + 3.5f}), + renderer->drawPath(PathBuilder::Oval({kPts[i].x - 3.5f, + kPts[i].y - 3.5f, + kPts[i].x + 3.5f, + kPts[i].y + 3.5f}), dotPaint); } renderer->drawPath(proc(), strokePaint);