OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "modules/canvas2d/BaseRenderingContext2D.h" | 5 #include "modules/canvas2d/BaseRenderingContext2D.h" |
6 | 6 |
7 #include "bindings/core/v8/ExceptionMessages.h" | 7 #include "bindings/core/v8/ExceptionMessages.h" |
8 #include "bindings/core/v8/ExceptionState.h" | 8 #include "bindings/core/v8/ExceptionState.h" |
9 #include "bindings/core/v8/ExceptionStatePlaceholder.h" | 9 #include "bindings/core/v8/ExceptionStatePlaceholder.h" |
10 #include "core/css/parser/CSSParser.h" | 10 #include "core/css/parser/CSSParser.h" |
(...skipping 539 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
550 bool BaseRenderingContext2D::isFullCanvasCompositeMode(SkXfermode::Mode op) | 550 bool BaseRenderingContext2D::isFullCanvasCompositeMode(SkXfermode::Mode op) |
551 { | 551 { |
552 // See 4.8.11.1.3 Compositing | 552 // See 4.8.11.1.3 Compositing |
553 // CompositeSourceAtop and CompositeDestinationOut are not listed here as th
e platforms already | 553 // CompositeSourceAtop and CompositeDestinationOut are not listed here as th
e platforms already |
554 // implement the specification's behavior. | 554 // implement the specification's behavior. |
555 return op == SkXfermode::kSrcIn_Mode || op == SkXfermode::kSrcOut_Mode || op
== SkXfermode::kDstIn_Mode || op == SkXfermode::kDstATop_Mode; | 555 return op == SkXfermode::kSrcIn_Mode || op == SkXfermode::kSrcOut_Mode || op
== SkXfermode::kDstIn_Mode || op == SkXfermode::kDstATop_Mode; |
556 } | 556 } |
557 | 557 |
558 static bool isPathExpensive(const Path& path) | 558 static bool isPathExpensive(const Path& path) |
559 { | 559 { |
560 const SkPath& skPath = path.skPath(); | 560 const SkPath& skPath = path.getSkPath(); |
561 if (ExpensiveCanvasHeuristicParameters::ConcavePathsAreExpensive && !skPath.
isConvex()) | 561 if (ExpensiveCanvasHeuristicParameters::ConcavePathsAreExpensive && !skPath.
isConvex()) |
562 return true; | 562 return true; |
563 | 563 |
564 if (skPath.countPoints() > ExpensiveCanvasHeuristicParameters::ExpensivePath
PointCount) | 564 if (skPath.countPoints() > ExpensiveCanvasHeuristicParameters::ExpensivePath
PointCount) |
565 return true; | 565 return true; |
566 | 566 |
567 return false; | 567 return false; |
568 } | 568 } |
569 | 569 |
570 void BaseRenderingContext2D::drawPathInternal(const Path& path, CanvasRenderingC
ontext2DState::PaintType paintType, SkPath::FillType fillType) | 570 void BaseRenderingContext2D::drawPathInternal(const Path& path, CanvasRenderingC
ontext2DState::PaintType paintType, SkPath::FillType fillType) |
571 { | 571 { |
572 if (path.isEmpty()) | 572 if (path.isEmpty()) |
573 return; | 573 return; |
574 | 574 |
575 SkPath skPath = path.skPath(); | 575 SkPath skPath = path.getSkPath(); |
576 FloatRect bounds = path.boundingRect(); | 576 FloatRect bounds = path.boundingRect(); |
577 skPath.setFillType(fillType); | 577 skPath.setFillType(fillType); |
578 | 578 |
579 if (paintType == CanvasRenderingContext2DState::StrokePaintType) | 579 if (paintType == CanvasRenderingContext2DState::StrokePaintType) |
580 inflateStrokeRect(bounds); | 580 inflateStrokeRect(bounds); |
581 | 581 |
582 if (!drawingCanvas()) | 582 if (!drawingCanvas()) |
583 return; | 583 return; |
584 | 584 |
585 if (draw( | 585 if (draw( |
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
690 void BaseRenderingContext2D::clipInternal(const Path& path, const String& windin
gRuleString) | 690 void BaseRenderingContext2D::clipInternal(const Path& path, const String& windin
gRuleString) |
691 { | 691 { |
692 SkCanvas* c = drawingCanvas(); | 692 SkCanvas* c = drawingCanvas(); |
693 if (!c) { | 693 if (!c) { |
694 return; | 694 return; |
695 } | 695 } |
696 if (!state().isTransformInvertible()) { | 696 if (!state().isTransformInvertible()) { |
697 return; | 697 return; |
698 } | 698 } |
699 | 699 |
700 SkPath skPath = path.skPath(); | 700 SkPath skPath = path.getSkPath(); |
701 skPath.setFillType(parseWinding(windingRuleString)); | 701 skPath.setFillType(parseWinding(windingRuleString)); |
702 modifiableState().clipPath(skPath, m_clipAntialiasing); | 702 modifiableState().clipPath(skPath, m_clipAntialiasing); |
703 c->clipPath(skPath, SkRegion::kIntersect_Op, m_clipAntialiasing == AntiAlias
ed); | 703 c->clipPath(skPath, SkRegion::kIntersect_Op, m_clipAntialiasing == AntiAlias
ed); |
704 if (ExpensiveCanvasHeuristicParameters::ComplexClipsAreExpensive && !skPath.
isRect(0) && hasImageBuffer()) { | 704 if (ExpensiveCanvasHeuristicParameters::ComplexClipsAreExpensive && !skPath.
isRect(0) && hasImageBuffer()) { |
705 imageBuffer()->setHasExpensiveOp(); | 705 imageBuffer()->setHasExpensiveOp(); |
706 } | 706 } |
707 } | 707 } |
708 | 708 |
709 void BaseRenderingContext2D::clip(const String& windingRuleString) | 709 void BaseRenderingContext2D::clip(const String& windingRuleString) |
710 { | 710 { |
(...skipping 663 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1374 | 1374 |
1375 imageBuffer()->willOverwriteCanvas(); | 1375 imageBuffer()->willOverwriteCanvas(); |
1376 } | 1376 } |
1377 | 1377 |
1378 DEFINE_TRACE(BaseRenderingContext2D) | 1378 DEFINE_TRACE(BaseRenderingContext2D) |
1379 { | 1379 { |
1380 visitor->trace(m_stateStack); | 1380 visitor->trace(m_stateStack); |
1381 } | 1381 } |
1382 | 1382 |
1383 } // namespace blink | 1383 } // namespace blink |
OLD | NEW |