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

Side by Side Diff: third_party/WebKit/Source/modules/canvas2d/CanvasRenderingContext2D.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 /* 1 /*
2 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012 Apple Inc. 2 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012 Apple Inc.
3 * All rights reserved. 3 * All rights reserved.
4 * Copyright (C) 2008, 2010 Nokia Corporation and/or its subsidiary(-ies) 4 * Copyright (C) 2008, 2010 Nokia Corporation and/or its subsidiary(-ies)
5 * Copyright (C) 2007 Alp Toker <alp@atoker.com> 5 * Copyright (C) 2007 Alp Toker <alp@atoker.com>
6 * Copyright (C) 2008 Eric Seidel <eric@webkit.org> 6 * Copyright (C) 2008 Eric Seidel <eric@webkit.org>
7 * Copyright (C) 2008 Dirk Schulze <krit@webkit.org> 7 * Copyright (C) 2008 Dirk Schulze <krit@webkit.org>
8 * Copyright (C) 2010 Torch Mobile (Beijing) Co. Ltd. All rights reserved. 8 * Copyright (C) 2010 Torch Mobile (Beijing) Co. Ltd. All rights reserved.
9 * Copyright (C) 2012, 2013 Intel Corporation. All rights reserved. 9 * Copyright (C) 2012, 2013 Intel Corporation. All rights reserved.
10 * Copyright (C) 2013 Adobe Systems Incorporated. All rights reserved. 10 * Copyright (C) 2013 Adobe Systems Incorporated. All rights reserved.
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
134 setShouldAntialias(true); 134 setShouldAntialias(true);
135 ThreadState::current()->registerPreFinalizer(this); 135 ThreadState::current()->registerPreFinalizer(this);
136 validateStateStack(); 136 validateStateStack();
137 } 137 }
138 138
139 void CanvasRenderingContext2D::setCanvasGetContextResult( 139 void CanvasRenderingContext2D::setCanvasGetContextResult(
140 RenderingContext& result) { 140 RenderingContext& result) {
141 result.setCanvasRenderingContext2D(this); 141 result.setCanvasRenderingContext2D(this);
142 } 142 }
143 143
144 void CanvasRenderingContext2D::unwindStateStack() {
145 if (size_t stackSize = m_stateStack.size()) {
146 if (SkCanvas* skCanvas = canvas()->existingDrawingCanvas()) {
147 while (--stackSize)
148 skCanvas->restore();
149 }
150 }
151 }
152
153 CanvasRenderingContext2D::~CanvasRenderingContext2D() {} 144 CanvasRenderingContext2D::~CanvasRenderingContext2D() {}
154 145
155 void CanvasRenderingContext2D::dispose() { 146 void CanvasRenderingContext2D::dispose() {
156 if (m_pruneLocalFontCacheScheduled) 147 if (m_pruneLocalFontCacheScheduled)
157 Platform::current()->currentThread()->removeTaskObserver(this); 148 Platform::current()->currentThread()->removeTaskObserver(this);
158 } 149 }
159 150
160 void CanvasRenderingContext2D::validateStateStack() const { 151 void CanvasRenderingContext2D::validateStateStack() const {
161 #if DCHECK_IS_ON() 152 #if DCHECK_IS_ON()
162 if (SkCanvas* skCanvas = canvas()->existingDrawingCanvas()) { 153 if (SkCanvas* skCanvas = canvas()->existingDrawingCanvas()) {
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
273 return; 264 return;
274 reset(); 265 reset();
275 m_contextLostMode = NotLostContext; 266 m_contextLostMode = NotLostContext;
276 if (contextLostRestoredEventsEnabled()) { 267 if (contextLostRestoredEventsEnabled()) {
277 Event* event(Event::create(EventTypeNames::contextrestored)); 268 Event* event(Event::create(EventTypeNames::contextrestored));
278 canvas()->dispatchEvent(event); 269 canvas()->dispatchEvent(event);
279 } 270 }
280 } 271 }
281 272
282 void CanvasRenderingContext2D::reset() { 273 void CanvasRenderingContext2D::reset() {
283 validateStateStack(); 274 // This is a multiple inherritance bootstrap
284 unwindStateStack(); 275 BaseRenderingContext2D::reset();
285 m_stateStack.resize(1);
286 m_stateStack.first() = CanvasRenderingContext2DState::create();
287 m_path.clear();
288 if (SkCanvas* c = canvas()->existingDrawingCanvas()) {
289 // The canvas should always have an initial/unbalanced save frame, which
290 // we use to reset the top level matrix and clip here.
291 DCHECK_EQ(c->getSaveCount(), 2);
292 c->restore();
293 c->save();
294 DCHECK(c->getTotalMatrix().isIdentity());
295 #if DCHECK_IS_ON()
296 SkIRect clipBounds;
297 DCHECK(c->getClipDeviceBounds(&clipBounds));
298 DCHECK(clipBounds == c->imageInfo().bounds());
299 #endif
300 }
301 validateStateStack();
302 } 276 }
303 277
304 void CanvasRenderingContext2D::restoreCanvasMatrixClipStack(SkCanvas* c) const { 278 void CanvasRenderingContext2D::restoreCanvasMatrixClipStack(SkCanvas* c) const {
305 restoreMatrixClipStack(c); 279 restoreMatrixClipStack(c);
306 } 280 }
307 281
308 bool CanvasRenderingContext2D::shouldAntialias() const { 282 bool CanvasRenderingContext2D::shouldAntialias() const {
309 return state().shouldAntialias(); 283 return state().shouldAntialias();
310 } 284 }
311 285
(...skipping 868 matching lines...) Expand 10 before | Expand all | Expand 10 after
1180 } 1154 }
1181 return true; 1155 return true;
1182 } 1156 }
1183 1157
1184 void CanvasRenderingContext2D::resetUsageTracking() { 1158 void CanvasRenderingContext2D::resetUsageTracking() {
1185 UsageCounters newCounters; 1159 UsageCounters newCounters;
1186 m_usageCounters = newCounters; 1160 m_usageCounters = newCounters;
1187 } 1161 }
1188 1162
1189 } // namespace blink 1163 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698