blob: c1ac2c129ecd03ece61b5c0d648cda2ed85fb0e0 [file] [log] [blame]
reed@google.comac10a2d2010-12-22 21:39:39 +00001/*
epoger@google.comec3ed6a2011-07-28 14:26:00 +00002 * 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.comac10a2d2010-12-22 21:39:39 +00006 */
7
reed@google.comac10a2d2010-12-22 21:39:39 +00008#ifndef GrRectanizer_DEFINED
9#define GrRectanizer_DEFINED
10
commit-bot@chromium.orgfd03d4a2013-07-17 21:39:42 +000011#include "GrPoint.h"
reed@google.comac10a2d2010-12-22 21:39:39 +000012
13class GrRectanizerPurgeListener {
14public:
15 virtual ~GrRectanizerPurgeListener() {}
16
17 virtual void notifyPurgeStrip(void*, int yCoord) = 0;
18};
19
20class GrRectanizer {
21public:
22 GrRectanizer(int width, int height) : fWidth(width), fHeight(height) {
tfarina@chromium.orgf6de4752013-08-17 00:02:59 +000023 SkASSERT(width >= 0);
24 SkASSERT(height >= 0);
reed@google.comac10a2d2010-12-22 21:39:39 +000025 }
26
27 virtual ~GrRectanizer() {}
28
commit-bot@chromium.org7d330eb2013-09-27 19:39:38 +000029 virtual void reset() = 0;
30
reed@google.comac10a2d2010-12-22 21:39:39 +000031 int width() const { return fWidth; }
32 int height() const { return fHeight; }
33
34 virtual bool addRect(int width, int height, GrIPoint16* loc) = 0;
35 virtual float percentFull() const = 0;
36
37 // return the Y-coordinate of a strip that should be purged, given height
38 // i.e. return the oldest such strip, or some other criteria. Return -1
39 // if there is no candidate
40 virtual int stripToPurge(int height) const = 0;
41 virtual void purgeStripAtY(int yCoord) = 0;
42
43 /**
44 * Our factory, which returns the subclass du jour
45 */
46 static GrRectanizer* Factory(int width, int height);
47
48private:
49 int fWidth;
50 int fHeight;
51};
52
53#endif