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

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

Issue 2351363002: Make CSSStyleImageValue a member of CanvasImageSource. (Closed)
Patch Set: Created 4 years, 3 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/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"
(...skipping 838 matching lines...) Expand 10 before | Expand all | Expand 10 after
858 srcRect->intersect(imageRect); 859 srcRect->intersect(imageRect);
859 860
860 // To clip the destination rectangle in the same proportion, transform the c lipped src rect 861 // To clip the destination rectangle in the same proportion, transform the c lipped src rect
861 *dstRect = *srcRect; 862 *dstRect = *srcRect;
862 dstRect->scale(scale.width(), scale.height()); 863 dstRect->scale(scale.width(), scale.height());
863 dstRect->move(offset); 864 dstRect->move(offset);
864 } 865 }
865 866
866 static inline CanvasImageSource* toImageSourceInternal(const CanvasImageSourceUn ion& value, ExceptionState& exceptionState) 867 static inline CanvasImageSource* toImageSourceInternal(const CanvasImageSourceUn ion& value, ExceptionState& exceptionState)
867 { 868 {
869 if (value.isCSSImageValue())
ikilpatrick 2016/09/27 18:06:00 it might be worth making this conditional on CSSPa
Gleb Lanbin 2016/09/28 16:58:22 Done.
870 return value.getAsCSSImageValue();
868 if (value.isHTMLImageElement()) 871 if (value.isHTMLImageElement())
869 return value.getAsHTMLImageElement(); 872 return value.getAsHTMLImageElement();
870 if (value.isHTMLVideoElement()) 873 if (value.isHTMLVideoElement())
871 return value.getAsHTMLVideoElement(); 874 return value.getAsHTMLVideoElement();
872 if (value.isHTMLCanvasElement()) 875 if (value.isHTMLCanvasElement())
873 return value.getAsHTMLCanvasElement(); 876 return value.getAsHTMLCanvasElement();
874 if (value.isImageBitmap()) { 877 if (value.isImageBitmap()) {
875 if (static_cast<ImageBitmap*>(value.getAsImageBitmap())->isNeutered()) { 878 if (static_cast<ImageBitmap*>(value.getAsImageBitmap())->isNeutered()) {
876 exceptionState.throwDOMException(InvalidStateError, String::format(" The image source is detached")); 879 exceptionState.throwDOMException(InvalidStateError, String::format(" The image source is detached"));
877 return nullptr; 880 return nullptr;
(...skipping 829 matching lines...) Expand 10 before | Expand all | Expand 10 after
1707 ExpensiveCanvasHeuristicParameters::RadialGradientFillVariableCostPerAre a[index] * m_usageCounters.boundingBoxAreaFillType[BaseRenderingContext2D::Radia lGradientFillType]; 1710 ExpensiveCanvasHeuristicParameters::RadialGradientFillVariableCostPerAre a[index] * m_usageCounters.boundingBoxAreaFillType[BaseRenderingContext2D::Radia lGradientFillType];
1708 1711
1709 float shadowAdjustment = 1712 float shadowAdjustment =
1710 ExpensiveCanvasHeuristicParameters::ShadowFixedCost[index] * m_usageCoun ters.numBlurredShadows + 1713 ExpensiveCanvasHeuristicParameters::ShadowFixedCost[index] * m_usageCoun ters.numBlurredShadows +
1711 ExpensiveCanvasHeuristicParameters::ShadowVariableCostPerAreaTimesShadow BlurSquared[index] * m_usageCounters.boundingBoxAreaTimesShadowBlurSquared; 1714 ExpensiveCanvasHeuristicParameters::ShadowVariableCostPerAreaTimesShadow BlurSquared[index] * m_usageCounters.boundingBoxAreaTimesShadowBlurSquared;
1712 1715
1713 return basicCostOfDrawCalls + fillTypeAdjustment + shadowAdjustment; 1716 return basicCostOfDrawCalls + fillTypeAdjustment + shadowAdjustment;
1714 } 1717 }
1715 1718
1716 } // namespace blink 1719 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698