| 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 |
| 11 #include "SkBBHFactory.h" | 11 #include "SkBBHFactory.h" |
| 12 #include "SkBBoxHierarchy.h" | 12 #include "SkBBoxHierarchy.h" |
| 13 | 13 |
| 14 /** | 14 /** |
| 15 * Subclass of SkBBoxHierarchy that stores elements in buckets that correspond | 15 * Subclass of SkBBoxHierarchy that stores elements in buckets that correspond |
| 16 * to tile regions, disposed in a regular grid. This is useful when the tile | 16 * to tile regions, disposed in a regular grid. This is useful when the tile |
| 17 * structure that will be use in search() calls is known prior to insertion. | 17 * structure that will be use in search() calls is known prior to insertion. |
| 18 */ | 18 */ |
| 19 class SkTileGrid : public SkBBoxHierarchy { | 19 class SkTileGrid : public SkBBoxHierarchy { |
| 20 public: | 20 public: |
| 21 SkTileGrid(int xTiles, int yTiles, const SkTileGridFactory::TileGridInfo& in
fo); | 21 SkTileGrid(int xTiles, int yTiles, const SkTileGridFactory::TileGridInfo& in
fo); |
| 22 virtual ~SkTileGrid(); | 22 virtual ~SkTileGrid(); |
| 23 | 23 |
| 24 virtual void insert(SkAutoTMalloc<SkRect>* boundsArray, int N) SK_OVERRIDE; | 24 virtual void insert(SkAutoTMalloc<SkRect>* boundsArray, int N) SK_OVERRIDE; |
| 25 virtual void search(const SkRect& query, SkTDArray<unsigned>* results) const
SK_OVERRIDE; | 25 virtual void search(const SkRect& query, SkTDArray<unsigned>* results) const
SK_OVERRIDE; |
| 26 | 26 |
| 27 // For testing. | 27 // For testing. |
| 28 int tileCount(int x, int y) { return fTiles[y * fXTiles + x].count(); } | 28 int tileCount(int x, int y) { return fTiles[y * fXTiles + x].count(); } |
| 29 | 29 |
| 30 virtual size_t bytesUsed() const SK_OVERRIDE; |
| 31 |
| 30 private: | 32 private: |
| 31 void reserve(int); | 33 void reserve(int); |
| 32 void shrinkToFit(); | 34 void shrinkToFit(); |
| 33 | 35 |
| 34 void commonAdjust(SkRect*) const; | 36 void commonAdjust(SkRect*) const; |
| 35 void userToGrid(const SkRect&, SkIRect* grid) const; | 37 void userToGrid(const SkRect&, SkIRect* grid) const; |
| 36 | 38 |
| 37 const int fXTiles, fYTiles; | 39 const int fXTiles, fYTiles; |
| 38 const SkScalar fInvWidth, fInvHeight; | 40 const SkScalar fInvWidth, fInvHeight; |
| 39 const SkScalar fMarginWidth, fMarginHeight; | 41 const SkScalar fMarginWidth, fMarginHeight; |
| 40 const SkPoint fOffset; | 42 const SkPoint fOffset; |
| 41 const SkRect fGridBounds; | 43 const SkRect fGridBounds; |
| 42 | 44 |
| 43 // (fXTiles * fYTiles) SkTDArrays, each listing ops overlapping that tile in
order. | 45 // (fXTiles * fYTiles) SkTDArrays, each listing ops overlapping that tile in
order. |
| 44 SkTDArray<unsigned>* fTiles; | 46 SkTDArray<unsigned>* fTiles; |
| 45 | 47 |
| 46 typedef SkBBoxHierarchy INHERITED; | 48 typedef SkBBoxHierarchy INHERITED; |
| 47 }; | 49 }; |
| 48 | 50 |
| 49 #endif | 51 #endif |
| OLD | NEW |