Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1)

Side by Side Diff: third_party/WebKit/Source/modules/canvas2d/BaseRenderingContext2D.cpp

Issue 2723093004: Adds SVGImageElement as a CanvasImageSource (Closed)
Patch Set: y Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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/ScriptState.h" 9 #include "bindings/core/v8/ScriptState.h"
10 #include "core/css/cssom/CSSURLImageValue.h" 10 #include "core/css/cssom/CSSURLImageValue.h"
11 #include "core/css/parser/CSSParser.h" 11 #include "core/css/parser/CSSParser.h"
12 #include "core/frame/ImageBitmap.h" 12 #include "core/frame/ImageBitmap.h"
13 #include "core/html/HTMLCanvasElement.h" 13 #include "core/html/HTMLCanvasElement.h"
14 #include "core/html/HTMLImageElement.h" 14 #include "core/html/HTMLImageElement.h"
15 #include "core/html/HTMLVideoElement.h" 15 #include "core/html/HTMLVideoElement.h"
16 #include "core/html/ImageData.h" 16 #include "core/html/ImageData.h"
17 #include "core/offscreencanvas/OffscreenCanvas.h" 17 #include "core/offscreencanvas/OffscreenCanvas.h"
18 #include "core/svg/SVGImageElement.h"
18 #include "modules/canvas2d/CanvasGradient.h" 19 #include "modules/canvas2d/CanvasGradient.h"
19 #include "modules/canvas2d/CanvasPattern.h" 20 #include "modules/canvas2d/CanvasPattern.h"
20 #include "modules/canvas2d/CanvasStyle.h" 21 #include "modules/canvas2d/CanvasStyle.h"
21 #include "modules/canvas2d/Path2D.h" 22 #include "modules/canvas2d/Path2D.h"
22 #include "platform/Histogram.h" 23 #include "platform/Histogram.h"
23 #include "platform/RuntimeEnabledFeatures.h" 24 #include "platform/RuntimeEnabledFeatures.h"
24 #include "platform/geometry/FloatQuad.h" 25 #include "platform/geometry/FloatQuad.h"
25 #include "platform/graphics/Color.h" 26 #include "platform/graphics/Color.h"
26 #include "platform/graphics/ExpensiveCanvasHeuristicParameters.h" 27 #include "platform/graphics/ExpensiveCanvasHeuristicParameters.h"
27 #include "platform/graphics/Image.h" 28 #include "platform/graphics/Image.h"
(...skipping 897 matching lines...) Expand 10 before | Expand all | Expand 10 after
925 } 926 }
926 if (value.isOffscreenCanvas()) { 927 if (value.isOffscreenCanvas()) {
927 if (static_cast<OffscreenCanvas*>(value.getAsOffscreenCanvas()) 928 if (static_cast<OffscreenCanvas*>(value.getAsOffscreenCanvas())
928 ->isNeutered()) { 929 ->isNeutered()) {
929 exceptionState.throwDOMException( 930 exceptionState.throwDOMException(
930 InvalidStateError, String::format("The image source is detached")); 931 InvalidStateError, String::format("The image source is detached"));
931 return nullptr; 932 return nullptr;
932 } 933 }
933 return value.getAsOffscreenCanvas(); 934 return value.getAsOffscreenCanvas();
934 } 935 }
936 if (value.isSVGImageElement()) {
937 SVGImageElement* image = value.getAsSVGImageElement();
938 return image;
939 }
935 NOTREACHED(); 940 NOTREACHED();
936 return nullptr; 941 return nullptr;
937 } 942 }
938 943
939 void BaseRenderingContext2D::drawImage( 944 void BaseRenderingContext2D::drawImage(
940 ScriptState* scriptState, 945 ScriptState* scriptState,
941 const CanvasImageSourceUnion& imageSource, 946 const CanvasImageSourceUnion& imageSource,
942 double x, 947 double x,
943 double y, 948 double y,
944 ExceptionState& exceptionState) { 949 ExceptionState& exceptionState) {
(...skipping 1077 matching lines...) Expand 10 before | Expand all | Expand 10 after
2022 ExpensiveCanvasHeuristicParameters::ShadowFixedCost[index] * 2027 ExpensiveCanvasHeuristicParameters::ShadowFixedCost[index] *
2023 m_usageCounters.numBlurredShadows + 2028 m_usageCounters.numBlurredShadows +
2024 ExpensiveCanvasHeuristicParameters:: 2029 ExpensiveCanvasHeuristicParameters::
2025 ShadowVariableCostPerAreaTimesShadowBlurSquared[index] * 2030 ShadowVariableCostPerAreaTimesShadowBlurSquared[index] *
2026 m_usageCounters.boundingBoxAreaTimesShadowBlurSquared; 2031 m_usageCounters.boundingBoxAreaTimesShadowBlurSquared;
2027 2032
2028 return basicCostOfDrawCalls + fillTypeAdjustment + shadowAdjustment; 2033 return basicCostOfDrawCalls + fillTypeAdjustment + shadowAdjustment;
2029 } 2034 }
2030 2035
2031 } // namespace blink 2036 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698