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 206 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
217 { | 217 { |
218 ASSERT(!m_destructionInProgress); | 218 ASSERT(!m_destructionInProgress); |
219 ASSERT(m_layer); | 219 ASSERT(m_layer); |
220 if (!checkSurfaceValid()) { | 220 if (!checkSurfaceValid()) { |
221 if (m_canvas) { | 221 if (m_canvas) { |
222 // drop pending commands because there is no surface to draw to | 222 // drop pending commands because there is no surface to draw to |
223 m_canvas->silentFlush(); | 223 m_canvas->silentFlush(); |
224 } | 224 } |
225 return; | 225 return; |
226 } | 226 } |
227 context()->makeContextCurrent(); | |
228 } | 227 } |
229 | 228 |
230 void Canvas2DLayerBridge::storageAllocatedForRecordingChanged(size_t bytesAlloca
ted) | 229 void Canvas2DLayerBridge::storageAllocatedForRecordingChanged(size_t bytesAlloca
ted) |
231 { | 230 { |
232 ASSERT(!m_destructionInProgress); | 231 ASSERT(!m_destructionInProgress); |
233 intptr_t delta = (intptr_t)bytesAllocated - (intptr_t)m_bytesAllocated; | 232 intptr_t delta = (intptr_t)bytesAllocated - (intptr_t)m_bytesAllocated; |
234 m_bytesAllocated = bytesAllocated; | 233 m_bytesAllocated = bytesAllocated; |
235 Canvas2DLayerManager::get().layerTransientResourceAllocationChanged(this, de
lta); | 234 Canvas2DLayerManager::get().layerTransientResourceAllocationChanged(this, de
lta); |
236 } | 235 } |
237 | 236 |
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
403 return false; | 402 return false; |
404 } | 403 } |
405 if (!checkSurfaceValid()) | 404 if (!checkSurfaceValid()) |
406 return false; | 405 return false; |
407 | 406 |
408 WebGraphicsContext3D* webContext = context(); | 407 WebGraphicsContext3D* webContext = context(); |
409 | 408 |
410 // Release to skia textures that were previouosly released by the | 409 // Release to skia textures that were previouosly released by the |
411 // compositor. We do this before acquiring the next snapshot in | 410 // compositor. We do this before acquiring the next snapshot in |
412 // order to cap maximum gpu memory consumption. | 411 // order to cap maximum gpu memory consumption. |
413 webContext->makeContextCurrent(); | |
414 flush(); | 412 flush(); |
415 | 413 |
416 RefPtr<SkImage> image = adoptRef(m_canvas->newImageSnapshot()); | 414 RefPtr<SkImage> image = adoptRef(m_canvas->newImageSnapshot()); |
417 | 415 |
418 // Early exit if canvas was not drawn to since last prepareMailbox | 416 // Early exit if canvas was not drawn to since last prepareMailbox |
419 if (image->uniqueID() == m_lastImageId) | 417 if (image->uniqueID() == m_lastImageId) |
420 return false; | 418 return false; |
421 m_lastImageId = image->uniqueID(); | 419 m_lastImageId = image->uniqueID(); |
422 | 420 |
423 MailboxInfo* mailboxInfo = createMailboxInfo(); | 421 MailboxInfo* mailboxInfo = createMailboxInfo(); |
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
570 Canvas2DLayerBridge::MailboxInfo::MailboxInfo(const MailboxInfo& other) { | 568 Canvas2DLayerBridge::MailboxInfo::MailboxInfo(const MailboxInfo& other) { |
571 // This copy constructor should only be used for Vector reallocation | 569 // This copy constructor should only be used for Vector reallocation |
572 // Assuming 'other' is to be destroyed, we transfer m_image ownership | 570 // Assuming 'other' is to be destroyed, we transfer m_image ownership |
573 // rather than do a refcount dance. | 571 // rather than do a refcount dance. |
574 memcpy(&m_mailbox, &other.m_mailbox, sizeof(m_mailbox)); | 572 memcpy(&m_mailbox, &other.m_mailbox, sizeof(m_mailbox)); |
575 m_image = const_cast<MailboxInfo*>(&other)->m_image.release(); | 573 m_image = const_cast<MailboxInfo*>(&other)->m_image.release(); |
576 m_status = other.m_status; | 574 m_status = other.m_status; |
577 } | 575 } |
578 | 576 |
579 } // namespace blink | 577 } // namespace blink |
OLD | NEW |