1
2/*
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.
7 */
8
9
10
11#ifndef GrRectanizer_DEFINED
12#define GrRectanizer_DEFINED
13
14#include "GrRect.h"
15#include "GrTDArray.h"
16
17class GrRectanizerPurgeListener {
18public:
19    virtual ~GrRectanizerPurgeListener() {}
20
21    virtual void notifyPurgeStrip(void*, int yCoord) = 0;
22};
23
24class GrRectanizer {
25public:
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
50private:
51    int fWidth;
52    int fHeight;
53};
54
55#endif
56
57
58