Chromium Code Reviews| Index: cc/texture_mailbox.cc |
| diff --git a/cc/texture_mailbox.cc b/cc/texture_mailbox.cc |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..861b4596494a7446a3d5f74faeb5bc2507c921d1 |
| --- /dev/null |
| +++ b/cc/texture_mailbox.cc |
| @@ -0,0 +1,52 @@ |
| +// Copyright 2013 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#include "base/logging.h" |
| +#include "cc/texture_mailbox.h" |
| + |
| +namespace cc { |
| + |
| +TextureMailbox::TextureMailbox() { |
| +} |
| + |
| +TextureMailbox::TextureMailbox( |
| + const std::string& mailbox_name, |
| + const ReleaseCallback& mailbox_callback) |
| + : callback_(mailbox_callback) { |
| + DCHECK(mailbox_name.empty() == mailbox_callback.is_null()); |
| + if (!mailbox_name.empty()) { |
| + DCHECK(mailbox_name.size() == sizeof(name_.name)); |
|
piman
2013/01/17 21:30:01
nit: could you make this a CHECK? If the check fai
alexst (slow to review)
2013/01/17 22:10:11
Done.
|
| + name_.setName(reinterpret_cast<const int8*>(mailbox_name.data())); |
| + } |
| +} |
| + |
| +TextureMailbox::TextureMailbox( |
| + const Mailbox& mailbox_name, |
| + const ReleaseCallback& mailbox_callback) |
| + : callback_(mailbox_callback) { |
| + DCHECK(mailbox_name.isZero() == mailbox_callback.is_null()); |
| + name_.setName(mailbox_name.name); |
| +} |
| + |
| +TextureMailbox::~TextureMailbox() { |
| +} |
| + |
| +bool TextureMailbox::Equals(const TextureMailbox& other) const { |
| + return !memcmp(data(), other.data(), sizeof(name_.name)); |
| +} |
| + |
| +bool TextureMailbox::IsEmpty() const { |
| + return name_.isZero(); |
| +} |
| + |
| +void TextureMailbox::RunReleaseCallback(unsigned sync_point) const { |
| + if (!callback_.is_null()) |
| + callback_.Run(sync_point); |
| +} |
| + |
| +void TextureMailbox::SetName(const int8* data) { |
| + name_.setName(data); |
| +} |
| + |
| +} // namespace cc |