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

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

Issue 166193004: PrepareMailbox when all mailboxes have been returned (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
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 | « Source/platform/graphics/Canvas2DLayerBridge.h ('k') | 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 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
86 , m_surfaceIsValid(true) 86 , m_surfaceIsValid(true)
87 , m_framesPending(0) 87 , m_framesPending(0)
88 , m_framesSinceMailboxRelease(0) 88 , m_framesSinceMailboxRelease(0)
89 , m_destructionInProgress(false) 89 , m_destructionInProgress(false)
90 , m_rateLimitingEnabled(false) 90 , m_rateLimitingEnabled(false)
91 , m_isHidden(false) 91 , m_isHidden(false)
92 , m_next(0) 92 , m_next(0)
93 , m_prev(0) 93 , m_prev(0)
94 , m_lastImageId(0) 94 , m_lastImageId(0)
95 , m_releasedMailboxInfoIndex(InvalidMailboxIndex) 95 , m_releasedMailboxInfoIndex(InvalidMailboxIndex)
96 , m_activeMailboxCount(0)
96 { 97 {
97 ASSERT(m_canvas); 98 ASSERT(m_canvas);
98 ASSERT(m_contextProvider); 99 ASSERT(m_contextProvider);
99 // Used by browser tests to detect the use of a Canvas2DLayerBridge. 100 // Used by browser tests to detect the use of a Canvas2DLayerBridge.
100 TRACE_EVENT_INSTANT0("test_gpu", "Canvas2DLayerBridgeCreation"); 101 TRACE_EVENT_INSTANT0("test_gpu", "Canvas2DLayerBridgeCreation");
101 m_layer = adoptPtr(blink::Platform::current()->compositorSupport()->createEx ternalTextureLayer(this)); 102 m_layer = adoptPtr(blink::Platform::current()->compositorSupport()->createEx ternalTextureLayer(this));
102 m_layer->setOpaque(opacityMode == Opaque); 103 m_layer->setOpaque(opacityMode == Opaque);
103 m_layer->setBlendBackgroundColor(opacityMode != Opaque); 104 m_layer->setBlendBackgroundColor(opacityMode != Opaque);
104 GraphicsLayer::registerContentsLayer(m_layer->layer()); 105 GraphicsLayer::registerContentsLayer(m_layer->layer());
105 m_layer->setRateLimitContext(m_rateLimitingEnabled); 106 m_layer->setRateLimitContext(m_rateLimitingEnabled);
(...skipping 256 matching lines...) Expand 10 before | Expand all | Expand 10 after
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();
370 mailboxInfo->m_status = MailboxInUse; 371 mailboxInfo->m_status = MailboxInUse;
371 mailboxInfo->m_image = image; 372 mailboxInfo->m_image = image;
373 m_activeMailboxCount++;
372 374
373 // Because of texture sharing with the compositor, we must invalidate 375 // Because of texture sharing with the compositor, we must invalidate
374 // the state cached in skia so that the deferred copy on write 376 // the state cached in skia so that the deferred copy on write
375 // in SkSurface_Gpu does not make any false assumptions. 377 // in SkSurface_Gpu does not make any false assumptions.
376 mailboxInfo->m_image->getTexture()->invalidateCachedState(); 378 mailboxInfo->m_image->getTexture()->invalidateCachedState();
377 379
378 ASSERT(mailboxInfo->m_mailbox.syncPoint == 0); 380 ASSERT(mailboxInfo->m_mailbox.syncPoint == 0);
379 ASSERT(mailboxInfo->m_image.get()); 381 ASSERT(mailboxInfo->m_image.get());
380 ASSERT(mailboxInfo->m_image->getTexture()); 382 ASSERT(mailboxInfo->m_image->getTexture());
381 383
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
432 434
433 void Canvas2DLayerBridge::mailboxReleased(const blink::WebExternalTextureMailbox & mailbox) 435 void Canvas2DLayerBridge::mailboxReleased(const blink::WebExternalTextureMailbox & mailbox)
434 { 436 {
435 freeReleasedMailbox(); // Never have more than one mailbox in the released s tate. 437 freeReleasedMailbox(); // Never have more than one mailbox in the released s tate.
436 Vector<MailboxInfo>::iterator mailboxInfo; 438 Vector<MailboxInfo>::iterator mailboxInfo;
437 for (mailboxInfo = m_mailboxes.begin(); mailboxInfo < m_mailboxes.end(); ++m ailboxInfo) { 439 for (mailboxInfo = m_mailboxes.begin(); mailboxInfo < m_mailboxes.end(); ++m ailboxInfo) {
438 if (!memcmp(mailboxInfo->m_mailbox.name, mailbox.name, sizeof(mailbox.na me))) { 440 if (!memcmp(mailboxInfo->m_mailbox.name, mailbox.name, sizeof(mailbox.na me))) {
439 mailboxInfo->m_mailbox.syncPoint = mailbox.syncPoint; 441 mailboxInfo->m_mailbox.syncPoint = mailbox.syncPoint;
440 ASSERT(mailboxInfo->m_status == MailboxInUse); 442 ASSERT(mailboxInfo->m_status == MailboxInUse);
441 mailboxInfo->m_status = MailboxReleased; 443 mailboxInfo->m_status = MailboxReleased;
444 ASSERT(m_activeMailboxCount > 0);
445 if (!--m_activeMailboxCount)
446 m_lastImageId = 0;
442 // Trigger Canvas2DLayerBridge self-destruction if this is the 447 // Trigger Canvas2DLayerBridge self-destruction if this is the
443 // last live mailbox and the layer bridge is not externally 448 // last live mailbox and the layer bridge is not externally
444 // referenced. 449 // referenced.
445 m_releasedMailboxInfoIndex = mailboxInfo - m_mailboxes.begin(); 450 m_releasedMailboxInfoIndex = mailboxInfo - m_mailboxes.begin();
446 m_framesSinceMailboxRelease = 0; 451 m_framesSinceMailboxRelease = 0;
447 if (isHidden()) { 452 if (isHidden()) {
448 freeReleasedMailbox(); 453 freeReleasedMailbox();
449 } else { 454 } else {
450 ASSERT(!m_destructionInProgress); 455 ASSERT(!m_destructionInProgress);
451 Canvas2DLayerManager::get().layerTransientResourceAllocationChan ged(this); 456 Canvas2DLayerManager::get().layerTransientResourceAllocationChan ged(this);
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
488 Canvas2DLayerBridge::MailboxInfo::MailboxInfo(const MailboxInfo& other) { 493 Canvas2DLayerBridge::MailboxInfo::MailboxInfo(const MailboxInfo& other) {
489 // This copy constructor should only be used for Vector reallocation 494 // This copy constructor should only be used for Vector reallocation
490 // Assuming 'other' is to be destroyed, we transfer m_image ownership 495 // Assuming 'other' is to be destroyed, we transfer m_image ownership
491 // rather than do a refcount dance. 496 // rather than do a refcount dance.
492 memcpy(&m_mailbox, &other.m_mailbox, sizeof(m_mailbox)); 497 memcpy(&m_mailbox, &other.m_mailbox, sizeof(m_mailbox));
493 m_image = const_cast<MailboxInfo*>(&other)->m_image.release(); 498 m_image = const_cast<MailboxInfo*>(&other)->m_image.release();
494 m_status = other.m_status; 499 m_status = other.m_status;
495 } 500 }
496 501
497 } 502 }
OLDNEW
« no previous file with comments | « Source/platform/graphics/Canvas2DLayerBridge.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698