Skip to content

Commit

Permalink
Use STArray in skia/test
Browse files Browse the repository at this point in the history
Bug: skia:14148
Change-Id: I142a4478305d23b12ab3158a14141357bd33ff12
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/667698
Reviewed-by: Kevin Lubick <[email protected]>
Commit-Queue: Herb Derby <[email protected]>
  • Loading branch information
herbderby authored and SkCQ committed Apr 7, 2023
1 parent 407e0a8 commit 5e936d5
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 38 deletions.
4 changes: 3 additions & 1 deletion tests/GrPipelineDynamicStateTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@
#include <memory>
#include <utility>

using namespace skia_private;

class GrAppliedClip;
class GrDstProxyView;
class GrGLSLProgramDataManager;
Expand Down Expand Up @@ -187,7 +189,7 @@ class GrPipelineDynamicStateTestOp : public GrDrawOp {
void onExecute(GrOpFlushState* flushState, const SkRect& chainBounds) override {
GrPipeline pipeline(fScissorTest, SkBlendMode::kSrc,
flushState->drawOpArgs().writeView().swizzle());
SkSTArray<kNumMeshes, GrSimpleMesh> meshes;
STArray<kNumMeshes, GrSimpleMesh> meshes;
for (int i = 0; i < kNumMeshes; ++i) {
GrSimpleMesh& mesh = meshes.push_back();
mesh.set(fVertexBuffer, 4, 4 * i);
Expand Down
11 changes: 6 additions & 5 deletions tests/SkStrikeTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
#include <tuple>
#include <vector>

using namespace skia_private;

using namespace sktext;
using namespace skglyph;
Expand Down Expand Up @@ -144,16 +145,16 @@ DEF_TEST(SkStrikeMultiThread, Reporter) {
auto local = data.subspan(threadIndex * 2, data.size() - kThreadCount * 2);
for (int i = 0; i < 100; i++) {
// Accepted buffers.
SkSTArray<64, SkPackedGlyphID> acceptedPackedGlyphIDs;
SkSTArray<64, SkPoint> acceptedPositions;
SkSTArray<64, SkMask::Format> acceptedFormats;
STArray<64, SkPackedGlyphID> acceptedPackedGlyphIDs;
STArray<64, SkPoint> acceptedPositions;
STArray<64, SkMask::Format> acceptedFormats;
acceptedPackedGlyphIDs.resize(glyphCount);
acceptedPositions.resize(glyphCount);
const auto acceptedBuffer = SkMakeZip(acceptedPackedGlyphIDs, acceptedPositions);

// Rejected buffers.
SkSTArray<64, SkGlyphID> rejectedGlyphIDs;
SkSTArray<64, SkPoint> rejectedPositions;
STArray<64, SkGlyphID> rejectedGlyphIDs;
STArray<64, SkPoint> rejectedPositions;
rejectedGlyphIDs.resize(glyphCount);
rejectedPositions.resize(glyphCount);
const auto rejectedBuffer = SkMakeZip(rejectedGlyphIDs, rejectedPositions);
Expand Down
64 changes: 32 additions & 32 deletions tests/TArrayTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -232,9 +232,9 @@ static void test_swap(skiatest::Reporter* reporter) {
int sizes[] = {0, 1, 5, 10, 15, 20, 25};

TArray<int> arr;
SkSTArray< 5, int> arr5;
SkSTArray<10, int> arr10;
SkSTArray<20, int> arr20;
STArray< 5, int> arr5;
STArray<10, int> arr10;
STArray<20, int> arr20;
TArray<int>* arrays[] = { &arr, &arr5, &arr10, &arr20 };
test_swap(reporter, arrays, sizes);

Expand All @@ -246,9 +246,9 @@ static void test_swap(skiatest::Reporter* reporter) {
};

TArray<MoveOnlyInt> moi;
SkSTArray< 5, MoveOnlyInt> moi5;
SkSTArray<10, MoveOnlyInt> moi10;
SkSTArray<20, MoveOnlyInt> moi20;
STArray< 5, MoveOnlyInt> moi5;
STArray<10, MoveOnlyInt> moi10;
STArray<20, MoveOnlyInt> moi20;
TArray<MoveOnlyInt>* arraysMoi[] = { &moi, &moi5, &moi10, &moi20 };
test_swap(reporter, arraysMoi, sizes);
}
Expand All @@ -259,7 +259,7 @@ void test_unnecessary_alloc(skiatest::Reporter* reporter) {
REPORTER_ASSERT(reporter, a.capacity() == 0);
}
{
SkSTArray<10, int> a;
STArray<10, int> a;
REPORTER_ASSERT(reporter, a.capacity() == 10);
}
{
Expand All @@ -272,7 +272,7 @@ void test_unnecessary_alloc(skiatest::Reporter* reporter) {
REPORTER_ASSERT(reporter, b.capacity() == 0);
}
{
SkSTArray<10, int> a;
STArray<10, int> a;
TArray<int> b;
b = a;
REPORTER_ASSERT(reporter, b.capacity() == 0);
Expand All @@ -283,7 +283,7 @@ void test_unnecessary_alloc(skiatest::Reporter* reporter) {
REPORTER_ASSERT(reporter, b.capacity() == 0);
}
{
SkSTArray<10, int> a;
STArray<10, int> a;
TArray<int> b(a); // NOLINT(performance-unnecessary-copy-initialization)
REPORTER_ASSERT(reporter, b.capacity() == 0);
}
Expand All @@ -293,7 +293,7 @@ void test_unnecessary_alloc(skiatest::Reporter* reporter) {
REPORTER_ASSERT(reporter, b.capacity() == 0);
}
{
SkSTArray<10, int> a;
STArray<10, int> a;
TArray<int> b(std::move(a));
REPORTER_ASSERT(reporter, b.capacity() == 0);
}
Expand All @@ -304,7 +304,7 @@ void test_unnecessary_alloc(skiatest::Reporter* reporter) {
REPORTER_ASSERT(reporter, b.capacity() == 0);
}
{
SkSTArray<10, int> a;
STArray<10, int> a;
TArray<int> b;
b = std::move(a);
REPORTER_ASSERT(reporter, b.capacity() == 0);
Expand Down Expand Up @@ -385,31 +385,31 @@ DEF_TEST(TArray, reporter) {
test_self_assignment(reporter);

test_reserve<TArray<int>>(reporter);
test_reserve<SkSTArray<1, int>>(reporter);
test_reserve<SkSTArray<2, int>>(reporter);
test_reserve<SkSTArray<16, int>>(reporter);
test_reserve<STArray<1, int>>(reporter);
test_reserve<STArray<2, int>>(reporter);
test_reserve<STArray<16, int>>(reporter);

test_reserve<TArray<TestClass>>(reporter);
test_reserve<SkSTArray<1, TestClass>>(reporter);
test_reserve<SkSTArray<2, TestClass>>(reporter);
test_reserve<SkSTArray<16, TestClass>>(reporter);
test_reserve<STArray<1, TestClass>>(reporter);
test_reserve<STArray<2, TestClass>>(reporter);
test_reserve<STArray<16, TestClass>>(reporter);

test_construction<TArray<int>>(reporter);
test_construction<TArray<double>>(reporter);
test_construction<TArray<TestClass>>(reporter);
test_construction<SkSTArray<1, int>>(reporter);
test_construction<SkSTArray<5, char>>(reporter);
test_construction<SkSTArray<7, TestClass>>(reporter);
test_construction<SkSTArray<10, float>>(reporter);

test_skstarray_compatibility<SkSTArray<1, int>, TArray<int>>(reporter);
test_skstarray_compatibility<SkSTArray<5, char>, TArray<char>>(reporter);
test_skstarray_compatibility<SkSTArray<10, float>, TArray<float>>(reporter);
test_skstarray_compatibility<TArray<int>, SkSTArray<1, int>>(reporter);
test_skstarray_compatibility<TArray<char>, SkSTArray<5, char>>(reporter);
test_skstarray_compatibility<TArray<float>, SkSTArray<10, float>>(reporter);
test_skstarray_compatibility<SkSTArray<10, uint8_t>, SkSTArray<1, uint8_t>>(reporter);
test_skstarray_compatibility<SkSTArray<1, long>, SkSTArray<10, long>>(reporter);
test_skstarray_compatibility<SkSTArray<3, double>, SkSTArray<4, double>>(reporter);
test_skstarray_compatibility<SkSTArray<2, short>, SkSTArray<1, short>>(reporter);
test_construction<STArray<1, int>>(reporter);
test_construction<STArray<5, char>>(reporter);
test_construction<STArray<7, TestClass>>(reporter);
test_construction<STArray<10, float>>(reporter);

test_skstarray_compatibility<STArray<1, int>, TArray<int>>(reporter);
test_skstarray_compatibility<STArray<5, char>, TArray<char>>(reporter);
test_skstarray_compatibility<STArray<10, float>, TArray<float>>(reporter);
test_skstarray_compatibility<TArray<int>, STArray<1, int>>(reporter);
test_skstarray_compatibility<TArray<char>, STArray<5, char>>(reporter);
test_skstarray_compatibility<TArray<float>, STArray<10, float>>(reporter);
test_skstarray_compatibility<STArray<10, uint8_t>, STArray<1, uint8_t>>(reporter);
test_skstarray_compatibility<STArray<1, long>, STArray<10, long>>(reporter);
test_skstarray_compatibility<STArray<3, double>, STArray<4, double>>(reporter);
test_skstarray_compatibility<STArray<2, short>, STArray<1, short>>(reporter);
}

0 comments on commit 5e936d5

Please sign in to comment.