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

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

Issue 2508943003: Make OffscreenCanvas resizeable (Closed)
Patch Set: 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 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
101 CHECK(currState->get()); 101 CHECK(currState->get());
102 c->setMatrix(SkMatrix::I()); 102 c->setMatrix(SkMatrix::I());
103 currState->get()->playbackClips(c); 103 currState->get()->playbackClips(c);
104 c->setMatrix(affineTransformToSkMatrix(currState->get()->transform())); 104 c->setMatrix(affineTransformToSkMatrix(currState->get()->transform()));
105 c->save(); 105 c->save();
106 } 106 }
107 c->restore(); 107 c->restore();
108 validateStateStack(); 108 validateStateStack();
109 } 109 }
110 110
111 void BaseRenderingContext2D::unwindStateStack() {
Justin Novosad 2016/11/16 22:58:18 code moved from CanvasRenderingContext2D.cpp
112 if (size_t stackSize = m_stateStack.size()) {
113 if (SkCanvas* skCanvas = existingDrawingCanvas()) {
114 while (--stackSize)
115 skCanvas->restore();
116 }
117 }
118 }
119
120 void BaseRenderingContext2D::reset() {
121 validateStateStack();
122 unwindStateStack();
123 m_stateStack.resize(1);
124 m_stateStack.first() = CanvasRenderingContext2DState::create();
125 m_path.clear();
126 if (SkCanvas* c = existingDrawingCanvas()) {
127 // The canvas should always have an initial/unbalanced save frame, which
128 // we use to reset the top level matrix and clip here.
129 DCHECK_EQ(c->getSaveCount(), 2);
130 c->restore();
131 c->save();
132 DCHECK(c->getTotalMatrix().isIdentity());
133 #if DCHECK_IS_ON()
134 SkIRect clipBounds;
135 DCHECK(c->getClipDeviceBounds(&clipBounds));
136 DCHECK(clipBounds == c->imageInfo().bounds());
137 #endif
138 }
139 validateStateStack();
140 }
141
111 static inline void convertCanvasStyleToUnionType( 142 static inline void convertCanvasStyleToUnionType(
112 CanvasStyle* style, 143 CanvasStyle* style,
113 StringOrCanvasGradientOrCanvasPattern& returnValue) { 144 StringOrCanvasGradientOrCanvasPattern& returnValue) {
114 if (CanvasGradient* gradient = style->getCanvasGradient()) { 145 if (CanvasGradient* gradient = style->getCanvasGradient()) {
115 returnValue.setCanvasGradient(gradient); 146 returnValue.setCanvasGradient(gradient);
116 return; 147 return;
117 } 148 }
118 if (CanvasPattern* pattern = style->getCanvasPattern()) { 149 if (CanvasPattern* pattern = style->getCanvasPattern()) {
119 returnValue.setCanvasPattern(pattern); 150 returnValue.setCanvasPattern(pattern);
120 return; 151 return;
(...skipping 1862 matching lines...) Expand 10 before | Expand all | Expand 10 after
1983 ExpensiveCanvasHeuristicParameters::ShadowFixedCost[index] * 2014 ExpensiveCanvasHeuristicParameters::ShadowFixedCost[index] *
1984 m_usageCounters.numBlurredShadows + 2015 m_usageCounters.numBlurredShadows +
1985 ExpensiveCanvasHeuristicParameters:: 2016 ExpensiveCanvasHeuristicParameters::
1986 ShadowVariableCostPerAreaTimesShadowBlurSquared[index] * 2017 ShadowVariableCostPerAreaTimesShadowBlurSquared[index] *
1987 m_usageCounters.boundingBoxAreaTimesShadowBlurSquared; 2018 m_usageCounters.boundingBoxAreaTimesShadowBlurSquared;
1988 2019
1989 return basicCostOfDrawCalls + fillTypeAdjustment + shadowAdjustment; 2020 return basicCostOfDrawCalls + fillTypeAdjustment + shadowAdjustment;
1990 } 2021 }
1991 2022
1992 } // namespace blink 2023 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698