Home | History | Annotate | Download | only in gpu
      1 /*
      2  * Copyright 2012 Google Inc.
      3  *
      4  * Use of this source code is governed by a BSD-style license that can be
      5  * found in the LICENSE file.
      6  */
      7 
      8 
      9 #ifndef GrAARectRenderer_DEFINED
     10 #define GrAARectRenderer_DEFINED
     11 
     12 #include "GrRect.h"
     13 #include "GrRefCnt.h"
     14 
     15 class GrGpu;
     16 class GrDrawTarget;
     17 class GrIndexBuffer;
     18 
     19 /*
     20  * This class wraps helper functions that draw AA rects (filled & stroked)
     21  */
     22 class GrAARectRenderer : public GrRefCnt {
     23 public:
     24     SK_DECLARE_INST_COUNT(GrAARectRenderer)
     25 
     26     GrAARectRenderer()
     27     : fAAFillRectIndexBuffer(NULL)
     28     , fAAStrokeRectIndexBuffer(NULL) {
     29     }
     30 
     31     void reset();
     32 
     33     ~GrAARectRenderer() {
     34         this->reset();
     35     }
     36 
     37     // TODO: potentialy fuse the fill & stroke methods and differentiate
     38     // btween them by passing in strokeWidth (<0 means fill).
     39 
     40     // TODO: Remove the useVertexCoverage boolean. Just use it all the time
     41     // since we now have a coverage vertex attribute
     42     void fillAARect(GrGpu* gpu,
     43                     GrDrawTarget* target,
     44                     const GrRect& devRect,
     45                     bool useVertexCoverage);
     46 
     47     void strokeAARect(GrGpu* gpu,
     48                       GrDrawTarget* target,
     49                       const GrRect& devRect,
     50                       const GrVec& devStrokeSize,
     51                       bool useVertexCoverage);
     52 
     53 private:
     54     GrIndexBuffer*              fAAFillRectIndexBuffer;
     55     GrIndexBuffer*              fAAStrokeRectIndexBuffer;
     56 
     57     GrIndexBuffer* aaFillRectIndexBuffer(GrGpu* gpu);
     58 
     59     static int aaStrokeRectIndexCount();
     60     GrIndexBuffer* aaStrokeRectIndexBuffer(GrGpu* gpu);
     61 
     62     typedef GrRefCnt INHERITED;
     63 };
     64 
     65 #endif // GrAARectRenderer_DEFINED
     66