| 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 15 matching lines...) Expand all Loading... |
| 26 #include "platform/graphics/ExpensiveCanvasHeuristicParameters.h" | 26 #include "platform/graphics/ExpensiveCanvasHeuristicParameters.h" |
| 27 #include "platform/graphics/Image.h" | 27 #include "platform/graphics/Image.h" |
| 28 #include "platform/graphics/ImageBuffer.h" | 28 #include "platform/graphics/ImageBuffer.h" |
| 29 #include "platform/graphics/StrokeData.h" | 29 #include "platform/graphics/StrokeData.h" |
| 30 #include "platform/graphics/skia/SkiaUtils.h" | 30 #include "platform/graphics/skia/SkiaUtils.h" |
| 31 | 31 |
| 32 namespace blink { | 32 namespace blink { |
| 33 | 33 |
| 34 BaseRenderingContext2D::BaseRenderingContext2D() | 34 BaseRenderingContext2D::BaseRenderingContext2D() |
| 35 : m_clipAntialiasing(NotAntiAliased) { | 35 : m_clipAntialiasing(NotAntiAliased) { |
| 36 m_stateStack.append(CanvasRenderingContext2DState::create()); | 36 m_stateStack.push_back(CanvasRenderingContext2DState::create()); |
| 37 } | 37 } |
| 38 | 38 |
| 39 BaseRenderingContext2D::~BaseRenderingContext2D() {} | 39 BaseRenderingContext2D::~BaseRenderingContext2D() {} |
| 40 | 40 |
| 41 CanvasRenderingContext2DState& BaseRenderingContext2D::modifiableState() { | 41 CanvasRenderingContext2DState& BaseRenderingContext2D::modifiableState() { |
| 42 realizeSaves(); | 42 realizeSaves(); |
| 43 return *m_stateStack.back(); | 43 return *m_stateStack.back(); |
| 44 } | 44 } |
| 45 | 45 |
| 46 void BaseRenderingContext2D::realizeSaves() { | 46 void BaseRenderingContext2D::realizeSaves() { |
| 47 validateStateStack(); | 47 validateStateStack(); |
| 48 if (state().hasUnrealizedSaves()) { | 48 if (state().hasUnrealizedSaves()) { |
| 49 ASSERT(m_stateStack.size() >= 1); | 49 ASSERT(m_stateStack.size() >= 1); |
| 50 // Reduce the current state's unrealized count by one now, | 50 // Reduce the current state's unrealized count by one now, |
| 51 // to reflect the fact we are saving one state. | 51 // to reflect the fact we are saving one state. |
| 52 m_stateStack.back()->restore(); | 52 m_stateStack.back()->restore(); |
| 53 m_stateStack.append(CanvasRenderingContext2DState::create( | 53 m_stateStack.push_back(CanvasRenderingContext2DState::create( |
| 54 state(), CanvasRenderingContext2DState::DontCopyClipList)); | 54 state(), CanvasRenderingContext2DState::DontCopyClipList)); |
| 55 // Set the new state's unrealized count to 0, because it has no outstanding | 55 // Set the new state's unrealized count to 0, because it has no outstanding |
| 56 // saves. | 56 // saves. |
| 57 // We need to do this explicitly because the copy constructor and operator= | 57 // We need to do this explicitly because the copy constructor and operator= |
| 58 // used by the Vector operations copy the unrealized count from the previous | 58 // used by the Vector operations copy the unrealized count from the previous |
| 59 // state (in turn necessary to support correct resizing and unwinding of the | 59 // state (in turn necessary to support correct resizing and unwinding of the |
| 60 // stack). | 60 // stack). |
| 61 m_stateStack.back()->resetUnrealizedSaveCount(); | 61 m_stateStack.back()->resetUnrealizedSaveCount(); |
| 62 SkCanvas* canvas = drawingCanvas(); | 62 SkCanvas* canvas = drawingCanvas(); |
| 63 if (canvas) | 63 if (canvas) |
| (...skipping 1949 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2013 ExpensiveCanvasHeuristicParameters::ShadowFixedCost[index] * | 2013 ExpensiveCanvasHeuristicParameters::ShadowFixedCost[index] * |
| 2014 m_usageCounters.numBlurredShadows + | 2014 m_usageCounters.numBlurredShadows + |
| 2015 ExpensiveCanvasHeuristicParameters:: | 2015 ExpensiveCanvasHeuristicParameters:: |
| 2016 ShadowVariableCostPerAreaTimesShadowBlurSquared[index] * | 2016 ShadowVariableCostPerAreaTimesShadowBlurSquared[index] * |
| 2017 m_usageCounters.boundingBoxAreaTimesShadowBlurSquared; | 2017 m_usageCounters.boundingBoxAreaTimesShadowBlurSquared; |
| 2018 | 2018 |
| 2019 return basicCostOfDrawCalls + fillTypeAdjustment + shadowAdjustment; | 2019 return basicCostOfDrawCalls + fillTypeAdjustment + shadowAdjustment; |
| 2020 } | 2020 } |
| 2021 | 2021 |
| 2022 } // namespace blink | 2022 } // namespace blink |
| OLD | NEW |