| 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 304 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 315 FloatRect inflatedRect = rect; | 315 FloatRect inflatedRect = rect; |
| 316 inflatedRect.inflate(1); | 316 inflatedRect.inflate(1); |
| 317 m_dirtyRect.unite(inflatedRect); | 317 m_dirtyRect.unite(inflatedRect); |
| 318 } else { | 318 } else { |
| 319 m_dirtyRect.unite(rect); | 319 m_dirtyRect.unite(rect); |
| 320 } | 320 } |
| 321 if (m_context && m_context->is2d() && hasImageBuffer()) | 321 if (m_context && m_context->is2d() && hasImageBuffer()) |
| 322 buffer()->didDraw(rect); | 322 buffer()->didDraw(rect); |
| 323 } | 323 } |
| 324 | 324 |
| 325 void HTMLCanvasElement::didFinalizeFrame() { | 325 void HTMLCanvasElement::finalizeFrame() { |
| 326 if (hasImageBuffer()) |
| 327 m_imageBuffer->finalizeFrame(); |
| 328 m_context->incrementFrameCount(); |
| 326 notifyListenersCanvasChanged(); | 329 notifyListenersCanvasChanged(); |
| 330 } |
| 331 |
| 332 void HTMLCanvasElement::didDisableAcceleration() { |
| 333 // We must force a paint invalidation on the canvas even if it's |
| 334 // content did not change because it layer was destroyed. |
| 335 didDraw(FloatRect(0, 0, size().width(), size().height())); |
| 336 } |
| 337 |
| 338 void HTMLCanvasElement::restoreCanvasMatrixClipStack(SkCanvas* canvas) const { |
| 339 if (m_context) |
| 340 m_context->restoreCanvasMatrixClipStack(canvas); |
| 341 } |
| 342 |
| 343 void HTMLCanvasElement::doDeferredPaintInvalidation() { |
| 344 DCHECK(!m_dirtyRect.isEmpty()); |
| 345 if (m_context->is2d()) { |
| 346 FloatRect srcRect(0, 0, size().width(), size().height()); |
| 347 m_dirtyRect.intersect(srcRect); |
| 348 LayoutBox* lb = layoutBox(); |
| 349 FloatRect invalidationRect; |
| 350 if (lb) { |
| 351 FloatRect mappedDirtyRect = |
| 352 mapRect(m_dirtyRect, srcRect, FloatRect(lb->contentBoxRect())); |
| 353 if (m_context->isAccelerated()) { |
| 354 // Accelerated 2D canvases need the dirty rect to be expressed relative |
| 355 // to the content box, as opposed to the layout box. |
| 356 mappedDirtyRect.move(-lb->contentBoxOffset()); |
| 357 } |
| 358 invalidationRect = mappedDirtyRect; |
| 359 } else { |
| 360 invalidationRect = m_dirtyRect; |
| 361 } |
| 362 if (hasImageBuffer()) { |
| 363 m_imageBuffer->doPaintInvalidation(invalidationRect); |
| 364 } |
| 365 } |
| 327 | 366 |
| 328 if (m_dirtyRect.isEmpty()) | 367 if (m_dirtyRect.isEmpty()) |
| 329 return; | 368 return; |
| 330 | 369 |
| 331 // Propagate the m_dirtyRect accumulated so far to the compositor | 370 // Propagate the m_dirtyRect accumulated so far to the compositor |
| 332 // before restarting with a blank dirty rect. | 371 // before restarting with a blank dirty rect. |
| 333 FloatRect srcRect(0, 0, size().width(), size().height()); | 372 FloatRect srcRect(0, 0, size().width(), size().height()); |
| 334 | 373 |
| 335 LayoutBox* ro = layoutBox(); | 374 LayoutBox* ro = layoutBox(); |
| 336 // Canvas content updates do not need to be propagated as | 375 // Canvas content updates do not need to be propagated as |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 378 m_numFramesSinceLastRenderingModeSwitch = 0; | 417 m_numFramesSinceLastRenderingModeSwitch = 0; |
| 379 m_pendingRenderingModeSwitch = true; | 418 m_pendingRenderingModeSwitch = true; |
| 380 } | 419 } |
| 381 } | 420 } |
| 382 } | 421 } |
| 383 | 422 |
| 384 if (m_pendingRenderingModeSwitch && buffer() && !buffer()->isAccelerated()) { | 423 if (m_pendingRenderingModeSwitch && buffer() && !buffer()->isAccelerated()) { |
| 385 m_pendingRenderingModeSwitch = false; | 424 m_pendingRenderingModeSwitch = false; |
| 386 } | 425 } |
| 387 | 426 |
| 388 m_context->incrementFrameCount(); | |
| 389 } | |
| 390 | |
| 391 void HTMLCanvasElement::didDisableAcceleration() { | |
| 392 // We must force a paint invalidation on the canvas even if it's | |
| 393 // content did not change because it layer was destroyed. | |
| 394 didDraw(FloatRect(0, 0, size().width(), size().height())); | |
| 395 } | |
| 396 | |
| 397 void HTMLCanvasElement::restoreCanvasMatrixClipStack( | |
| 398 PaintCanvas* canvas) const { | |
| 399 if (m_context) | |
| 400 m_context->restoreCanvasMatrixClipStack(canvas); | |
| 401 } | |
| 402 | |
| 403 void HTMLCanvasElement::doDeferredPaintInvalidation() { | |
| 404 DCHECK(!m_dirtyRect.isEmpty()); | |
| 405 if (!m_context->is2d()) { | |
| 406 didFinalizeFrame(); | |
| 407 } else { | |
| 408 FloatRect srcRect(0, 0, size().width(), size().height()); | |
| 409 m_dirtyRect.intersect(srcRect); | |
| 410 LayoutBox* lb = layoutBox(); | |
| 411 FloatRect invalidationRect; | |
| 412 if (lb) { | |
| 413 FloatRect mappedDirtyRect = | |
| 414 mapRect(m_dirtyRect, srcRect, FloatRect(lb->contentBoxRect())); | |
| 415 if (m_context->isAccelerated()) { | |
| 416 // Accelerated 2D canvases need the dirty rect to be expressed relative | |
| 417 // to the content box, as opposed to the layout box. | |
| 418 mappedDirtyRect.move(-lb->contentBoxOffset()); | |
| 419 } | |
| 420 invalidationRect = mappedDirtyRect; | |
| 421 } else { | |
| 422 invalidationRect = m_dirtyRect; | |
| 423 } | |
| 424 if (hasImageBuffer()) { | |
| 425 m_imageBuffer->finalizeFrame(invalidationRect); | |
| 426 } else { | |
| 427 didFinalizeFrame(); | |
| 428 } | |
| 429 } | |
| 430 DCHECK(m_dirtyRect.isEmpty()); | 427 DCHECK(m_dirtyRect.isEmpty()); |
| 431 } | 428 } |
| 432 | 429 |
| 433 void HTMLCanvasElement::reset() { | 430 void HTMLCanvasElement::reset() { |
| 434 if (m_ignoreReset) | 431 if (m_ignoreReset) |
| 435 return; | 432 return; |
| 436 | 433 |
| 437 m_dirtyRect = FloatRect(); | 434 m_dirtyRect = FloatRect(); |
| 438 | 435 |
| 439 bool ok; | 436 bool ok; |
| (...skipping 999 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1439 // Creates a placeholder layer first before Surface is created. | 1436 // Creates a placeholder layer first before Surface is created. |
| 1440 m_surfaceLayerBridge->createSolidColorLayer(); | 1437 m_surfaceLayerBridge->createSolidColorLayer(); |
| 1441 } | 1438 } |
| 1442 } | 1439 } |
| 1443 | 1440 |
| 1444 void HTMLCanvasElement::OnWebLayerReplaced() { | 1441 void HTMLCanvasElement::OnWebLayerReplaced() { |
| 1445 setNeedsCompositingUpdate(); | 1442 setNeedsCompositingUpdate(); |
| 1446 } | 1443 } |
| 1447 | 1444 |
| 1448 } // namespace blink | 1445 } // namespace blink |
| OLD | NEW |