Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 /* | 1 /* |
| 2 * Copyright (C) 2012 Google Inc. All rights reserved. | 2 * Copyright (C) 2012 Google 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 * | 7 * |
| 8 * 1. Redistributions of source code must retain the above copyright | 8 * 1. Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * 2. Redistributions in binary form must reproduce the above copyright | 10 * 2. Redistributions in binary form must reproduce the above copyright |
| (...skipping 421 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 432 | 432 |
| 433 void Canvas2DLayerBridge::mailboxReleased(const blink::WebExternalTextureMailbox & mailbox) | 433 void Canvas2DLayerBridge::mailboxReleased(const blink::WebExternalTextureMailbox & mailbox) |
| 434 { | 434 { |
| 435 freeReleasedMailbox(); // Never have more than one mailbox in the released s tate. | 435 freeReleasedMailbox(); // Never have more than one mailbox in the released s tate. |
| 436 Vector<MailboxInfo>::iterator mailboxInfo; | 436 Vector<MailboxInfo>::iterator mailboxInfo; |
| 437 for (mailboxInfo = m_mailboxes.begin(); mailboxInfo < m_mailboxes.end(); ++m ailboxInfo) { | 437 for (mailboxInfo = m_mailboxes.begin(); mailboxInfo < m_mailboxes.end(); ++m ailboxInfo) { |
| 438 if (!memcmp(mailboxInfo->m_mailbox.name, mailbox.name, sizeof(mailbox.na me))) { | 438 if (!memcmp(mailboxInfo->m_mailbox.name, mailbox.name, sizeof(mailbox.na me))) { |
| 439 mailboxInfo->m_mailbox.syncPoint = mailbox.syncPoint; | 439 mailboxInfo->m_mailbox.syncPoint = mailbox.syncPoint; |
| 440 ASSERT(mailboxInfo->m_status == MailboxInUse); | 440 ASSERT(mailboxInfo->m_status == MailboxInUse); |
| 441 mailboxInfo->m_status = MailboxReleased; | 441 mailboxInfo->m_status = MailboxReleased; |
| 442 resetLastImageIdIfNecessary(); | |
| 442 // Trigger Canvas2DLayerBridge self-destruction if this is the | 443 // Trigger Canvas2DLayerBridge self-destruction if this is the |
| 443 // last live mailbox and the layer bridge is not externally | 444 // last live mailbox and the layer bridge is not externally |
| 444 // referenced. | 445 // referenced. |
| 445 m_releasedMailboxInfoIndex = mailboxInfo - m_mailboxes.begin(); | 446 m_releasedMailboxInfoIndex = mailboxInfo - m_mailboxes.begin(); |
| 446 m_framesSinceMailboxRelease = 0; | 447 m_framesSinceMailboxRelease = 0; |
| 447 if (isHidden()) { | 448 if (isHidden()) { |
| 448 freeReleasedMailbox(); | 449 freeReleasedMailbox(); |
| 449 } else { | 450 } else { |
| 450 ASSERT(!m_destructionInProgress); | 451 ASSERT(!m_destructionInProgress); |
| 451 Canvas2DLayerManager::get().layerTransientResourceAllocationChan ged(this); | 452 Canvas2DLayerManager::get().layerTransientResourceAllocationChan ged(this); |
| 452 } | 453 } |
| 453 ASSERT(mailboxInfo->m_parentLayerBridge.get() == this); | 454 ASSERT(mailboxInfo->m_parentLayerBridge.get() == this); |
| 454 mailboxInfo->m_parentLayerBridge.clear(); | 455 mailboxInfo->m_parentLayerBridge.clear(); |
| 455 return; | 456 return; |
| 456 } | 457 } |
| 457 } | 458 } |
| 458 } | 459 } |
| 459 | 460 |
| 461 void Canvas2DLayerBridge::resetLastImageIdIfNecessary() | |
| 462 { | |
| 463 Vector<MailboxInfo>::iterator mailboxInfo; | |
| 464 for (mailboxInfo = m_mailboxes.begin(); mailboxInfo < m_mailboxes.end(); ++m ailboxInfo) { | |
|
Justin Novosad
2014/02/13 15:32:18
You can do the check in O(1) time instead of O(N)
| |
| 465 if (mailboxInfo->m_status == MailboxInUse) | |
| 466 return; | |
| 467 } | |
| 468 m_lastImageId = 0; | |
| 469 } | |
| 470 | |
| 460 blink::WebLayer* Canvas2DLayerBridge::layer() const | 471 blink::WebLayer* Canvas2DLayerBridge::layer() const |
| 461 { | 472 { |
| 462 ASSERT(m_layer); | 473 ASSERT(m_layer); |
| 463 return m_layer->layer(); | 474 return m_layer->layer(); |
| 464 } | 475 } |
| 465 | 476 |
| 466 void Canvas2DLayerBridge::willUse() | 477 void Canvas2DLayerBridge::willUse() |
| 467 { | 478 { |
| 468 ASSERT(!m_destructionInProgress); | 479 ASSERT(!m_destructionInProgress); |
| 469 Canvas2DLayerManager::get().layerDidDraw(this); | 480 Canvas2DLayerManager::get().layerDidDraw(this); |
| (...skipping 18 matching lines...) Expand all Loading... | |
| 488 Canvas2DLayerBridge::MailboxInfo::MailboxInfo(const MailboxInfo& other) { | 499 Canvas2DLayerBridge::MailboxInfo::MailboxInfo(const MailboxInfo& other) { |
| 489 // This copy constructor should only be used for Vector reallocation | 500 // This copy constructor should only be used for Vector reallocation |
| 490 // Assuming 'other' is to be destroyed, we transfer m_image ownership | 501 // Assuming 'other' is to be destroyed, we transfer m_image ownership |
| 491 // rather than do a refcount dance. | 502 // rather than do a refcount dance. |
| 492 memcpy(&m_mailbox, &other.m_mailbox, sizeof(m_mailbox)); | 503 memcpy(&m_mailbox, &other.m_mailbox, sizeof(m_mailbox)); |
| 493 m_image = const_cast<MailboxInfo*>(&other)->m_image.release(); | 504 m_image = const_cast<MailboxInfo*>(&other)->m_image.release(); |
| 494 m_status = other.m_status; | 505 m_status = other.m_status; |
| 495 } | 506 } |
| 496 | 507 |
| 497 } | 508 } |
| OLD | NEW |