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

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

Issue 2768683002: Fix unreliable MediaStream capture from WebGL canvases (Closed)
Patch Set: mac suppress 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
« no previous file with comments | « third_party/WebKit/Source/core/html/HTMLCanvasElement.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2004, 2006, 2007 Apple Inc. All rights reserved. 2 * Copyright (C) 2004, 2006, 2007 Apple Inc. All rights reserved.
3 * Copyright (C) 2007 Alp Toker <alp@atoker.com> 3 * Copyright (C) 2007 Alp Toker <alp@atoker.com>
4 * Copyright (C) 2010 Torch Mobile (Beijing) Co. Ltd. All rights reserved. 4 * Copyright (C) 2010 Torch Mobile (Beijing) Co. Ltd. All rights reserved.
5 * 5 *
6 * Redistribution and use in source and binary forms, with or without 6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions 7 * modification, are permitted provided that the following conditions
8 * are met: 8 * are met:
9 * 1. Redistributions of source code must retain the above copyright 9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer. 10 * notice, this list of conditions and the following disclaimer.
(...skipping 311 matching lines...) Expand 10 before | Expand all | Expand 10 after
322 } else { 322 } else {
323 m_dirtyRect.unite(rect); 323 m_dirtyRect.unite(rect);
324 } 324 }
325 if (m_context && m_context->is2d() && hasImageBuffer()) 325 if (m_context && m_context->is2d() && hasImageBuffer())
326 buffer()->didDraw(rect); 326 buffer()->didDraw(rect);
327 } 327 }
328 328
329 void HTMLCanvasElement::finalizeFrame() { 329 void HTMLCanvasElement::finalizeFrame() {
330 if (hasImageBuffer()) 330 if (hasImageBuffer())
331 m_imageBuffer->finalizeFrame(); 331 m_imageBuffer->finalizeFrame();
332 notifyListenersCanvasChanged(); 332
333 // If the canvas is visible, notifying listeners is taken
334 // care of in the in doDeferredPaintInvalidation, which allows
335 // the frame to be grabbed prior to compositing, which is
336 // critically important because compositing may clear the canvas's
337 // image. (e.g. WebGL context with preserveDrawingBuffer=false).
338 // If the canvas is not visible, doDeferredPaintInvalidation
339 // will not get called, so we need to take care of business here.
340 if (!m_didNotifyListenersForCurrentFrame)
341 notifyListenersCanvasChanged();
342 m_didNotifyListenersForCurrentFrame = false;
333 } 343 }
334 344
335 void HTMLCanvasElement::didDisableAcceleration() { 345 void HTMLCanvasElement::didDisableAcceleration() {
336 // We must force a paint invalidation on the canvas even if it's 346 // We must force a paint invalidation on the canvas even if it's
337 // content did not change because it layer was destroyed. 347 // content did not change because it layer was destroyed.
338 didDraw(FloatRect(0, 0, size().width(), size().height())); 348 didDraw(FloatRect(0, 0, size().width(), size().height()));
339 } 349 }
340 350
341 void HTMLCanvasElement::restoreCanvasMatrixClipStack( 351 void HTMLCanvasElement::restoreCanvasMatrixClipStack(
342 PaintCanvas* canvas) const { 352 PaintCanvas* canvas) const {
(...skipping 21 matching lines...) Expand all
364 invalidationRect = m_dirtyRect; 374 invalidationRect = m_dirtyRect;
365 } 375 }
366 if (hasImageBuffer()) { 376 if (hasImageBuffer()) {
367 m_imageBuffer->doPaintInvalidation(invalidationRect); 377 m_imageBuffer->doPaintInvalidation(invalidationRect);
368 } 378 }
369 } 379 }
370 380
371 if (m_dirtyRect.isEmpty()) 381 if (m_dirtyRect.isEmpty())
372 return; 382 return;
373 383
384 notifyListenersCanvasChanged();
385 m_didNotifyListenersForCurrentFrame = true;
386
374 // Propagate the m_dirtyRect accumulated so far to the compositor 387 // Propagate the m_dirtyRect accumulated so far to the compositor
375 // before restarting with a blank dirty rect. 388 // before restarting with a blank dirty rect.
376 FloatRect srcRect(0, 0, size().width(), size().height()); 389 FloatRect srcRect(0, 0, size().width(), size().height());
377 390
378 LayoutBox* ro = layoutBox(); 391 LayoutBox* ro = layoutBox();
379 // Canvas content updates do not need to be propagated as 392 // Canvas content updates do not need to be propagated as
380 // paint invalidations if the canvas is accelerated, since 393 // paint invalidations if the canvas is accelerated, since
381 // the canvas contents are sent separately through a texture layer. 394 // the canvas contents are sent separately through a texture layer.
382 if (ro && (!m_context || !m_context->isAccelerated())) { 395 if (ro && (!m_context || !m_context->isAccelerated())) {
383 // If ro->contentBoxRect() is larger than srcRect the canvas's image is 396 // If ro->contentBoxRect() is larger than srcRect the canvas's image is
(...skipping 1065 matching lines...) Expand 10 before | Expand all | Expand 10 after
1449 // Creates a placeholder layer first before Surface is created. 1462 // Creates a placeholder layer first before Surface is created.
1450 m_surfaceLayerBridge->createSolidColorLayer(); 1463 m_surfaceLayerBridge->createSolidColorLayer();
1451 } 1464 }
1452 } 1465 }
1453 1466
1454 void HTMLCanvasElement::OnWebLayerReplaced() { 1467 void HTMLCanvasElement::OnWebLayerReplaced() {
1455 setNeedsCompositingUpdate(); 1468 setNeedsCompositingUpdate();
1456 } 1469 }
1457 1470
1458 } // namespace blink 1471 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/html/HTMLCanvasElement.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698