Home | History | Annotate | Download | only in gpu
      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 
     16 class GrRectanizerPurgeListener {
     17 public:
     18     virtual ~GrRectanizerPurgeListener() {}
     19 
     20     virtual void notifyPurgeStrip(void*, int yCoord) = 0;
     21 };
     22 
     23 class GrRectanizer {
     24 public:
     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 
     49 private:
     50     int fWidth;
     51     int fHeight;
     52 };
     53 
     54 #endif
     55