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

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

Issue 12817011: Fixing SkPicture command pattern optimizations to make them work correctly with bounding box hierar… (Closed) Base URL: http://skia.googlecode.com/svn/trunk/
Patch Set: Created 7 years, 9 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | src/core/SkBBoxHierarchyRecord.h » ('j') | src/core/SkPicturePlayback.cpp » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 1
2 /* 2 /*
3 * Copyright 2012 Google Inc. 3 * Copyright 2012 Google Inc.
4 * 4 *
5 * Use of this source code is governed by a BSD-style license that can be 5 * Use of this source code is governed by a BSD-style license that can be
6 * found in the LICENSE file. 6 * found in the LICENSE file.
7 */ 7 */
8 8
9 #ifndef SkBBoxHierarchy_DEFINED 9 #ifndef SkBBoxHierarchy_DEFINED
10 #define SkBBoxHierarchy_DEFINED 10 #define SkBBoxHierarchy_DEFINED
11 11
12 #include "SkRect.h" 12 #include "SkRect.h"
13 #include "SkTDArray.h" 13 #include "SkTDArray.h"
14 #include "SkRefCnt.h" 14 #include "SkRefCnt.h"
15 15
16 class SkBBoxHierarchyClient {
17 public:
18 virtual bool shouldRewind(void* data) = 0;
19 };
20
16 /** 21 /**
17 * Interface for a spatial data structure that associates user data pointers wit h axis-aligned 22 * Interface for a spatial data structure that associates user data pointers wit h axis-aligned
18 * bounding boxes, and allows efficient retrieval of intersections with query re ctangles. 23 * bounding boxes, and allows efficient retrieval of intersections with query re ctangles.
19 */ 24 */
20 class SkBBoxHierarchy : public SkRefCnt { 25 class SkBBoxHierarchy : public SkRefCnt {
21 public: 26 public:
22 SK_DECLARE_INST_COUNT(SkBBoxHierarchy) 27 SK_DECLARE_INST_COUNT(SkBBoxHierarchy)
23 28
29 SkBBoxHierarchy() : fClient(NULL) {}
30
24 /** 31 /**
25 * Insert a data pointer and corresponding bounding box 32 * Insert a data pointer and corresponding bounding box
26 * @param data The data pointer, may be NULL 33 * @param data The data pointer, may be NULL
27 * @param bounds The bounding box, should not be empty 34 * @param bounds The bounding box, should not be empty
28 * @param defer Whether or not it is acceptable to delay insertion of this e lement (building up 35 * @param defer Whether or not it is acceptable to delay insertion of this e lement (building up
29 * an entire spatial data structure at once is often faster and produ ces better 36 * an entire spatial data structure at once is often faster and produ ces better
30 * structures than repeated inserts) until flushDeferredInserts is ca lled or the first 37 * structures than repeated inserts) until flushDeferredInserts is ca lled or the first
31 * search. 38 * search.
32 */ 39 */
33 virtual void insert(void* data, const SkIRect& bounds, bool defer = false) = 0; 40 virtual void insert(void* data, const SkIRect& bounds, bool defer = false) = 0;
34 41
35 /** 42 /**
36 * If any insertions have been deferred, this forces them to be inserted 43 * If any insertions have been deferred, this forces them to be inserted
37 */ 44 */
38 virtual void flushDeferredInserts() = 0; 45 virtual void flushDeferredInserts() = 0;
39 46
40 /** 47 /**
41 * Populate 'results' with data pointers corresponding to bounding boxes tha t intersect 'query' 48 * Populate 'results' with data pointers corresponding to bounding boxes tha t intersect 'query'
42 */ 49 */
43 virtual void search(const SkIRect& query, SkTDArray<void*>* results) = 0; 50 virtual void search(const SkIRect& query, SkTDArray<void*>* results) = 0;
44 51
45 virtual void clear() = 0; 52 virtual void clear() = 0;
46 53
47 /** 54 /**
48 * Gets the number of insertions 55 * Gets the number of insertions
49 */ 56 */
50 virtual int getCount() const = 0; 57 virtual int getCount() const = 0;
51 58
59 /**
60 * Rewinds all the most recently inserted data elements until an element
61 * is encountered for which client->shouldRewind(data) returns false. May
62 * not rewind elements that were inserted prior to the last call to
63 * flushDeferredInserts.
64 */
65 virtual void rewindInserts() = 0;
66
67 void setClient(SkBBoxHierarchyClient* client) {fClient = client;}
68
69 protected:
70 SkBBoxHierarchyClient* fClient;
71
52 private: 72 private:
53 typedef SkRefCnt INHERITED; 73 typedef SkRefCnt INHERITED;
54 }; 74 };
55 75
56 #endif 76 #endif
OLDNEW
« no previous file with comments | « no previous file | src/core/SkBBoxHierarchyRecord.h » ('j') | src/core/SkPicturePlayback.cpp » ('J')

Powered by Google App Engine
This is Rietveld 408576698