| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2013 Google Inc. | 2 * Copyright 2013 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 "GrOvalRenderer.h" | 8 #include "GrOvalRenderer.h" |
| 9 | 9 |
| 10 #include "GrBatch.h" | 10 #include "GrBatch.h" |
| (...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 119 fsBuilder->codeAppendf("float innerAlpha = clamp(%s.z * (d - %s.
w), 0.0, 1.0);", | 119 fsBuilder->codeAppendf("float innerAlpha = clamp(%s.z * (d - %s.
w), 0.0, 1.0);", |
| 120 v.fsIn(), v.fsIn()); | 120 v.fsIn(), v.fsIn()); |
| 121 fsBuilder->codeAppend("edgeAlpha *= innerAlpha;"); | 121 fsBuilder->codeAppend("edgeAlpha *= innerAlpha;"); |
| 122 } | 122 } |
| 123 | 123 |
| 124 fsBuilder->codeAppendf("%s = vec4(edgeAlpha);", args.fOutputCoverage
); | 124 fsBuilder->codeAppendf("%s = vec4(edgeAlpha);", args.fOutputCoverage
); |
| 125 } | 125 } |
| 126 | 126 |
| 127 static void GenKey(const GrGeometryProcessor& gp, | 127 static void GenKey(const GrGeometryProcessor& gp, |
| 128 const GrBatchTracker& bt, | 128 const GrBatchTracker& bt, |
| 129 const GrGLCaps&, | 129 const GrGLSLCaps&, |
| 130 GrProcessorKeyBuilder* b) { | 130 GrProcessorKeyBuilder* b) { |
| 131 const BatchTracker& local = bt.cast<BatchTracker>(); | 131 const BatchTracker& local = bt.cast<BatchTracker>(); |
| 132 const CircleEdgeEffect& circleEffect = gp.cast<CircleEdgeEffect>(); | 132 const CircleEdgeEffect& circleEffect = gp.cast<CircleEdgeEffect>(); |
| 133 uint16_t key = circleEffect.isStroked() ? 0x1 : 0x0; | 133 uint16_t key = circleEffect.isStroked() ? 0x1 : 0x0; |
| 134 key |= local.fUsesLocalCoords && gp.localMatrix().hasPerspective() ?
0x2 : 0x0; | 134 key |= local.fUsesLocalCoords && gp.localMatrix().hasPerspective() ?
0x2 : 0x0; |
| 135 key |= ComputePosKey(gp.viewMatrix()) << 2; | 135 key |= ComputePosKey(gp.viewMatrix()) << 2; |
| 136 b->add32(key << 16 | local.fInputColorType); | 136 b->add32(key << 16 | local.fInputColorType); |
| 137 } | 137 } |
| 138 | 138 |
| 139 virtual void setData(const GrGLProgramDataManager& pdman, | 139 virtual void setData(const GrGLProgramDataManager& pdman, |
| (...skipping 10 matching lines...) Expand all Loading... |
| 150 } | 150 } |
| 151 } | 151 } |
| 152 | 152 |
| 153 private: | 153 private: |
| 154 GrColor fColor; | 154 GrColor fColor; |
| 155 UniformHandle fColorUniform; | 155 UniformHandle fColorUniform; |
| 156 typedef GrGLGeometryProcessor INHERITED; | 156 typedef GrGLGeometryProcessor INHERITED; |
| 157 }; | 157 }; |
| 158 | 158 |
| 159 virtual void getGLProcessorKey(const GrBatchTracker& bt, | 159 virtual void getGLProcessorKey(const GrBatchTracker& bt, |
| 160 const GrGLCaps& caps, | 160 const GrGLSLCaps& caps, |
| 161 GrProcessorKeyBuilder* b) const override { | 161 GrProcessorKeyBuilder* b) const override { |
| 162 GLProcessor::GenKey(*this, bt, caps, b); | 162 GLProcessor::GenKey(*this, bt, caps, b); |
| 163 } | 163 } |
| 164 | 164 |
| 165 virtual GrGLPrimitiveProcessor* createGLInstance(const GrBatchTracker& bt, | 165 virtual GrGLPrimitiveProcessor* createGLInstance(const GrBatchTracker& bt, |
| 166 const GrGLCaps&) const over
ride { | 166 const GrGLSLCaps&) const ov
erride { |
| 167 return SkNEW_ARGS(GLProcessor, (*this, bt)); | 167 return SkNEW_ARGS(GLProcessor, (*this, bt)); |
| 168 } | 168 } |
| 169 | 169 |
| 170 void initBatchTracker(GrBatchTracker* bt, const GrPipelineInfo& init) const
override { | 170 void initBatchTracker(GrBatchTracker* bt, const GrPipelineInfo& init) const
override { |
| 171 BatchTracker* local = bt->cast<BatchTracker>(); | 171 BatchTracker* local = bt->cast<BatchTracker>(); |
| 172 local->fInputColorType = GetColorInputType(&local->fColor, this->color()
, init, false); | 172 local->fInputColorType = GetColorInputType(&local->fColor, this->color()
, init, false); |
| 173 local->fUsesLocalCoords = init.fUsesLocalCoords; | 173 local->fUsesLocalCoords = init.fUsesLocalCoords; |
| 174 } | 174 } |
| 175 | 175 |
| 176 bool onCanMakeEqual(const GrBatchTracker& m, | 176 bool onCanMakeEqual(const GrBatchTracker& m, |
| (...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 313 ellipseRadii.fsIn()); | 313 ellipseRadii.fsIn()); |
| 314 fsBuilder->codeAppend("invlen = inversesqrt(dot(grad, grad));"); | 314 fsBuilder->codeAppend("invlen = inversesqrt(dot(grad, grad));"); |
| 315 fsBuilder->codeAppend("edgeAlpha *= clamp(0.5+test*invlen, 0.0,
1.0);"); | 315 fsBuilder->codeAppend("edgeAlpha *= clamp(0.5+test*invlen, 0.0,
1.0);"); |
| 316 } | 316 } |
| 317 | 317 |
| 318 fsBuilder->codeAppendf("%s = vec4(edgeAlpha);", args.fOutputCoverage
); | 318 fsBuilder->codeAppendf("%s = vec4(edgeAlpha);", args.fOutputCoverage
); |
| 319 } | 319 } |
| 320 | 320 |
| 321 static void GenKey(const GrGeometryProcessor& gp, | 321 static void GenKey(const GrGeometryProcessor& gp, |
| 322 const GrBatchTracker& bt, | 322 const GrBatchTracker& bt, |
| 323 const GrGLCaps&, | 323 const GrGLSLCaps&, |
| 324 GrProcessorKeyBuilder* b) { | 324 GrProcessorKeyBuilder* b) { |
| 325 const BatchTracker& local = bt.cast<BatchTracker>(); | 325 const BatchTracker& local = bt.cast<BatchTracker>(); |
| 326 const EllipseEdgeEffect& ellipseEffect = gp.cast<EllipseEdgeEffect>(
); | 326 const EllipseEdgeEffect& ellipseEffect = gp.cast<EllipseEdgeEffect>(
); |
| 327 uint16_t key = ellipseEffect.isStroked() ? 0x1 : 0x0; | 327 uint16_t key = ellipseEffect.isStroked() ? 0x1 : 0x0; |
| 328 key |= local.fUsesLocalCoords && gp.localMatrix().hasPerspective() ?
0x2 : 0x0; | 328 key |= local.fUsesLocalCoords && gp.localMatrix().hasPerspective() ?
0x2 : 0x0; |
| 329 key |= ComputePosKey(gp.viewMatrix()) << 2; | 329 key |= ComputePosKey(gp.viewMatrix()) << 2; |
| 330 b->add32(key << 16 | local.fInputColorType); | 330 b->add32(key << 16 | local.fInputColorType); |
| 331 } | 331 } |
| 332 | 332 |
| 333 virtual void setData(const GrGLProgramDataManager& pdman, | 333 virtual void setData(const GrGLProgramDataManager& pdman, |
| (...skipping 11 matching lines...) Expand all Loading... |
| 345 } | 345 } |
| 346 | 346 |
| 347 private: | 347 private: |
| 348 GrColor fColor; | 348 GrColor fColor; |
| 349 UniformHandle fColorUniform; | 349 UniformHandle fColorUniform; |
| 350 | 350 |
| 351 typedef GrGLGeometryProcessor INHERITED; | 351 typedef GrGLGeometryProcessor INHERITED; |
| 352 }; | 352 }; |
| 353 | 353 |
| 354 virtual void getGLProcessorKey(const GrBatchTracker& bt, | 354 virtual void getGLProcessorKey(const GrBatchTracker& bt, |
| 355 const GrGLCaps& caps, | 355 const GrGLSLCaps& caps, |
| 356 GrProcessorKeyBuilder* b) const override { | 356 GrProcessorKeyBuilder* b) const override { |
| 357 GLProcessor::GenKey(*this, bt, caps, b); | 357 GLProcessor::GenKey(*this, bt, caps, b); |
| 358 } | 358 } |
| 359 | 359 |
| 360 virtual GrGLPrimitiveProcessor* createGLInstance(const GrBatchTracker& bt, | 360 virtual GrGLPrimitiveProcessor* createGLInstance(const GrBatchTracker& bt, |
| 361 const GrGLCaps&) const over
ride { | 361 const GrGLSLCaps&) const ov
erride { |
| 362 return SkNEW_ARGS(GLProcessor, (*this, bt)); | 362 return SkNEW_ARGS(GLProcessor, (*this, bt)); |
| 363 } | 363 } |
| 364 | 364 |
| 365 void initBatchTracker(GrBatchTracker* bt, const GrPipelineInfo& init) const
override { | 365 void initBatchTracker(GrBatchTracker* bt, const GrPipelineInfo& init) const
override { |
| 366 BatchTracker* local = bt->cast<BatchTracker>(); | 366 BatchTracker* local = bt->cast<BatchTracker>(); |
| 367 local->fInputColorType = GetColorInputType(&local->fColor, this->color()
, init, false); | 367 local->fInputColorType = GetColorInputType(&local->fColor, this->color()
, init, false); |
| 368 local->fUsesLocalCoords = init.fUsesLocalCoords; | 368 local->fUsesLocalCoords = init.fUsesLocalCoords; |
| 369 } | 369 } |
| 370 | 370 |
| 371 bool onCanMakeEqual(const GrBatchTracker& m, | 371 bool onCanMakeEqual(const GrBatchTracker& m, |
| (...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 528 offsets1.fsIn()); | 528 offsets1.fsIn()); |
| 529 fsBuilder->codeAppend("invlen = inversesqrt(dot(grad, grad));"); | 529 fsBuilder->codeAppend("invlen = inversesqrt(dot(grad, grad));"); |
| 530 fsBuilder->codeAppend("edgeAlpha *= clamp(0.5+test*invlen, 0.0,
1.0);"); | 530 fsBuilder->codeAppend("edgeAlpha *= clamp(0.5+test*invlen, 0.0,
1.0);"); |
| 531 } | 531 } |
| 532 | 532 |
| 533 fsBuilder->codeAppendf("%s = vec4(edgeAlpha);", args.fOutputCoverage
); | 533 fsBuilder->codeAppendf("%s = vec4(edgeAlpha);", args.fOutputCoverage
); |
| 534 } | 534 } |
| 535 | 535 |
| 536 static void GenKey(const GrGeometryProcessor& gp, | 536 static void GenKey(const GrGeometryProcessor& gp, |
| 537 const GrBatchTracker& bt, | 537 const GrBatchTracker& bt, |
| 538 const GrGLCaps&, | 538 const GrGLSLCaps&, |
| 539 GrProcessorKeyBuilder* b) { | 539 GrProcessorKeyBuilder* b) { |
| 540 const BatchTracker& local = bt.cast<BatchTracker>(); | 540 const BatchTracker& local = bt.cast<BatchTracker>(); |
| 541 const DIEllipseEdgeEffect& ellipseEffect = gp.cast<DIEllipseEdgeEffe
ct>(); | 541 const DIEllipseEdgeEffect& ellipseEffect = gp.cast<DIEllipseEdgeEffe
ct>(); |
| 542 uint16_t key = ellipseEffect.getMode(); | 542 uint16_t key = ellipseEffect.getMode(); |
| 543 key |= local.fUsesLocalCoords && gp.localMatrix().hasPerspective() ?
0x1 << 8 : 0x0; | 543 key |= local.fUsesLocalCoords && gp.localMatrix().hasPerspective() ?
0x1 << 8 : 0x0; |
| 544 key |= ComputePosKey(gp.viewMatrix()) << 9; | 544 key |= ComputePosKey(gp.viewMatrix()) << 9; |
| 545 b->add32(key << 16 | local.fInputColorType); | 545 b->add32(key << 16 | local.fInputColorType); |
| 546 } | 546 } |
| 547 | 547 |
| 548 virtual void setData(const GrGLProgramDataManager& pdman, | 548 virtual void setData(const GrGLProgramDataManager& pdman, |
| (...skipping 11 matching lines...) Expand all Loading... |
| 560 } | 560 } |
| 561 | 561 |
| 562 private: | 562 private: |
| 563 GrColor fColor; | 563 GrColor fColor; |
| 564 UniformHandle fColorUniform; | 564 UniformHandle fColorUniform; |
| 565 | 565 |
| 566 typedef GrGLGeometryProcessor INHERITED; | 566 typedef GrGLGeometryProcessor INHERITED; |
| 567 }; | 567 }; |
| 568 | 568 |
| 569 virtual void getGLProcessorKey(const GrBatchTracker& bt, | 569 virtual void getGLProcessorKey(const GrBatchTracker& bt, |
| 570 const GrGLCaps& caps, | 570 const GrGLSLCaps& caps, |
| 571 GrProcessorKeyBuilder* b) const override { | 571 GrProcessorKeyBuilder* b) const override { |
| 572 GLProcessor::GenKey(*this, bt, caps, b); | 572 GLProcessor::GenKey(*this, bt, caps, b); |
| 573 } | 573 } |
| 574 | 574 |
| 575 virtual GrGLPrimitiveProcessor* createGLInstance(const GrBatchTracker& bt, | 575 virtual GrGLPrimitiveProcessor* createGLInstance(const GrBatchTracker& bt, |
| 576 const GrGLCaps&) const over
ride { | 576 const GrGLSLCaps&) const ov
erride { |
| 577 return SkNEW_ARGS(GLProcessor, (*this, bt)); | 577 return SkNEW_ARGS(GLProcessor, (*this, bt)); |
| 578 } | 578 } |
| 579 | 579 |
| 580 void initBatchTracker(GrBatchTracker* bt, const GrPipelineInfo& init) const
override { | 580 void initBatchTracker(GrBatchTracker* bt, const GrPipelineInfo& init) const
override { |
| 581 BatchTracker* local = bt->cast<BatchTracker>(); | 581 BatchTracker* local = bt->cast<BatchTracker>(); |
| 582 local->fInputColorType = GetColorInputType(&local->fColor, this->color()
, init, false); | 582 local->fInputColorType = GetColorInputType(&local->fColor, this->color()
, init, false); |
| 583 local->fUsesLocalCoords = init.fUsesLocalCoords; | 583 local->fUsesLocalCoords = init.fUsesLocalCoords; |
| 584 } | 584 } |
| 585 | 585 |
| 586 bool onCanMakeEqual(const GrBatchTracker& m, | 586 bool onCanMakeEqual(const GrBatchTracker& m, |
| (...skipping 1635 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2222 geometry.fInnerXRadius = innerXRadius; | 2222 geometry.fInnerXRadius = innerXRadius; |
| 2223 geometry.fInnerYRadius = innerYRadius; | 2223 geometry.fInnerYRadius = innerYRadius; |
| 2224 geometry.fStroke = isStrokeOnly; | 2224 geometry.fStroke = isStrokeOnly; |
| 2225 geometry.fDevBounds = bounds; | 2225 geometry.fDevBounds = bounds; |
| 2226 | 2226 |
| 2227 SkAutoTUnref<GrBatch> batch(RRectEllipseRendererBatch::Create(geometry,
indexBuffer)); | 2227 SkAutoTUnref<GrBatch> batch(RRectEllipseRendererBatch::Create(geometry,
indexBuffer)); |
| 2228 target->drawBatch(pipelineBuilder, batch, &bounds); | 2228 target->drawBatch(pipelineBuilder, batch, &bounds); |
| 2229 } | 2229 } |
| 2230 return true; | 2230 return true; |
| 2231 } | 2231 } |
| OLD | NEW |