From c6ad06acefa096716f8dabed5342f9b89dc43dfe Mon Sep 17 00:00:00 2001 From: mtklein Date: Wed, 19 Aug 2015 09:51:00 -0700 Subject: [PATCH] unsigned -> int for counts and indices in picture-related code also, (C) BUG=skia: Review URL: https://codereview.chromium.org/1300163002 --- bench/RTreeBench.cpp | 2 +- dm/DMSrcSink.cpp | 2 +- src/core/SkBBoxHierarchy.h | 4 +-- src/core/SkBigPicture.cpp | 6 ++-- src/core/SkBigPicture.h | 4 +-- src/core/SkLayerInfo.h | 4 +-- src/core/SkRTree.cpp | 4 +-- src/core/SkRTree.h | 8 ++--- src/core/SkRecord.cpp | 2 +- src/core/SkRecord.h | 12 ++++---- src/core/SkRecordDraw.cpp | 38 ++++++++++++------------ src/core/SkRecordDraw.h | 2 +- src/core/SkRecordOpts.cpp | 18 ++++++------ src/core/SkRecordPattern.h | 17 +++++++---- src/core/SkRecorder.cpp | 4 +-- src/gpu/GrLayerCache.cpp | 8 ++--- src/gpu/GrLayerCache.h | 52 ++++++++++++++++----------------- src/gpu/GrRecordReplaceDraw.cpp | 8 ++--- tests/GpuLayerCacheTest.cpp | 42 +++++++++++++------------- tests/PictureTest.cpp | 2 +- tests/RTreeTest.cpp | 6 ++-- tests/RecordDrawTest.cpp | 8 ++--- tests/RecordOptsTest.cpp | 8 ++--- tests/RecordPatternTest.cpp | 11 +++++-- tests/RecordReplaceDrawTest.cpp | 4 +-- tests/RecordTest.cpp | 4 +-- tests/RecordTestUtils.h | 13 +++++++-- tests/RecorderTest.cpp | 2 +- tools/DumpRecord.cpp | 2 +- 29 files changed, 159 insertions(+), 138 deletions(-) diff --git a/bench/RTreeBench.cpp b/bench/RTreeBench.cpp index 6f76bd19bd..3b3dc72a3e 100644 --- a/bench/RTreeBench.cpp +++ b/bench/RTreeBench.cpp @@ -79,7 +79,7 @@ protected: void onDraw(const int loops, SkCanvas* canvas) override { SkRandom rand; for (int i = 0; i < loops; ++i) { - SkTDArray hits; + SkTDArray hits; SkRect query; query.fLeft = rand.nextRangeF(0, GENERATE_EXTENTS); query.fTop = rand.nextRangeF(0, GENERATE_EXTENTS); diff --git a/dm/DMSrcSink.cpp b/dm/DMSrcSink.cpp index 5b2ccc8f57..a7240b8579 100644 --- a/dm/DMSrcSink.cpp +++ b/dm/DMSrcSink.cpp @@ -1060,7 +1060,7 @@ Error ViaSingletonPictures::draw( macroCanvas, drawables ? *drawables : empty, }; - for (unsigned i = 0; i < skr.count(); i++) { + for (int i = 0; i < skr.count(); i++) { skr.visit(i, drawsAsSingletonPictures); } SkAutoTUnref macroPic(macroRec.endRecordingAsPicture()); diff --git a/src/core/SkBBoxHierarchy.h b/src/core/SkBBoxHierarchy.h index 69fb4fd982..795406f61b 100644 --- a/src/core/SkBBoxHierarchy.h +++ b/src/core/SkBBoxHierarchy.h @@ -30,14 +30,14 @@ public: /** * Populate results with the indices of bounding boxes interesecting that query. */ - virtual void search(const SkRect& query, SkTDArray* results) const = 0; + virtual void search(const SkRect& query, SkTDArray* results) const = 0; virtual size_t bytesUsed() const = 0; // Get the root bound. virtual SkRect getRootBound() const = 0; - + private: typedef SkRefCnt INHERITED; }; diff --git a/src/core/SkBigPicture.cpp b/src/core/SkBigPicture.cpp index 6609586ca2..bbe9882c2b 100644 --- a/src/core/SkBigPicture.cpp +++ b/src/core/SkBigPicture.cpp @@ -43,8 +43,8 @@ void SkBigPicture::playback(SkCanvas* canvas, AbortCallback* callback) const { } void SkBigPicture::partialPlayback(SkCanvas* canvas, - unsigned start, - unsigned stop, + int start, + int stop, const SkMatrix& initialCTM) const { SkASSERT(canvas); SkRecordPartialDraw(*fRecord, @@ -86,7 +86,7 @@ SkBigPicture::Analysis::Analysis(const SkRecord& record) { SkPathCounter path; bool hasText = false, hasBitmap = false; - for (unsigned i = 0; i < record.count(); i++) { + for (int i = 0; i < record.count(); i++) { hasText = hasText || record.visit(i, text); hasBitmap = hasBitmap || record.visit(i, bitmap); record.visit(i, path); diff --git a/src/core/SkBigPicture.h b/src/core/SkBigPicture.h index 14e413b55a..b7da09ee55 100644 --- a/src/core/SkBigPicture.h +++ b/src/core/SkBigPicture.h @@ -52,8 +52,8 @@ public: // Used by GrLayerHoister void partialPlayback(SkCanvas*, - unsigned start, - unsigned stop, + int start, + int stop, const SkMatrix& initialCTM) const; // Used by GrRecordReplaceDraw const SkBBoxHierarchy* bbh() const { return fBBH; } diff --git a/src/core/SkLayerInfo.h b/src/core/SkLayerInfo.h index 3d4b26960c..54c4f7b705 100644 --- a/src/core/SkLayerInfo.h +++ b/src/core/SkLayerInfo.h @@ -56,8 +56,8 @@ public: // The variable length key for this saveLayer block. It stores the // thread of drawPicture and saveLayer operation indices that lead to this // saveLayer (including its own op index). The BlockInfo owns this memory. - unsigned* fKey; - int fKeySize; // # of ints + int* fKey; + int fKeySize; // # of ints }; SkLayerInfo() {} diff --git a/src/core/SkRTree.cpp b/src/core/SkRTree.cpp index 2fded6f72b..bae2fdce3f 100644 --- a/src/core/SkRTree.cpp +++ b/src/core/SkRTree.cpp @@ -161,13 +161,13 @@ SkRTree::Branch SkRTree::bulkLoad(SkTDArray* branches, int level) { return this->bulkLoad(branches, level + 1); } -void SkRTree::search(const SkRect& query, SkTDArray* results) const { +void SkRTree::search(const SkRect& query, SkTDArray* results) const { if (fCount > 0 && SkRect::Intersects(fRoot.fBounds, query)) { this->search(fRoot.fSubtree, query, results); } } -void SkRTree::search(Node* node, const SkRect& query, SkTDArray* results) const { +void SkRTree::search(Node* node, const SkRect& query, SkTDArray* results) const { for (int i = 0; i < node->fNumChildren; ++i) { if (SkRect::Intersects(node->fChildren[i].fBounds, query)) { if (0 == node->fLevel) { diff --git a/src/core/SkRTree.h b/src/core/SkRTree.h index 205c0b60c2..557817189d 100644 --- a/src/core/SkRTree.h +++ b/src/core/SkRTree.h @@ -31,7 +31,7 @@ */ class SkRTree : public SkBBoxHierarchy { public: - + /** * If you have some prior information about the distribution of bounds you're expecting, you @@ -42,7 +42,7 @@ public: virtual ~SkRTree() {} void insert(const SkRect[], int N) override; - void search(const SkRect& query, SkTDArray* results) const override; + void search(const SkRect& query, SkTDArray* results) const override; size_t bytesUsed() const override; // Methods and constants below here are only public for tests. @@ -65,7 +65,7 @@ private: struct Branch { union { Node* fSubtree; - unsigned fOpIndex; + int fOpIndex; }; SkRect fBounds; }; @@ -76,7 +76,7 @@ private: Branch fChildren[kMaxChildren]; }; - void search(Node* root, const SkRect& query, SkTDArray* results) const; + void search(Node* root, const SkRect& query, SkTDArray* results) const; // Consumes the input array. Branch bulkLoad(SkTDArray* branches, int level = 0); diff --git a/src/core/SkRecord.cpp b/src/core/SkRecord.cpp index 349fbf6075..2d2fa58991 100644 --- a/src/core/SkRecord.cpp +++ b/src/core/SkRecord.cpp @@ -9,7 +9,7 @@ SkRecord::~SkRecord() { Destroyer destroyer; - for (unsigned i = 0; i < this->count(); i++) { + for (int i = 0; i < this->count(); i++) { this->mutate(i, destroyer); } } diff --git a/src/core/SkRecord.h b/src/core/SkRecord.h index 0fe316ee78..9672bbcffa 100644 --- a/src/core/SkRecord.h +++ b/src/core/SkRecord.h @@ -40,14 +40,14 @@ public: ~SkRecord(); // Returns the number of canvas commands in this SkRecord. - unsigned count() const { return fCount; } + int count() const { return fCount; } // Visit the i-th canvas command with a functor matching this interface: // template // R operator()(const T& record) { ... } // This operator() must be defined for at least all SkRecords::*. template - R visit(unsigned i, F& f) const { + R visit(int i, F& f) const { SkASSERT(i < this->count()); return fRecords[i].visit(f); } @@ -57,7 +57,7 @@ public: // R operator()(T* record) { ... } // This operator() must be defined for at least all SkRecords::*. template - R mutate(unsigned i, F& f) { + R mutate(int i, F& f) { SkASSERT(i < this->count()); return fRecords[i].mutate(f); } @@ -85,7 +85,7 @@ public: // You are expected to placement new an object of type T onto this pointer. // References to the original command are invalidated. template - T* replace(unsigned i) { + T* replace(int i) { SkASSERT(i < this->count()); Destroyer destroyer; @@ -98,7 +98,7 @@ public: // You are expected to placement new an object of type T onto this pointer. // You must show proof that you've already adopted the existing command. template - T* replace(unsigned i, const SkRecords::Adopted& proofOfAdoption) { + T* replace(int i, const SkRecords::Adopted& proofOfAdoption) { SkASSERT(i < this->count()); SkASSERT(Existing::kType == fRecords[i].type()); @@ -186,7 +186,7 @@ private: // fRecords needs to be a data structure that can append fixed length data, and need to // support efficient random access and forward iteration. (It doesn't need to be contiguous.) - unsigned fCount, fReserved; + int fCount, fReserved; SkAutoSTMalloc fRecords; // fAlloc needs to be a data structure which can append variable length data in contiguous diff --git a/src/core/SkRecordDraw.cpp b/src/core/SkRecordDraw.cpp index 8c884d98bb..890a0bff24 100644 --- a/src/core/SkRecordDraw.cpp +++ b/src/core/SkRecordDraw.cpp @@ -29,7 +29,7 @@ void SkRecordDraw(const SkRecord& record, query.setEmpty(); } - SkTDArray ops; + SkTDArray ops; bbh->search(query, &ops); SkRecords::Draw draw(canvas, drawablePicts, drawables, drawableCount); @@ -45,7 +45,7 @@ void SkRecordDraw(const SkRecord& record, } else { // Draw all ops. SkRecords::Draw draw(canvas, drawablePicts, drawables, drawableCount); - for (unsigned i = 0; i < record.count(); i++) { + for (int i = 0; i < record.count(); i++) { if (callback && callback->abort()) { return; } @@ -59,13 +59,13 @@ void SkRecordDraw(const SkRecord& record, void SkRecordPartialDraw(const SkRecord& record, SkCanvas* canvas, SkPicture const* const drawablePicts[], int drawableCount, - unsigned start, unsigned stop, + int start, int stop, const SkMatrix& initialCTM) { SkAutoCanvasRestore saveRestore(canvas, true /*save now, restore at exit*/); stop = SkTMin(stop, record.count()); SkRecords::Draw draw(canvas, drawablePicts, NULL, drawableCount, &initialCTM); - for (unsigned i = start; i < stop; i++) { + for (int i = start; i < stop; i++) { record.visit(i, draw); } } @@ -161,7 +161,7 @@ public: fCurrentClipBounds = fCullRect; } - void setCurrentOp(unsigned currentOp) { fCurrentOp = currentOp; } + void setCurrentOp(int currentOp) { fCurrentOp = currentOp; } void cleanUp(SkBBoxHierarchy* bbh) { // If we have any lingering unpaired Saves, simulate restores to make @@ -190,9 +190,9 @@ public: // In this file, SkRect are in local coordinates, Bounds are translated back to identity space. typedef SkRect Bounds; - unsigned currentOp() const { return fCurrentOp; } + int currentOp() const { return fCurrentOp; } const SkMatrix& ctm() const { return *fCTM; } - const Bounds& getBounds(unsigned index) const { return fBounds[index]; } + const Bounds& getBounds(int index) const { return fBounds[index]; } // Adjust rect for all paints that may affect its geometry, then map it to identity space. Bounds adjustAndMap(SkRect rect, const SkPaint* paint) const { @@ -574,7 +574,7 @@ private: return true; } - const unsigned fNumRecords; + const int fNumRecords; // We do not guarantee anything for operations outside of the cull rect const SkRect fCullRect; @@ -585,13 +585,13 @@ private: // We walk fCurrentOp through the SkRecord, as we go using updateCTM() // and updateClipBounds() to maintain the exact CTM (fCTM) and conservative // identity-space bounds of the current clip (fCurrentClipBounds). - unsigned fCurrentOp; + int fCurrentOp; const SkMatrix* fCTM; Bounds fCurrentClipBounds; // Used to track the bounds of Save/Restore blocks and the control ops inside them. SkTDArray fSaveStack; - SkTDArray fControlIndices; + SkTDArray fControlIndices; }; // SkRecord visitor to gather saveLayer/restore information. @@ -605,7 +605,7 @@ public: , fFillBounds(cullRect, record) {} - void setCurrentOp(unsigned currentOp) { fFillBounds.setCurrentOp(currentOp); } + void setCurrentOp(int currentOp) { fFillBounds.setCurrentOp(currentOp); } void cleanUp(SkBBoxHierarchy* bbh) { // fFillBounds must perform its cleanUp first so that all the bounding @@ -696,10 +696,10 @@ private: // Store 'saveLayer ops from enclosing picture' + drawPict op + 'ops from sub-picture' dst.fKeySize = fSaveLayerOpStack.count() + src.fKeySize + 1; - dst.fKey = SkNEW_ARRAY(unsigned, dst.fKeySize); - memcpy(dst.fKey, fSaveLayerOpStack.begin(), fSaveLayerOpStack.count() * sizeof(unsigned)); + dst.fKey = SkNEW_ARRAY(int, dst.fKeySize); + memcpy(dst.fKey, fSaveLayerOpStack.begin(), fSaveLayerOpStack.count() * sizeof(int)); dst.fKey[fSaveLayerOpStack.count()] = fFillBounds.currentOp(); - memcpy(&dst.fKey[fSaveLayerOpStack.count()+1], src.fKey, src.fKeySize * sizeof(unsigned)); + memcpy(&dst.fKey[fSaveLayerOpStack.count()+1], src.fKey, src.fKeySize * sizeof(int)); } } @@ -773,8 +773,8 @@ private: block.fIsNested = fSaveLayersInStack > 0; block.fKeySize = fSaveLayerOpStack.count(); - block.fKey = SkNEW_ARRAY(unsigned, block.fKeySize); - memcpy(block.fKey, fSaveLayerOpStack.begin(), block.fKeySize * sizeof(unsigned)); + block.fKey = SkNEW_ARRAY(int, block.fKeySize); + memcpy(block.fKey, fSaveLayerOpStack.begin(), block.fKeySize * sizeof(int)); fSaveLayerOpStack.pop(); } @@ -783,7 +783,7 @@ private: int fSaveLayersInStack; SkTDArray fSaveLayerStack; // The op code indices of all the currently active saveLayers - SkTDArray fSaveLayerOpStack; + SkTDArray fSaveLayerOpStack; SkLayerInfo* fAccelData; const SkBigPicture::SnapshotArray* fPictList; @@ -795,7 +795,7 @@ private: void SkRecordFillBounds(const SkRect& cullRect, const SkRecord& record, SkBBoxHierarchy* bbh) { SkRecords::FillBounds visitor(cullRect, record); - for (unsigned curOp = 0; curOp < record.count(); curOp++) { + for (int curOp = 0; curOp < record.count(); curOp++) { visitor.setCurrentOp(curOp); record.visit(curOp, visitor); } @@ -808,7 +808,7 @@ void SkRecordComputeLayers(const SkRect& cullRect, const SkRecord& record, SkLayerInfo* data) { SkRecords::CollectLayers visitor(cullRect, record, pictList, data); - for (unsigned curOp = 0; curOp < record.count(); curOp++) { + for (int curOp = 0; curOp < record.count(); curOp++) { visitor.setCurrentOp(curOp); record.visit(curOp, visitor); } diff --git a/src/core/SkRecordDraw.h b/src/core/SkRecordDraw.h index 5b248cfbd5..5af74dc7db 100644 --- a/src/core/SkRecordDraw.h +++ b/src/core/SkRecordDraw.h @@ -36,7 +36,7 @@ void SkRecordDraw(const SkRecord&, SkCanvas*, SkPicture const* const drawablePic // the initialCTM parameter must set to just the replay matrix. void SkRecordPartialDraw(const SkRecord&, SkCanvas*, SkPicture const* const drawablePicts[], int drawableCount, - unsigned start, unsigned stop, const SkMatrix& initialCTM); + int start, int stop, const SkMatrix& initialCTM); namespace SkRecords { diff --git a/src/core/SkRecordOpts.cpp b/src/core/SkRecordOpts.cpp index 83512926da..07aac3e467 100644 --- a/src/core/SkRecordOpts.cpp +++ b/src/core/SkRecordOpts.cpp @@ -26,7 +26,7 @@ void SkRecordOptimize(SkRecord* record) { // Most of the optimizations in this file are pattern-based. These are all defined as structs with: // - a Pattern typedef -// - a bool onMatch(SkRceord*, Pattern*, unsigned begin, unsigned end) method, +// - a bool onMatch(SkRceord*, Pattern*, int begin, int end) method, // which returns true if it made changes and false if not. // Run a pattern-based optimization once across the SkRecord, returning true if it made any changes. @@ -36,7 +36,7 @@ template static bool apply(Pass* pass, SkRecord* record) { typename Pass::Pattern pattern; bool changed = false; - unsigned begin, end = 0; + int begin, end = 0; while (pattern.search(record, &begin, &end)) { changed |= pass->onMatch(record, &pattern, begin, end); @@ -51,7 +51,7 @@ struct SaveOnlyDrawsRestoreNooper { Is > Pattern; - bool onMatch(SkRecord* record, Pattern* pattern, unsigned begin, unsigned end) { + bool onMatch(SkRecord* record, Pattern* pattern, int begin, int end) { record->replace(begin); // Save record->replace(end-1); // Restore return true; @@ -127,9 +127,9 @@ struct SaveNoDrawsRestoreNooper { Is > Pattern; - bool onMatch(SkRecord* record, Pattern* pattern, unsigned begin, unsigned end) { + bool onMatch(SkRecord* record, Pattern* pattern, int begin, int end) { // The entire span between Save and Restore (inclusively) does nothing. - for (unsigned i = begin; i < end; i++) { + for (int i = begin; i < end; i++) { record->replace(i); } return true; @@ -148,7 +148,7 @@ void SkRecordNoopSaveRestores(SkRecord* record) { struct SaveLayerDrawRestoreNooper { typedef Pattern3, IsDraw, Is > Pattern; - bool onMatch(SkRecord* record, Pattern* pattern, unsigned begin, unsigned end) { + bool onMatch(SkRecord* record, Pattern* pattern, int begin, int end) { // A SaveLayer's bounds field is just a hint, so we should be free to ignore it. SkPaint* layerPaint = pattern->first()->paint; if (NULL == layerPaint) { @@ -170,7 +170,7 @@ struct SaveLayerDrawRestoreNooper { return KillSaveLayerAndRestore(record, begin); } - static bool KillSaveLayerAndRestore(SkRecord* record, unsigned saveLayerIndex) { + static bool KillSaveLayerAndRestore(SkRecord* record, int saveLayerIndex) { record->replace(saveLayerIndex); // SaveLayer record->replace(saveLayerIndex+2); // Restore return true; @@ -195,7 +195,7 @@ struct SvgOpacityAndFilterLayerMergePass { typedef Pattern7, Is, Is, Is, Is, Is, Is > Pattern; - bool onMatch(SkRecord* record, Pattern* pattern, unsigned begin, unsigned end) { + bool onMatch(SkRecord* record, Pattern* pattern, int begin, int end) { SkPaint* opacityPaint = pattern->first()->paint; if (NULL == opacityPaint) { // There wasn't really any point to this SaveLayer at all. @@ -219,7 +219,7 @@ struct SvgOpacityAndFilterLayerMergePass { return KillSaveLayerAndRestore(record, begin); } - static bool KillSaveLayerAndRestore(SkRecord* record, unsigned saveLayerIndex) { + static bool KillSaveLayerAndRestore(SkRecord* record, int saveLayerIndex) { record->replace(saveLayerIndex); // SaveLayer record->replace(saveLayerIndex + 6); // Restore return true; diff --git a/src/core/SkRecordPattern.h b/src/core/SkRecordPattern.h index 85c38ac5fe..174665afc3 100644 --- a/src/core/SkRecordPattern.h +++ b/src/core/SkRecordPattern.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 SkRecordPattern_DEFINED #define SkRecordPattern_DEFINED @@ -109,14 +116,14 @@ class Cons { public: // If this pattern matches the SkRecord starting at i, // return the index just past the end of the pattern, otherwise return 0. - SK_ALWAYS_INLINE unsigned match(SkRecord* record, unsigned i) { + SK_ALWAYS_INLINE int match(SkRecord* record, int i) { i = this->matchHead(&fHead, record, i); return i == 0 ? 0 : fTail.match(record, i); } // Starting from *end, walk through the SkRecord to find the first span matching this pattern. // If there is no such span, return false. If there is, return true and set [*begin, *end). - SK_ALWAYS_INLINE bool search(SkRecord* record, unsigned* begin, unsigned* end) { + SK_ALWAYS_INLINE bool search(SkRecord* record, int* begin, int* end) { for (*begin = *end; *begin < record->count(); ++(*begin)) { *end = this->match(record, *begin); if (*end != 0) { @@ -137,7 +144,7 @@ public: private: // If head isn't a Star, try to match at i once. template - unsigned matchHead(T*, SkRecord* record, unsigned i) { + int matchHead(T*, SkRecord* record, int i) { if (i < record->count()) { if (record->mutate(i, fHead)) { return i+1; @@ -148,7 +155,7 @@ private: // If head is a Star, walk i until it doesn't match. template - unsigned matchHead(Star*, SkRecord* record, unsigned i) { + int matchHead(Star*, SkRecord* record, int i) { while (i < record->count()) { if (!record->mutate(i, fHead)) { return i; @@ -168,7 +175,7 @@ private: // Nil is the end of every pattern Cons chain. struct Nil { // Bottoms out recursion down the fTail chain. Just return whatever i the front decided on. - unsigned match(SkRecord*, unsigned i) { return i; } + int match(SkRecord*, int i) { return i; } }; // These Pattern# types are syntax sugar over Cons and Nil, just to help eliminate some of the diff --git a/src/core/SkRecorder.cpp b/src/core/SkRecorder.cpp index c00a353cec..b12b1eb296 100644 --- a/src/core/SkRecorder.cpp +++ b/src/core/SkRecorder.cpp @@ -245,7 +245,7 @@ void SkRecorder::onDrawText(const void* text, size_t byteLength, void SkRecorder::onDrawPosText(const void* text, size_t byteLength, const SkPoint pos[], const SkPaint& paint) { - const unsigned points = paint.countText(text, byteLength); + const int points = paint.countText(text, byteLength); APPEND(DrawPosText, paint, this->copy((const char*)text, byteLength), @@ -255,7 +255,7 @@ void SkRecorder::onDrawPosText(const void* text, size_t byteLength, void SkRecorder::onDrawPosTextH(const void* text, size_t byteLength, const SkScalar xpos[], SkScalar constY, const SkPaint& paint) { - const unsigned points = paint.countText(text, byteLength); + const int points = paint.countText(text, byteLength); APPEND(DrawPosTextH, paint, this->copy((const char*)text, byteLength), diff --git a/src/gpu/GrLayerCache.cpp b/src/gpu/GrLayerCache.cpp index 4d5f2b46f8..4a2060779a 100644 --- a/src/gpu/GrLayerCache.cpp +++ b/src/gpu/GrLayerCache.cpp @@ -128,7 +128,7 @@ GrCachedLayer* GrLayerCache::createLayer(uint32_t pictureID, const SkIRect& srcIR, const SkIRect& dstIR, const SkMatrix& initialMat, - const unsigned* key, + const int* key, int keySize, const SkPaint* paint) { SkASSERT(pictureID != SK_InvalidGenID && start >= 0 && stop > 0); @@ -141,7 +141,7 @@ GrCachedLayer* GrLayerCache::createLayer(uint32_t pictureID, } GrCachedLayer* GrLayerCache::findLayer(uint32_t pictureID, const SkMatrix& initialMat, - const unsigned* key, int keySize) { + const int* key, int keySize) { SkASSERT(pictureID != SK_InvalidGenID); return fLayerHash.find(GrCachedLayer::Key(pictureID, initialMat, key, keySize)); } @@ -151,7 +151,7 @@ GrCachedLayer* GrLayerCache::findLayerOrCreate(uint32_t pictureID, const SkIRect& srcIR, const SkIRect& dstIR, const SkMatrix& initialMat, - const unsigned* key, + const int* key, int keySize, const SkPaint* paint) { SkASSERT(pictureID != SK_InvalidGenID && start >= 0 && stop > 0); @@ -216,7 +216,7 @@ bool GrLayerCache::tryToAtlas(GrCachedLayer* layer, pictInfo->incPlotUsage(plot->id()); #endif // The layer was successfully added to the atlas - const SkIRect bounds = SkIRect::MakeXYWH(loc.fX, loc.fY, + const SkIRect bounds = SkIRect::MakeXYWH(loc.fX, loc.fY, desc.fWidth, desc.fHeight); layer->setTexture(fAtlas->getTexture(), bounds); layer->setPlot(plot); diff --git a/src/gpu/GrLayerCache.h b/src/gpu/GrLayerCache.h index df8c670689..cf35de80b5 100644 --- a/src/gpu/GrLayerCache.h +++ b/src/gpu/GrLayerCache.h @@ -31,9 +31,9 @@ public: static uint32_t Hash(const uint32_t& key) { return SkChecksum::Mix(key); } // GrPictureInfo proper - GrPictureInfo(uint32_t pictureID) : fPictureID(pictureID) { + GrPictureInfo(uint32_t pictureID) : fPictureID(pictureID) { #if !GR_CACHE_HOISTED_LAYERS - memset(fPlotUses, 0, sizeof(fPlotUses)); + memset(fPlotUses, 0, sizeof(fPlotUses)); #endif } @@ -49,7 +49,7 @@ public: fPlotUses[plotID]--; } - int plotUsage(int plotID) const { + int plotUsage(int plotID) const { SkASSERT(plotID < kNumPlots); return fPlotUses[plotID]; } @@ -67,7 +67,7 @@ private: // GrCachedLayer encapsulates the caching information for a single saveLayer. // // Atlased layers get a ref to the backing GrTexture while non-atlased layers -// get a ref to the GrTexture in which they reside. In both cases 'fRect' +// get a ref to the GrTexture in which they reside. In both cases 'fRect' // contains the layer's extent in its texture. // Atlased layers also get a pointer to the plot in which they reside. // For non-atlased layers, the lock field just corresponds to locking in @@ -77,17 +77,17 @@ struct GrCachedLayer { public: // For SkTDynamicHash struct Key { - Key(uint32_t pictureID, const SkMatrix& initialMat, - const unsigned* key, int keySize, bool copyKey = false) - : fKeySize(keySize) + Key(uint32_t pictureID, const SkMatrix& initialMat, + const int* key, int keySize, bool copyKey = false) + : fKeySize(keySize) , fFreeKey(copyKey) { fIDMatrix.fPictureID = pictureID; fIDMatrix.fInitialMat = initialMat; fIDMatrix.fInitialMat.getType(); // force initialization of type so hashes match if (copyKey) { - unsigned* tempKey = SkNEW_ARRAY(unsigned, keySize); - memcpy(tempKey, key, keySize*sizeof(unsigned)); + int* tempKey = SkNEW_ARRAY(int, keySize); + memcpy(tempKey, key, keySize*sizeof(int)); fKey = tempKey; } else { fKey = key; @@ -116,13 +116,13 @@ public: uint32_t pictureID() const { return fIDMatrix.fPictureID; } // TODO: remove these when GrCachedLayer & ReplacementInfo fuse - const unsigned* key() const { SkASSERT(fFreeKey); return fKey; } + const int* key() const { SkASSERT(fFreeKey); return fKey; } int keySize() const { SkASSERT(fFreeKey); return fKeySize; } uint32_t hash() const { uint32_t hash = SkChecksum::Murmur3(reinterpret_cast(fKey), fKeySize * sizeof(int)); - return SkChecksum::Murmur3(reinterpret_cast(&fIDMatrix), + return SkChecksum::Murmur3(reinterpret_cast(&fIDMatrix), sizeof(IDMatrix), hash); } @@ -134,19 +134,19 @@ public: SkMatrix fInitialMat; } fIDMatrix; - const unsigned* fKey; - const int fKeySize; - bool fFreeKey; + const int* fKey; + const int fKeySize; + bool fFreeKey; }; static const Key& GetKey(const GrCachedLayer& layer) { return layer.fKey; } static uint32_t Hash(const Key& key) { return key.hash(); } // GrCachedLayer proper - GrCachedLayer(uint32_t pictureID, unsigned start, unsigned stop, + GrCachedLayer(uint32_t pictureID, int start, int stop, const SkIRect& srcIR, const SkIRect& dstIR, const SkMatrix& ctm, - const unsigned* key, int keySize, + const int* key, int keySize, const SkPaint* paint) : fKey(pictureID, ctm, key, keySize, true) , fStart(start) @@ -179,14 +179,14 @@ public: uint32_t pictureID() const { return fKey.pictureID(); } // TODO: remove these when GrCachedLayer & ReplacementInfo fuse - const unsigned* key() const { return fKey.key(); } + const int* key() const { return fKey.key(); } int keySize() const { return fKey.keySize(); } - unsigned start() const { return fStart; } + int start() const { return fStart; } // TODO: make bound debug only const SkIRect& srcIR() const { return fSrcIR; } const SkIRect& dstIR() const { return fDstIR; } - unsigned stop() const { return fStop; } + int stop() const { return fStop; } void setTexture(GrTexture* texture, const SkIRect& rect) { SkRefCnt_SafeAssign(fTexture, texture); fRect = rect; @@ -220,9 +220,9 @@ private: const Key fKey; // The "saveLayer" operation index of the cached layer - const unsigned fStart; + const int fStart; // The final "restore" operation index of the cached layer - const unsigned fStop; + const int fStop; // The layer's src rect (i.e., the portion of the source scene required // for filtering). @@ -291,13 +291,13 @@ public: void freeAll(); GrCachedLayer* findLayer(uint32_t pictureID, const SkMatrix& ctm, - const unsigned* key, int keySize); + const int* key, int keySize); GrCachedLayer* findLayerOrCreate(uint32_t pictureID, - int start, int stop, + int start, int stop, const SkIRect& srcIR, const SkIRect& dstIR, const SkMatrix& initialMat, - const unsigned* key, int keySize, + const int* key, int keySize, const SkPaint* paint); // Attempt to place 'layer' in the atlas. Return true on success; false on failure. @@ -357,7 +357,7 @@ private: // We cache this information here (rather then, say, on the owning picture) // because we want to be able to clean it up as needed (e.g., if a picture - // is leaked and never cleans itself up we still want to be able to + // is leaked and never cleans itself up we still want to be able to // remove the GrPictureInfo once its layers are purged from all the atlas // plots). SkTDynamicHash fPictureHash; @@ -381,7 +381,7 @@ private: GrCachedLayer* createLayer(uint32_t pictureID, int start, int stop, const SkIRect& srcIR, const SkIRect& dstIR, const SkMatrix& initialMat, - const unsigned* key, int keySize, + const int* key, int keySize, const SkPaint* paint); // Remove all the layers (and unlock any resources) associated with 'pictureID' diff --git a/src/gpu/GrRecordReplaceDraw.cpp b/src/gpu/GrRecordReplaceDraw.cpp index 11eb38d8dc..d1a8d93558 100644 --- a/src/gpu/GrRecordReplaceDraw.cpp +++ b/src/gpu/GrRecordReplaceDraw.cpp @@ -63,7 +63,7 @@ public: const SkBigPicture* picture, const SkMatrix& initialMatrix, SkPicture::AbortCallback* callback, - const unsigned* opIndices, int numIndices) + const int* opIndices, int numIndices) : INHERITED(canvas, drawablePicts, NULL, drawableCount) , fCanvas(canvas) , fLayerCache(layerCache) @@ -154,7 +154,7 @@ public: // For a saveLayer command, check if it can be replaced by a drawBitmap // call and, if so, draw it and then update the current op index accordingly. - unsigned startOffset; + int startOffset; if (fOps.count()) { startOffset = fOps[fIndex]; } else { @@ -199,12 +199,12 @@ private: const SkMatrix fInitialMatrix; SkPicture::AbortCallback* fCallback; - SkTDArray fOps; + SkTDArray fOps; int fIndex; int fNumReplaced; // The op code indices of all the enclosing drawPicture and saveLayer calls - SkTDArray fOpIndexStack; + SkTDArray fOpIndexStack; typedef Draw INHERITED; }; 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* results) const override { + void search(const SkRect& query, SkTDArray* 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& found) { - SkTDArray expected; +static bool verify_query(SkRect query, SkRect rects[], SkTDArray& found) { + SkTDArray 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& 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 hits; + SkTDArray 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* results) const override {} + void search(const SkRect& query, SkTDArray* 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 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(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(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(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(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(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 -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 reader; record.visit(index, reader); REPORTER_ASSERT(r, T::kType == reader.type); @@ -36,7 +43,7 @@ template struct MatchType { template int count_instances_of_type(const SkRecord& record) { MatchType matcher; int counter = 0; - for (unsigned i = 0; i < record.count(); i++) { + for (int i = 0; i < record.count(); i++) { counter += record.visit(i, matcher); } return counter; @@ -44,7 +51,7 @@ template int count_instances_of_type(const SkRecord& record) { template int find_first_instances_of_type(const SkRecord& record) { MatchType matcher; - for (unsigned i = 0; i < record.count(); i++) { + for (int i = 0; i < record.count(); i++) { if (record.visit(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(i, *this); } } diff --git a/tools/DumpRecord.cpp b/tools/DumpRecord.cpp index 4f05fd46c1..3c34231e18 100644 --- a/tools/DumpRecord.cpp +++ b/tools/DumpRecord.cpp @@ -105,7 +105,7 @@ void DumpRecord(const SkRecord& record, SkCanvas* canvas, bool timeWithCommand) { Dumper dumper(canvas, record.count(), timeWithCommand); - for (unsigned i = 0; i < record.count(); i++) { + for (int i = 0; i < record.count(); i++) { record.visit(i, dumper); } } -- 2.34.1