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 return RuntimeEnabledFeatures::cssPaintAPIEnabled() ? value.getAsCSSImag eValue() : nullptr; | |
Justin Novosad
2016/09/28 17:12:33
Good idea to do it this way.
Justin Novosad
2016/09/28 17:17:35
Wait a second... To be correct, a TypeError except
Gleb Lanbin
2016/09/28 17:47:00
Done.
| |
870 if (value.isHTMLImageElement()) | 874 if (value.isHTMLImageElement()) |
871 return value.getAsHTMLImageElement(); | 875 return value.getAsHTMLImageElement(); |
872 if (value.isHTMLVideoElement()) | 876 if (value.isHTMLVideoElement()) |
873 return value.getAsHTMLVideoElement(); | 877 return value.getAsHTMLVideoElement(); |
874 if (value.isHTMLCanvasElement()) | 878 if (value.isHTMLCanvasElement()) |
875 return value.getAsHTMLCanvasElement(); | 879 return value.getAsHTMLCanvasElement(); |
876 if (value.isImageBitmap()) { | 880 if (value.isImageBitmap()) { |
877 if (static_cast<ImageBitmap*>(value.getAsImageBitmap())->isNeutered()) { | 881 if (static_cast<ImageBitmap*>(value.getAsImageBitmap())->isNeutered()) { |
878 exceptionState.throwDOMException(InvalidStateError, String::format(" The image source is detached")); | 882 exceptionState.throwDOMException(InvalidStateError, String::format(" The image source is detached")); |
879 return nullptr; | 883 return nullptr; |
(...skipping 829 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1709 ExpensiveCanvasHeuristicParameters::RadialGradientFillVariableCostPerAre a[index] * m_usageCounters.boundingBoxAreaFillType[BaseRenderingContext2D::Radia lGradientFillType]; | 1713 ExpensiveCanvasHeuristicParameters::RadialGradientFillVariableCostPerAre a[index] * m_usageCounters.boundingBoxAreaFillType[BaseRenderingContext2D::Radia lGradientFillType]; |
1710 | 1714 |
1711 float shadowAdjustment = | 1715 float shadowAdjustment = |
1712 ExpensiveCanvasHeuristicParameters::ShadowFixedCost[index] * m_usageCoun ters.numBlurredShadows + | 1716 ExpensiveCanvasHeuristicParameters::ShadowFixedCost[index] * m_usageCoun ters.numBlurredShadows + |
1713 ExpensiveCanvasHeuristicParameters::ShadowVariableCostPerAreaTimesShadow BlurSquared[index] * m_usageCounters.boundingBoxAreaTimesShadowBlurSquared; | 1717 ExpensiveCanvasHeuristicParameters::ShadowVariableCostPerAreaTimesShadow BlurSquared[index] * m_usageCounters.boundingBoxAreaTimesShadowBlurSquared; |
1714 | 1718 |
1715 return basicCostOfDrawCalls + fillTypeAdjustment + shadowAdjustment; | 1719 return basicCostOfDrawCalls + fillTypeAdjustment + shadowAdjustment; |
1716 } | 1720 } |
1717 | 1721 |
1718 } // namespace blink | 1722 } // namespace blink |
OLD | NEW |