| 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" | 
|  | 15 | #include "GrTDArray.h" | 
|  | 16 |  | 
|  | 17 | class GrRectanizerPurgeListener { | 
|  | 18 | public: | 
|  | 19 | virtual ~GrRectanizerPurgeListener() {} | 
|  | 20 |  | 
|  | 21 | virtual void notifyPurgeStrip(void*, int yCoord) = 0; | 
|  | 22 | }; | 
|  | 23 |  | 
|  | 24 | class GrRectanizer { | 
|  | 25 | public: | 
|  | 26 | GrRectanizer(int width, int height) : fWidth(width), fHeight(height) { | 
|  | 27 | GrAssert(width >= 0); | 
|  | 28 | GrAssert(height >= 0); | 
|  | 29 | } | 
|  | 30 |  | 
|  | 31 | virtual ~GrRectanizer() {} | 
|  | 32 |  | 
|  | 33 | int width() const { return fWidth; } | 
|  | 34 | int height() const { return fHeight; } | 
|  | 35 |  | 
|  | 36 | virtual bool addRect(int width, int height, GrIPoint16* loc) = 0; | 
|  | 37 | virtual float percentFull() const = 0; | 
|  | 38 |  | 
|  | 39 | // return the Y-coordinate of a strip that should be purged, given height | 
|  | 40 | // i.e. return the oldest such strip, or some other criteria. Return -1 | 
|  | 41 | // if there is no candidate | 
|  | 42 | virtual int stripToPurge(int height) const = 0; | 
|  | 43 | virtual void purgeStripAtY(int yCoord) = 0; | 
|  | 44 |  | 
|  | 45 | /** | 
|  | 46 | *  Our factory, which returns the subclass du jour | 
|  | 47 | */ | 
|  | 48 | static GrRectanizer* Factory(int width, int height); | 
|  | 49 |  | 
|  | 50 | private: | 
|  | 51 | int fWidth; | 
|  | 52 | int fHeight; | 
|  | 53 | }; | 
|  | 54 |  | 
|  | 55 | #endif | 
|  | 56 |  | 
|  | 57 |  |