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 #include "gl/builders/GrGLProgramBuilder.h" | 8 #include "gl/builders/GrGLProgramBuilder.h" |
9 #include "GrAARectRenderer.h" | 9 #include "GrAARectRenderer.h" |
10 #include "GrGpu.h" | 10 #include "GrGpu.h" |
11 #include "gl/GrGLEffect.h" | 11 #include "gl/GrGLEffect.h" |
12 #include "gl/GrGLVertexEffect.h" | 12 #include "gl/GrGLGeometryProcessor.h" |
13 #include "GrTBackendEffectFactory.h" | 13 #include "GrTBackendEffectFactory.h" |
14 #include "SkColorPriv.h" | 14 #include "SkColorPriv.h" |
15 #include "effects/GrVertexEffect.h" | 15 #include "effects/GrGeometryProcessor.h" |
16 | 16 |
17 /////////////////////////////////////////////////////////////////////////////// | 17 /////////////////////////////////////////////////////////////////////////////// |
18 class GrGLAlignedRectEffect; | 18 class GrGLAlignedRectEffect; |
19 | 19 |
20 // Axis Aligned special case | 20 // Axis Aligned special case |
21 class GrAlignedRectEffect : public GrVertexEffect { | 21 class GrAlignedRectEffect : public GrGeometryProcessor { |
22 public: | 22 public: |
23 static GrEffect* Create() { | 23 static GrEffect* Create() { |
24 GR_CREATE_STATIC_EFFECT(gAlignedRectEffect, GrAlignedRectEffect, ()); | 24 GR_CREATE_STATIC_EFFECT(gAlignedRectEffect, GrAlignedRectEffect, ()); |
25 gAlignedRectEffect->ref(); | 25 gAlignedRectEffect->ref(); |
26 return gAlignedRectEffect; | 26 return gAlignedRectEffect; |
27 } | 27 } |
28 | 28 |
29 virtual ~GrAlignedRectEffect() {} | 29 virtual ~GrAlignedRectEffect() {} |
30 | 30 |
31 static const char* Name() { return "AlignedRectEdge"; } | 31 static const char* Name() { return "AlignedRectEdge"; } |
32 | 32 |
33 virtual void getConstantColorComponents(GrColor* color, | 33 virtual void getConstantColorComponents(GrColor* color, |
34 uint32_t* validFlags) const SK_OVERR IDE { | 34 uint32_t* validFlags) const SK_OVERR IDE { |
35 *validFlags = 0; | 35 *validFlags = 0; |
36 } | 36 } |
37 | 37 |
38 const GrShaderVar& inRect() const { return fInRect; } | |
39 | |
38 virtual const GrBackendEffectFactory& getFactory() const SK_OVERRIDE { | 40 virtual const GrBackendEffectFactory& getFactory() const SK_OVERRIDE { |
39 return GrTBackendEffectFactory<GrAlignedRectEffect>::getInstance(); | 41 return GrTBackendEffectFactory<GrAlignedRectEffect>::getInstance(); |
40 } | 42 } |
41 | 43 |
42 class GLEffect : public GrGLVertexEffect { | 44 class GLEffect : public GrGLGeometryProcessor { |
43 public: | 45 public: |
44 GLEffect(const GrBackendEffectFactory& factory, const GrDrawEffect&) | 46 GLEffect(const GrBackendEffectFactory& factory, const GrDrawEffect&) |
45 : INHERITED (factory) {} | 47 : INHERITED (factory) {} |
46 | 48 |
47 virtual void emitCode(GrGLFullProgramBuilder* builder, | 49 virtual void emitCode(GrGLFullProgramBuilder* builder, |
48 const GrDrawEffect& drawEffect, | 50 const GrDrawEffect& drawEffect, |
49 const GrEffectKey& key, | 51 const GrEffectKey& key, |
50 const char* outputColor, | 52 const char* outputColor, |
51 const char* inputColor, | 53 const char* inputColor, |
52 const TransformedCoordsArray&, | 54 const TransformedCoordsArray&, |
53 const TextureSamplerArray& samplers) SK_OVERRIDE { | 55 const TextureSamplerArray& samplers) SK_OVERRIDE { |
54 // setup the varying for the Axis aligned rect effect | 56 // setup the varying for the Axis aligned rect effect |
55 // xy -> interpolated offset | 57 // xy -> interpolated offset |
56 // zw -> w/2+0.5, h/2+0.5 | 58 // zw -> w/2+0.5, h/2+0.5 |
57 const char *vsRectName, *fsRectName; | 59 const char *vsRectName, *fsRectName; |
58 builder->addVarying(kVec4f_GrSLType, "Rect", &vsRectName, &fsRectNam e); | 60 builder->addVarying(kVec4f_GrSLType, "Rect", &vsRectName, &fsRectNam e); |
59 | 61 |
62 const GrShaderVar& inRect = drawEffect.castEffect<GrAlignedRectEffec t>().inRect(); | |
60 GrGLVertexShaderBuilder* vsBuilder = builder->getVertexShaderBuilder (); | 63 GrGLVertexShaderBuilder* vsBuilder = builder->getVertexShaderBuilder (); |
61 const SkString* attr0Name = | 64 vsBuilder->codeAppendf("\t%s = %s;\n", vsRectName, inRect.c_str()); |
bsalomon
2014/09/15 17:46:25
happy about the result of our discussion earlier t
| |
62 vsBuilder->getEffectAttributeName(drawEffect.getVertexAttribIndi ces()[0]); | |
63 vsBuilder->codeAppendf("\t%s = %s;\n", vsRectName, attr0Name->c_str( )); | |
64 | 65 |
65 GrGLFragmentShaderBuilder* fsBuilder = builder->getFragmentShaderBui lder(); | 66 GrGLFragmentShaderBuilder* fsBuilder = builder->getFragmentShaderBui lder(); |
66 // TODO: compute all these offsets, spans, and scales in the VS | 67 // TODO: compute all these offsets, spans, and scales in the VS |
67 fsBuilder->codeAppendf("\tfloat insetW = min(1.0, %s.z) - 0.5;\n", f sRectName); | 68 fsBuilder->codeAppendf("\tfloat insetW = min(1.0, %s.z) - 0.5;\n", f sRectName); |
68 fsBuilder->codeAppendf("\tfloat insetH = min(1.0, %s.w) - 0.5;\n", f sRectName); | 69 fsBuilder->codeAppendf("\tfloat insetH = min(1.0, %s.w) - 0.5;\n", f sRectName); |
69 fsBuilder->codeAppend("\tfloat outset = 0.5;\n"); | 70 fsBuilder->codeAppend("\tfloat outset = 0.5;\n"); |
70 // For rects > 1 pixel wide and tall the span's are noops (i.e., 1.0 ). For rects | 71 // For rects > 1 pixel wide and tall the span's are noops (i.e., 1.0 ). For rects |
71 // < 1 pixel wide or tall they serve to normalize the < 1 ramp to a 0 .. 1 range. | 72 // < 1 pixel wide or tall they serve to normalize the < 1 ramp to a 0 .. 1 range. |
72 fsBuilder->codeAppend("\tfloat spanW = insetW + outset;\n"); | 73 fsBuilder->codeAppend("\tfloat spanW = insetW + outset;\n"); |
73 fsBuilder->codeAppend("\tfloat spanH = insetH + outset;\n"); | 74 fsBuilder->codeAppend("\tfloat spanH = insetH + outset;\n"); |
(...skipping 15 matching lines...) Expand all Loading... | |
89 | 90 |
90 fsBuilder->codeAppendf("\t%s = %s;\n", outputColor, | 91 fsBuilder->codeAppendf("\t%s = %s;\n", outputColor, |
91 (GrGLSLExpr4(inputColor) * GrGLSLExpr1("cover age")).c_str()); | 92 (GrGLSLExpr4(inputColor) * GrGLSLExpr1("cover age")).c_str()); |
92 } | 93 } |
93 | 94 |
94 static void GenKey(const GrDrawEffect&, const GrGLCaps&, GrEffectKeyBuil der*) {} | 95 static void GenKey(const GrDrawEffect&, const GrGLCaps&, GrEffectKeyBuil der*) {} |
95 | 96 |
96 virtual void setData(const GrGLProgramDataManager& pdman, const GrDrawEf fect&) SK_OVERRIDE {} | 97 virtual void setData(const GrGLProgramDataManager& pdman, const GrDrawEf fect&) SK_OVERRIDE {} |
97 | 98 |
98 private: | 99 private: |
99 typedef GrGLVertexEffect INHERITED; | 100 typedef GrGLGeometryProcessor INHERITED; |
100 }; | 101 }; |
101 | 102 |
102 | 103 |
103 private: | 104 private: |
104 GrAlignedRectEffect() : GrVertexEffect() { | 105 GrAlignedRectEffect() |
105 this->addVertexAttrib(kVec4f_GrSLType); | 106 : fInRect(this->addVertexAttrib(GrShaderVar("inRect", |
107 kVec4f_GrSLType, | |
108 GrShaderVar::kAttribute_Type Modifier))) { | |
106 } | 109 } |
107 | 110 |
111 const GrShaderVar& fInRect; | |
112 | |
108 virtual bool onIsEqual(const GrEffect&) const SK_OVERRIDE { return true; } | 113 virtual bool onIsEqual(const GrEffect&) const SK_OVERRIDE { return true; } |
109 | 114 |
110 GR_DECLARE_EFFECT_TEST; | 115 GR_DECLARE_EFFECT_TEST; |
111 | 116 |
112 typedef GrVertexEffect INHERITED; | 117 typedef GrGeometryProcessor INHERITED; |
113 }; | 118 }; |
114 | 119 |
115 | 120 |
116 GR_DEFINE_EFFECT_TEST(GrAlignedRectEffect); | 121 GR_DEFINE_EFFECT_TEST(GrAlignedRectEffect); |
117 | 122 |
118 GrEffect* GrAlignedRectEffect::TestCreate(SkRandom* random, | 123 GrEffect* GrAlignedRectEffect::TestCreate(SkRandom* random, |
119 GrContext* context, | 124 GrContext* context, |
120 const GrDrawTargetCaps&, | 125 const GrDrawTargetCaps&, |
121 GrTexture* textures[]) { | 126 GrTexture* textures[]) { |
122 return GrAlignedRectEffect::Create(); | 127 return GrAlignedRectEffect::Create(); |
123 } | 128 } |
124 | 129 |
125 /////////////////////////////////////////////////////////////////////////////// | 130 /////////////////////////////////////////////////////////////////////////////// |
126 class GrGLRectEffect; | 131 class GrGLRectEffect; |
127 | 132 |
128 /** | 133 /** |
129 * The output of this effect is a modulation of the input color and coverage | 134 * The output of this effect is a modulation of the input color and coverage |
130 * for an arbitrarily oriented rect. The rect is specified as: | 135 * for an arbitrarily oriented rect. The rect is specified as: |
131 * Center of the rect | 136 * Center of the rect |
132 * Unit vector point down the height of the rect | 137 * Unit vector point down the height of the rect |
133 * Half width + 0.5 | 138 * Half width + 0.5 |
134 * Half height + 0.5 | 139 * Half height + 0.5 |
135 * The center and vector are stored in a vec4 varying ("RectEdge") with the | 140 * The center and vector are stored in a vec4 varying ("RectEdge") with the |
136 * center in the xy components and the vector in the zw components. | 141 * center in the xy components and the vector in the zw components. |
137 * The munged width and height are stored in a vec2 varying ("WidthHeight") | 142 * The munged width and height are stored in a vec2 varying ("WidthHeight") |
138 * with the width in x and the height in y. | 143 * with the width in x and the height in y. |
139 */ | 144 */ |
140 class GrRectEffect : public GrVertexEffect { | 145 |
146 class GrRectEffect : public GrGeometryProcessor { | |
141 public: | 147 public: |
142 static GrEffect* Create() { | 148 static GrEffect* Create() { |
143 GR_CREATE_STATIC_EFFECT(gRectEffect, GrRectEffect, ()); | 149 GR_CREATE_STATIC_EFFECT(gRectEffect, GrRectEffect, ()); |
144 gRectEffect->ref(); | 150 gRectEffect->ref(); |
145 return gRectEffect; | 151 return gRectEffect; |
146 } | 152 } |
147 | 153 |
148 virtual ~GrRectEffect() {} | 154 virtual ~GrRectEffect() {} |
149 | 155 |
150 static const char* Name() { return "RectEdge"; } | 156 static const char* Name() { return "RectEdge"; } |
151 | 157 |
152 virtual void getConstantColorComponents(GrColor* color, | 158 virtual void getConstantColorComponents(GrColor* color, |
153 uint32_t* validFlags) const SK_OVERR IDE { | 159 uint32_t* validFlags) const SK_OVERR IDE { |
154 *validFlags = 0; | 160 *validFlags = 0; |
155 } | 161 } |
156 | 162 |
163 const GrShaderVar& inRectEdge() const { return fInRectEdge; } | |
164 const GrShaderVar& inWidthHeight() const { return fInWidthHeight; } | |
165 | |
157 virtual const GrBackendEffectFactory& getFactory() const SK_OVERRIDE { | 166 virtual const GrBackendEffectFactory& getFactory() const SK_OVERRIDE { |
158 return GrTBackendEffectFactory<GrRectEffect>::getInstance(); | 167 return GrTBackendEffectFactory<GrRectEffect>::getInstance(); |
159 } | 168 } |
160 | 169 |
161 class GLEffect : public GrGLVertexEffect { | 170 class GLEffect : public GrGLGeometryProcessor { |
162 public: | 171 public: |
163 GLEffect(const GrBackendEffectFactory& factory, const GrDrawEffect&) | 172 GLEffect(const GrBackendEffectFactory& factory, const GrDrawEffect&) |
164 : INHERITED (factory) {} | 173 : INHERITED (factory) {} |
165 | 174 |
166 virtual void emitCode(GrGLFullProgramBuilder* builder, | 175 virtual void emitCode(GrGLFullProgramBuilder* builder, |
167 const GrDrawEffect& drawEffect, | 176 const GrDrawEffect& drawEffect, |
168 const GrEffectKey& key, | 177 const GrEffectKey& key, |
169 const char* outputColor, | 178 const char* outputColor, |
170 const char* inputColor, | 179 const char* inputColor, |
171 const TransformedCoordsArray&, | 180 const TransformedCoordsArray&, |
172 const TextureSamplerArray& samplers) SK_OVERRIDE { | 181 const TextureSamplerArray& samplers) SK_OVERRIDE { |
173 // setup the varying for the center point and the unit vector | 182 // setup the varying for the center point and the unit vector |
174 // that points down the height of the rect | 183 // that points down the height of the rect |
175 const char *vsRectEdgeName, *fsRectEdgeName; | 184 const char *vsRectEdgeName, *fsRectEdgeName; |
176 builder->addVarying(kVec4f_GrSLType, "RectEdge", | 185 builder->addVarying(kVec4f_GrSLType, "RectEdge", |
177 &vsRectEdgeName, &fsRectEdgeName); | 186 &vsRectEdgeName, &fsRectEdgeName); |
178 | 187 |
188 const GrRectEffect& rectEffect = drawEffect.castEffect<GrRectEffect> (); | |
179 GrGLVertexShaderBuilder* vsBuilder = builder->getVertexShaderBuilder (); | 189 GrGLVertexShaderBuilder* vsBuilder = builder->getVertexShaderBuilder (); |
180 const SkString* attr0Name = | 190 vsBuilder->codeAppendf("%s = %s;", vsRectEdgeName, rectEffect.inRect Edge().c_str()); |
181 vsBuilder->getEffectAttributeName(drawEffect.getVertexAttribIndi ces()[0]); | |
182 vsBuilder->codeAppendf("\t%s = %s;\n", vsRectEdgeName, attr0Name->c_ str()); | |
183 | 191 |
184 // setup the varying for width/2+.5 and height/2+.5 | 192 // setup the varying for width/2+.5 and height/2+.5 |
185 const char *vsWidthHeightName, *fsWidthHeightName; | 193 const char *vsWidthHeightName, *fsWidthHeightName; |
186 builder->addVarying(kVec2f_GrSLType, "WidthHeight", | 194 builder->addVarying(kVec2f_GrSLType, "WidthHeight", |
187 &vsWidthHeightName, &fsWidthHeightName); | 195 &vsWidthHeightName, &fsWidthHeightName); |
188 const SkString* attr1Name = | 196 vsBuilder->codeAppendf("%s = %s;", |
189 vsBuilder->getEffectAttributeName(drawEffect.getVertexAttribIndi ces()[1]); | 197 vsWidthHeightName, |
190 vsBuilder->codeAppendf("\t%s = %s;\n", vsWidthHeightName, attr1Name- >c_str()); | 198 rectEffect.inWidthHeight().c_str()); |
191 | 199 |
192 GrGLFragmentShaderBuilder* fsBuilder = builder->getFragmentShaderBui lder(); | 200 GrGLFragmentShaderBuilder* fsBuilder = builder->getFragmentShaderBui lder(); |
193 // TODO: compute all these offsets, spans, and scales in the VS | 201 // TODO: compute all these offsets, spans, and scales in the VS |
194 fsBuilder->codeAppendf("\tfloat insetW = min(1.0, %s.x) - 0.5;\n", f sWidthHeightName); | 202 fsBuilder->codeAppendf("\tfloat insetW = min(1.0, %s.x) - 0.5;\n", f sWidthHeightName); |
195 fsBuilder->codeAppendf("\tfloat insetH = min(1.0, %s.y) - 0.5;\n", f sWidthHeightName); | 203 fsBuilder->codeAppendf("\tfloat insetH = min(1.0, %s.y) - 0.5;\n", f sWidthHeightName); |
196 fsBuilder->codeAppend("\tfloat outset = 0.5;\n"); | 204 fsBuilder->codeAppend("\tfloat outset = 0.5;\n"); |
197 // For rects > 1 pixel wide and tall the span's are noops (i.e., 1.0 ). For rects | 205 // For rects > 1 pixel wide and tall the span's are noops (i.e., 1.0 ). For rects |
198 // < 1 pixel wide or tall they serve to normalize the < 1 ramp to a 0 .. 1 range. | 206 // < 1 pixel wide or tall they serve to normalize the < 1 ramp to a 0 .. 1 range. |
199 fsBuilder->codeAppend("\tfloat spanW = insetW + outset;\n"); | 207 fsBuilder->codeAppend("\tfloat spanW = insetW + outset;\n"); |
200 fsBuilder->codeAppend("\tfloat spanH = insetH + outset;\n"); | 208 fsBuilder->codeAppend("\tfloat spanH = insetH + outset;\n"); |
(...skipping 22 matching lines...) Expand all Loading... | |
223 | 231 |
224 fsBuilder->codeAppendf("\t%s = %s;\n", outputColor, | 232 fsBuilder->codeAppendf("\t%s = %s;\n", outputColor, |
225 (GrGLSLExpr4(inputColor) * GrGLSLExpr1("cover age")).c_str()); | 233 (GrGLSLExpr4(inputColor) * GrGLSLExpr1("cover age")).c_str()); |
226 } | 234 } |
227 | 235 |
228 static void GenKey(const GrDrawEffect&, const GrGLCaps&, GrEffectKeyBuil der*) {} | 236 static void GenKey(const GrDrawEffect&, const GrGLCaps&, GrEffectKeyBuil der*) {} |
229 | 237 |
230 virtual void setData(const GrGLProgramDataManager& pdman, const GrDrawEf fect&) SK_OVERRIDE {} | 238 virtual void setData(const GrGLProgramDataManager& pdman, const GrDrawEf fect&) SK_OVERRIDE {} |
231 | 239 |
232 private: | 240 private: |
233 typedef GrGLVertexEffect INHERITED; | 241 typedef GrGLGeometryProcessor INHERITED; |
234 }; | 242 }; |
235 | 243 |
236 | 244 |
245 | |
237 private: | 246 private: |
238 GrRectEffect() : GrVertexEffect() { | 247 GrRectEffect() |
239 this->addVertexAttrib(kVec4f_GrSLType); | 248 : fInRectEdge(this->addVertexAttrib(GrShaderVar("inRectEdge", |
240 this->addVertexAttrib(kVec2f_GrSLType); | 249 kVec4f_GrSLType, |
250 GrShaderVar::kAttribute_ TypeModifier))) | |
251 , fInWidthHeight(this->addVertexAttrib( | |
252 GrShaderVar("inWidthHeight", | |
253 kVec2f_GrSLType, | |
254 GrShaderVar::kAttribute_TypeModifier))) { | |
241 this->setWillReadFragmentPosition(); | 255 this->setWillReadFragmentPosition(); |
242 } | 256 } |
243 | 257 |
244 virtual bool onIsEqual(const GrEffect&) const SK_OVERRIDE { return true; } | 258 virtual bool onIsEqual(const GrEffect&) const SK_OVERRIDE { return true; } |
245 | 259 |
260 const GrShaderVar& fInRectEdge; | |
261 const GrShaderVar& fInWidthHeight; | |
262 | |
246 GR_DECLARE_EFFECT_TEST; | 263 GR_DECLARE_EFFECT_TEST; |
247 | 264 |
248 typedef GrVertexEffect INHERITED; | 265 typedef GrGeometryProcessor INHERITED; |
249 }; | 266 }; |
250 | 267 |
251 | 268 |
252 GR_DEFINE_EFFECT_TEST(GrRectEffect); | 269 GR_DEFINE_EFFECT_TEST(GrRectEffect); |
253 | 270 |
254 GrEffect* GrRectEffect::TestCreate(SkRandom* random, | 271 GrEffect* GrRectEffect::TestCreate(SkRandom* random, |
255 GrContext* context, | 272 GrContext* context, |
256 const GrDrawTargetCaps&, | 273 const GrDrawTargetCaps&, |
257 GrTexture* textures[]) { | 274 GrTexture* textures[]) { |
258 return GrRectEffect::Create(); | 275 return GrRectEffect::Create(); |
(...skipping 380 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
639 | 656 |
640 GrDrawTarget::AutoReleaseGeometry geo(target, 4, 0); | 657 GrDrawTarget::AutoReleaseGeometry geo(target, 4, 0); |
641 if (!geo.succeeded()) { | 658 if (!geo.succeeded()) { |
642 GrPrintf("Failed to get space for vertices!\n"); | 659 GrPrintf("Failed to get space for vertices!\n"); |
643 return; | 660 return; |
644 } | 661 } |
645 | 662 |
646 RectVertex* verts = reinterpret_cast<RectVertex*>(geo.vertices()); | 663 RectVertex* verts = reinterpret_cast<RectVertex*>(geo.vertices()); |
647 | 664 |
648 GrEffect* effect = GrRectEffect::Create(); | 665 GrEffect* effect = GrRectEffect::Create(); |
649 static const int kRectAttrIndex = 1; | 666 drawState->setGeometryProcessor(effect)->unref(); |
650 static const int kWidthIndex = 2; | |
651 drawState->setGeometryProcessor(effect, kRectAttrIndex, kWidthIndex)->unref( ); | |
652 | 667 |
653 for (int i = 0; i < 4; ++i) { | 668 for (int i = 0; i < 4; ++i) { |
654 verts[i].fCenter = center; | 669 verts[i].fCenter = center; |
655 verts[i].fDir = dir; | 670 verts[i].fDir = dir; |
656 verts[i].fWidthHeight.fX = newWidth; | 671 verts[i].fWidthHeight.fX = newWidth; |
657 verts[i].fWidthHeight.fY = newHeight; | 672 verts[i].fWidthHeight.fY = newHeight; |
658 } | 673 } |
659 | 674 |
660 SkRect devRect; | 675 SkRect devRect; |
661 combinedMatrix.mapRect(&devRect, rect); | 676 combinedMatrix.mapRect(&devRect, rect); |
(...skipping 27 matching lines...) Expand all Loading... | |
689 | 704 |
690 GrDrawTarget::AutoReleaseGeometry geo(target, 4, 0); | 705 GrDrawTarget::AutoReleaseGeometry geo(target, 4, 0); |
691 if (!geo.succeeded()) { | 706 if (!geo.succeeded()) { |
692 GrPrintf("Failed to get space for vertices!\n"); | 707 GrPrintf("Failed to get space for vertices!\n"); |
693 return; | 708 return; |
694 } | 709 } |
695 | 710 |
696 AARectVertex* verts = reinterpret_cast<AARectVertex*>(geo.vertices()); | 711 AARectVertex* verts = reinterpret_cast<AARectVertex*>(geo.vertices()); |
697 | 712 |
698 GrEffect* effect = GrAlignedRectEffect::Create(); | 713 GrEffect* effect = GrAlignedRectEffect::Create(); |
699 static const int kOffsetIndex = 1; | 714 drawState->setGeometryProcessor(effect)->unref(); |
700 drawState->setGeometryProcessor(effect, kOffsetIndex)->unref(); | |
701 | 715 |
702 SkRect devRect; | 716 SkRect devRect; |
703 combinedMatrix.mapRect(&devRect, rect); | 717 combinedMatrix.mapRect(&devRect, rect); |
704 | 718 |
705 SkRect devBounds = { | 719 SkRect devBounds = { |
706 devRect.fLeft - SK_ScalarHalf, | 720 devRect.fLeft - SK_ScalarHalf, |
707 devRect.fTop - SK_ScalarHalf, | 721 devRect.fTop - SK_ScalarHalf, |
708 devRect.fRight + SK_ScalarHalf, | 722 devRect.fRight + SK_ScalarHalf, |
709 devRect.fBottom + SK_ScalarHalf | 723 devRect.fBottom + SK_ScalarHalf |
710 }; | 724 }; |
(...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
949 // can't call mapRect for devInside since it calls sort | 963 // can't call mapRect for devInside since it calls sort |
950 combinedMatrix.mapPoints((SkPoint*)&devInside, (const SkPoint*)&rects[1], 2) ; | 964 combinedMatrix.mapPoints((SkPoint*)&devInside, (const SkPoint*)&rects[1], 2) ; |
951 | 965 |
952 if (devInside.isEmpty()) { | 966 if (devInside.isEmpty()) { |
953 this->fillAARect(gpu, target, devOutside, SkMatrix::I(), devOutside); | 967 this->fillAARect(gpu, target, devOutside, SkMatrix::I(), devOutside); |
954 return; | 968 return; |
955 } | 969 } |
956 | 970 |
957 this->geometryStrokeAARect(gpu, target, devOutside, devOutsideAssist, devIns ide, true); | 971 this->geometryStrokeAARect(gpu, target, devOutside, devOutsideAssist, devIns ide, true); |
958 } | 972 } |
OLD | NEW |