Chromium Code Reviews| Index: cc/resources/texture_mailbox.cc |
| diff --git a/cc/resources/texture_mailbox.cc b/cc/resources/texture_mailbox.cc |
| index 6900518967a3af3787b2b12d7faac00f4b289386..9b07840c98f68e67fab8706c31f493bc134af71a 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), |
| + 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 Contains(other.name()); |
| + else if (other.IsSharedMemory()) |
| + return Contains(other.handle()); |
| + |
| + DCHECK(!other.IsValid()); |
| + return !IsValid(); |
| } |
| -bool TextureMailbox::IsEmpty() const { |
| - return name_.IsZero(); |
| +bool TextureMailbox::Contains(const gpu::Mailbox& other) const { |
| + return IsTexture() && !memcmp(data(), other.name, sizeof(name_.name)); |
| +} |
| + |
| +bool TextureMailbox::Contains(base::SharedMemoryHandle handle) const { |
| + return IsSharedMemory() && handle_ == handle; |
| } |
| void TextureMailbox::RunReleaseCallback(unsigned sync_point, |
| @@ -83,6 +105,14 @@ void TextureMailbox::RunReleaseCallback(unsigned sync_point, |
| void TextureMailbox::SetName(const gpu::Mailbox& other) { |
| name_.SetName(other.name); |
| + handle_ = base::SharedMemory::NULLHandle(); |
|
piman
2013/05/28 20:58:57
Maybe we should DCHECK that it is NULL? I don't th
slavi
2013/05/29 18:31:48
Done.
|
| +} |
| + |
| +void TextureMailbox::SetHandle(base::SharedMemoryHandle handle, |
| + gfx::Size size) { |
| + name_.SetZero(); |
| + handle_ = handle; |
| + size_ = size; |
| } |
| } // namespace cc |