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

Side by Side Diff: cc/resources/texture_mailbox.h

Issue 132233041: Add gpu::MailboxHolder to hold state for a gpu::Mailbox (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: ff7262fa Rebase. Created 6 years, 10 months 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 | Annotate | Revision Log
« no previous file with comments | « cc/resources/single_release_callback.cc ('k') | cc/resources/texture_mailbox.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 CC_RESOURCES_TEXTURE_MAILBOX_H_ 5 #ifndef CC_RESOURCES_TEXTURE_MAILBOX_H_
6 #define CC_RESOURCES_TEXTURE_MAILBOX_H_ 6 #define CC_RESOURCES_TEXTURE_MAILBOX_H_
7 7
8 #include <string> 8 #include <string>
9 9
10 #include "base/callback.h" 10 #include "base/callback.h"
11 #include "base/memory/shared_memory.h" 11 #include "base/memory/shared_memory.h"
12 #include "cc/base/cc_export.h" 12 #include "cc/base/cc_export.h"
13 #include "gpu/command_buffer/common/mailbox.h" 13 #include "gpu/command_buffer/common/mailbox_holder.h"
14 #include "ui/gfx/size.h" 14 #include "ui/gfx/size.h"
15 15
16 namespace cc { 16 namespace cc {
17 17
18 // TODO(skaslev, danakj) Rename this class more apropriately since now it 18 // TODO(skaslev, danakj) Rename this class more apropriately since now it
19 // can hold a shared memory resource as well as a texture mailbox. 19 // can hold a shared memory resource as well as a texture mailbox.
20 class CC_EXPORT TextureMailbox { 20 class CC_EXPORT TextureMailbox {
21 public: 21 public:
22 TextureMailbox(); 22 TextureMailbox();
23 explicit TextureMailbox(const std::string& mailbox_name); 23 explicit TextureMailbox(const gpu::MailboxHolder& mailbox_holder);
24 explicit TextureMailbox(const gpu::Mailbox& mailbox_name); 24 TextureMailbox(const gpu::Mailbox& mailbox, uint32 target, uint32 sync_point);
25 TextureMailbox(const gpu::Mailbox& mailbox_name, 25 TextureMailbox(base::SharedMemory* shared_memory, const gfx::Size& size);
26 unsigned sync_point);
27 TextureMailbox(const gpu::Mailbox& mailbox_name,
28 unsigned texture_target,
29 unsigned sync_point);
30 TextureMailbox(base::SharedMemory* shared_memory,
31 const gfx::Size& size);
32 26
33 ~TextureMailbox(); 27 ~TextureMailbox();
34 28
35 bool IsValid() const { return IsTexture() || IsSharedMemory(); } 29 bool IsValid() const { return IsTexture() || IsSharedMemory(); }
36 bool IsTexture() const { return !name_.IsZero(); } 30 bool IsTexture() const { return !mailbox_holder_.mailbox.IsZero(); }
37 bool IsSharedMemory() const { return shared_memory_ != NULL; } 31 bool IsSharedMemory() const { return shared_memory_ != NULL; }
38 32
39 bool Equals(const TextureMailbox&) const; 33 bool Equals(const TextureMailbox&) const;
40 bool ContainsMailbox(const gpu::Mailbox&) const;
41 bool ContainsHandle(base::SharedMemoryHandle handle) const;
42 34
43 const int8* data() const { return name_.name; } 35 const gpu::Mailbox& mailbox() const { return mailbox_holder_.mailbox; }
44 const gpu::Mailbox& name() const { return name_; } 36 const int8* name() const { return mailbox().name; }
45 void ResetSyncPoint() { sync_point_ = 0; } 37 uint32 target() const { return mailbox_holder_.texture_target; }
46 unsigned target() const { return target_; } 38 uint32 sync_point() const { return mailbox_holder_.sync_point; }
47 unsigned sync_point() const { return sync_point_; } 39 void set_sync_point(int32 sync_point) {
40 mailbox_holder_.sync_point = sync_point;
41 }
48 42
49 base::SharedMemory* shared_memory() const { return shared_memory_; } 43 base::SharedMemory* shared_memory() const { return shared_memory_; }
50 gfx::Size shared_memory_size() const { return shared_memory_size_; } 44 gfx::Size shared_memory_size() const { return shared_memory_size_; }
51 size_t shared_memory_size_in_bytes() const; 45 size_t shared_memory_size_in_bytes() const;
52 46
53 // TODO(danakj): ReleaseCallback should be separate from this class, and stop
54 // storing a TextureMailbox in ResourceProvider. Then we can remove this.
55 void SetName(const gpu::Mailbox& name);
56
57 private: 47 private:
58 gpu::Mailbox name_; 48 gpu::MailboxHolder mailbox_holder_;
59 unsigned target_;
60 unsigned sync_point_;
61 base::SharedMemory* shared_memory_; 49 base::SharedMemory* shared_memory_;
62 gfx::Size shared_memory_size_; 50 gfx::Size shared_memory_size_;
63 }; 51 };
64 52
65 } // namespace cc 53 } // namespace cc
66 54
67 #endif // CC_RESOURCES_TEXTURE_MAILBOX_H_ 55 #endif // CC_RESOURCES_TEXTURE_MAILBOX_H_
OLDNEW
« no previous file with comments | « cc/resources/single_release_callback.cc ('k') | cc/resources/texture_mailbox.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698