Index: cc/resources/texture_mailbox.cc |
diff --git a/cc/resources/texture_mailbox.cc b/cc/resources/texture_mailbox.cc |
index 6900518967a3af3787b2b12d7faac00f4b289386..4907b7e8b40b7976f65f121c2bea8eb0db6fded7 100644 |
--- a/cc/resources/texture_mailbox.cc |
+++ b/cc/resources/texture_mailbox.cc |
@@ -11,16 +11,18 @@ namespace cc { |
TextureMailbox::TextureMailbox() |
: target_(GL_TEXTURE_2D), |
- sync_point_(0) { |
+ sync_point_(0), |
+ handle_(base::SharedMemory::NULLHandle()) { |
} |
TextureMailbox::TextureMailbox( |
const std::string& mailbox_name, |
- const ReleaseCallback& mailbox_callback) |
- : callback_(mailbox_callback), |
+ const ReleaseCallback& callback) |
+ : callback_(callback), |
target_(GL_TEXTURE_2D), |
- sync_point_(0) { |
- DCHECK(mailbox_name.empty() == mailbox_callback.is_null()); |
+ sync_point_(0), |
+ handle_(base::SharedMemory::NULLHandle()) { |
+ DCHECK(mailbox_name.empty() == callback.is_null()); |
if (!mailbox_name.empty()) { |
CHECK(mailbox_name.size() == sizeof(name_.name)); |
name_.SetName(reinterpret_cast<const int8*>(mailbox_name.data())); |
@@ -29,50 +31,70 @@ TextureMailbox::TextureMailbox( |
TextureMailbox::TextureMailbox( |
const gpu::Mailbox& mailbox_name, |
- const ReleaseCallback& mailbox_callback) |
- : callback_(mailbox_callback), |
+ const ReleaseCallback& callback) |
+ : callback_(callback), |
target_(GL_TEXTURE_2D), |
- sync_point_(0) { |
- DCHECK(mailbox_name.IsZero() == mailbox_callback.is_null()); |
+ sync_point_(0), |
+ handle_(base::SharedMemory::NULLHandle()) { |
+ DCHECK(mailbox_name.IsZero() == callback.is_null()); |
name_.SetName(mailbox_name.name); |
} |
TextureMailbox::TextureMailbox( |
const gpu::Mailbox& mailbox_name, |
- const ReleaseCallback& mailbox_callback, |
+ const ReleaseCallback& callback, |
unsigned sync_point) |
- : callback_(mailbox_callback), |
+ : callback_(callback), |
target_(GL_TEXTURE_2D), |
- sync_point_(sync_point) { |
- DCHECK(mailbox_name.IsZero() == mailbox_callback.is_null()); |
+ sync_point_(sync_point), |
+ handle_(base::SharedMemory::NULLHandle()) { |
+ DCHECK(mailbox_name.IsZero() == callback.is_null()); |
name_.SetName(mailbox_name.name); |
} |
TextureMailbox::TextureMailbox( |
const gpu::Mailbox& mailbox_name, |
- const ReleaseCallback& mailbox_callback, |
+ const ReleaseCallback& callback, |
unsigned texture_target, |
unsigned sync_point) |
- : callback_(mailbox_callback), |
+ : callback_(callback), |
target_(texture_target), |
- sync_point_(sync_point) { |
- DCHECK(mailbox_name.IsZero() == mailbox_callback.is_null()); |
+ sync_point_(sync_point), |
+ handle_(base::SharedMemory::NULLHandle()) { |
+ DCHECK(mailbox_name.IsZero() == callback.is_null()); |
name_.SetName(mailbox_name.name); |
} |
-TextureMailbox::~TextureMailbox() { |
+TextureMailbox::TextureMailbox( |
+ base::SharedMemoryHandle handle, |
+ gfx::Size size, |
+ const ReleaseCallback& callback) |
+ : callback_(callback), |
+ target_(GL_TEXTURE_2D), |
+ sync_point_(0), |
+ handle_(handle), |
+ shared_memory_size_(size) { |
} |
-bool TextureMailbox::Equals(const gpu::Mailbox& other) const { |
- return !memcmp(data(), other.name, sizeof(name_.name)); |
+TextureMailbox::~TextureMailbox() { |
} |
bool TextureMailbox::Equals(const TextureMailbox& other) const { |
- return Equals(other.name()); |
+ if (other.IsTexture()) |
+ return ContainsMailbox(other.name()); |
+ else if (other.IsSharedMemory()) |
+ return ContainsHandle(other.handle()); |
+ |
+ DCHECK(!other.IsValid()); |
+ return !IsValid(); |
+} |
+ |
+bool TextureMailbox::ContainsMailbox(const gpu::Mailbox& other) const { |
+ return IsTexture() && !memcmp(data(), other.name, sizeof(name_.name)); |
} |
-bool TextureMailbox::IsEmpty() const { |
- return name_.IsZero(); |
+bool TextureMailbox::ContainsHandle(base::SharedMemoryHandle handle) const { |
+ return IsSharedMemory() && handle_ == handle; |
} |
void TextureMailbox::RunReleaseCallback(unsigned sync_point, |
@@ -82,7 +104,26 @@ void TextureMailbox::RunReleaseCallback(unsigned sync_point, |
} |
void TextureMailbox::SetName(const gpu::Mailbox& other) { |
+ DCHECK(!base::SharedMemory::IsHandleValid(handle_)); |
name_.SetName(other.name); |
} |
+void TextureMailbox::SetHandle(base::SharedMemoryHandle handle, |
+ gfx::Size size) { |
+ DCHECK(name_.IsZero()); |
+ handle_ = handle; |
+ shared_memory_size_ = size; |
+} |
+ |
+TextureMailbox TextureMailbox::CopyWithNewCallback( |
+ const ReleaseCallback& callback) const { |
+ if (IsTexture()) |
+ return TextureMailbox(name(), callback, sync_point()); |
+ else if (IsSharedMemory()) |
+ return TextureMailbox(handle(), shared_memory_size(), callback); |
+ |
+ DCHECK(!IsValid()); |
+ return TextureMailbox(); |
piman
2013/05/29 20:00:10
How about:
TextureMailbox copy(*this);
copy.callba
slavi
2013/06/03 22:14:16
Done.
|
+} |
+ |
} // namespace cc |