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

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

Issue 2294383002: Make OffscreenCanvas a member of CanvasImageSource (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase 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/parser/CSSParser.h" 10 #include "core/css/parser/CSSParser.h"
11 #include "core/frame/ImageBitmap.h" 11 #include "core/frame/ImageBitmap.h"
12 #include "core/html/HTMLCanvasElement.h" 12 #include "core/html/HTMLCanvasElement.h"
13 #include "core/html/HTMLImageElement.h" 13 #include "core/html/HTMLImageElement.h"
14 #include "core/html/HTMLVideoElement.h" 14 #include "core/html/HTMLVideoElement.h"
15 #include "core/html/ImageData.h" 15 #include "core/html/ImageData.h"
16 #include "core/offscreencanvas/OffscreenCanvas.h"
16 #include "modules/canvas2d/CanvasGradient.h" 17 #include "modules/canvas2d/CanvasGradient.h"
17 #include "modules/canvas2d/CanvasPattern.h" 18 #include "modules/canvas2d/CanvasPattern.h"
18 #include "modules/canvas2d/CanvasStyle.h" 19 #include "modules/canvas2d/CanvasStyle.h"
19 #include "modules/canvas2d/Path2D.h" 20 #include "modules/canvas2d/Path2D.h"
20 #include "platform/Histogram.h" 21 #include "platform/Histogram.h"
21 #include "platform/geometry/FloatQuad.h" 22 #include "platform/geometry/FloatQuad.h"
22 #include "platform/graphics/Color.h" 23 #include "platform/graphics/Color.h"
23 #include "platform/graphics/ExpensiveCanvasHeuristicParameters.h" 24 #include "platform/graphics/ExpensiveCanvasHeuristicParameters.h"
24 #include "platform/graphics/Image.h" 25 #include "platform/graphics/Image.h"
25 #include "platform/graphics/ImageBuffer.h" 26 #include "platform/graphics/ImageBuffer.h"
(...skipping 845 matching lines...) Expand 10 before | Expand all | Expand 10 after
871 return value.getAsHTMLVideoElement(); 872 return value.getAsHTMLVideoElement();
872 if (value.isHTMLCanvasElement()) 873 if (value.isHTMLCanvasElement())
873 return value.getAsHTMLCanvasElement(); 874 return value.getAsHTMLCanvasElement();
874 if (value.isImageBitmap()) { 875 if (value.isImageBitmap()) {
875 if (static_cast<ImageBitmap*>(value.getAsImageBitmap())->isNeutered()) { 876 if (static_cast<ImageBitmap*>(value.getAsImageBitmap())->isNeutered()) {
876 exceptionState.throwDOMException(InvalidStateError, String::format(" The image source is detached")); 877 exceptionState.throwDOMException(InvalidStateError, String::format(" The image source is detached"));
877 return nullptr; 878 return nullptr;
878 } 879 }
879 return value.getAsImageBitmap(); 880 return value.getAsImageBitmap();
880 } 881 }
882 if (value.isOffscreenCanvas()) {
883 if (static_cast<OffscreenCanvas*>(value.getAsOffscreenCanvas())->isNeute red()) {
884 exceptionState.throwDOMException(InvalidStateError, String::format(" The image source is detached"));
885 return nullptr;
886 }
887 return value.getAsOffscreenCanvas();
888 }
881 ASSERT_NOT_REACHED(); 889 ASSERT_NOT_REACHED();
882 return nullptr; 890 return nullptr;
883 } 891 }
884 892
885 void BaseRenderingContext2D::drawImage(ExecutionContext* executionContext, const CanvasImageSourceUnion& imageSource, double x, double y, ExceptionState& except ionState) 893 void BaseRenderingContext2D::drawImage(ExecutionContext* executionContext, const CanvasImageSourceUnion& imageSource, double x, double y, ExceptionState& except ionState)
886 { 894 {
887 CanvasImageSource* imageSourceInternal = toImageSourceInternal(imageSource, exceptionState); 895 CanvasImageSource* imageSourceInternal = toImageSourceInternal(imageSource, exceptionState);
888 if (!imageSourceInternal) 896 if (!imageSourceInternal)
889 return; 897 return;
890 FloatSize defaultObjectSize(width(), height()); 898 FloatSize defaultObjectSize(width(), height());
(...skipping 809 matching lines...) Expand 10 before | Expand all | Expand 10 after
1700 ExpensiveCanvasHeuristicParameters::RadialGradientFillVariableCostPerAre a[index] * m_usageCounters.boundingBoxAreaFillType[BaseRenderingContext2D::Radia lGradientFillType]; 1708 ExpensiveCanvasHeuristicParameters::RadialGradientFillVariableCostPerAre a[index] * m_usageCounters.boundingBoxAreaFillType[BaseRenderingContext2D::Radia lGradientFillType];
1701 1709
1702 float shadowAdjustment = 1710 float shadowAdjustment =
1703 ExpensiveCanvasHeuristicParameters::ShadowFixedCost[index] * m_usageCoun ters.numBlurredShadows + 1711 ExpensiveCanvasHeuristicParameters::ShadowFixedCost[index] * m_usageCoun ters.numBlurredShadows +
1704 ExpensiveCanvasHeuristicParameters::ShadowVariableCostPerAreaTimesShadow BlurSquared[index] * m_usageCounters.boundingBoxAreaTimesShadowBlurSquared; 1712 ExpensiveCanvasHeuristicParameters::ShadowVariableCostPerAreaTimesShadow BlurSquared[index] * m_usageCounters.boundingBoxAreaTimesShadowBlurSquared;
1705 1713
1706 return basicCostOfDrawCalls + fillTypeAdjustment + shadowAdjustment; 1714 return basicCostOfDrawCalls + fillTypeAdjustment + shadowAdjustment;
1707 } 1715 }
1708 1716
1709 } // namespace blink 1717 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698