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 "GrEffect.h" | 10 #include "GrEffect.h" |
(...skipping 313 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
324 const SkStrokeRec& stroke) | 324 const SkStrokeRec& stroke) |
325 { | 325 { |
326 GrDrawState* drawState = target->drawState(); | 326 GrDrawState* drawState = target->drawState(); |
327 | 327 |
328 const SkMatrix& vm = drawState->getViewMatrix(); | 328 const SkMatrix& vm = drawState->getViewMatrix(); |
329 GrPoint center = GrPoint::Make(circle.centerX(), circle.centerY()); | 329 GrPoint center = GrPoint::Make(circle.centerX(), circle.centerY()); |
330 vm.mapPoints(¢er, 1); | 330 vm.mapPoints(¢er, 1); |
331 SkScalar radius = vm.mapRadius(SkScalarHalf(circle.width())); | 331 SkScalar radius = vm.mapRadius(SkScalarHalf(circle.width())); |
332 SkScalar strokeWidth = vm.mapRadius(stroke.getWidth()); | 332 SkScalar strokeWidth = vm.mapRadius(stroke.getWidth()); |
333 | 333 |
334 GrDrawState::AutoDeviceCoordDraw adcd(drawState); | 334 GrDrawState::AutoViewMatrixRestore avmr; |
335 if (!adcd.succeeded()) { | 335 if (!avmr.setIdentity(drawState)) { |
336 return; | 336 return; |
337 } | 337 } |
338 | 338 |
339 drawState->setVertexAttribs<gCircleVertexAttribs>(SK_ARRAY_COUNT(gCircleVert
exAttribs)); | 339 drawState->setVertexAttribs<gCircleVertexAttribs>(SK_ARRAY_COUNT(gCircleVert
exAttribs)); |
340 GrAssert(sizeof(CircleVertex) == drawState->getVertexSize()); | 340 GrAssert(sizeof(CircleVertex) == drawState->getVertexSize()); |
341 | 341 |
342 GrDrawTarget::AutoReleaseGeometry geo(target, 4, 0); | 342 GrDrawTarget::AutoReleaseGeometry geo(target, 4, 0); |
343 if (!geo.succeeded()) { | 343 if (!geo.succeeded()) { |
344 GrPrintf("Failed to get space for vertices!\n"); | 344 GrPrintf("Failed to get space for vertices!\n"); |
345 return; | 345 return; |
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
486 if (isStroked) { | 486 if (isStroked) { |
487 innerXRadius = xRadius - scaledStroke.fX; | 487 innerXRadius = xRadius - scaledStroke.fX; |
488 innerYRadius = yRadius - scaledStroke.fY; | 488 innerYRadius = yRadius - scaledStroke.fY; |
489 isStroked = (innerXRadius > 0 && innerYRadius > 0); | 489 isStroked = (innerXRadius > 0 && innerYRadius > 0); |
490 } | 490 } |
491 | 491 |
492 xRadius += scaledStroke.fX; | 492 xRadius += scaledStroke.fX; |
493 yRadius += scaledStroke.fY; | 493 yRadius += scaledStroke.fY; |
494 } | 494 } |
495 | 495 |
496 GrDrawState::AutoDeviceCoordDraw adcd(drawState); | 496 GrDrawState::AutoViewMatrixRestore avmr; |
497 if (!adcd.succeeded()) { | 497 if (!avmr.setIdentity(drawState)) { |
498 return false; | 498 return false; |
499 } | 499 } |
500 | 500 |
501 drawState->setVertexAttribs<gEllipseVertexAttribs>(SK_ARRAY_COUNT(gEllipseVe
rtexAttribs)); | 501 drawState->setVertexAttribs<gEllipseVertexAttribs>(SK_ARRAY_COUNT(gEllipseVe
rtexAttribs)); |
502 GrAssert(sizeof(EllipseVertex) == drawState->getVertexSize()); | 502 GrAssert(sizeof(EllipseVertex) == drawState->getVertexSize()); |
503 | 503 |
504 GrDrawTarget::AutoReleaseGeometry geo(target, 4, 0); | 504 GrDrawTarget::AutoReleaseGeometry geo(target, 4, 0); |
505 if (!geo.succeeded()) { | 505 if (!geo.succeeded()) { |
506 GrPrintf("Failed to get space for vertices!\n"); | 506 GrPrintf("Failed to get space for vertices!\n"); |
507 return false; | 507 return false; |
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
643 scaledStroke.fX = SkScalarAbs(strokeWidth*(vm[SkMatrix::kMScaleX] + vm[SkMat
rix::kMSkewY])); | 643 scaledStroke.fX = SkScalarAbs(strokeWidth*(vm[SkMatrix::kMScaleX] + vm[SkMat
rix::kMSkewY])); |
644 scaledStroke.fY = SkScalarAbs(strokeWidth*(vm[SkMatrix::kMSkewX] + vm[SkMatr
ix::kMScaleY])); | 644 scaledStroke.fY = SkScalarAbs(strokeWidth*(vm[SkMatrix::kMSkewX] + vm[SkMatr
ix::kMScaleY])); |
645 | 645 |
646 // if half of strokewidth is greater than radius, we don't handle that right
now | 646 // if half of strokewidth is greater than radius, we don't handle that right
now |
647 if (SK_ScalarHalf*scaledStroke.fX >= xRadius || SK_ScalarHalf*scaledStroke.f
Y >= yRadius) { | 647 if (SK_ScalarHalf*scaledStroke.fX >= xRadius || SK_ScalarHalf*scaledStroke.f
Y >= yRadius) { |
648 return false; | 648 return false; |
649 } | 649 } |
650 | 650 |
651 // reset to device coordinates | 651 // reset to device coordinates |
652 GrDrawState* drawState = target->drawState(); | 652 GrDrawState* drawState = target->drawState(); |
653 GrDrawState::AutoDeviceCoordDraw adcd(drawState); | 653 GrDrawState::AutoViewMatrixRestore avmr; |
654 if (!adcd.succeeded()) { | 654 if (!avmr.setIdentity(drawState)) { |
655 return false; | 655 return false; |
656 } | 656 } |
657 | 657 |
658 bool isStroked = (SkStrokeRec::kStroke_Style == style || SkStrokeRec::kHairl
ine_Style == style); | 658 bool isStroked = (SkStrokeRec::kStroke_Style == style || SkStrokeRec::kHairl
ine_Style == style); |
659 | 659 |
660 enum { | 660 enum { |
661 // the edge effects share this stage with glyph rendering | 661 // the edge effects share this stage with glyph rendering |
662 // (kGlyphMaskStage in GrTextContext) && SW path rendering | 662 // (kGlyphMaskStage in GrTextContext) && SW path rendering |
663 // (kPathMaskStage in GrSWMaskHelper) | 663 // (kPathMaskStage in GrSWMaskHelper) |
664 kEdgeEffectStage = GrPaint::kTotalStages, | 664 kEdgeEffectStage = GrPaint::kTotalStages, |
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
861 } | 861 } |
862 | 862 |
863 // drop out the middle quad if we're stroked | 863 // drop out the middle quad if we're stroked |
864 int indexCnt = isStroked ? GR_ARRAY_COUNT(gRRectIndices)-6 : GR_ARRAY_CO
UNT(gRRectIndices); | 864 int indexCnt = isStroked ? GR_ARRAY_COUNT(gRRectIndices)-6 : GR_ARRAY_CO
UNT(gRRectIndices); |
865 target->setIndexSourceToBuffer(indexBuffer); | 865 target->setIndexSourceToBuffer(indexBuffer); |
866 target->drawIndexed(kTriangles_GrPrimitiveType, 0, 0, 16, indexCnt, &bou
nds); | 866 target->drawIndexed(kTriangles_GrPrimitiveType, 0, 0, 16, indexCnt, &bou
nds); |
867 } | 867 } |
868 | 868 |
869 return true; | 869 return true; |
870 } | 870 } |
OLD | NEW |