| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2012 Google Inc. | 2 * Copyright 2012 Google Inc. |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
| 5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
| 6 */ | 6 */ |
| 7 | 7 |
| 8 #ifndef SkTileGrid_DEFINED | 8 #ifndef SkTileGrid_DEFINED |
| 9 #define SkTileGrid_DEFINED | 9 #define SkTileGrid_DEFINED |
| 10 | 10 |
| (...skipping 10 matching lines...) Expand all Loading... |
| 21 SkTileGrid(int xTiles, int yTiles, const SkTileGridFactory::TileGridInfo& in
fo); | 21 SkTileGrid(int xTiles, int yTiles, const SkTileGridFactory::TileGridInfo& in
fo); |
| 22 | 22 |
| 23 virtual ~SkTileGrid(); | 23 virtual ~SkTileGrid(); |
| 24 | 24 |
| 25 /** | 25 /** |
| 26 * Insert a data pointer and corresponding bounding box | 26 * Insert a data pointer and corresponding bounding box |
| 27 * @param data An arbitrary data pointer, may be NULL. | 27 * @param data An arbitrary data pointer, may be NULL. |
| 28 * @param bounds The bounding box, should not be empty. | 28 * @param bounds The bounding box, should not be empty. |
| 29 * @param defer Ignored; SkTileGrid does not defer insertions. | 29 * @param defer Ignored; SkTileGrid does not defer insertions. |
| 30 */ | 30 */ |
| 31 virtual void insert(void* data, const SkRect& bounds, bool) SK_OVERRIDE; | 31 virtual void insert(void* data, const SkIRect& bounds, bool) SK_OVERRIDE; |
| 32 | 32 |
| 33 virtual void flushDeferredInserts() SK_OVERRIDE {}; | 33 virtual void flushDeferredInserts() SK_OVERRIDE {}; |
| 34 | 34 |
| 35 /** | 35 /** |
| 36 * Populate 'results' with data pointers corresponding to bounding boxes tha
t intersect 'query'. | 36 * Populate 'results' with data pointers corresponding to bounding boxes tha
t intersect 'query'. |
| 37 * This will be fastest if the query is an exact match to a single grid tile
. | 37 * This will be fastest if the query is an exact match to a single grid tile
. |
| 38 */ | 38 */ |
| 39 virtual void search(const SkRect& query, SkTDArray<void*>* results) const SK
_OVERRIDE; | 39 virtual void search(const SkIRect& query, SkTDArray<void*>* results) const S
K_OVERRIDE; |
| 40 | 40 |
| 41 virtual void clear() SK_OVERRIDE; | 41 virtual void clear() SK_OVERRIDE; |
| 42 | 42 |
| 43 virtual int getCount() const SK_OVERRIDE { return fCount; } | 43 virtual int getCount() const SK_OVERRIDE { return fCount; } |
| 44 | 44 |
| 45 virtual int getDepth() const SK_OVERRIDE { return -1; } | 45 virtual int getDepth() const SK_OVERRIDE { return -1; } |
| 46 | 46 |
| 47 virtual void rewindInserts() SK_OVERRIDE; | 47 virtual void rewindInserts() SK_OVERRIDE; |
| 48 | 48 |
| 49 // For testing. | 49 // For testing. |
| 50 int tileCount(int x, int y) { return fTiles[y * fXTiles + x].count(); } | 50 int tileCount(int x, int y) { return fTiles[y * fXTiles + x].count(); } |
| 51 | 51 |
| 52 private: | 52 private: |
| 53 struct Entry { | 53 struct Entry { |
| 54 size_t order; // Insertion order. Used to preserve order when merging
multiple tiles. | 54 size_t order; // Insertion order. Used to preserve order when merging
multiple tiles. |
| 55 void* data; | 55 void* data; |
| 56 }; | 56 }; |
| 57 | 57 |
| 58 const int fXTiles, fYTiles; | 58 const int fXTiles, fYTiles; |
| 59 SkTileGridFactory::TileGridInfo fInfo; | 59 SkTileGridFactory::TileGridInfo fInfo; |
| 60 size_t fCount; | 60 size_t fCount; |
| 61 | 61 |
| 62 // (fXTiles * fYTiles) SkTDArrays, each listing data overlapping that tile i
n insertion order. | 62 // (fXTiles * fYTiles) SkTDArrays, each listing data overlapping that tile i
n insertion order. |
| 63 SkTDArray<Entry>* fTiles; | 63 SkTDArray<Entry>* fTiles; |
| 64 | 64 |
| 65 typedef SkBBoxHierarchy INHERITED; | 65 typedef SkBBoxHierarchy INHERITED; |
| 66 }; | 66 }; |
| 67 | 67 |
| 68 #endif | 68 #endif |
| OLD | NEW |