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 | |
commit-bot@chromium.org | fd03d4a | 2013-07-17 21:39:42 +0000 | [diff] [blame] | 11 | #include "GrPoint.h" |
reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 12 | |
| 13 | class GrRectanizerPurgeListener { |
| 14 | public: |
| 15 | virtual ~GrRectanizerPurgeListener() {} |
| 16 | |
| 17 | virtual void notifyPurgeStrip(void*, int yCoord) = 0; |
| 18 | }; |
| 19 | |
| 20 | class GrRectanizer { |
| 21 | public: |
| 22 | GrRectanizer(int width, int height) : fWidth(width), fHeight(height) { |
tfarina@chromium.org | f6de475 | 2013-08-17 00:02:59 +0000 | [diff] [blame] | 23 | SkASSERT(width >= 0); |
| 24 | SkASSERT(height >= 0); |
reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 25 | } |
| 26 | |
| 27 | virtual ~GrRectanizer() {} |
| 28 | |
| 29 | int width() const { return fWidth; } |
| 30 | int height() const { return fHeight; } |
| 31 | |
| 32 | virtual bool addRect(int width, int height, GrIPoint16* loc) = 0; |
| 33 | virtual float percentFull() const = 0; |
| 34 | |
| 35 | // return the Y-coordinate of a strip that should be purged, given height |
| 36 | // i.e. return the oldest such strip, or some other criteria. Return -1 |
| 37 | // if there is no candidate |
| 38 | virtual int stripToPurge(int height) const = 0; |
| 39 | virtual void purgeStripAtY(int yCoord) = 0; |
| 40 | |
| 41 | /** |
| 42 | * Our factory, which returns the subclass du jour |
| 43 | */ |
| 44 | static GrRectanizer* Factory(int width, int height); |
| 45 | |
| 46 | private: |
| 47 | int fWidth; |
| 48 | int fHeight; |
| 49 | }; |
| 50 | |
| 51 | #endif |