Home | History | Annotate | Download | only in include
      1 /*
      2     Copyright 2010 Google Inc.
      3 
      4     Licensed under the Apache License, Version 2.0 (the "License");
      5     you may not use this file except in compliance with the License.
      6     You may obtain a copy of the License at
      7 
      8          http://www.apache.org/licenses/LICENSE-2.0
      9 
     10     Unless required by applicable law or agreed to in writing, software
     11     distributed under the License is distributed on an "AS IS" BASIS,
     12     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     13     See the License for the specific language governing permissions and
     14     limitations under the License.
     15  */
     16 
     17 
     18 #ifndef GrRectanizer_DEFINED
     19 #define GrRectanizer_DEFINED
     20 
     21 #include "GrRect.h"
     22 #include "GrTDArray.h"
     23 
     24 class GrRectanizerPurgeListener {
     25 public:
     26     virtual ~GrRectanizerPurgeListener() {}
     27 
     28     virtual void notifyPurgeStrip(void*, int yCoord) = 0;
     29 };
     30 
     31 class GrRectanizer {
     32 public:
     33     GrRectanizer(int width, int height) : fWidth(width), fHeight(height) {
     34         GrAssert(width >= 0);
     35         GrAssert(height >= 0);
     36     }
     37 
     38     virtual ~GrRectanizer() {}
     39 
     40     int width() const { return fWidth; }
     41     int height() const { return fHeight; }
     42 
     43     virtual bool addRect(int width, int height, GrIPoint16* loc) = 0;
     44     virtual float percentFull() const = 0;
     45 
     46     // return the Y-coordinate of a strip that should be purged, given height
     47     // i.e. return the oldest such strip, or some other criteria. Return -1
     48     // if there is no candidate
     49     virtual int stripToPurge(int height) const = 0;
     50     virtual void purgeStripAtY(int yCoord) = 0;
     51 
     52     /**
     53      *  Our factory, which returns the subclass du jour
     54      */
     55     static GrRectanizer* Factory(int width, int height);
     56 
     57 private:
     58     int fWidth;
     59     int fHeight;
     60 };
     61 
     62 #endif
     63 
     64 
     65