OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2010 Google Inc. | 2 * Copyright 2010 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 GrRectanizer_DEFINED | 8 #ifndef GrRectanizer_DEFINED |
9 #define GrRectanizer_DEFINED | 9 #define GrRectanizer_DEFINED |
10 | 10 |
11 #include "GrPoint.h" | 11 #include "GrPoint.h" |
12 | 12 |
13 class GrRectanizerPurgeListener { | |
14 public: | |
15 virtual ~GrRectanizerPurgeListener() {} | |
16 | |
17 virtual void notifyPurgeStrip(void*, int yCoord) = 0; | |
18 }; | |
19 | |
20 class GrRectanizer { | 13 class GrRectanizer { |
21 public: | 14 public: |
22 GrRectanizer(int width, int height) : fWidth(width), fHeight(height) { | 15 GrRectanizer(int width, int height) : fWidth(width), fHeight(height) { |
23 SkASSERT(width >= 0); | 16 SkASSERT(width >= 0); |
24 SkASSERT(height >= 0); | 17 SkASSERT(height >= 0); |
25 } | 18 } |
26 | 19 |
27 virtual ~GrRectanizer() {} | 20 virtual ~GrRectanizer() {} |
28 | 21 |
29 virtual void reset() = 0; | 22 virtual void reset() = 0; |
30 | 23 |
31 int width() const { return fWidth; } | 24 int width() const { return fWidth; } |
32 int height() const { return fHeight; } | 25 int height() const { return fHeight; } |
33 | 26 |
34 virtual bool addRect(int width, int height, GrIPoint16* loc) = 0; | 27 virtual bool addRect(int width, int height, GrIPoint16* loc) = 0; |
35 virtual float percentFull() const = 0; | 28 virtual float percentFull() const = 0; |
36 | 29 |
37 // return the Y-coordinate of a strip that should be purged, given height | |
38 // i.e. return the oldest such strip, or some other criteria. Return -1 | |
39 // if there is no candidate | |
40 virtual int stripToPurge(int height) const = 0; | |
41 virtual void purgeStripAtY(int yCoord) = 0; | |
42 | |
43 /** | 30 /** |
44 * Our factory, which returns the subclass du jour | 31 * Our factory, which returns the subclass du jour |
45 */ | 32 */ |
46 static GrRectanizer* Factory(int width, int height); | 33 static GrRectanizer* Factory(int width, int height); |
47 | 34 |
48 private: | 35 private: |
49 int fWidth; | 36 int fWidth; |
50 int fHeight; | 37 int fHeight; |
51 }; | 38 }; |
52 | 39 |
53 #endif | 40 #endif |
OLD | NEW |