| 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& aRect() const { return fAttrRect; } |
| 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& aRect = drawEffect.castEffect<GrAlignedRectEffect
>().aRect(); |
| 60 GrGLVertexShaderBuilder* vsBuilder = builder->getVertexShaderBuilder
(); | 63 GrGLVertexShaderBuilder* vsBuilder = builder->getVertexShaderBuilder
(); |
| 61 const SkString* attr0Name = | 64 vsBuilder->codeAppendf("\t%s = %s;\n", vsRectName, aRect.c_str()); |
| 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 : GrGeometryProcessor() |
| 107 , fAttrRect(this->addVertexAttrib(GrShaderVar("aRect", |
| 108 kVec4f_GrSLType, |
| 109 GrShaderVar::kAttribute_Ty
peModifier))) { |
| 106 } | 110 } |
| 107 | 111 |
| 112 const GrShaderVar& fAttrRect; |
| 113 |
| 108 virtual bool onIsEqual(const GrEffect&) const SK_OVERRIDE { return true; } | 114 virtual bool onIsEqual(const GrEffect&) const SK_OVERRIDE { return true; } |
| 109 | 115 |
| 110 GR_DECLARE_EFFECT_TEST; | 116 GR_DECLARE_EFFECT_TEST; |
| 111 | 117 |
| 112 typedef GrVertexEffect INHERITED; | 118 typedef GrGeometryProcessor INHERITED; |
| 113 }; | 119 }; |
| 114 | 120 |
| 115 | 121 |
| 116 GR_DEFINE_EFFECT_TEST(GrAlignedRectEffect); | 122 GR_DEFINE_EFFECT_TEST(GrAlignedRectEffect); |
| 117 | 123 |
| 118 GrEffect* GrAlignedRectEffect::TestCreate(SkRandom* random, | 124 GrEffect* GrAlignedRectEffect::TestCreate(SkRandom* random, |
| 119 GrContext* context, | 125 GrContext* context, |
| 120 const GrDrawTargetCaps&, | 126 const GrDrawTargetCaps&, |
| 121 GrTexture* textures[]) { | 127 GrTexture* textures[]) { |
| 122 return GrAlignedRectEffect::Create(); | 128 return GrAlignedRectEffect::Create(); |
| 123 } | 129 } |
| 124 | 130 |
| 125 /////////////////////////////////////////////////////////////////////////////// | 131 /////////////////////////////////////////////////////////////////////////////// |
| 126 class GrGLRectEffect; | 132 class GrGLRectEffect; |
| 127 | 133 |
| 128 /** | 134 /** |
| 129 * The output of this effect is a modulation of the input color and coverage | 135 * 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: | 136 * for an arbitrarily oriented rect. The rect is specified as: |
| 131 * Center of the rect | 137 * Center of the rect |
| 132 * Unit vector point down the height of the rect | 138 * Unit vector point down the height of the rect |
| 133 * Half width + 0.5 | 139 * Half width + 0.5 |
| 134 * Half height + 0.5 | 140 * Half height + 0.5 |
| 135 * The center and vector are stored in a vec4 varying ("RectEdge") with the | 141 * 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. | 142 * 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") | 143 * The munged width and height are stored in a vec2 varying ("WidthHeight") |
| 138 * with the width in x and the height in y. | 144 * with the width in x and the height in y. |
| 139 */ | 145 */ |
| 140 class GrRectEffect : public GrVertexEffect { | 146 |
| 147 class GrRectEffect : public GrGeometryProcessor { |
| 141 public: | 148 public: |
| 142 static GrEffect* Create() { | 149 static GrEffect* Create() { |
| 143 GR_CREATE_STATIC_EFFECT(gRectEffect, GrRectEffect, ()); | 150 GR_CREATE_STATIC_EFFECT(gRectEffect, GrRectEffect, ()); |
| 144 gRectEffect->ref(); | 151 gRectEffect->ref(); |
| 145 return gRectEffect; | 152 return gRectEffect; |
| 146 } | 153 } |
| 147 | 154 |
| 148 virtual ~GrRectEffect() {} | 155 virtual ~GrRectEffect() {} |
| 149 | 156 |
| 150 static const char* Name() { return "RectEdge"; } | 157 static const char* Name() { return "RectEdge"; } |
| 151 | 158 |
| 152 virtual void getConstantColorComponents(GrColor* color, | 159 virtual void getConstantColorComponents(GrColor* color, |
| 153 uint32_t* validFlags) const SK_OVERR
IDE { | 160 uint32_t* validFlags) const SK_OVERR
IDE { |
| 154 *validFlags = 0; | 161 *validFlags = 0; |
| 155 } | 162 } |
| 156 | 163 |
| 164 const GrShaderVar& aRectEdge() const { return fAttrRectEdge; } |
| 165 const GrShaderVar& aWidthHeight() const { return fAttrWidthHeight; } |
| 166 |
| 157 virtual const GrBackendEffectFactory& getFactory() const SK_OVERRIDE { | 167 virtual const GrBackendEffectFactory& getFactory() const SK_OVERRIDE { |
| 158 return GrTBackendEffectFactory<GrRectEffect>::getInstance(); | 168 return GrTBackendEffectFactory<GrRectEffect>::getInstance(); |
| 159 } | 169 } |
| 160 | 170 |
| 161 class GLEffect : public GrGLVertexEffect { | 171 class GLEffect : public GrGLGeometryProcessor { |
| 162 public: | 172 public: |
| 163 GLEffect(const GrBackendEffectFactory& factory, const GrDrawEffect&) | 173 GLEffect(const GrBackendEffectFactory& factory, const GrDrawEffect&) |
| 164 : INHERITED (factory) {} | 174 : INHERITED (factory) {} |
| 165 | 175 |
| 166 virtual void emitCode(GrGLFullProgramBuilder* builder, | 176 virtual void emitCode(GrGLFullProgramBuilder* builder, |
| 167 const GrDrawEffect& drawEffect, | 177 const GrDrawEffect& drawEffect, |
| 168 const GrEffectKey& key, | 178 const GrEffectKey& key, |
| 169 const char* outputColor, | 179 const char* outputColor, |
| 170 const char* inputColor, | 180 const char* inputColor, |
| 171 const TransformedCoordsArray&, | 181 const TransformedCoordsArray&, |
| 172 const TextureSamplerArray& samplers) SK_OVERRIDE { | 182 const TextureSamplerArray& samplers) SK_OVERRIDE { |
| 173 // setup the varying for the center point and the unit vector | 183 // setup the varying for the center point and the unit vector |
| 174 // that points down the height of the rect | 184 // that points down the height of the rect |
| 175 const char *vsRectEdgeName, *fsRectEdgeName; | 185 const char *vsRectEdgeName, *fsRectEdgeName; |
| 176 builder->addVarying(kVec4f_GrSLType, "RectEdge", | 186 builder->addVarying(kVec4f_GrSLType, "RectEdge", |
| 177 &vsRectEdgeName, &fsRectEdgeName); | 187 &vsRectEdgeName, &fsRectEdgeName); |
| 178 | 188 |
| 189 const GrRectEffect& rectEffect = drawEffect.castEffect<GrRectEffect>
(); |
| 179 GrGLVertexShaderBuilder* vsBuilder = builder->getVertexShaderBuilder
(); | 190 GrGLVertexShaderBuilder* vsBuilder = builder->getVertexShaderBuilder
(); |
| 180 const SkString* attr0Name = | 191 vsBuilder->codeAppendf("%s = %s;", vsRectEdgeName, rectEffect.aRectE
dge().c_str()); |
| 181 vsBuilder->getEffectAttributeName(drawEffect.getVertexAttribIndi
ces()[0]); | |
| 182 vsBuilder->codeAppendf("\t%s = %s;\n", vsRectEdgeName, attr0Name->c_
str()); | |
| 183 | 192 |
| 184 // setup the varying for width/2+.5 and height/2+.5 | 193 // setup the varying for width/2+.5 and height/2+.5 |
| 185 const char *vsWidthHeightName, *fsWidthHeightName; | 194 const char *vsWidthHeightName, *fsWidthHeightName; |
| 186 builder->addVarying(kVec2f_GrSLType, "WidthHeight", | 195 builder->addVarying(kVec2f_GrSLType, "WidthHeight", |
| 187 &vsWidthHeightName, &fsWidthHeightName); | 196 &vsWidthHeightName, &fsWidthHeightName); |
| 188 const SkString* attr1Name = | 197 vsBuilder->codeAppendf("%s = %s;", |
| 189 vsBuilder->getEffectAttributeName(drawEffect.getVertexAttribIndi
ces()[1]); | 198 vsWidthHeightName, |
| 190 vsBuilder->codeAppendf("\t%s = %s;\n", vsWidthHeightName, attr1Name-
>c_str()); | 199 rectEffect.aWidthHeight().c_str()); |
| 191 | 200 |
| 192 GrGLFragmentShaderBuilder* fsBuilder = builder->getFragmentShaderBui
lder(); | 201 GrGLFragmentShaderBuilder* fsBuilder = builder->getFragmentShaderBui
lder(); |
| 193 // TODO: compute all these offsets, spans, and scales in the VS | 202 // 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); | 203 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); | 204 fsBuilder->codeAppendf("\tfloat insetH = min(1.0, %s.y) - 0.5;\n", f
sWidthHeightName); |
| 196 fsBuilder->codeAppend("\tfloat outset = 0.5;\n"); | 205 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 | 206 // 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. | 207 // < 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"); | 208 fsBuilder->codeAppend("\tfloat spanW = insetW + outset;\n"); |
| 200 fsBuilder->codeAppend("\tfloat spanH = insetH + outset;\n"); | 209 fsBuilder->codeAppend("\tfloat spanH = insetH + outset;\n"); |
| (...skipping 22 matching lines...) Expand all Loading... |
| 223 | 232 |
| 224 fsBuilder->codeAppendf("\t%s = %s;\n", outputColor, | 233 fsBuilder->codeAppendf("\t%s = %s;\n", outputColor, |
| 225 (GrGLSLExpr4(inputColor) * GrGLSLExpr1("cover
age")).c_str()); | 234 (GrGLSLExpr4(inputColor) * GrGLSLExpr1("cover
age")).c_str()); |
| 226 } | 235 } |
| 227 | 236 |
| 228 static void GenKey(const GrDrawEffect&, const GrGLCaps&, GrEffectKeyBuil
der*) {} | 237 static void GenKey(const GrDrawEffect&, const GrGLCaps&, GrEffectKeyBuil
der*) {} |
| 229 | 238 |
| 230 virtual void setData(const GrGLProgramDataManager& pdman, const GrDrawEf
fect&) SK_OVERRIDE {} | 239 virtual void setData(const GrGLProgramDataManager& pdman, const GrDrawEf
fect&) SK_OVERRIDE {} |
| 231 | 240 |
| 232 private: | 241 private: |
| 233 typedef GrGLVertexEffect INHERITED; | 242 typedef GrGLGeometryProcessor INHERITED; |
| 234 }; | 243 }; |
| 235 | 244 |
| 236 | 245 |
| 246 |
| 237 private: | 247 private: |
| 238 GrRectEffect() : GrVertexEffect() { | 248 GrRectEffect() |
| 239 this->addVertexAttrib(kVec4f_GrSLType); | 249 : GrGeometryProcessor() |
| 240 this->addVertexAttrib(kVec2f_GrSLType); | 250 , fAttrRectEdge(this->addVertexAttrib(GrShaderVar("aRectEdge", |
| 251 kVec4f_GrSLType, |
| 252 GrShaderVar::kAttribut
e_TypeModifier))) |
| 253 , fAttrWidthHeight(this->addVertexAttrib( |
| 254 GrShaderVar("aWidthHeight", |
| 255 kVec2f_GrSLType, |
| 256 GrShaderVar::kAttribute_TypeModifier))) { |
| 241 this->setWillReadFragmentPosition(); | 257 this->setWillReadFragmentPosition(); |
| 242 } | 258 } |
| 243 | 259 |
| 244 virtual bool onIsEqual(const GrEffect&) const SK_OVERRIDE { return true; } | 260 virtual bool onIsEqual(const GrEffect&) const SK_OVERRIDE { return true; } |
| 245 | 261 |
| 262 const GrShaderVar& fAttrRectEdge; |
| 263 const GrShaderVar& fAttrWidthHeight; |
| 264 |
| 246 GR_DECLARE_EFFECT_TEST; | 265 GR_DECLARE_EFFECT_TEST; |
| 247 | 266 |
| 248 typedef GrVertexEffect INHERITED; | 267 typedef GrGeometryProcessor INHERITED; |
| 249 }; | 268 }; |
| 250 | 269 |
| 251 | 270 |
| 252 GR_DEFINE_EFFECT_TEST(GrRectEffect); | 271 GR_DEFINE_EFFECT_TEST(GrRectEffect); |
| 253 | 272 |
| 254 GrEffect* GrRectEffect::TestCreate(SkRandom* random, | 273 GrEffect* GrRectEffect::TestCreate(SkRandom* random, |
| 255 GrContext* context, | 274 GrContext* context, |
| 256 const GrDrawTargetCaps&, | 275 const GrDrawTargetCaps&, |
| 257 GrTexture* textures[]) { | 276 GrTexture* textures[]) { |
| 258 return GrRectEffect::Create(); | 277 return GrRectEffect::Create(); |
| (...skipping 380 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 639 | 658 |
| 640 GrDrawTarget::AutoReleaseGeometry geo(target, 4, 0); | 659 GrDrawTarget::AutoReleaseGeometry geo(target, 4, 0); |
| 641 if (!geo.succeeded()) { | 660 if (!geo.succeeded()) { |
| 642 GrPrintf("Failed to get space for vertices!\n"); | 661 GrPrintf("Failed to get space for vertices!\n"); |
| 643 return; | 662 return; |
| 644 } | 663 } |
| 645 | 664 |
| 646 RectVertex* verts = reinterpret_cast<RectVertex*>(geo.vertices()); | 665 RectVertex* verts = reinterpret_cast<RectVertex*>(geo.vertices()); |
| 647 | 666 |
| 648 GrEffect* effect = GrRectEffect::Create(); | 667 GrEffect* effect = GrRectEffect::Create(); |
| 649 static const int kRectAttrIndex = 1; | 668 drawState->setGeometryProcessor(effect)->unref(); |
| 650 static const int kWidthIndex = 2; | |
| 651 drawState->setGeometryProcessor(effect, kRectAttrIndex, kWidthIndex)->unref(
); | |
| 652 | 669 |
| 653 for (int i = 0; i < 4; ++i) { | 670 for (int i = 0; i < 4; ++i) { |
| 654 verts[i].fCenter = center; | 671 verts[i].fCenter = center; |
| 655 verts[i].fDir = dir; | 672 verts[i].fDir = dir; |
| 656 verts[i].fWidthHeight.fX = newWidth; | 673 verts[i].fWidthHeight.fX = newWidth; |
| 657 verts[i].fWidthHeight.fY = newHeight; | 674 verts[i].fWidthHeight.fY = newHeight; |
| 658 } | 675 } |
| 659 | 676 |
| 660 SkRect devRect; | 677 SkRect devRect; |
| 661 combinedMatrix.mapRect(&devRect, rect); | 678 combinedMatrix.mapRect(&devRect, rect); |
| (...skipping 27 matching lines...) Expand all Loading... |
| 689 | 706 |
| 690 GrDrawTarget::AutoReleaseGeometry geo(target, 4, 0); | 707 GrDrawTarget::AutoReleaseGeometry geo(target, 4, 0); |
| 691 if (!geo.succeeded()) { | 708 if (!geo.succeeded()) { |
| 692 GrPrintf("Failed to get space for vertices!\n"); | 709 GrPrintf("Failed to get space for vertices!\n"); |
| 693 return; | 710 return; |
| 694 } | 711 } |
| 695 | 712 |
| 696 AARectVertex* verts = reinterpret_cast<AARectVertex*>(geo.vertices()); | 713 AARectVertex* verts = reinterpret_cast<AARectVertex*>(geo.vertices()); |
| 697 | 714 |
| 698 GrEffect* effect = GrAlignedRectEffect::Create(); | 715 GrEffect* effect = GrAlignedRectEffect::Create(); |
| 699 static const int kOffsetIndex = 1; | 716 drawState->setGeometryProcessor(effect)->unref(); |
| 700 drawState->setGeometryProcessor(effect, kOffsetIndex)->unref(); | |
| 701 | 717 |
| 702 SkRect devRect; | 718 SkRect devRect; |
| 703 combinedMatrix.mapRect(&devRect, rect); | 719 combinedMatrix.mapRect(&devRect, rect); |
| 704 | 720 |
| 705 SkRect devBounds = { | 721 SkRect devBounds = { |
| 706 devRect.fLeft - SK_ScalarHalf, | 722 devRect.fLeft - SK_ScalarHalf, |
| 707 devRect.fTop - SK_ScalarHalf, | 723 devRect.fTop - SK_ScalarHalf, |
| 708 devRect.fRight + SK_ScalarHalf, | 724 devRect.fRight + SK_ScalarHalf, |
| 709 devRect.fBottom + SK_ScalarHalf | 725 devRect.fBottom + SK_ScalarHalf |
| 710 }; | 726 }; |
| (...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 949 // can't call mapRect for devInside since it calls sort | 965 // can't call mapRect for devInside since it calls sort |
| 950 combinedMatrix.mapPoints((SkPoint*)&devInside, (const SkPoint*)&rects[1], 2)
; | 966 combinedMatrix.mapPoints((SkPoint*)&devInside, (const SkPoint*)&rects[1], 2)
; |
| 951 | 967 |
| 952 if (devInside.isEmpty()) { | 968 if (devInside.isEmpty()) { |
| 953 this->fillAARect(gpu, target, devOutside, SkMatrix::I(), devOutside); | 969 this->fillAARect(gpu, target, devOutside, SkMatrix::I(), devOutside); |
| 954 return; | 970 return; |
| 955 } | 971 } |
| 956 | 972 |
| 957 this->geometryStrokeAARect(gpu, target, devOutside, devOutsideAssist, devIns
ide, true); | 973 this->geometryStrokeAARect(gpu, target, devOutside, devOutsideAssist, devIns
ide, true); |
| 958 } | 974 } |
| OLD | NEW |