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

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

Issue 2502413004: WTF/std normalization: replace WTF::Vector::last with ::back (Closed)
Patch Set: rebase Created 4 years, 1 month 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/cssom/CSSURLImageValue.h"
(...skipping 22 matching lines...) Expand all
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.append(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.last(); 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.last()->restore(); 52 m_stateStack.back()->restore();
53 m_stateStack.append(CanvasRenderingContext2DState::create( 53 m_stateStack.append(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.last()->resetUnrealizedSaveCount(); 61 m_stateStack.back()->resetUnrealizedSaveCount();
62 SkCanvas* canvas = drawingCanvas(); 62 SkCanvas* canvas = drawingCanvas();
63 if (canvas) 63 if (canvas)
64 canvas->save(); 64 canvas->save();
65 validateStateStack(); 65 validateStateStack();
66 } 66 }
67 } 67 }
68 68
69 void BaseRenderingContext2D::save() { 69 void BaseRenderingContext2D::save() {
70 m_stateStack.last()->save(); 70 m_stateStack.back()->save();
71 } 71 }
72 72
73 void BaseRenderingContext2D::restore() { 73 void BaseRenderingContext2D::restore() {
74 validateStateStack(); 74 validateStateStack();
75 if (state().hasUnrealizedSaves()) { 75 if (state().hasUnrealizedSaves()) {
76 // We never realized the save, so just record that it was unnecessary. 76 // We never realized the save, so just record that it was unnecessary.
77 m_stateStack.last()->restore(); 77 m_stateStack.back()->restore();
78 return; 78 return;
79 } 79 }
80 ASSERT(m_stateStack.size() >= 1); 80 ASSERT(m_stateStack.size() >= 1);
81 if (m_stateStack.size() <= 1) 81 if (m_stateStack.size() <= 1)
82 return; 82 return;
83 m_path.transform(state().transform()); 83 m_path.transform(state().transform());
84 m_stateStack.pop_back(); 84 m_stateStack.pop_back();
85 m_stateStack.last()->clearResolvedFilter(); 85 m_stateStack.back()->clearResolvedFilter();
86 m_path.transform(state().transform().inverse()); 86 m_path.transform(state().transform().inverse());
87 SkCanvas* c = drawingCanvas(); 87 SkCanvas* c = drawingCanvas();
88 if (c) 88 if (c)
89 c->restore(); 89 c->restore();
90 90
91 validateStateStack(); 91 validateStateStack();
92 } 92 }
93 93
94 void BaseRenderingContext2D::restoreMatrixClipStack(SkCanvas* c) const { 94 void BaseRenderingContext2D::restoreMatrixClipStack(SkCanvas* c) const {
95 if (!c) 95 if (!c)
(...skipping 1918 matching lines...) Expand 10 before | Expand all | Expand 10 after
2014 ExpensiveCanvasHeuristicParameters::ShadowFixedCost[index] * 2014 ExpensiveCanvasHeuristicParameters::ShadowFixedCost[index] *
2015 m_usageCounters.numBlurredShadows + 2015 m_usageCounters.numBlurredShadows +
2016 ExpensiveCanvasHeuristicParameters:: 2016 ExpensiveCanvasHeuristicParameters::
2017 ShadowVariableCostPerAreaTimesShadowBlurSquared[index] * 2017 ShadowVariableCostPerAreaTimesShadowBlurSquared[index] *
2018 m_usageCounters.boundingBoxAreaTimesShadowBlurSquared; 2018 m_usageCounters.boundingBoxAreaTimesShadowBlurSquared;
2019 2019
2020 return basicCostOfDrawCalls + fillTypeAdjustment + shadowAdjustment; 2020 return basicCostOfDrawCalls + fillTypeAdjustment + shadowAdjustment;
2021 } 2021 }
2022 2022
2023 } // namespace blink 2023 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698