blob: 44d14a1c0301e66ba36136bed316059d5fae5b6b [file] [log] [blame]
epoger@google.comec3ed6a2011-07-28 14:26:00 +00001
reed@google.comac10a2d2010-12-22 21:39:39 +00002/*
epoger@google.comec3ed6a2011-07-28 14:26:00 +00003 * 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.comac10a2d2010-12-22 21:39:39 +00007 */
8
9
epoger@google.comec3ed6a2011-07-28 14:26:00 +000010
reed@google.comac10a2d2010-12-22 21:39:39 +000011#ifndef GrRectanizer_DEFINED
12#define GrRectanizer_DEFINED
13
14#include "GrRect.h"
reed@google.comac10a2d2010-12-22 21:39:39 +000015
16class GrRectanizerPurgeListener {
17public:
18 virtual ~GrRectanizerPurgeListener() {}
19
20 virtual void notifyPurgeStrip(void*, int yCoord) = 0;
21};
22
23class GrRectanizer {
24public:
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
49private:
50 int fWidth;
51 int fHeight;
52};
53
54#endif