Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(531)

Side by Side Diff: Source/platform/graphics/Canvas2DLayerBridge.cpp

Issue 101163004: Fix the context loss issue when switching tabs after enabled Canvas2D hardware acceleration (Closed) Base URL: http://src.chromium.org/blink/trunk/
Patch Set: Created 6 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 255 matching lines...) Expand 10 before | Expand all | Expand 10 after
266 } 266 }
267 267
268 bool Canvas2DLayerBridge::hasReleasedMailbox() const 268 bool Canvas2DLayerBridge::hasReleasedMailbox() const
269 { 269 {
270 return m_releasedMailboxInfoIndex != InvalidMailboxIndex; 270 return m_releasedMailboxInfoIndex != InvalidMailboxIndex;
271 } 271 }
272 272
273 void Canvas2DLayerBridge::freeReleasedMailbox() 273 void Canvas2DLayerBridge::freeReleasedMailbox()
274 { 274 {
275 MailboxInfo* mailboxInfo = releasedMailboxInfo(); 275 MailboxInfo* mailboxInfo = releasedMailboxInfo();
276 m_lastImageId = -1;
boliu 2014/02/11 19:29:41 We only want to do this if the released mailbox ma
276 if (!mailboxInfo) 277 if (!mailboxInfo)
277 return; 278 return;
278 279
279 ASSERT(mailboxInfo->m_status == MailboxReleased); 280 ASSERT(mailboxInfo->m_status == MailboxReleased);
280 if (mailboxInfo->m_mailbox.syncPoint) { 281 if (mailboxInfo->m_mailbox.syncPoint) {
281 context()->waitSyncPoint(mailboxInfo->m_mailbox.syncPoint); 282 context()->waitSyncPoint(mailboxInfo->m_mailbox.syncPoint);
282 mailboxInfo->m_mailbox.syncPoint = 0; 283 mailboxInfo->m_mailbox.syncPoint = 0;
283 } 284 }
284 // Invalidate texture state in case the compositor altered it since the copy -on-write. 285 // Invalidate texture state in case the compositor altered it since the copy -on-write.
285 if (mailboxInfo->m_image) { 286 if (mailboxInfo->m_image) {
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
359 webContext->makeContextCurrent(); 360 webContext->makeContextCurrent();
360 flush(); 361 flush();
361 362
362 RefPtr<SkImage> image = adoptRef(m_canvas->newImageSnapshot()); 363 RefPtr<SkImage> image = adoptRef(m_canvas->newImageSnapshot());
363 364
364 // Early exit if canvas was not drawn to since last prepareMailbox 365 // Early exit if canvas was not drawn to since last prepareMailbox
365 if (image->uniqueID() == m_lastImageId) 366 if (image->uniqueID() == m_lastImageId)
366 return false; 367 return false;
367 m_lastImageId = image->uniqueID(); 368 m_lastImageId = image->uniqueID();
368 369
369 MailboxInfo* mailboxInfo = createMailboxInfo(); 370 MailboxInfo* mailboxInfo = createMailboxInfo();
boliu 2014/02/11 19:29:41 Here, will need to check if there is already a mai
370 mailboxInfo->m_status = MailboxInUse; 371 mailboxInfo->m_status = MailboxInUse;
371 mailboxInfo->m_image = image; 372 mailboxInfo->m_image = image;
372 373
373 // Because of texture sharing with the compositor, we must invalidate 374 // Because of texture sharing with the compositor, we must invalidate
374 // the state cached in skia so that the deferred copy on write 375 // the state cached in skia so that the deferred copy on write
375 // in SkSurface_Gpu does not make any false assumptions. 376 // in SkSurface_Gpu does not make any false assumptions.
376 mailboxInfo->m_image->getTexture()->invalidateCachedState(); 377 mailboxInfo->m_image->getTexture()->invalidateCachedState();
377 378
378 ASSERT(mailboxInfo->m_mailbox.syncPoint == 0); 379 ASSERT(mailboxInfo->m_mailbox.syncPoint == 0);
379 ASSERT(mailboxInfo->m_image.get()); 380 ASSERT(mailboxInfo->m_image.get());
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
488 Canvas2DLayerBridge::MailboxInfo::MailboxInfo(const MailboxInfo& other) { 489 Canvas2DLayerBridge::MailboxInfo::MailboxInfo(const MailboxInfo& other) {
489 // This copy constructor should only be used for Vector reallocation 490 // This copy constructor should only be used for Vector reallocation
490 // Assuming 'other' is to be destroyed, we transfer m_image ownership 491 // Assuming 'other' is to be destroyed, we transfer m_image ownership
491 // rather than do a refcount dance. 492 // rather than do a refcount dance.
492 memcpy(&m_mailbox, &other.m_mailbox, sizeof(m_mailbox)); 493 memcpy(&m_mailbox, &other.m_mailbox, sizeof(m_mailbox));
493 m_image = const_cast<MailboxInfo*>(&other)->m_image.release(); 494 m_image = const_cast<MailboxInfo*>(&other)->m_image.release();
494 m_status = other.m_status; 495 m_status = other.m_status;
495 } 496 }
496 497
497 } 498 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698