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 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
94 GraphicsLayer::registerContentsLayer(m_layer->layer()); | 94 GraphicsLayer::registerContentsLayer(m_layer->layer()); |
95 m_layer->setRateLimitContext(m_rateLimitingEnabled); | 95 m_layer->setRateLimitContext(m_rateLimitingEnabled); |
96 m_canvas->setNotificationClient(this); | 96 m_canvas->setNotificationClient(this); |
97 } | 97 } |
98 | 98 |
99 Canvas2DLayerBridge::~Canvas2DLayerBridge() | 99 Canvas2DLayerBridge::~Canvas2DLayerBridge() |
100 { | 100 { |
101 ASSERT(m_destructionInProgress); | 101 ASSERT(m_destructionInProgress); |
102 m_layer.clear(); | 102 m_layer.clear(); |
103 Vector<MailboxInfo>::iterator mailboxInfo; | 103 Vector<MailboxInfo>::iterator mailboxInfo; |
104 for (mailboxInfo = m_mailboxes.begin(); mailboxInfo < m_mailboxes.end(); mai
lboxInfo++) { | 104 for (mailboxInfo = m_mailboxes.begin(); mailboxInfo < m_mailboxes.end(); ++m
ailboxInfo) { |
105 ASSERT(mailboxInfo->m_status != MailboxInUse); | 105 ASSERT(mailboxInfo->m_status != MailboxInUse); |
106 if (mailboxInfo->m_status == MailboxReleased) { | 106 if (mailboxInfo->m_status == MailboxReleased) { |
107 if (mailboxInfo->m_mailbox.syncPoint) { | 107 if (mailboxInfo->m_mailbox.syncPoint) { |
108 context()->waitSyncPoint(mailboxInfo->m_mailbox.syncPoint); | 108 context()->waitSyncPoint(mailboxInfo->m_mailbox.syncPoint); |
109 mailboxInfo->m_mailbox.syncPoint = 0; | 109 mailboxInfo->m_mailbox.syncPoint = 0; |
110 } | 110 } |
111 // Invalidate texture state in case the compositor altered it since
the copy-on-write. | 111 // Invalidate texture state in case the compositor altered it since
the copy-on-write. |
112 mailboxInfo->m_image->getTexture()->invalidateCachedState(); | 112 mailboxInfo->m_image->getTexture()->invalidateCachedState(); |
113 } | 113 } |
114 } | 114 } |
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
274 return false; | 274 return false; |
275 | 275 |
276 blink::WebGraphicsContext3D* webContext = context(); | 276 blink::WebGraphicsContext3D* webContext = context(); |
277 | 277 |
278 // Release to skia textures that were previouosly released by the | 278 // Release to skia textures that were previouosly released by the |
279 // compositor. We do this before acquiring the next snapshot in | 279 // compositor. We do this before acquiring the next snapshot in |
280 // order to cap maximum gpu memory consumption. | 280 // order to cap maximum gpu memory consumption. |
281 webContext->makeContextCurrent(); | 281 webContext->makeContextCurrent(); |
282 flush(); | 282 flush(); |
283 Vector<MailboxInfo>::iterator mailboxInfo; | 283 Vector<MailboxInfo>::iterator mailboxInfo; |
284 for (mailboxInfo = m_mailboxes.begin(); mailboxInfo < m_mailboxes.end(); mai
lboxInfo++) { | 284 for (mailboxInfo = m_mailboxes.begin(); mailboxInfo < m_mailboxes.end(); ++m
ailboxInfo) { |
285 if (mailboxInfo->m_status == MailboxReleased) { | 285 if (mailboxInfo->m_status == MailboxReleased) { |
286 if (mailboxInfo->m_mailbox.syncPoint) { | 286 if (mailboxInfo->m_mailbox.syncPoint) { |
287 webContext->waitSyncPoint(mailboxInfo->m_mailbox.syncPoint); | 287 webContext->waitSyncPoint(mailboxInfo->m_mailbox.syncPoint); |
288 mailboxInfo->m_mailbox.syncPoint = 0; | 288 mailboxInfo->m_mailbox.syncPoint = 0; |
289 } | 289 } |
290 // Invalidate texture state in case the compositor altered it since
the copy-on-write. | 290 // Invalidate texture state in case the compositor altered it since
the copy-on-write. |
291 mailboxInfo->m_image->getTexture()->invalidateCachedState(); | 291 mailboxInfo->m_image->getTexture()->invalidateCachedState(); |
292 mailboxInfo->m_image.reset(0); | 292 mailboxInfo->m_image.reset(0); |
293 mailboxInfo->m_status = MailboxAvailable; | 293 mailboxInfo->m_status = MailboxAvailable; |
294 } | 294 } |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
352 // Because of crbug.com/247874, it needs to be kMaxSwapBuffersPending+2. | 352 // Because of crbug.com/247874, it needs to be kMaxSwapBuffersPending+2. |
353 // TODO(piman): fix this. | 353 // TODO(piman): fix this. |
354 ASSERT(m_mailboxes.size() <= 4); | 354 ASSERT(m_mailboxes.size() <= 4); |
355 ASSERT(mailboxInfo < m_mailboxes.end()); | 355 ASSERT(mailboxInfo < m_mailboxes.end()); |
356 return mailboxInfo; | 356 return mailboxInfo; |
357 } | 357 } |
358 | 358 |
359 void Canvas2DLayerBridge::mailboxReleased(const blink::WebExternalTextureMailbox
& mailbox) | 359 void Canvas2DLayerBridge::mailboxReleased(const blink::WebExternalTextureMailbox
& mailbox) |
360 { | 360 { |
361 Vector<MailboxInfo>::iterator mailboxInfo; | 361 Vector<MailboxInfo>::iterator mailboxInfo; |
362 for (mailboxInfo = m_mailboxes.begin(); mailboxInfo < m_mailboxes.end(); mai
lboxInfo++) { | 362 for (mailboxInfo = m_mailboxes.begin(); mailboxInfo < m_mailboxes.end(); ++m
ailboxInfo) { |
363 if (!memcmp(mailboxInfo->m_mailbox.name, mailbox.name, sizeof(mailbox.na
me))) { | 363 if (!memcmp(mailboxInfo->m_mailbox.name, mailbox.name, sizeof(mailbox.na
me))) { |
364 mailboxInfo->m_mailbox.syncPoint = mailbox.syncPoint; | 364 mailboxInfo->m_mailbox.syncPoint = mailbox.syncPoint; |
365 ASSERT(mailboxInfo->m_status == MailboxInUse); | 365 ASSERT(mailboxInfo->m_status == MailboxInUse); |
366 mailboxInfo->m_status = MailboxReleased; | 366 mailboxInfo->m_status = MailboxReleased; |
367 // Trigger Canvas2DLayerBridge self-destruction if this is the | 367 // Trigger Canvas2DLayerBridge self-destruction if this is the |
368 // last live mailbox and the layer bridge is not externally | 368 // last live mailbox and the layer bridge is not externally |
369 // referenced. | 369 // referenced. |
370 ASSERT(mailboxInfo->m_parentLayerBridge.get() == this); | 370 ASSERT(mailboxInfo->m_parentLayerBridge.get() == this); |
371 mailboxInfo->m_parentLayerBridge.clear(); | 371 mailboxInfo->m_parentLayerBridge.clear(); |
372 return; | 372 return; |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
405 Canvas2DLayerBridge::MailboxInfo::MailboxInfo(const MailboxInfo& other) { | 405 Canvas2DLayerBridge::MailboxInfo::MailboxInfo(const MailboxInfo& other) { |
406 // This copy constructor should only be used for Vector reallocation | 406 // This copy constructor should only be used for Vector reallocation |
407 // Assuming 'other' is to be destroyed, we swap m_image ownership | 407 // Assuming 'other' is to be destroyed, we swap m_image ownership |
408 // rather than do a refcount dance. | 408 // rather than do a refcount dance. |
409 memcpy(&m_mailbox, &other.m_mailbox, sizeof(m_mailbox)); | 409 memcpy(&m_mailbox, &other.m_mailbox, sizeof(m_mailbox)); |
410 m_image.swap(const_cast<SkAutoTUnref<SkImage>*>(&other.m_image)); | 410 m_image.swap(const_cast<SkAutoTUnref<SkImage>*>(&other.m_image)); |
411 m_status = other.m_status; | 411 m_status = other.m_status; |
412 } | 412 } |
413 | 413 |
414 } | 414 } |
OLD | NEW |