Skip to content

Commit

Permalink
removed skia from a few gms
Browse files Browse the repository at this point in the history
the start of skia removal from GMs

Diffs=
63a88a1ce removed skia from a few gms (#8076)

Co-authored-by: Jonathon Copeland <[email protected]>
  • Loading branch information
blakdragan7 and blakdragan7 committed Sep 6, 2024
1 parent 37d2131 commit b3d7031
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 47 deletions.
2 changes: 1 addition & 1 deletion .rive_head
Original file line number Diff line number Diff line change
@@ -1 +1 @@
177921a515956eacd9858eb210c7a85af71c8f6c
63a88a1ceb4fab4d50b7cd40b7a579221bde3196
6 changes: 3 additions & 3 deletions tests/gm/batchedconvexpaths.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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
{
Expand All @@ -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),
Expand Down
34 changes: 16 additions & 18 deletions tests/gm/beziers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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();
Expand All @@ -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);
Expand Down
16 changes: 8 additions & 8 deletions tests/gm/convexpaths.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -25,7 +25,7 @@ class SkDoOnce
bool alreadyDone() const { return fDidOnce; }
void accomplished()
{
SkASSERT(!fDidOnce);
assert(!fDidOnce);
fDidOnce = true;
}

Expand Down Expand Up @@ -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());

Expand Down Expand Up @@ -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.
Expand All @@ -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
Expand Down
32 changes: 15 additions & 17 deletions tests/gm/emptypath.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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},
Expand All @@ -25,41 +23,41 @@ 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();
}

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();
}

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();
}

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();
}

Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit b3d7031

Please sign in to comment.