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

Side by Side Diff: third_party/WebKit/Source/core/html/canvas/CanvasRenderingContext.cpp

Issue 2778483002: Synchronize commits at end of JS task (Closed)
Patch Set: fix layout test Created 3 years, 8 months 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) 2009 Apple Inc. All rights reserved. 2 * Copyright (C) 2009 Apple Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 1. Redistributions of source code must retain the above copyright 7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer. 8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright 9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the 10 * notice, this list of conditions and the following disclaimer in the
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after
158 m_canvas = nullptr; 158 m_canvas = nullptr;
159 } 159 }
160 if (offscreenCanvas()) { 160 if (offscreenCanvas()) {
161 offscreenCanvas()->detachContext(); 161 offscreenCanvas()->detachContext();
162 m_offscreenCanvas = nullptr; 162 m_offscreenCanvas = nullptr;
163 } 163 }
164 } 164 }
165 165
166 void CanvasRenderingContext::didDraw(const SkIRect& dirtyRect) { 166 void CanvasRenderingContext::didDraw(const SkIRect& dirtyRect) {
167 canvas()->didDraw(SkRect::Make(dirtyRect)); 167 canvas()->didDraw(SkRect::Make(dirtyRect));
168 needsFinalizeFrame();
169 }
170
171 void CanvasRenderingContext::needsFinalizeFrame() {
168 if (!m_finalizeFrameScheduled) { 172 if (!m_finalizeFrameScheduled) {
169 m_finalizeFrameScheduled = true; 173 m_finalizeFrameScheduled = true;
170 Platform::current()->currentThread()->addTaskObserver(this); 174 Platform::current()->currentThread()->addTaskObserver(this);
171 } 175 }
172 } 176 }
173 177
174 void CanvasRenderingContext::didProcessTask() { 178 void CanvasRenderingContext::didProcessTask() {
175 Platform::current()->currentThread()->removeTaskObserver(this); 179 Platform::current()->currentThread()->removeTaskObserver(this);
176 m_finalizeFrameScheduled = false; 180 m_finalizeFrameScheduled = false;
177 181
178 // The end of a script task that drew content to the canvas is the point 182 // The end of a script task that drew content to the canvas is the point
179 // at which the current frame may be considered complete. 183 // at which the current frame may be considered complete.
180 if (canvas()) 184 if (canvas())
181 canvas()->finalizeFrame(); 185 canvas()->finalizeFrame();
186 if (offscreenCanvas())
187 offscreenCanvas()->finalizeFrame();
182 finalizeFrame(); 188 finalizeFrame();
183 } 189 }
184 190
185 CanvasRenderingContext::ContextType CanvasRenderingContext::contextTypeFromId( 191 CanvasRenderingContext::ContextType CanvasRenderingContext::contextTypeFromId(
186 const String& id) { 192 const String& id) {
187 if (id == "2d") 193 if (id == "2d")
188 return Context2d; 194 return Context2d;
189 if (id == "experimental-webgl") 195 if (id == "experimental-webgl")
190 return ContextExperimentalWebgl; 196 return ContextExperimentalWebgl;
191 if (id == "webgl") 197 if (id == "webgl")
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
235 } 241 }
236 return taintOrigin; 242 return taintOrigin;
237 } 243 }
238 244
239 DEFINE_TRACE(CanvasRenderingContext) { 245 DEFINE_TRACE(CanvasRenderingContext) {
240 visitor->trace(m_canvas); 246 visitor->trace(m_canvas);
241 visitor->trace(m_offscreenCanvas); 247 visitor->trace(m_offscreenCanvas);
242 } 248 }
243 249
244 } // namespace blink 250 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698