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

Side by Side Diff: content/browser/compositor/owned_mailbox.cc

Issue 2083853002: exo: Recreate Surface resources on context lost. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix nits Created 4 years, 6 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
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "content/browser/compositor/owned_mailbox.h" 5 #include "content/browser/compositor/owned_mailbox.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "components/display_compositor/gl_helper.h" 8 #include "components/display_compositor/gl_helper.h"
9 #include "content/browser/compositor/image_transport_factory.h" 9 #include "content/browser/compositor/image_transport_factory.h"
10 10
11 namespace content { 11 namespace content {
12 12
13 OwnedMailbox::OwnedMailbox(display_compositor::GLHelper* gl_helper) 13 OwnedMailbox::OwnedMailbox(display_compositor::GLHelper* gl_helper)
14 : texture_id_(0), gl_helper_(gl_helper) { 14 : texture_id_(0), gl_helper_(gl_helper) {
15 texture_id_ = gl_helper_->CreateTexture(); 15 texture_id_ = gl_helper_->CreateTexture();
16 mailbox_holder_ = gl_helper_->ProduceMailboxHolderFromTexture(texture_id_); 16 mailbox_holder_ = gl_helper_->ProduceMailboxHolderFromTexture(texture_id_);
17 ImageTransportFactory::GetInstance()->AddObserver(this); 17 ImageTransportFactory::GetInstance()->GetContextFactory()->AddObserver(this);
18 } 18 }
19 19
20 OwnedMailbox::~OwnedMailbox() { 20 OwnedMailbox::~OwnedMailbox() {
21 if (gl_helper_) 21 if (gl_helper_)
22 Destroy(); 22 Destroy();
23 } 23 }
24 24
25 void OwnedMailbox::UpdateSyncToken(const gpu::SyncToken& sync_token) { 25 void OwnedMailbox::UpdateSyncToken(const gpu::SyncToken& sync_token) {
26 if (sync_token.HasData()) 26 if (sync_token.HasData())
27 mailbox_holder_.sync_token = sync_token; 27 mailbox_holder_.sync_token = sync_token;
28 } 28 }
29 29
30 void OwnedMailbox::Destroy() { 30 void OwnedMailbox::Destroy() {
31 ImageTransportFactory::GetInstance()->RemoveObserver(this); 31 ImageTransportFactory::GetInstance()->GetContextFactory()->RemoveObserver(
32 this);
32 gl_helper_->WaitSyncToken(mailbox_holder_.sync_token); 33 gl_helper_->WaitSyncToken(mailbox_holder_.sync_token);
33 gl_helper_->DeleteTexture(texture_id_); 34 gl_helper_->DeleteTexture(texture_id_);
34 texture_id_ = 0; 35 texture_id_ = 0;
35 mailbox_holder_ = gpu::MailboxHolder(); 36 mailbox_holder_ = gpu::MailboxHolder();
36 gl_helper_ = NULL; 37 gl_helper_ = NULL;
37 } 38 }
38 39
39 void OwnedMailbox::OnLostResources() { 40 void OwnedMailbox::OnLostResources() {
40 if (gl_helper_) 41 if (gl_helper_)
41 Destroy(); 42 Destroy();
42 } 43 }
43 44
44 } // namespace content 45 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/compositor/owned_mailbox.h ('k') | content/browser/compositor/test/no_transport_image_transport_factory.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698