Don't add an aura tooltip to bubble close buttons on Windows.
[chromium-blink-merge.git] / gpu / command_buffer / service / mailbox_manager_sync.h
blob4b3abf9b4eb1b653c9ebfceccabd5feaecbfa2aa
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.
5 #ifndef GPU_COMMAND_BUFFER_SERVICE_MAILBOX_MANAGER_SYNC_H_
6 #define GPU_COMMAND_BUFFER_SERVICE_MAILBOX_MANAGER_SYNC_H_
8 #include <map>
9 #include <utility>
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"
19 namespace gpu {
20 namespace gles2 {
22 class Texture;
23 class TextureManager;
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();
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;
40 private:
41 friend class base::RefCounted<MailboxManager>;
43 static bool SkipTextureWorkarounds(const Texture* texture);
45 ~MailboxManagerSync() override;
47 class TextureGroup : public base::RefCounted<TextureGroup> {
48 public:
49 static TextureGroup* CreateFromTexture(const Mailbox& name,
50 MailboxManagerSync* manager,
51 Texture* texture);
52 static TextureGroup* FromName(const Mailbox& name);
54 void AddName(const Mailbox& name);
55 void RemoveName(const Mailbox& name);
57 void AddTexture(MailboxManagerSync* manager, Texture* texture);
58 // Returns true if there are other textures left in the group after removal.
59 bool RemoveTexture(MailboxManagerSync* manager, Texture* texture);
60 Texture* FindTexture(MailboxManagerSync* manager);
62 const TextureDefinition& GetDefinition() { return definition_; }
63 void SetDefinition(TextureDefinition definition) {
64 definition_ = definition;
67 private:
68 friend class base::RefCounted<TextureGroup>;
69 TextureGroup();
70 ~TextureGroup();
72 typedef std::vector<std::pair<MailboxManagerSync*, Texture*>> TextureList;
73 std::vector<Mailbox> names_;
74 TextureList textures_;
75 TextureDefinition definition_;
77 typedef std::map<Mailbox, scoped_refptr<TextureGroup>>
78 MailboxToGroupMap;
79 static base::LazyInstance<MailboxToGroupMap> mailbox_to_group_;
82 struct TextureGroupRef {
83 TextureGroupRef(unsigned version, TextureGroup* group);
84 ~TextureGroupRef();
85 unsigned version;
86 scoped_refptr<TextureGroup> group;
88 static void UpdateDefinitionLocked(Texture* texture,
89 TextureGroupRef* group_ref);
91 typedef std::map<Texture*, TextureGroupRef> TextureToGroupMap;
92 TextureToGroupMap texture_to_group_;
94 DISALLOW_COPY_AND_ASSIGN(MailboxManagerSync);
97 } // namespage gles2
98 } // namespace gpu
100 #endif // GPU_COMMAND_BUFFER_SERVICE_MAILBOX_MANAGER_SYNC_H_