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 GrRectanizer { | 13 class GrRectanizer { |
14 public: | 14 public: |
15 GrRectanizer(int width, int height) : fWidth(width), fHeight(height) { | 15 GrRectanizer(int width, int height) : fWidth(width), fHeight(height) { |
16 SkASSERT(width >= 0); | 16 SkASSERT(width >= 0); |
17 SkASSERT(height >= 0); | 17 SkASSERT(height >= 0); |
18 } | 18 } |
19 | 19 |
20 virtual ~GrRectanizer() {} | 20 virtual ~GrRectanizer() {} |
21 | 21 |
22 virtual void reset() = 0; | 22 virtual void reset() = 0; |
23 | 23 |
24 int width() const { return fWidth; } | 24 int width() const { return fWidth; } |
25 int height() const { return fHeight; } | 25 int height() const { return fHeight; } |
26 | 26 |
| 27 // Attempt to add a rect. Return true on success; false on failure. If |
| 28 // successful the position in the atlas is returned in 'loc'. |
27 virtual bool addRect(int width, int height, GrIPoint16* loc) = 0; | 29 virtual bool addRect(int width, int height, GrIPoint16* loc) = 0; |
28 virtual float percentFull() const = 0; | 30 virtual float percentFull() const = 0; |
29 | 31 |
30 /** | 32 /** |
31 * Our factory, which returns the subclass du jour | 33 * Our factory, which returns the subclass du jour |
32 */ | 34 */ |
33 static GrRectanizer* Factory(int width, int height); | 35 static GrRectanizer* Factory(int width, int height); |
34 | 36 |
35 private: | 37 private: |
36 int fWidth; | 38 int fWidth; |
37 int fHeight; | 39 int fHeight; |
38 }; | 40 }; |
39 | 41 |
40 #endif | 42 #endif |
OLD | NEW |