Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(47)

Side by Side Diff: src/core/SkTileGrid.h

Issue 617393004: BBHs: void* data -> unsigned data (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: The rest Created 6 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/core/SkRecordDraw.cpp ('k') | src/core/SkTileGrid.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 22
23 virtual ~SkTileGrid(); 23 virtual ~SkTileGrid();
24 24
25 /** 25 /**
26 * Insert a data pointer and corresponding bounding box 26 * Insert a opIndex value and corresponding bounding box
27 * @param data An arbitrary data pointer, may be NULL. 27 * @param opIndex
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(unsigned opIndex, const SkRect& bounds, bool) SK_OVERRID E;
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 opIndexes corresponding to bounding boxes that in tersect '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 SkRect& query, SkTDArray<unsigned>* results) const SK_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;
48
49 // For testing. 47 // For testing.
50 int tileCount(int x, int y) { return fTiles[y * fXTiles + x].count(); } 48 int tileCount(int x, int y) { return fTiles[y * fXTiles + x].count(); }
51 49
52 private: 50 private:
53 struct Entry {
54 size_t order; // Insertion order. Used to preserve order when merging multiple tiles.
55 void* data;
56 };
57
58 const int fXTiles, fYTiles; 51 const int fXTiles, fYTiles;
59 SkTileGridFactory::TileGridInfo fInfo; 52 SkTileGridFactory::TileGridInfo fInfo;
60 size_t fCount; 53 size_t fCount;
61 54
62 // (fXTiles * fYTiles) SkTDArrays, each listing data overlapping that tile i n insertion order. 55 // (fXTiles * fYTiles) SkTDArrays, each listing ops overlapping that tile in order.
63 SkTDArray<Entry>* fTiles; 56 SkTDArray<unsigned>* fTiles;
64 57
65 typedef SkBBoxHierarchy INHERITED; 58 typedef SkBBoxHierarchy INHERITED;
66 }; 59 };
67 60
68 #endif 61 #endif
OLDNEW
« no previous file with comments | « src/core/SkRecordDraw.cpp ('k') | src/core/SkTileGrid.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698