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/cssom/CSSURLImageValue.h" |
10 #include "core/css/parser/CSSParser.h" | 11 #include "core/css/parser/CSSParser.h" |
11 #include "core/frame/ImageBitmap.h" | 12 #include "core/frame/ImageBitmap.h" |
12 #include "core/html/HTMLCanvasElement.h" | 13 #include "core/html/HTMLCanvasElement.h" |
13 #include "core/html/HTMLImageElement.h" | 14 #include "core/html/HTMLImageElement.h" |
14 #include "core/html/HTMLVideoElement.h" | 15 #include "core/html/HTMLVideoElement.h" |
15 #include "core/html/ImageData.h" | 16 #include "core/html/ImageData.h" |
16 #include "core/offscreencanvas/OffscreenCanvas.h" | 17 #include "core/offscreencanvas/OffscreenCanvas.h" |
17 #include "modules/canvas2d/CanvasGradient.h" | 18 #include "modules/canvas2d/CanvasGradient.h" |
18 #include "modules/canvas2d/CanvasPattern.h" | 19 #include "modules/canvas2d/CanvasPattern.h" |
19 #include "modules/canvas2d/CanvasStyle.h" | 20 #include "modules/canvas2d/CanvasStyle.h" |
20 #include "modules/canvas2d/Path2D.h" | 21 #include "modules/canvas2d/Path2D.h" |
21 #include "platform/Histogram.h" | 22 #include "platform/Histogram.h" |
| 23 #include "platform/RuntimeEnabledFeatures.h" |
22 #include "platform/geometry/FloatQuad.h" | 24 #include "platform/geometry/FloatQuad.h" |
23 #include "platform/graphics/Color.h" | 25 #include "platform/graphics/Color.h" |
24 #include "platform/graphics/ExpensiveCanvasHeuristicParameters.h" | 26 #include "platform/graphics/ExpensiveCanvasHeuristicParameters.h" |
25 #include "platform/graphics/Image.h" | 27 #include "platform/graphics/Image.h" |
26 #include "platform/graphics/ImageBuffer.h" | 28 #include "platform/graphics/ImageBuffer.h" |
27 #include "platform/graphics/StrokeData.h" | 29 #include "platform/graphics/StrokeData.h" |
28 #include "platform/graphics/skia/SkiaUtils.h" | 30 #include "platform/graphics/skia/SkiaUtils.h" |
29 | 31 |
30 namespace blink { | 32 namespace blink { |
31 | 33 |
(...skipping 828 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
860 srcRect->intersect(imageRect); | 862 srcRect->intersect(imageRect); |
861 | 863 |
862 // To clip the destination rectangle in the same proportion, transform the c
lipped src rect | 864 // To clip the destination rectangle in the same proportion, transform the c
lipped src rect |
863 *dstRect = *srcRect; | 865 *dstRect = *srcRect; |
864 dstRect->scale(scale.width(), scale.height()); | 866 dstRect->scale(scale.width(), scale.height()); |
865 dstRect->move(offset); | 867 dstRect->move(offset); |
866 } | 868 } |
867 | 869 |
868 static inline CanvasImageSource* toImageSourceInternal(const CanvasImageSourceUn
ion& value, ExceptionState& exceptionState) | 870 static inline CanvasImageSource* toImageSourceInternal(const CanvasImageSourceUn
ion& value, ExceptionState& exceptionState) |
869 { | 871 { |
| 872 if (value.isCSSImageValue()) { |
| 873 if (RuntimeEnabledFeatures::cssPaintAPIEnabled()) |
| 874 return value.getAsCSSImageValue(); |
| 875 exceptionState.throwTypeError("CSSImageValue is not yet supported"); |
| 876 return nullptr; |
| 877 } |
870 if (value.isHTMLImageElement()) | 878 if (value.isHTMLImageElement()) |
871 return value.getAsHTMLImageElement(); | 879 return value.getAsHTMLImageElement(); |
872 if (value.isHTMLVideoElement()) | 880 if (value.isHTMLVideoElement()) |
873 return value.getAsHTMLVideoElement(); | 881 return value.getAsHTMLVideoElement(); |
874 if (value.isHTMLCanvasElement()) | 882 if (value.isHTMLCanvasElement()) |
875 return value.getAsHTMLCanvasElement(); | 883 return value.getAsHTMLCanvasElement(); |
876 if (value.isImageBitmap()) { | 884 if (value.isImageBitmap()) { |
877 if (static_cast<ImageBitmap*>(value.getAsImageBitmap())->isNeutered()) { | 885 if (static_cast<ImageBitmap*>(value.getAsImageBitmap())->isNeutered()) { |
878 exceptionState.throwDOMException(InvalidStateError, String::format("
The image source is detached")); | 886 exceptionState.throwDOMException(InvalidStateError, String::format("
The image source is detached")); |
879 return nullptr; | 887 return nullptr; |
(...skipping 848 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1728 ExpensiveCanvasHeuristicParameters::RadialGradientFillVariableCostPerAre
a[index] * m_usageCounters.boundingBoxAreaFillType[BaseRenderingContext2D::Radia
lGradientFillType]; | 1736 ExpensiveCanvasHeuristicParameters::RadialGradientFillVariableCostPerAre
a[index] * m_usageCounters.boundingBoxAreaFillType[BaseRenderingContext2D::Radia
lGradientFillType]; |
1729 | 1737 |
1730 float shadowAdjustment = | 1738 float shadowAdjustment = |
1731 ExpensiveCanvasHeuristicParameters::ShadowFixedCost[index] * m_usageCoun
ters.numBlurredShadows + | 1739 ExpensiveCanvasHeuristicParameters::ShadowFixedCost[index] * m_usageCoun
ters.numBlurredShadows + |
1732 ExpensiveCanvasHeuristicParameters::ShadowVariableCostPerAreaTimesShadow
BlurSquared[index] * m_usageCounters.boundingBoxAreaTimesShadowBlurSquared; | 1740 ExpensiveCanvasHeuristicParameters::ShadowVariableCostPerAreaTimesShadow
BlurSquared[index] * m_usageCounters.boundingBoxAreaTimesShadowBlurSquared; |
1733 | 1741 |
1734 return basicCostOfDrawCalls + fillTypeAdjustment + shadowAdjustment; | 1742 return basicCostOfDrawCalls + fillTypeAdjustment + shadowAdjustment; |
1735 } | 1743 } |
1736 | 1744 |
1737 } // namespace blink | 1745 } // namespace blink |
OLD | NEW |