OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2012 Google Inc. | 2 * Copyright 2012 Google Inc. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
6 */ | 6 */ |
7 | 7 |
8 #ifndef GrAARectRenderer_DEFINED | 8 #ifndef GrAARectRenderer_DEFINED |
9 #define GrAARectRenderer_DEFINED | 9 #define GrAARectRenderer_DEFINED |
10 | 10 |
11 #include "GrColor.h" | 11 #include "GrColor.h" |
12 #include "SkMatrix.h" | 12 #include "SkMatrix.h" |
13 #include "SkRect.h" | 13 #include "SkRect.h" |
14 #include "SkRefCnt.h" | 14 #include "SkRefCnt.h" |
15 #include "SkStrokeRec.h" | 15 #include "SkStrokeRec.h" |
16 | 16 |
17 class GrGpu; | 17 class GrGpu; |
18 class GrDrawState; | 18 class GrPipelineBuilder; |
19 class GrDrawTarget; | 19 class GrDrawTarget; |
20 class GrIndexBuffer; | 20 class GrIndexBuffer; |
21 | 21 |
22 /* | 22 /* |
23 * This class wraps helper functions that draw AA rects (filled & stroked) | 23 * This class wraps helper functions that draw AA rects (filled & stroked) |
24 */ | 24 */ |
25 class GrAARectRenderer : public SkRefCnt { | 25 class GrAARectRenderer : public SkRefCnt { |
26 public: | 26 public: |
27 SK_DECLARE_INST_COUNT(GrAARectRenderer) | 27 SK_DECLARE_INST_COUNT(GrAARectRenderer) |
28 | 28 |
29 GrAARectRenderer(GrGpu* gpu) | 29 GrAARectRenderer(GrGpu* gpu) |
30 : fGpu(gpu) | 30 : fGpu(gpu) |
31 , fAAFillRectIndexBuffer(NULL) | 31 , fAAFillRectIndexBuffer(NULL) |
32 , fAAMiterStrokeRectIndexBuffer(NULL) | 32 , fAAMiterStrokeRectIndexBuffer(NULL) |
33 , fAABevelStrokeRectIndexBuffer(NULL) { | 33 , fAABevelStrokeRectIndexBuffer(NULL) { |
34 } | 34 } |
35 | 35 |
36 void reset(); | 36 void reset(); |
37 | 37 |
38 ~GrAARectRenderer() { | 38 ~GrAARectRenderer() { |
39 this->reset(); | 39 this->reset(); |
40 } | 40 } |
41 | 41 |
42 // TODO: potentialy fuse the fill & stroke methods and differentiate | 42 // TODO: potentialy fuse the fill & stroke methods and differentiate |
43 // between them by passing in stroke (==NULL means fill). | 43 // between them by passing in stroke (==NULL means fill). |
44 | 44 |
45 void fillAARect(GrDrawTarget* target, | 45 void fillAARect(GrDrawTarget* target, |
46 GrDrawState* ds, | 46 GrPipelineBuilder* pipelineBuilder, |
47 GrColor color, | 47 GrColor color, |
48 const SkMatrix& viewMatrix, | 48 const SkMatrix& viewMatrix, |
49 const SkRect& rect, | 49 const SkRect& rect, |
50 const SkRect& devRect) { | 50 const SkRect& devRect) { |
51 this->geometryFillAARect(target, ds, color, viewMatrix, rect, devRect); | 51 this->geometryFillAARect(target, pipelineBuilder, color, viewMatrix, rec
t, devRect); |
52 } | 52 } |
53 | 53 |
54 void strokeAARect(GrDrawTarget*, | 54 void strokeAARect(GrDrawTarget*, |
55 GrDrawState*, | 55 GrPipelineBuilder*, |
56 GrColor, | 56 GrColor, |
57 const SkMatrix& viewMatrix, | 57 const SkMatrix& viewMatrix, |
58 const SkRect& rect, | 58 const SkRect& rect, |
59 const SkRect& devRect, | 59 const SkRect& devRect, |
60 const SkStrokeRec& stroke); | 60 const SkStrokeRec& stroke); |
61 | 61 |
62 // First rect is outer; second rect is inner | 62 // First rect is outer; second rect is inner |
63 void fillAANestedRects(GrDrawTarget*, | 63 void fillAANestedRects(GrDrawTarget*, |
64 GrDrawState*, | 64 GrPipelineBuilder*, |
65 GrColor, | 65 GrColor, |
66 const SkMatrix& viewMatrix, | 66 const SkMatrix& viewMatrix, |
67 const SkRect rects[2]); | 67 const SkRect rects[2]); |
68 | 68 |
69 private: | 69 private: |
70 GrIndexBuffer* aaStrokeRectIndexBuffer(bool miterStroke); | 70 GrIndexBuffer* aaStrokeRectIndexBuffer(bool miterStroke); |
71 | 71 |
72 void geometryFillAARect(GrDrawTarget*, | 72 void geometryFillAARect(GrDrawTarget*, |
73 GrDrawState*, | 73 GrPipelineBuilder*, |
74 GrColor, | 74 GrColor, |
75 const SkMatrix& viewMatrix, | 75 const SkMatrix& viewMatrix, |
76 const SkRect& rect, | 76 const SkRect& rect, |
77 const SkRect& devRect); | 77 const SkRect& devRect); |
78 | 78 |
79 void geometryStrokeAARect(GrDrawTarget*, | 79 void geometryStrokeAARect(GrDrawTarget*, |
80 GrDrawState*, | 80 GrPipelineBuilder*, |
81 GrColor, | 81 GrColor, |
82 const SkMatrix& viewMatrix, | 82 const SkMatrix& viewMatrix, |
83 const SkRect& devOutside, | 83 const SkRect& devOutside, |
84 const SkRect& devOutsideAssist, | 84 const SkRect& devOutsideAssist, |
85 const SkRect& devInside, | 85 const SkRect& devInside, |
86 bool miterStroke); | 86 bool miterStroke); |
87 | 87 |
88 GrGpu* fGpu; | 88 GrGpu* fGpu; |
89 GrIndexBuffer* fAAFillRectIndexBuffer; | 89 GrIndexBuffer* fAAFillRectIndexBuffer; |
90 GrIndexBuffer* fAAMiterStrokeRectIndexBuffer; | 90 GrIndexBuffer* fAAMiterStrokeRectIndexBuffer; |
91 GrIndexBuffer* fAABevelStrokeRectIndexBuffer; | 91 GrIndexBuffer* fAABevelStrokeRectIndexBuffer; |
92 | 92 |
93 typedef SkRefCnt INHERITED; | 93 typedef SkRefCnt INHERITED; |
94 }; | 94 }; |
95 | 95 |
96 #endif // GrAARectRenderer_DEFINED | 96 #endif // GrAARectRenderer_DEFINED |
OLD | NEW |