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

Side by Side Diff: gpu/command_buffer/service/mailbox_manager.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
1 // Copyright (c) 2012 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 #ifndef GPU_COMMAND_BUFFER_SERVICE_MAILBOX_MANAGER_H_ 5 #ifndef GPU_COMMAND_BUFFER_SERVICE_MAILBOX_MANAGER_H_
6 #define GPU_COMMAND_BUFFER_SERVICE_MAILBOX_MANAGER_H_ 6 #define GPU_COMMAND_BUFFER_SERVICE_MAILBOX_MANAGER_H_
7 7
8 #include <functional>
9 #include <map>
10
11 #include "base/memory/linked_ptr.h"
12 #include "base/memory/ref_counted.h" 8 #include "base/memory/ref_counted.h"
13 #include "gpu/command_buffer/common/constants.h"
14 #include "gpu/command_buffer/common/mailbox.h" 9 #include "gpu/command_buffer/common/mailbox.h"
15 #include "gpu/gpu_export.h" 10 #include "gpu/gpu_export.h"
16 11
17 typedef signed char GLbyte;
18
19 namespace gpu { 12 namespace gpu {
20 namespace gles2 { 13 namespace gles2 {
21 14
22 class MailboxSynchronizer;
23 class Texture; 15 class Texture;
24 class TextureManager;
25 16
26 // Manages resources scoped beyond the context or context group level. 17 // Manages resources scoped beyond the context or context group level.
27 class GPU_EXPORT MailboxManager : public base::RefCounted<MailboxManager> { 18 class GPU_EXPORT MailboxManager : public base::RefCounted<MailboxManager> {
28 public: 19 public:
29 MailboxManager();
30
31 // Look up the texture definition from the named mailbox. 20 // Look up the texture definition from the named mailbox.
32 Texture* ConsumeTexture(unsigned target, const Mailbox& mailbox); 21 virtual Texture* ConsumeTexture(const Mailbox& mailbox) = 0;
33 22
34 // Put the texture into the named mailbox. 23 // Put the texture into the named mailbox.
35 void ProduceTexture(unsigned target, 24 virtual void ProduceTexture(const Mailbox& mailbox, Texture* texture) = 0;
36 const Mailbox& mailbox,
37 Texture* texture);
38 25
39 // Returns whether this manager synchronizes with other instances. 26 // If |true| then Pull/PushTextureUpdates() needs to be called.
40 bool UsesSync() { return sync_ != NULL; } 27 virtual bool UsesSync() = 0;
41 28
42 // Used with the MailboxSynchronizer to push/pull texture state to/from 29 // Used to synchronize texture state across share groups.
43 // other manager instances. 30 virtual void PushTextureUpdates(uint32 sync_point) = 0;
44 void PushTextureUpdates(uint32 sync_point); 31 virtual void PullTextureUpdates(uint32 sync_point) = 0;
45 void PullTextureUpdates(uint32 sync_point);
46 32
47 // Destroy any mailbox that reference the given texture. 33 // Destroy any mailbox that reference the given texture.
48 void TextureDeleted(Texture* texture); 34 virtual void TextureDeleted(Texture* texture) = 0;
35
36 protected:
37 MailboxManager() {}
38 virtual ~MailboxManager() {}
49 39
50 private: 40 private:
51 friend class base::RefCounted<MailboxManager>; 41 friend class base::RefCounted<MailboxManager>;
52 friend class MailboxSynchronizer;
53
54 ~MailboxManager();
55
56 struct TargetName {
57 TargetName(unsigned target, const Mailbox& mailbox);
58 unsigned target;
59 Mailbox mailbox;
60 };
61 void InsertTexture(TargetName target_name, Texture* texture);
62
63 static bool TargetNameLess(const TargetName& lhs, const TargetName& rhs);
64
65 // This is a bidirectional map between mailbox and textures. We can have
66 // multiple mailboxes per texture, but one texture per mailbox. We keep an
67 // iterator in the MailboxToTextureMap to be able to manage changes to
68 // the TextureToMailboxMap efficiently.
69 typedef std::multimap<Texture*, TargetName> TextureToMailboxMap;
70 typedef std::map<TargetName,
71 TextureToMailboxMap::iterator,
72 std::pointer_to_binary_function<const TargetName&,
73 const TargetName&,
74 bool> > MailboxToTextureMap;
75
76 MailboxToTextureMap mailbox_to_textures_;
77 TextureToMailboxMap textures_to_mailboxes_;
78
79 MailboxSynchronizer* sync_;
80 42
81 DISALLOW_COPY_AND_ASSIGN(MailboxManager); 43 DISALLOW_COPY_AND_ASSIGN(MailboxManager);
82 }; 44 };
45
83 } // namespage gles2 46 } // namespage gles2
84 } // namespace gpu 47 } // namespace gpu
85 48
86 #endif // GPU_COMMAND_BUFFER_SERVICE_MAILBOX_MANAGER_H_ 49 #endif // GPU_COMMAND_BUFFER_SERVICE_MAILBOX_MANAGER_H_
87 50
OLDNEW
« no previous file with comments | « gpu/command_buffer/service/in_process_command_buffer.cc ('k') | gpu/command_buffer/service/mailbox_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698