michael@0: /* michael@0: * Copyright 2010 Google Inc. michael@0: * michael@0: * Use of this source code is governed by a BSD-style license that can be michael@0: * found in the LICENSE file. michael@0: */ michael@0: michael@0: #ifndef GrRectanizer_DEFINED michael@0: #define GrRectanizer_DEFINED michael@0: michael@0: #include "GrPoint.h" michael@0: michael@0: class GrRectanizerPurgeListener { michael@0: public: michael@0: virtual ~GrRectanizerPurgeListener() {} michael@0: michael@0: virtual void notifyPurgeStrip(void*, int yCoord) = 0; michael@0: }; michael@0: michael@0: class GrRectanizer { michael@0: public: michael@0: GrRectanizer(int width, int height) : fWidth(width), fHeight(height) { michael@0: SkASSERT(width >= 0); michael@0: SkASSERT(height >= 0); michael@0: } michael@0: michael@0: virtual ~GrRectanizer() {} michael@0: michael@0: virtual void reset() = 0; michael@0: michael@0: int width() const { return fWidth; } michael@0: int height() const { return fHeight; } michael@0: michael@0: virtual bool addRect(int width, int height, GrIPoint16* loc) = 0; michael@0: virtual float percentFull() const = 0; michael@0: michael@0: // return the Y-coordinate of a strip that should be purged, given height michael@0: // i.e. return the oldest such strip, or some other criteria. Return -1 michael@0: // if there is no candidate michael@0: virtual int stripToPurge(int height) const = 0; michael@0: virtual void purgeStripAtY(int yCoord) = 0; michael@0: michael@0: /** michael@0: * Our factory, which returns the subclass du jour michael@0: */ michael@0: static GrRectanizer* Factory(int width, int height); michael@0: michael@0: private: michael@0: int fWidth; michael@0: int fHeight; michael@0: }; michael@0: michael@0: #endif