diff options
author | mtklein <mtklein@chromium.org> | 2015-08-19 09:51:00 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-08-19 09:51:01 -0700 |
commit | c6ad06acefa096716f8dabed5342f9b89dc43dfe (patch) | |
tree | d7f0f880609d4e7876790a846cdbab4702590109 /tests | |
parent | 4b013296bf67df6c8d119a8f5a2b3dd6530c0b6f (diff) |
unsigned -> int for counts and indices in picture-related code
also, (C)
BUG=skia:
Review URL: https://codereview.chromium.org/1300163002
Diffstat (limited to 'tests')
-rw-r--r-- | tests/GpuLayerCacheTest.cpp | 42 | ||||
-rw-r--r-- | tests/PictureTest.cpp | 2 | ||||
-rw-r--r-- | tests/RTreeTest.cpp | 6 | ||||
-rw-r--r-- | tests/RecordDrawTest.cpp | 8 | ||||
-rw-r--r-- | tests/RecordOptsTest.cpp | 8 | ||||
-rw-r--r-- | tests/RecordPatternTest.cpp | 11 | ||||
-rw-r--r-- | tests/RecordReplaceDrawTest.cpp | 4 | ||||
-rw-r--r-- | tests/RecordTest.cpp | 4 | ||||
-rw-r--r-- | tests/RecordTestUtils.h | 13 | ||||
-rw-r--r-- | tests/RecorderTest.cpp | 2 |
10 files changed, 57 insertions, 43 deletions
diff --git a/tests/GpuLayerCacheTest.cpp b/tests/GpuLayerCacheTest.cpp index efb1ec1c20..411a10ba3b 100644 --- a/tests/GpuLayerCacheTest.cpp +++ b/tests/GpuLayerCacheTest.cpp @@ -15,7 +15,7 @@ class TestingAccess { public: - static unsigned NumLayers(GrLayerCache* cache) { + static int NumLayers(GrLayerCache* cache) { return cache->numLayers(); } static void Purge(GrLayerCache* cache, uint32_t pictureID) { @@ -25,8 +25,8 @@ public: return layer->uses(); } static GrCachedLayer* Find(GrLayerCache* cache, uint32_t pictureID, - const SkMatrix& initialMat, - const unsigned* key, int keySize) { + const SkMatrix& initialMat, + const int* key, int keySize) { return cache->findLayer(pictureID, initialMat, key, keySize); } }; @@ -35,20 +35,20 @@ public: static void create_layers(skiatest::Reporter* reporter, GrLayerCache* cache, const SkPicture& picture, - unsigned numToAdd, - unsigned idOffset) { + int numToAdd, + int idOffset) { - for (unsigned i = 0; i < numToAdd; ++i) { - unsigned indices[1] = { idOffset+i+1 }; - GrCachedLayer* layer = cache->findLayerOrCreate(picture.uniqueID(), - idOffset+i+1, idOffset+i+2, + for (int i = 0; i < numToAdd; ++i) { + int indices[1] = { idOffset+i+1 }; + GrCachedLayer* layer = cache->findLayerOrCreate(picture.uniqueID(), + idOffset+i+1, idOffset+i+2, SkIRect::MakeEmpty(), SkIRect::MakeEmpty(), SkMatrix::I(), indices, 1, NULL); REPORTER_ASSERT(reporter, layer); - GrCachedLayer* temp = TestingAccess::Find(cache, picture.uniqueID(), SkMatrix::I(), + GrCachedLayer* temp = TestingAccess::Find(cache, picture.uniqueID(), SkMatrix::I(), indices, 1); REPORTER_ASSERT(reporter, temp == layer); @@ -95,7 +95,7 @@ static void lock_layer(skiatest::Reporter* reporter, // locking & unlocking textures). // TODO: need to add checks on VRAM usage! DEF_GPUTEST(GpuLayerCache, reporter, factory) { - static const unsigned kInitialNumLayers = 5; + static const int kInitialNumLayers = 5; for (int i= 0; i < GrContextFactory::kGLContextTypeCnt; ++i) { GrContextFactory::GLContextType glCtxType = (GrContextFactory::GLContextType) i; @@ -121,8 +121,8 @@ DEF_GPUTEST(GpuLayerCache, reporter, factory) { create_layers(reporter, &cache, *picture, kInitialNumLayers, 0); - for (unsigned i = 0; i < kInitialNumLayers; ++i) { - unsigned indices[1] = { i + 1 }; + for (int i = 0; i < kInitialNumLayers; ++i) { + int indices[1] = { i + 1 }; GrCachedLayer* layer = TestingAccess::Find(&cache, picture->uniqueID(), SkMatrix::I(), indices, 1); REPORTER_ASSERT(reporter, layer); @@ -140,8 +140,8 @@ DEF_GPUTEST(GpuLayerCache, reporter, factory) { } // Unlock the textures - for (unsigned i = 0; i < kInitialNumLayers; ++i) { - unsigned indices[1] = { i+1 }; + for (int i = 0; i < kInitialNumLayers; ++i) { + int indices[1] = { i+1 }; GrCachedLayer* layer = TestingAccess::Find(&cache, picture->uniqueID(), SkMatrix::I(), indices, 1); @@ -149,8 +149,8 @@ DEF_GPUTEST(GpuLayerCache, reporter, factory) { cache.removeUse(layer); } - for (unsigned i = 0; i < kInitialNumLayers; ++i) { - unsigned indices[1] = { i+1 }; + for (int i = 0; i < kInitialNumLayers; ++i) { + int indices[1] = { i+1 }; GrCachedLayer* layer = TestingAccess::Find(&cache, picture->uniqueID(), SkMatrix::I(), indices, 1); @@ -177,9 +177,9 @@ DEF_GPUTEST(GpuLayerCache, reporter, factory) { } { - unsigned indices[1] = { kInitialNumLayers+1 }; + int indices[1] = { kInitialNumLayers+1 }; - // Add an additional layer. Since all the layers are unlocked this + // Add an additional layer. Since all the layers are unlocked this // will force out the first atlased layer create_layers(reporter, &cache, *picture, 1, kInitialNumLayers); GrCachedLayer* layer = TestingAccess::Find(&cache, picture->uniqueID(), SkMatrix::I(), @@ -190,8 +190,8 @@ DEF_GPUTEST(GpuLayerCache, reporter, factory) { cache.removeUse(layer); } - for (unsigned i = 0; i < kInitialNumLayers+1; ++i) { - unsigned indices[1] = { i+1 }; + for (int i = 0; i < kInitialNumLayers+1; ++i) { + int indices[1] = { i+1 }; GrCachedLayer* layer = TestingAccess::Find(&cache, picture->uniqueID(), SkMatrix::I(), indices, 1); diff --git a/tests/PictureTest.cpp b/tests/PictureTest.cpp index bcfd9c479e..17a8f31585 100644 --- a/tests/PictureTest.cpp +++ b/tests/PictureTest.cpp @@ -1247,7 +1247,7 @@ struct CountingBBH : public SkBBoxHierarchy { CountingBBH(const SkRect& bound) : searchCalls(0), rootBound(bound) {} - void search(const SkRect& query, SkTDArray<unsigned>* results) const override { + void search(const SkRect& query, SkTDArray<int>* results) const override { this->searchCalls++; } diff --git a/tests/RTreeTest.cpp b/tests/RTreeTest.cpp index 16ccb4f508..b39af6747e 100644 --- a/tests/RTreeTest.cpp +++ b/tests/RTreeTest.cpp @@ -25,8 +25,8 @@ static SkRect random_rect(SkRandom& rand) { return rect; } -static bool verify_query(SkRect query, SkRect rects[], SkTDArray<unsigned>& found) { - SkTDArray<unsigned> expected; +static bool verify_query(SkRect query, SkRect rects[], SkTDArray<int>& found) { + SkTDArray<int> expected; // manually intersect with every rectangle for (int i = 0; i < NUM_RECTS; ++i) { if (SkRect::Intersects(query, rects[i])) { @@ -46,7 +46,7 @@ static bool verify_query(SkRect query, SkRect rects[], SkTDArray<unsigned>& foun static void run_queries(skiatest::Reporter* reporter, SkRandom& rand, SkRect rects[], const SkRTree& tree) { for (size_t i = 0; i < NUM_QUERIES; ++i) { - SkTDArray<unsigned> hits; + SkTDArray<int> hits; SkRect query = random_rect(rand); tree.search(query, &hits); REPORTER_ASSERT(reporter, verify_query(query, rects, hits)); diff --git a/tests/RecordDrawTest.cpp b/tests/RecordDrawTest.cpp index da78296648..84ceb20f54 100644 --- a/tests/RecordDrawTest.cpp +++ b/tests/RecordDrawTest.cpp @@ -126,17 +126,17 @@ struct TestBBH : public SkBBoxHierarchy { void insert(const SkRect boundsArray[], int N) override { fEntries.setCount(N); for (int i = 0; i < N; i++) { - Entry e = { (unsigned)i, boundsArray[i] }; + Entry e = { i, boundsArray[i] }; fEntries[i] = e; } } - void search(const SkRect& query, SkTDArray<unsigned>* results) const override {} + void search(const SkRect& query, SkTDArray<int>* results) const override {} size_t bytesUsed() const override { return 0; } SkRect getRootBound() const override { return SkRect::MakeEmpty(); } struct Entry { - unsigned opIndex; + int opIndex; SkRect bounds; }; SkTDArray<Entry> fEntries; @@ -166,7 +166,7 @@ DEF_TEST(RecordDraw_BBH, r) { REPORTER_ASSERT(r, bbh.fEntries.count() == 5); for (int i = 0; i < bbh.fEntries.count(); i++) { - REPORTER_ASSERT(r, bbh.fEntries[i].opIndex == (unsigned)i); + REPORTER_ASSERT(r, bbh.fEntries[i].opIndex == i); REPORTER_ASSERT(r, sloppy_rect_eq(SkRect::MakeWH(400, 480), bbh.fEntries[i].bounds)); } diff --git a/tests/RecordOptsTest.cpp b/tests/RecordOptsTest.cpp index e550244004..25102c4fc8 100644 --- a/tests/RecordOptsTest.cpp +++ b/tests/RecordOptsTest.cpp @@ -43,7 +43,7 @@ DEF_TEST(RecordOpts_SingleNoopSaveRestore, r) { recorder.restore(); SkRecordNoopSaveRestores(&record); - for (unsigned i = 0; i < 3; i++) { + for (int i = 0; i < 3; i++) { assert_type<SkRecords::NoOp>(r, record, i); } } @@ -66,7 +66,7 @@ DEF_TEST(RecordOpts_NoopSaveRestores, r) { recorder.restore(); SkRecordNoopSaveRestores(&record); - for (unsigned index = 0; index < record.count(); index++) { + for (int index = 0; index < record.count(); index++) { assert_type<SkRecords::NoOp>(r, record, index); } } @@ -102,7 +102,7 @@ DEF_TEST(RecordOpts_SaveSaveLayerRestoreRestore, r) { static void assert_savelayer_restore(skiatest::Reporter* r, SkRecord* record, - unsigned i, + int i, bool shouldBeNoOped) { SkRecordNoopSaveLayerDrawRestores(record); if (shouldBeNoOped) { @@ -175,7 +175,7 @@ DEF_TEST(RecordOpts_NoopSaveLayerDrawRestore, r) { static void assert_merge_svg_opacity_and_filter_layers(skiatest::Reporter* r, SkRecord* record, - unsigned i, + int i, bool shouldBeNoOped) { SkRecordMergeSvgOpacityAndFilterLayers(record); if (shouldBeNoOped) { diff --git a/tests/RecordPatternTest.cpp b/tests/RecordPatternTest.cpp index ae13b28fc4..b88165d6f3 100644 --- a/tests/RecordPatternTest.cpp +++ b/tests/RecordPatternTest.cpp @@ -1,3 +1,10 @@ +/* + * Copyright 2015 Google Inc. + * + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + #include "Test.h" #include "SkRecord.h" @@ -47,7 +54,7 @@ DEF_TEST(RecordPattern_StartingIndex, r) { } // We should match only at 0 and 3. Going over the length should fail gracefully. - for (unsigned i = 0; i < 8; i++) { + for (int i = 0; i < 8; i++) { if (i == 0 || i == 3) { REPORTER_ASSERT(r, pattern.match(&record, i) == i + 3); } else { @@ -99,7 +106,7 @@ DEF_TEST(RecordPattern_Complex, r) { SkRecord record; SkRecorder recorder(&record, 1920, 1200); - unsigned start, begin, end; + int start, begin, end; start = record.count(); recorder.save(); diff --git a/tests/RecordReplaceDrawTest.cpp b/tests/RecordReplaceDrawTest.cpp index 473683bc56..8c45ee14dd 100644 --- a/tests/RecordReplaceDrawTest.cpp +++ b/tests/RecordReplaceDrawTest.cpp @@ -108,7 +108,7 @@ void test_replacements(skiatest::Reporter* r, GrContext* context, bool useBBH) { pic.reset(recorder.endRecording()); } - unsigned key[1] = { 0 }; + int key[1] = { 0 }; SkPaint paint; GrLayerCache* layerCache = context->getLayerCache(); @@ -149,7 +149,7 @@ void test_replacements(skiatest::Reporter* r, GrContext* context, bool useBBH) { } } -DEF_GPUTEST(RecordReplaceDraw, r, factory) { +DEF_GPUTEST(RecordReplaceDraw, r, factory) { for (int type = 0; type < GrContextFactory::kLastGLContextType; ++type) { GrContextFactory::GLContextType glType = static_cast<GrContextFactory::GLContextType>(type); if (!GrContextFactory::IsRenderingGLContext(glType)) { diff --git a/tests/RecordTest.cpp b/tests/RecordTest.cpp index 49efc28d2c..b510da7673 100644 --- a/tests/RecordTest.cpp +++ b/tests/RecordTest.cpp @@ -27,7 +27,7 @@ public: int area() const { return fArea; } void apply(const SkRecord& record) { - for (unsigned i = 0; i < record.count(); i++) { + for (int i = 0; i < record.count(); i++) { record.visit<void>(i, *this); } } @@ -45,7 +45,7 @@ struct Stretch { } void apply(SkRecord* record) { - for (unsigned i = 0; i < record->count(); i++) { + for (int i = 0; i < record->count(); i++) { record->mutate<void>(i, *this); } } diff --git a/tests/RecordTestUtils.h b/tests/RecordTestUtils.h index 4bab8e4a39..8243089e5d 100644 --- a/tests/RecordTestUtils.h +++ b/tests/RecordTestUtils.h @@ -1,3 +1,10 @@ +/* + * Copyright 2015 Google Inc. + * + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + #ifndef RecordTestUtils_DEFINED #define RecordTestUtils_DEFINED @@ -20,7 +27,7 @@ struct ReadAs { // Assert that the ith command in record is of type T, and return it. template <typename T> -static const T* assert_type(skiatest::Reporter* r, const SkRecord& record, unsigned index) { +static const T* assert_type(skiatest::Reporter* r, const SkRecord& record, int index) { ReadAs<T> reader; record.visit<void>(index, reader); REPORTER_ASSERT(r, T::kType == reader.type); @@ -36,7 +43,7 @@ template <typename DrawT> struct MatchType { template <typename DrawT> int count_instances_of_type(const SkRecord& record) { MatchType<DrawT> matcher; int counter = 0; - for (unsigned i = 0; i < record.count(); i++) { + for (int i = 0; i < record.count(); i++) { counter += record.visit<int>(i, matcher); } return counter; @@ -44,7 +51,7 @@ template <typename DrawT> int count_instances_of_type(const SkRecord& record) { template <typename DrawT> int find_first_instances_of_type(const SkRecord& record) { MatchType<DrawT> matcher; - for (unsigned i = 0; i < record.count(); i++) { + for (int i = 0; i < record.count(); i++) { if (record.visit<int>(i, matcher)) { return i; } diff --git a/tests/RecorderTest.cpp b/tests/RecorderTest.cpp index c41d634b44..b4bc58dddd 100644 --- a/tests/RecorderTest.cpp +++ b/tests/RecorderTest.cpp @@ -30,7 +30,7 @@ public: int count() const { return fHistogram[T::kType]; } void apply(const SkRecord& record) { - for (unsigned i = 0; i < record.count(); i++) { + for (int i = 0; i < record.count(); i++) { record.visit<void>(i, *this); } } |