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 GrClipIterator_DEFINED
     12 #define GrClipIterator_DEFINED
     13 
     14 #include "GrPath.h"
     15 #include "GrRect.h"
     16 
     17 /**
     18  * A clip is a list of paths and/or rects with set operations to combine them.
     19  */
     20 class GrClipIterator {
     21 public:
     22     virtual ~GrClipIterator() {}
     23 
     24     /**
     25      *  Returns true if there are no more rects to process
     26      */
     27     virtual bool isDone() const = 0;
     28 
     29     /**
     30      *  Rewind the iterator to replay the set of clip elements again
     31      */
     32     virtual void rewind() = 0;
     33 
     34     /**
     35      * Get the type of the current clip element
     36      */
     37     virtual GrClipType getType() const = 0;
     38 
     39     /**
     40      * Return the current path. It is an error to call this when isDone() is
     41      * true or when getType() is kRect_Type.
     42      */
     43     virtual const GrPath* getPath() = 0;
     44 
     45     /**
     46      * Return the fill rule for the path. It is an error to call this when
     47      * isDone() is true or when getType is kRect_Type.
     48      */
     49     virtual GrPathFill getPathFill() const = 0;
     50 
     51     /**
     52     * Return the current rect. It is an error to call this when isDone is true
     53     * or when getType() is kPath_Type.
     54     */
     55     virtual void getRect(GrRect* rect) const = 0;
     56 
     57     /**
     58      * Gets the operation used to apply the current item to previously iterated
     59      * items. Iterators should not produce a Replace op.
     60      */
     61     virtual GrSetOp getOp() const = 0;
     62 
     63     /**
     64      *  Call to move to the next element in the list, previous path iter can be
     65      *  made invalid.
     66      */
     67     virtual void next() = 0;
     68 };
     69 
     70 /**
     71  *  Call to rewind iter, first checking to see if iter is NULL
     72  */
     73 static inline void GrSafeRewind(GrClipIterator* iter) {
     74     if (iter) {
     75         iter->rewind();
     76     }
     77 }
     78 
     79 #endif
     80 
     81