| OLD | NEW |
| 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 Loading... |
| 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 Loading... |
| 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 1072 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1456 // Creates a placeholder layer first before Surface is created. | 1469 // Creates a placeholder layer first before Surface is created. |
| 1457 m_surfaceLayerBridge->createSolidColorLayer(); | 1470 m_surfaceLayerBridge->createSolidColorLayer(); |
| 1458 } | 1471 } |
| 1459 } | 1472 } |
| 1460 | 1473 |
| 1461 void HTMLCanvasElement::OnWebLayerReplaced() { | 1474 void HTMLCanvasElement::OnWebLayerReplaced() { |
| 1462 setNeedsCompositingUpdate(); | 1475 setNeedsCompositingUpdate(); |
| 1463 } | 1476 } |
| 1464 | 1477 |
| 1465 } // namespace blink | 1478 } // namespace blink |
| OLD | NEW |