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

Side by Side Diff: gpu/command_buffer/service/mailbox_manager_sync.h

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 #ifndef GPU_COMMAND_BUFFER_SERVICE_MAILBOX_MANAGER_SYNC_H_
6 #define GPU_COMMAND_BUFFER_SERVICE_MAILBOX_MANAGER_SYNC_H_
7
8 #include <map>
9 #include <utility>
10
11 #include "base/lazy_instance.h"
12 #include "base/memory/ref_counted.h"
13 #include "gpu/command_buffer/common/constants.h"
14 #include "gpu/command_buffer/common/mailbox.h"
15 #include "gpu/command_buffer/service/mailbox_manager.h"
16 #include "gpu/command_buffer/service/texture_definition.h"
17 #include "gpu/gpu_export.h"
18
19 namespace gpu {
20 namespace gles2 {
21
22 class Texture;
23 class TextureManager;
24
25 // Manages resources scoped beyond the context or context group level
26 // and across threads and driver level share groups by synchronizing
27 // texture state.
28 class GPU_EXPORT MailboxManagerSync : public MailboxManager {
29 public:
30 MailboxManagerSync();
31
32 // MailboxManager implementation:
33 Texture* ConsumeTexture(const Mailbox& mailbox) override;
34 void ProduceTexture(const Mailbox& mailbox, Texture* texture) override;
35 bool UsesSync() override;
36 void PushTextureUpdates(uint32 sync_point) override;
37 void PullTextureUpdates(uint32 sync_point) override;
38 void TextureDeleted(Texture* texture) override;
39
40 private:
41 friend class base::RefCounted<MailboxManager>;
42
43 ~MailboxManagerSync() override;
44
45 class TextureGroup : public base::RefCounted<TextureGroup> {
46 public:
47 static TextureGroup* CreateFromTexture(const Mailbox& name,
48 MailboxManagerSync* manager,
49 Texture* texture);
50 static TextureGroup* FromName(const Mailbox& name);
51
52 void AddName(const Mailbox& name);
53 void RemoveName(const Mailbox& name);
54
55 void AddTexture(MailboxManagerSync* manager, Texture* texture);
56 // Returns true if there are other textures left in the group after removal.
57 bool RemoveTexture(MailboxManagerSync* manager, Texture* texture);
58 Texture* FindTexture(MailboxManagerSync* manager);
59
60 const TextureDefinition& GetDefinition() { return definition_; }
61 void SetDefinition(TextureDefinition definition) {
62 definition_ = definition;
63 }
64
65 private:
66 friend class base::RefCounted<TextureGroup>;
67 TextureGroup();
68 ~TextureGroup();
69
70 typedef std::vector<std::pair<MailboxManagerSync*, Texture*>> TextureList;
71 std::vector<Mailbox> names_;
72 TextureList textures_;
73 TextureDefinition definition_;
74
75 typedef std::map<Mailbox, scoped_refptr<TextureGroup>>
76 MailboxToGroupMap;
77 static base::LazyInstance<MailboxToGroupMap> mailbox_to_group_;
78 };
79
80 struct TextureGroupRef {
81 TextureGroupRef(unsigned version, TextureGroup* group);
82 ~TextureGroupRef();
83 unsigned version;
84 scoped_refptr<TextureGroup> group;
85 };
86 static void UpdateDefinitionLocked(Texture* texture,
87 TextureGroupRef* group_ref);
88
89 typedef std::map<Texture*, TextureGroupRef> TextureToGroupMap;
90 TextureToGroupMap texture_to_group_;
91
92 DISALLOW_COPY_AND_ASSIGN(MailboxManagerSync);
93 };
94
95 } // namespage gles2
96 } // namespace gpu
97
98 #endif // GPU_COMMAND_BUFFER_SERVICE_MAILBOX_MANAGER_SYNC_H_
99
OLDNEW
« no previous file with comments | « gpu/command_buffer/service/mailbox_manager_impl.cc ('k') | gpu/command_buffer/service/mailbox_manager_sync.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698