reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 1 | /* |
epoger@google.com | ec3ed6a | 2011-07-28 14:26:00 +0000 | [diff] [blame] | 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. |
reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 6 | */ |
| 7 | |
reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 8 | #ifndef GrRectanizer_DEFINED |
| 9 | #define GrRectanizer_DEFINED |
| 10 | |
robertphillips | d537341 | 2014-06-02 10:20:14 -0700 | [diff] [blame] | 11 | #include "GrTypes.h" |
| 12 | |
| 13 | struct SkIPoint16; |
reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 14 | |
reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 15 | class GrRectanizer { |
| 16 | public: |
| 17 | GrRectanizer(int width, int height) : fWidth(width), fHeight(height) { |
tfarina@chromium.org | f6de475 | 2013-08-17 00:02:59 +0000 | [diff] [blame] | 18 | SkASSERT(width >= 0); |
| 19 | SkASSERT(height >= 0); |
reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 20 | } |
| 21 | |
| 22 | virtual ~GrRectanizer() {} |
| 23 | |
commit-bot@chromium.org | 7d330eb | 2013-09-27 19:39:38 +0000 | [diff] [blame] | 24 | virtual void reset() = 0; |
| 25 | |
reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 26 | int width() const { return fWidth; } |
| 27 | int height() const { return fHeight; } |
| 28 | |
robertphillips | 901e96d | 2014-06-02 07:15:18 -0700 | [diff] [blame] | 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'. |
robertphillips | d537341 | 2014-06-02 10:20:14 -0700 | [diff] [blame] | 31 | virtual bool addRect(int width, int height, SkIPoint16* loc) = 0; |
reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 32 | virtual float percentFull() const = 0; |
| 33 | |
reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 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 |