OLD | NEW |
---|---|
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/basictypes.h" | |
11 #include "base/callback.h" | 10 #include "base/callback.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.h" |
14 #include "ui/gfx/size.h" | |
14 | 15 |
15 namespace cc { | 16 namespace cc { |
16 | 17 |
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. | |
17 class CC_EXPORT TextureMailbox { | 20 class CC_EXPORT TextureMailbox { |
18 public: | 21 public: |
19 typedef base::Callback<void(unsigned sync_point, | 22 typedef base::Callback<void(unsigned sync_point, |
20 bool lost_resource)> ReleaseCallback; | 23 bool lost_resource)> ReleaseCallback; |
21 TextureMailbox(); | 24 TextureMailbox(); |
22 TextureMailbox(const std::string& mailbox_name, | 25 TextureMailbox(const std::string& mailbox_name, |
23 const ReleaseCallback& callback); | 26 const ReleaseCallback& callback); |
24 TextureMailbox(const gpu::Mailbox& mailbox_name, | 27 TextureMailbox(const gpu::Mailbox& mailbox_name, |
25 const ReleaseCallback& callback); | 28 const ReleaseCallback& callback); |
26 TextureMailbox(const gpu::Mailbox& mailbox_name, | 29 TextureMailbox(const gpu::Mailbox& mailbox_name, |
27 const ReleaseCallback& callback, | 30 const ReleaseCallback& callback, |
28 unsigned sync_point); | 31 unsigned sync_point); |
29 TextureMailbox(const gpu::Mailbox& mailbox_name, | 32 TextureMailbox(const gpu::Mailbox& mailbox_name, |
30 const ReleaseCallback& callback, | 33 const ReleaseCallback& callback, |
31 unsigned texture_target, | 34 unsigned texture_target, |
32 unsigned sync_point); | 35 unsigned sync_point); |
36 TextureMailbox(base::SharedMemoryHandle handle, | |
37 gfx::Size size, | |
38 const ReleaseCallback& callback); | |
33 | 39 |
34 ~TextureMailbox(); | 40 ~TextureMailbox(); |
35 | 41 |
42 bool IsValid() const { return IsTexture() || IsSharedMemory(); } | |
43 bool IsTexture() const { return !name_.IsZero(); } | |
44 bool IsSharedMemory() const { | |
45 return base::SharedMemory::IsHandleValid(handle_); | |
46 } | |
47 | |
48 bool Equals(const TextureMailbox&) const; | |
49 bool Contains(const gpu::Mailbox&) const; | |
50 bool Contains(base::SharedMemoryHandle handle) const; | |
piman
2013/05/28 20:58:57
nit: no overloading.
slavi
2013/05/29 18:31:48
Done.
| |
51 | |
36 const ReleaseCallback& callback() const { return callback_; } | 52 const ReleaseCallback& callback() const { return callback_; } |
37 const int8* data() const { return name_.name; } | 53 const int8* data() const { return name_.name; } |
38 bool Equals(const gpu::Mailbox&) const; | |
39 bool Equals(const TextureMailbox&) const; | |
40 bool IsEmpty() const; | |
41 const gpu::Mailbox& name() const { return name_; } | 54 const gpu::Mailbox& name() const { return name_; } |
42 void ResetSyncPoint() { sync_point_ = 0; } | 55 void ResetSyncPoint() { sync_point_ = 0; } |
43 void RunReleaseCallback(unsigned sync_point, bool lost_resource) const; | 56 void RunReleaseCallback(unsigned sync_point, bool lost_resource) const; |
44 void SetName(const gpu::Mailbox&); | 57 void SetName(const gpu::Mailbox&); |
45 unsigned target() const { return target_; } | 58 unsigned target() const { return target_; } |
46 unsigned sync_point() const { return sync_point_; } | 59 unsigned sync_point() const { return sync_point_; } |
47 | 60 |
61 void SetHandle(base::SharedMemoryHandle handle, gfx::Size size); | |
62 base::SharedMemoryHandle handle() const { return handle_; } | |
63 gfx::Size size() const { return size_; } | |
piman
2013/05/28 20:58:57
Maybe name this software_size, or shared_memory_si
slavi
2013/05/29 18:31:48
Done.
| |
64 | |
48 private: | 65 private: |
49 gpu::Mailbox name_; | 66 gpu::Mailbox name_; |
50 ReleaseCallback callback_; | 67 ReleaseCallback callback_; |
51 unsigned target_; | 68 unsigned target_; |
52 unsigned sync_point_; | 69 unsigned sync_point_; |
70 base::SharedMemoryHandle handle_; | |
71 gfx::Size size_; | |
53 }; | 72 }; |
54 | 73 |
55 } // namespace cc | 74 } // namespace cc |
56 | 75 |
57 #endif // CC_RESOURCES_TEXTURE_MAILBOX_H_ | 76 #endif // CC_RESOURCES_TEXTURE_MAILBOX_H_ |
OLD | NEW |