• 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 GrRectanizer_DEFINED
9 #define GrRectanizer_DEFINED
10 
11 #include "include/gpu/GrTypes.h"
12 
13 struct SkIPoint16;
14 
15 class GrRectanizer {
16 public:
GrRectanizer(int width,int height)17     GrRectanizer(int width, int height) : fWidth(width), fHeight(height) {
18         SkASSERT(width >= 0);
19         SkASSERT(height >= 0);
20     }
21 
~GrRectanizer()22     virtual ~GrRectanizer() {}
23 
24     virtual void reset() = 0;
25 
width()26     int width() const { return fWidth; }
height()27     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     const int fWidth;
41     const int fHeight;
42 };
43 
44 #endif
45