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/cssom/CSSURLImageValue.h" |
(...skipping 1060 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1071 imagePaint.setImageFilter(nullptr); | 1071 imagePaint.setImageFilter(nullptr); |
1072 } | 1072 } |
1073 | 1073 |
1074 if (!imageSmoothingEnabled() && | 1074 if (!imageSmoothingEnabled() && |
1075 isDrawScalingDown(srcRect, dstRect, state().transform().xScaleSquared(), | 1075 isDrawScalingDown(srcRect, dstRect, state().transform().xScaleSquared(), |
1076 state().transform().yScaleSquared())) | 1076 state().transform().yScaleSquared())) |
1077 imagePaint.setFilterQuality(kLow_SkFilterQuality); | 1077 imagePaint.setFilterQuality(kLow_SkFilterQuality); |
1078 | 1078 |
1079 if (!imageSource->isVideoElement()) { | 1079 if (!imageSource->isVideoElement()) { |
1080 imagePaint.setAntiAlias(shouldDrawImageAntialiased(dstRect)); | 1080 imagePaint.setAntiAlias(shouldDrawImageAntialiased(dstRect)); |
1081 // TODO(ccameron): Canvas should draw in sRGB by default. | |
Justin Novosad
2016/12/09 02:17:35
Actually, we want to use whatever the canvas's col
| |
1082 // https://crbug.com/672299 | |
1081 image->draw(c, imagePaint, dstRect, srcRect, DoNotRespectImageOrientation, | 1083 image->draw(c, imagePaint, dstRect, srcRect, DoNotRespectImageOrientation, |
1082 Image::DoNotClampImageToSourceRect); | 1084 Image::DoNotClampImageToSourceRect, |
1085 ColorBehavior::transformToGlobalTarget()); | |
Justin Novosad
2016/12/09 02:17:35
I am concerned about this approach, I understand t
ccameron
2016/12/09 03:30:56
It is true, as you mention, that, if two different
| |
1083 } else { | 1086 } else { |
1084 c->save(); | 1087 c->save(); |
1085 c->clipRect(dstRect); | 1088 c->clipRect(dstRect); |
1086 c->translate(dstRect.x(), dstRect.y()); | 1089 c->translate(dstRect.x(), dstRect.y()); |
1087 c->scale(dstRect.width() / srcRect.width(), | 1090 c->scale(dstRect.width() / srcRect.width(), |
1088 dstRect.height() / srcRect.height()); | 1091 dstRect.height() / srcRect.height()); |
1089 c->translate(-srcRect.x(), -srcRect.y()); | 1092 c->translate(-srcRect.x(), -srcRect.y()); |
1090 HTMLVideoElement* video = static_cast<HTMLVideoElement*>(imageSource); | 1093 HTMLVideoElement* video = static_cast<HTMLVideoElement*>(imageSource); |
1091 video->paintCurrentFrame( | 1094 video->paintCurrentFrame( |
1092 c, | 1095 c, |
(...skipping 920 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2013 ExpensiveCanvasHeuristicParameters::ShadowFixedCost[index] * | 2016 ExpensiveCanvasHeuristicParameters::ShadowFixedCost[index] * |
2014 m_usageCounters.numBlurredShadows + | 2017 m_usageCounters.numBlurredShadows + |
2015 ExpensiveCanvasHeuristicParameters:: | 2018 ExpensiveCanvasHeuristicParameters:: |
2016 ShadowVariableCostPerAreaTimesShadowBlurSquared[index] * | 2019 ShadowVariableCostPerAreaTimesShadowBlurSquared[index] * |
2017 m_usageCounters.boundingBoxAreaTimesShadowBlurSquared; | 2020 m_usageCounters.boundingBoxAreaTimesShadowBlurSquared; |
2018 | 2021 |
2019 return basicCostOfDrawCalls + fillTypeAdjustment + shadowAdjustment; | 2022 return basicCostOfDrawCalls + fillTypeAdjustment + shadowAdjustment; |
2020 } | 2023 } |
2021 | 2024 |
2022 } // namespace blink | 2025 } // namespace blink |
OLD | NEW |