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 #ifndef GrAARectRenderer_DEFINED 9 #define GrAARectRenderer_DEFINED 10 11 #include "GrColor.h" 12 #include "SkMatrix.h" 13 #include "SkRect.h" 14 #include "SkRefCnt.h" 15 #include "SkStrokeRec.h" 16 17 class GrClip; 18 class GrDrawTarget; 19 class GrIndexBuffer; 20 class GrPipelineBuilder; 21 22 /* 23 * This class wraps helper functions that draw AA rects (filled & stroked) 24 */ 25 class GrAARectRenderer : public SkRefCnt { 26 public: SK_DECLARE_INST_COUNT(GrAARectRenderer)27 SK_DECLARE_INST_COUNT(GrAARectRenderer) 28 29 // TODO: potentialy fuse the fill & stroke methods and differentiate 30 // between them by passing in stroke (==NULL means fill). 31 32 void fillAARect(GrDrawTarget* target, 33 GrPipelineBuilder* pipelineBuilder, 34 GrColor color, 35 const SkMatrix& viewMatrix, 36 const SkRect& rect, 37 const SkRect& devRect) { 38 this->geometryFillAARect(target, pipelineBuilder, color, viewMatrix, rect, devRect); 39 } 40 41 void strokeAARect(GrDrawTarget*, 42 GrPipelineBuilder*, 43 GrColor, 44 const SkMatrix& viewMatrix, 45 const SkRect& rect, 46 const SkRect& devRect, 47 const SkStrokeRec& stroke); 48 49 // First rect is outer; second rect is inner 50 void fillAANestedRects(GrDrawTarget*, 51 GrPipelineBuilder*, 52 GrColor, 53 const SkMatrix& viewMatrix, 54 const SkRect rects[2]); 55 56 private: 57 void geometryFillAARect(GrDrawTarget*, 58 GrPipelineBuilder*, 59 GrColor, 60 const SkMatrix& viewMatrix, 61 const SkRect& rect, 62 const SkRect& devRect); 63 64 void geometryStrokeAARect(GrDrawTarget*, 65 GrPipelineBuilder*, 66 GrColor, 67 const SkMatrix& viewMatrix, 68 const SkRect& devOutside, 69 const SkRect& devOutsideAssist, 70 const SkRect& devInside, 71 bool miterStroke); 72 73 typedef SkRefCnt INHERITED; 74 }; 75 76 #endif // GrAARectRenderer_DEFINED 77