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

Side by Side Diff: gpu/command_buffer/service/mailbox_manager_impl.cc

Issue 681713002: Update from chromium https://crrev.com/301315 (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Created 6 years, 1 month 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
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "gpu/command_buffer/service/mailbox_manager_impl.h"
6
7 #include <algorithm>
8
9 #include "gpu/command_buffer/service/texture_manager.h"
10
11 namespace gpu {
12 namespace gles2 {
13
14 MailboxManagerImpl::MailboxManagerImpl() {
15 }
16
17 MailboxManagerImpl::~MailboxManagerImpl() {
18 DCHECK(mailbox_to_textures_.empty());
19 DCHECK(textures_to_mailboxes_.empty());
20 }
21
22 bool MailboxManagerImpl::UsesSync() {
23 return false;
24 }
25
26 Texture* MailboxManagerImpl::ConsumeTexture(const Mailbox& mailbox) {
27 MailboxToTextureMap::iterator it =
28 mailbox_to_textures_.find(mailbox);
29 if (it != mailbox_to_textures_.end())
30 return it->second->first;
31
32 return NULL;
33 }
34
35 void MailboxManagerImpl::ProduceTexture(const Mailbox& mailbox,
36 Texture* texture) {
37 MailboxToTextureMap::iterator it = mailbox_to_textures_.find(mailbox);
38 if (it != mailbox_to_textures_.end()) {
39 if (it->second->first == texture)
40 return;
41 TextureToMailboxMap::iterator texture_it = it->second;
42 mailbox_to_textures_.erase(it);
43 textures_to_mailboxes_.erase(texture_it);
44 }
45 InsertTexture(mailbox, texture);
46 }
47
48 void MailboxManagerImpl::InsertTexture(const Mailbox& mailbox,
49 Texture* texture) {
50 texture->SetMailboxManager(this);
51 TextureToMailboxMap::iterator texture_it =
52 textures_to_mailboxes_.insert(std::make_pair(texture, mailbox));
53 mailbox_to_textures_.insert(std::make_pair(mailbox, texture_it));
54 DCHECK_EQ(mailbox_to_textures_.size(), textures_to_mailboxes_.size());
55 }
56
57 void MailboxManagerImpl::TextureDeleted(Texture* texture) {
58 std::pair<TextureToMailboxMap::iterator,
59 TextureToMailboxMap::iterator> range =
60 textures_to_mailboxes_.equal_range(texture);
61 for (TextureToMailboxMap::iterator it = range.first;
62 it != range.second; ++it) {
63 size_t count = mailbox_to_textures_.erase(it->second);
64 DCHECK(count == 1);
65 }
66 textures_to_mailboxes_.erase(range.first, range.second);
67 DCHECK_EQ(mailbox_to_textures_.size(), textures_to_mailboxes_.size());
68 }
69
70 } // namespace gles2
71 } // namespace gpu
OLDNEW
« no previous file with comments | « gpu/command_buffer/service/mailbox_manager_impl.h ('k') | gpu/command_buffer/service/mailbox_manager_sync.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698