blob: 0f9d8fdfb62ddd6bee739bee0a940792e6f43843 [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
commit-bot@chromium.orgfd03d4a2013-07-17 21:39:42 +000011#include "GrPoint.h"
reed@google.comac10a2d2010-12-22 21:39:39 +000012
reed@google.comac10a2d2010-12-22 21:39:39 +000013class GrRectanizer {
14public:
15 GrRectanizer(int width, int height) : fWidth(width), fHeight(height) {
tfarina@chromium.orgf6de4752013-08-17 00:02:59 +000016 SkASSERT(width >= 0);
17 SkASSERT(height >= 0);
reed@google.comac10a2d2010-12-22 21:39:39 +000018 }
19
20 virtual ~GrRectanizer() {}
21
commit-bot@chromium.org7d330eb2013-09-27 19:39:38 +000022 virtual void reset() = 0;
23
reed@google.comac10a2d2010-12-22 21:39:39 +000024 int width() const { return fWidth; }
25 int height() const { return fHeight; }
26
robertphillips901e96d2014-06-02 07:15:18 -070027 // Attempt to add a rect. Return true on success; false on failure. If
28 // successful the position in the atlas is returned in 'loc'.
reed@google.comac10a2d2010-12-22 21:39:39 +000029 virtual bool addRect(int width, int height, GrIPoint16* loc) = 0;
30 virtual float percentFull() const = 0;
31
reed@google.comac10a2d2010-12-22 21:39:39 +000032 /**
33 * Our factory, which returns the subclass du jour
34 */
35 static GrRectanizer* Factory(int width, int height);
36
37private:
38 int fWidth;
39 int fHeight;
40};
41
42#endif