Chromium Code Reviews| Index: cc/resources/texture_mailbox.cc |
| diff --git a/cc/resources/texture_mailbox.cc b/cc/resources/texture_mailbox.cc |
| index 934a86f4d016f869cca35470bc6933a0fb7f522b..15d32a355c0c11a7553ed09da4315a51091f592c 100644 |
| --- a/cc/resources/texture_mailbox.cc |
| +++ b/cc/resources/texture_mailbox.cc |
| @@ -10,16 +10,18 @@ |
| namespace cc { |
| TextureMailbox::TextureMailbox() |
| - : 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())); |
| @@ -28,50 +30,64 @@ 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( |
| + base::SharedMemoryHandle handle, |
| + gfx::Size size, |
| + const ReleaseCallback& callback) |
| + : callback_(callback), |
| + target_(GL_TEXTURE_2D), |
| + sync_point_(0), |
| + handle_(handle), |
| + size_(size) { |
| +} |
| + |
| TextureMailbox::~TextureMailbox() { |
| } |
| bool TextureMailbox::Equals(const gpu::Mailbox& other) const { |
| - return !memcmp(data(), other.name, sizeof(name_.name)); |
| + return IsTexture() && !memcmp(data(), other.name, sizeof(name_.name)); |
| } |
| -bool TextureMailbox::Equals(const TextureMailbox& other) const { |
| - return Equals(other.name()); |
| +bool TextureMailbox::Equals(base::SharedMemoryHandle handle) const { |
| + return IsSharedMemory() && handle_ == handle; |
| } |
| -bool TextureMailbox::IsEmpty() const { |
| - return name_.IsZero(); |
| +bool TextureMailbox::Equals(const TextureMailbox& other) const { |
| + return Equals(other.name()) || Equals(other.handle()); |
|
danakj
2013/05/23 15:34:33
check that IsTexture() and IsSharedMemory() also m
slavi
2013/05/28 18:55:13
Done.
|
| } |
| void TextureMailbox::RunReleaseCallback(unsigned sync_point, |
| @@ -82,6 +98,14 @@ void TextureMailbox::RunReleaseCallback(unsigned sync_point, |
| void TextureMailbox::SetName(const gpu::Mailbox& other) { |
| name_.SetName(other.name); |
| + handle_ = base::SharedMemory::NULLHandle(); |
| +} |
| + |
| +void TextureMailbox::SetHandle(base::SharedMemoryHandle handle, |
| + gfx::Size size) { |
| + name_.SetZero(); |
| + handle_ = handle; |
| + size_ = size; |
| } |
| } // namespace cc |