blob: 8e0558212a68cfeac852dfdc3147e38317747d05 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
|
// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "content/browser/compositor/owned_mailbox.h"
#include "base/logging.h"
#include "content/browser/compositor/gl_helper.h"
#include "content/browser/compositor/image_transport_factory.h"
namespace content {
OwnedMailbox::OwnedMailbox(GLHelper* gl_helper)
: texture_id_(0), gl_helper_(gl_helper) {
texture_id_ = gl_helper_->CreateTexture();
mailbox_holder_ = gl_helper_->ProduceMailboxHolderFromTexture(texture_id_);
ImageTransportFactory::GetInstance()->AddObserver(this);
}
OwnedMailbox::~OwnedMailbox() {
if (gl_helper_)
Destroy();
}
void OwnedMailbox::UpdateSyncToken(const gpu::SyncToken& sync_token) {
if (sync_token.HasData())
mailbox_holder_.sync_token = sync_token;
}
void OwnedMailbox::Destroy() {
ImageTransportFactory::GetInstance()->RemoveObserver(this);
gl_helper_->WaitSyncToken(mailbox_holder_.sync_token);
gl_helper_->DeleteTexture(texture_id_);
texture_id_ = 0;
mailbox_holder_ = gpu::MailboxHolder();
gl_helper_ = NULL;
}
void OwnedMailbox::OnLostResources() {
if (gl_helper_)
Destroy();
}
} // namespace content
|