epoger@google.com | ec3ed6a | 2011-07-28 14:26:00 +0000 | [diff] [blame] | 1 | |
reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 2 | /* |
epoger@google.com | ec3ed6a | 2011-07-28 14:26:00 +0000 | [diff] [blame] | 3 | * Copyright 2010 Google Inc. |
| 4 | * |
| 5 | * Use of this source code is governed by a BSD-style license that can be |
| 6 | * found in the LICENSE file. |
reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 7 | */ |
| 8 | |
| 9 | |
epoger@google.com | ec3ed6a | 2011-07-28 14:26:00 +0000 | [diff] [blame] | 10 | |
reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 11 | #ifndef GrRectanizer_DEFINED |
| 12 | #define GrRectanizer_DEFINED |
| 13 | |
| 14 | #include "GrRect.h" |
reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 15 | |
| 16 | class GrRectanizerPurgeListener { |
| 17 | public: |
| 18 | virtual ~GrRectanizerPurgeListener() {} |
| 19 | |
| 20 | virtual void notifyPurgeStrip(void*, int yCoord) = 0; |
| 21 | }; |
| 22 | |
| 23 | class GrRectanizer { |
| 24 | public: |
| 25 | GrRectanizer(int width, int height) : fWidth(width), fHeight(height) { |
| 26 | GrAssert(width >= 0); |
| 27 | GrAssert(height >= 0); |
| 28 | } |
| 29 | |
| 30 | virtual ~GrRectanizer() {} |
| 31 | |
| 32 | int width() const { return fWidth; } |
| 33 | int height() const { return fHeight; } |
| 34 | |
| 35 | virtual bool addRect(int width, int height, GrIPoint16* loc) = 0; |
| 36 | virtual float percentFull() const = 0; |
| 37 | |
| 38 | // return the Y-coordinate of a strip that should be purged, given height |
| 39 | // i.e. return the oldest such strip, or some other criteria. Return -1 |
| 40 | // if there is no candidate |
| 41 | virtual int stripToPurge(int height) const = 0; |
| 42 | virtual void purgeStripAtY(int yCoord) = 0; |
| 43 | |
| 44 | /** |
| 45 | * Our factory, which returns the subclass du jour |
| 46 | */ |
| 47 | static GrRectanizer* Factory(int width, int height); |
| 48 | |
| 49 | private: |
| 50 | int fWidth; |
| 51 | int fHeight; |
| 52 | }; |
| 53 | |
| 54 | #endif |