Line data Source code
1 : /*
2 : * Copyright 2010 Google Inc.
3 : *
4 : * Use of this source code is governed by a BSD-style license that can be
5 : * found in the LICENSE file.
6 : */
7 :
8 : #ifndef GrRectanizer_DEFINED
9 : #define GrRectanizer_DEFINED
10 :
11 : #include "GrTypes.h"
12 :
13 : struct SkIPoint16;
14 :
15 : class GrRectanizer {
16 : public:
17 0 : GrRectanizer(int width, int height) : fWidth(width), fHeight(height) {
18 0 : SkASSERT(width >= 0);
19 0 : SkASSERT(height >= 0);
20 0 : }
21 :
22 0 : virtual ~GrRectanizer() {}
23 :
24 : virtual void reset() = 0;
25 :
26 0 : int width() const { return fWidth; }
27 0 : int height() const { return fHeight; }
28 :
29 : // Attempt to add a rect. Return true on success; false on failure. If
30 : // successful the position in the atlas is returned in 'loc'.
31 : virtual bool addRect(int width, int height, SkIPoint16* loc) = 0;
32 : virtual float percentFull() const = 0;
33 :
34 : /**
35 : * Our factory, which returns the subclass du jour
36 : */
37 : static GrRectanizer* Factory(int width, int height);
38 :
39 : private:
40 : int fWidth;
41 : int fHeight;
42 : };
43 :
44 : #endif
|