• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 skgpu_Rectanizer_DEFINED
9 #define skgpu_Rectanizer_DEFINED
10 
11 #include "include/gpu/GrTypes.h"
12 
13 struct SkIPoint16;
14 
15 namespace skgpu {
16 
17 class Rectanizer {
18 public:
Rectanizer(int width,int height)19     Rectanizer(int width, int height) : fWidth(width), fHeight(height) {
20         SkASSERT(width >= 0);
21         SkASSERT(height >= 0);
22     }
23 
~Rectanizer()24     virtual ~Rectanizer() {}
25 
26     virtual void reset() = 0;
27 
width()28     int width() const { return fWidth; }
height()29     int height() const { return fHeight; }
30 
31     // Attempt to add a rect. Return true on success; false on failure. If
32     // successful the position in the atlas is returned in 'loc'.
33     virtual bool addRect(int width, int height, SkIPoint16* loc) = 0;
34     virtual float percentFull() const = 0;
35 
36     /**
37      *  Our factory, which returns the subclass du jour
38      */
39     static Rectanizer* Factory(int width, int height);
40 
41 private:
42     const int fWidth;
43     const int fHeight;
44 };
45 
46 } // End of namespace skgpu
47 
48 #endif
49