blob: dc697c41d7d19b7df9ebbbbcfe3118e8882c5426 [file] [log] [blame]
reed@google.comac10a2d2010-12-22 21:39:39 +00001/*
epoger@google.comec3ed6a2011-07-28 14:26:00 +00002 * 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.
reed@google.comac10a2d2010-12-22 21:39:39 +00006 */
7
reed@google.comac10a2d2010-12-22 21:39:39 +00008#ifndef GrRectanizer_DEFINED
9#define GrRectanizer_DEFINED
10
robertphillipsd5373412014-06-02 10:20:14 -070011#include "GrTypes.h"
12
13struct SkIPoint16;
reed@google.comac10a2d2010-12-22 21:39:39 +000014
reed@google.comac10a2d2010-12-22 21:39:39 +000015class GrRectanizer {
16public:
17 GrRectanizer(int width, int height) : fWidth(width), fHeight(height) {
tfarina@chromium.orgf6de4752013-08-17 00:02:59 +000018 SkASSERT(width >= 0);
19 SkASSERT(height >= 0);
reed@google.comac10a2d2010-12-22 21:39:39 +000020 }
21
22 virtual ~GrRectanizer() {}
23
commit-bot@chromium.org7d330eb2013-09-27 19:39:38 +000024 virtual void reset() = 0;
25
reed@google.comac10a2d2010-12-22 21:39:39 +000026 int width() const { return fWidth; }
27 int height() const { return fHeight; }
28
robertphillips901e96d2014-06-02 07:15:18 -070029 // Attempt to add a rect. Return true on success; false on failure. If
30 // successful the position in the atlas is returned in 'loc'.
robertphillipsd5373412014-06-02 10:20:14 -070031 virtual bool addRect(int width, int height, SkIPoint16* loc) = 0;
reed@google.comac10a2d2010-12-22 21:39:39 +000032 virtual float percentFull() const = 0;
33
reed@google.comac10a2d2010-12-22 21:39:39 +000034 /**
35 * Our factory, which returns the subclass du jour
36 */
37 static GrRectanizer* Factory(int width, int height);
38
39private:
40 int fWidth;
41 int fHeight;
42};
43
44#endif