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 "Sk4x.h" | |
12 #include "SkBBHFactory.h" | 11 #include "SkBBHFactory.h" |
13 #include "SkBBoxHierarchy.h" | 12 #include "SkBBoxHierarchy.h" |
14 | 13 |
15 /** | 14 /** |
16 * Subclass of SkBBoxHierarchy that stores elements in buckets that correspond | 15 * Subclass of SkBBoxHierarchy that stores elements in buckets that correspond |
17 * 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 |
18 * 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. |
19 */ | 18 */ |
20 class SkTileGrid : public SkBBoxHierarchy { | 19 class SkTileGrid : public SkBBoxHierarchy { |
21 public: | 20 public: |
(...skipping 15 matching lines...) Expand all Loading... |
37 */ | 36 */ |
38 virtual void search(const SkRect& query, SkTDArray<unsigned>* results) const
SK_OVERRIDE; | 37 virtual void search(const SkRect& query, SkTDArray<unsigned>* results) const
SK_OVERRIDE; |
39 | 38 |
40 // For testing. | 39 // For testing. |
41 int tileCount(int x, int y) { return fTiles[y * fXTiles + x].count(); } | 40 int tileCount(int x, int y) { return fTiles[y * fXTiles + x].count(); } |
42 | 41 |
43 virtual void reserve(unsigned opCount) SK_OVERRIDE; | 42 virtual void reserve(unsigned opCount) SK_OVERRIDE; |
44 virtual void flushDeferredInserts() SK_OVERRIDE; | 43 virtual void flushDeferredInserts() SK_OVERRIDE; |
45 | 44 |
46 private: | 45 private: |
47 void userToGrid(const Sk4f&, SkIRect*) const; | 46 void commonAdjust(SkRect*) const; |
48 bool intersectsGrid(const Sk4f&) const; | 47 void userToGrid(const SkRect&, SkIRect* grid) const; |
49 | 48 |
50 const int fXTiles, // Number of tiles in a single row. | 49 const int fXTiles, fYTiles; |
51 fNumTiles; // Total number of tiles. | 50 const SkScalar fInvWidth, fInvHeight; |
| 51 const SkScalar fMarginWidth, fMarginHeight; |
| 52 const SkPoint fOffset; |
| 53 const SkRect fGridBounds; |
52 | 54 |
53 const SkRect fGridBounds; // Only used for intersectsGrid(). Remove if tha
t's removed. | 55 // (fXTiles * fYTiles) SkTDArrays, each listing ops overlapping that tile in
order. |
54 const Sk4f fMargin, fOffset, fUserToGrid, fGridHigh; | |
55 | |
56 // fNumTiles SkTDArrays, each listing ops overlapping that tile in order. | |
57 SkTDArray<unsigned>* fTiles; | 56 SkTDArray<unsigned>* fTiles; |
58 | 57 |
59 typedef SkBBoxHierarchy INHERITED; | 58 typedef SkBBoxHierarchy INHERITED; |
60 }; | 59 }; |
61 | 60 |
62 #endif | 61 #endif |
OLD | NEW |