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