2 * Copyright 2012 Google Inc.
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
8 #ifndef GrAARectRenderer_DEFINED
9 #define GrAARectRenderer_DEFINED
14 #include "SkStrokeRec.h"
21 * This class wraps helper functions that draw AA rects (filled & stroked)
23 class GrAARectRenderer : public SkRefCnt {
25 SK_DECLARE_INST_COUNT(GrAARectRenderer)
28 : fAAFillRectIndexBuffer(NULL)
29 , fAAMiterStrokeRectIndexBuffer(NULL)
30 , fAABevelStrokeRectIndexBuffer(NULL) {
39 // TODO: potentialy fuse the fill & stroke methods and differentiate
40 // between them by passing in stroke (==NULL means fill).
42 void fillAARect(GrGpu* gpu,
45 const SkMatrix& combinedMatrix,
46 const SkRect& devRect) {
47 #ifdef SHADER_AA_FILL_RECT
48 if (combinedMatrix.rectStaysRect()) {
49 this->shaderFillAlignedAARect(gpu, target,
50 rect, combinedMatrix);
52 this->shaderFillAARect(gpu, target,
53 rect, combinedMatrix);
56 this->geometryFillAARect(gpu, target, rect, combinedMatrix, devRect);
60 void strokeAARect(GrGpu* gpu,
63 const SkMatrix& combinedMatrix,
64 const SkRect& devRect,
65 const SkStrokeRec& stroke);
67 // First rect is outer; second rect is inner
68 void fillAANestedRects(GrGpu* gpu,
70 const SkRect rects[2],
71 const SkMatrix& combinedMatrix);
74 GrIndexBuffer* fAAFillRectIndexBuffer;
75 GrIndexBuffer* fAAMiterStrokeRectIndexBuffer;
76 GrIndexBuffer* fAABevelStrokeRectIndexBuffer;
78 GrIndexBuffer* aaFillRectIndexBuffer(GrGpu* gpu);
80 static int aaStrokeRectIndexCount(bool miterStroke);
81 GrIndexBuffer* aaStrokeRectIndexBuffer(GrGpu* gpu, bool miterStroke);
83 void geometryFillAARect(GrGpu* gpu,
86 const SkMatrix& combinedMatrix,
87 const SkRect& devRect);
89 void shaderFillAARect(GrGpu* gpu,
92 const SkMatrix& combinedMatrix);
94 void shaderFillAlignedAARect(GrGpu* gpu,
97 const SkMatrix& combinedMatrix);
99 void geometryStrokeAARect(GrGpu* gpu,
100 GrDrawTarget* target,
101 const SkRect& devOutside,
102 const SkRect& devOutsideAssist,
103 const SkRect& devInside,
106 typedef SkRefCnt INHERITED;
109 #endif // GrAARectRenderer_DEFINED