| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "base/logging.h" | 5 #include "base/logging.h" |
| 6 #include "cc/texture_mailbox.h" | 6 #include "cc/texture_mailbox.h" |
| 7 | 7 |
| 8 namespace cc { | 8 namespace cc { |
| 9 | 9 |
| 10 TextureMailbox::TextureMailbox() | 10 TextureMailbox::TextureMailbox() |
| 11 : sync_point_(0) { | 11 : sync_point_(0) { |
| 12 } | 12 } |
| 13 | 13 |
| 14 TextureMailbox::TextureMailbox( | 14 TextureMailbox::TextureMailbox( |
| 15 const std::string& mailbox_name, | 15 const std::string& mailbox_name, |
| 16 const ReleaseCallback& mailbox_callback) | 16 const ReleaseCallback& mailbox_callback) |
| 17 : callback_(mailbox_callback), | 17 : callback_(mailbox_callback), |
| 18 sync_point_(0) { | 18 sync_point_(0) { |
| 19 DCHECK(mailbox_name.empty() == mailbox_callback.is_null()); | 19 DCHECK(mailbox_name.empty() == mailbox_callback.is_null()); |
| 20 if (!mailbox_name.empty()) { | 20 if (!mailbox_name.empty()) { |
| 21 CHECK(mailbox_name.size() == sizeof(name_.name)); | 21 CHECK(mailbox_name.size() == sizeof(name_.name)); |
| 22 name_.setName(reinterpret_cast<const int8*>(mailbox_name.data())); | 22 name_.SetName(reinterpret_cast<const int8*>(mailbox_name.data())); |
| 23 } | 23 } |
| 24 } | 24 } |
| 25 | 25 |
| 26 TextureMailbox::TextureMailbox( | 26 TextureMailbox::TextureMailbox( |
| 27 const Mailbox& mailbox_name, | 27 const gpu::Mailbox& mailbox_name, |
| 28 const ReleaseCallback& mailbox_callback) | 28 const ReleaseCallback& mailbox_callback) |
| 29 : callback_(mailbox_callback), | 29 : callback_(mailbox_callback), |
| 30 sync_point_(0) { | 30 sync_point_(0) { |
| 31 DCHECK(mailbox_name.isZero() == mailbox_callback.is_null()); | 31 DCHECK(mailbox_name.IsZero() == mailbox_callback.is_null()); |
| 32 name_.setName(mailbox_name.name); | 32 name_.SetName(mailbox_name.name); |
| 33 } | 33 } |
| 34 | 34 |
| 35 TextureMailbox::TextureMailbox( | 35 TextureMailbox::TextureMailbox( |
| 36 const Mailbox& mailbox_name, | 36 const gpu::Mailbox& mailbox_name, |
| 37 const ReleaseCallback& mailbox_callback, | 37 const ReleaseCallback& mailbox_callback, |
| 38 unsigned sync_point) | 38 unsigned sync_point) |
| 39 : callback_(mailbox_callback), | 39 : callback_(mailbox_callback), |
| 40 sync_point_(sync_point) { | 40 sync_point_(sync_point) { |
| 41 DCHECK(mailbox_name.isZero() == mailbox_callback.is_null()); | 41 DCHECK(mailbox_name.IsZero() == mailbox_callback.is_null()); |
| 42 name_.setName(mailbox_name.name); | 42 name_.SetName(mailbox_name.name); |
| 43 } | 43 } |
| 44 | 44 |
| 45 TextureMailbox::~TextureMailbox() { | 45 TextureMailbox::~TextureMailbox() { |
| 46 } | 46 } |
| 47 | 47 |
| 48 bool TextureMailbox::Equals(const Mailbox& other) const { | 48 bool TextureMailbox::Equals(const gpu::Mailbox& other) const { |
| 49 return !memcmp(data(), other.name, sizeof(name_.name)); | 49 return !memcmp(data(), other.name, sizeof(name_.name)); |
| 50 } | 50 } |
| 51 | 51 |
| 52 bool TextureMailbox::Equals(const TextureMailbox& other) const { | 52 bool TextureMailbox::Equals(const TextureMailbox& other) const { |
| 53 return Equals(other.name()); | 53 return Equals(other.name()); |
| 54 } | 54 } |
| 55 | 55 |
| 56 bool TextureMailbox::IsEmpty() const { | 56 bool TextureMailbox::IsEmpty() const { |
| 57 return name_.isZero(); | 57 return name_.IsZero(); |
| 58 } | 58 } |
| 59 | 59 |
| 60 void TextureMailbox::RunReleaseCallback(unsigned sync_point) const { | 60 void TextureMailbox::RunReleaseCallback(unsigned sync_point) const { |
| 61 if (!callback_.is_null()) | 61 if (!callback_.is_null()) |
| 62 callback_.Run(sync_point); | 62 callback_.Run(sync_point); |
| 63 } | 63 } |
| 64 | 64 |
| 65 void TextureMailbox::SetName(const Mailbox& other) { | 65 void TextureMailbox::SetName(const gpu::Mailbox& other) { |
| 66 name_.setName(other.name); | 66 name_.SetName(other.name); |
| 67 } | 67 } |
| 68 | 68 |
| 69 } // namespace cc | 69 } // namespace cc |
| OLD | NEW |