Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "base/logging.h" | |
| 6 #include "cc/texture_mailbox.h" | |
| 7 | |
| 8 namespace cc { | |
| 9 | |
| 10 TextureMailbox::TextureMailbox() { | |
| 11 } | |
| 12 | |
| 13 TextureMailbox::TextureMailbox( | |
| 14 const std::string& mailbox_name, | |
| 15 const ReleaseCallback& mailbox_callback) | |
| 16 : callback_(mailbox_callback) { | |
| 17 DCHECK(mailbox_name.empty() == mailbox_callback.is_null()); | |
| 18 if (!mailbox_name.empty()) { | |
| 19 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.
| |
| 20 name_.setName(reinterpret_cast<const int8*>(mailbox_name.data())); | |
| 21 } | |
| 22 } | |
| 23 | |
| 24 TextureMailbox::TextureMailbox( | |
| 25 const Mailbox& mailbox_name, | |
| 26 const ReleaseCallback& mailbox_callback) | |
| 27 : callback_(mailbox_callback) { | |
| 28 DCHECK(mailbox_name.isZero() == mailbox_callback.is_null()); | |
| 29 name_.setName(mailbox_name.name); | |
| 30 } | |
| 31 | |
| 32 TextureMailbox::~TextureMailbox() { | |
| 33 } | |
| 34 | |
| 35 bool TextureMailbox::Equals(const TextureMailbox& other) const { | |
| 36 return !memcmp(data(), other.data(), sizeof(name_.name)); | |
| 37 } | |
| 38 | |
| 39 bool TextureMailbox::IsEmpty() const { | |
| 40 return name_.isZero(); | |
| 41 } | |
| 42 | |
| 43 void TextureMailbox::RunReleaseCallback(unsigned sync_point) const { | |
| 44 if (!callback_.is_null()) | |
| 45 callback_.Run(sync_point); | |
| 46 } | |
| 47 | |
| 48 void TextureMailbox::SetName(const int8* data) { | |
| 49 name_.setName(data); | |
| 50 } | |
| 51 | |
| 52 } // namespace cc | |
| OLD | NEW |