Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(634)

Side by Side Diff: src/gpu/GrAARectRenderer.h

Issue 683483004: aa rect renderer takes a gpu on construction (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: feedback inc Created 6 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | src/gpu/GrAARectRenderer.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "SkMatrix.h" 11 #include "SkMatrix.h"
12 #include "SkRect.h" 12 #include "SkRect.h"
13 #include "SkRefCnt.h" 13 #include "SkRefCnt.h"
14 #include "SkStrokeRec.h" 14 #include "SkStrokeRec.h"
15 15
16 class GrGpu; 16 class GrGpu;
17 class GrDrawTarget; 17 class GrDrawTarget;
18 class GrIndexBuffer; 18 class GrIndexBuffer;
19 19
20 /* 20 /*
21 * This class wraps helper functions that draw AA rects (filled & stroked) 21 * This class wraps helper functions that draw AA rects (filled & stroked)
22 */ 22 */
23 class GrAARectRenderer : public SkRefCnt { 23 class GrAARectRenderer : public SkRefCnt {
24 public: 24 public:
25 SK_DECLARE_INST_COUNT(GrAARectRenderer) 25 SK_DECLARE_INST_COUNT(GrAARectRenderer)
26 26
27 GrAARectRenderer() 27 GrAARectRenderer(GrGpu* gpu)
28 : fAAFillRectIndexBuffer(NULL) 28 : fGpu(gpu)
29 , fAAFillRectIndexBuffer(NULL)
29 , fAAMiterStrokeRectIndexBuffer(NULL) 30 , fAAMiterStrokeRectIndexBuffer(NULL)
30 , fAABevelStrokeRectIndexBuffer(NULL) { 31 , fAABevelStrokeRectIndexBuffer(NULL) {
31 } 32 }
32 33
33 void reset(); 34 void reset();
34 35
35 ~GrAARectRenderer() { 36 ~GrAARectRenderer() {
36 this->reset(); 37 this->reset();
37 } 38 }
38 39
39 // TODO: potentialy fuse the fill & stroke methods and differentiate 40 // TODO: potentialy fuse the fill & stroke methods and differentiate
40 // between them by passing in stroke (==NULL means fill). 41 // between them by passing in stroke (==NULL means fill).
41 42
42 void fillAARect(GrGpu* gpu, 43 void fillAARect(GrDrawTarget* target,
43 GrDrawTarget* target,
44 const SkRect& rect, 44 const SkRect& rect,
45 const SkMatrix& combinedMatrix, 45 const SkMatrix& combinedMatrix,
46 const SkRect& devRect) { 46 const SkRect& devRect) {
47 #ifdef SHADER_AA_FILL_RECT 47 #ifdef SHADER_AA_FILL_RECT
48 if (combinedMatrix.rectStaysRect()) { 48 if (combinedMatrix.rectStaysRect()) {
49 this->shaderFillAlignedAARect(gpu, target, 49 this->shaderFillAlignedAARect(gpu, target,
50 rect, combinedMatrix); 50 rect, combinedMatrix);
51 } else { 51 } else {
52 this->shaderFillAARect(gpu, target, 52 this->shaderFillAARect(gpu, target,
53 rect, combinedMatrix); 53 rect, combinedMatrix);
54 } 54 }
55 #else 55 #else
56 this->geometryFillAARect(gpu, target, rect, combinedMatrix, devRect); 56 this->geometryFillAARect(target, rect, combinedMatrix, devRect);
57 #endif 57 #endif
58 } 58 }
59 59
60 void strokeAARect(GrGpu* gpu, 60 void strokeAARect(GrDrawTarget* target,
61 GrDrawTarget* target,
62 const SkRect& rect, 61 const SkRect& rect,
63 const SkMatrix& combinedMatrix, 62 const SkMatrix& combinedMatrix,
64 const SkRect& devRect, 63 const SkRect& devRect,
65 const SkStrokeRec& stroke); 64 const SkStrokeRec& stroke);
66 65
67 // First rect is outer; second rect is inner 66 // First rect is outer; second rect is inner
68 void fillAANestedRects(GrGpu* gpu, 67 void fillAANestedRects(GrDrawTarget* target,
69 GrDrawTarget* target,
70 const SkRect rects[2], 68 const SkRect rects[2],
71 const SkMatrix& combinedMatrix); 69 const SkMatrix& combinedMatrix);
72 70
73 private: 71 private:
74 GrIndexBuffer* fAAFillRectIndexBuffer; 72 GrIndexBuffer* aaStrokeRectIndexBuffer(bool miterStroke);
75 GrIndexBuffer* fAAMiterStrokeRectIndexBuffer;
76 GrIndexBuffer* fAABevelStrokeRectIndexBuffer;
77 73
78 static int aaStrokeRectIndexCount(bool miterStroke); 74 void geometryFillAARect(GrDrawTarget* target,
79 GrIndexBuffer* aaStrokeRectIndexBuffer(GrGpu* gpu, bool miterStroke);
80
81 void geometryFillAARect(GrGpu* gpu,
82 GrDrawTarget* target,
83 const SkRect& rect, 75 const SkRect& rect,
84 const SkMatrix& combinedMatrix, 76 const SkMatrix& combinedMatrix,
85 const SkRect& devRect); 77 const SkRect& devRect);
86 78
87 void shaderFillAARect(GrGpu* gpu, 79 void shaderFillAARect(GrDrawTarget* target,
88 GrDrawTarget* target,
89 const SkRect& rect, 80 const SkRect& rect,
90 const SkMatrix& combinedMatrix); 81 const SkMatrix& combinedMatrix);
91 82
92 void shaderFillAlignedAARect(GrGpu* gpu, 83 void shaderFillAlignedAARect(GrDrawTarget* target,
93 GrDrawTarget* target,
94 const SkRect& rect, 84 const SkRect& rect,
95 const SkMatrix& combinedMatrix); 85 const SkMatrix& combinedMatrix);
96 86
97 void geometryStrokeAARect(GrGpu* gpu, 87 void geometryStrokeAARect(GrDrawTarget* target,
98 GrDrawTarget* target,
99 const SkRect& devOutside, 88 const SkRect& devOutside,
100 const SkRect& devOutsideAssist, 89 const SkRect& devOutsideAssist,
101 const SkRect& devInside, 90 const SkRect& devInside,
102 bool miterStroke); 91 bool miterStroke);
103 92
93 GrGpu* fGpu;
94 GrIndexBuffer* fAAFillRectIndexBuffer;
95 GrIndexBuffer* fAAMiterStrokeRectIndexBuffer;
96 GrIndexBuffer* fAABevelStrokeRectIndexBuffer;
97
104 typedef SkRefCnt INHERITED; 98 typedef SkRefCnt INHERITED;
105 }; 99 };
106 100
107 #endif // GrAARectRenderer_DEFINED 101 #endif // GrAARectRenderer_DEFINED
OLDNEW
« no previous file with comments | « no previous file | src/gpu/GrAARectRenderer.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698