diff options
author | jamesr@chromium.org <jamesr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-03-18 08:24:40 +0000 |
---|---|---|
committer | jamesr@chromium.org <jamesr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-03-18 08:24:40 +0000 |
commit | e12dd0e802b2a80112cb40e01fabcc5c0475f05b (patch) | |
tree | fbfd355be68b05d64c98e4c0618e1d4ad8122f6a /cc/resources/texture_mailbox.cc | |
parent | 0d4f1f4b15d63e5976f0a2c0205d414da861c8a5 (diff) | |
download | chromium_src-e12dd0e802b2a80112cb40e01fabcc5c0475f05b.zip chromium_src-e12dd0e802b2a80112cb40e01fabcc5c0475f05b.tar.gz chromium_src-e12dd0e802b2a80112cb40e01fabcc5c0475f05b.tar.bz2 |
Part 8 of cc/ directory shuffles: resources
Continuation of https://src.chromium.org/viewvc/chrome?view=rev&revision=188681
BUG=190824
TBR=enne@chromium.org, piman@chromium.org, jschuh@chromium.org
Review URL: https://codereview.chromium.org/12471007
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@188696 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'cc/resources/texture_mailbox.cc')
-rw-r--r-- | cc/resources/texture_mailbox.cc | 69 |
1 files changed, 69 insertions, 0 deletions
diff --git a/cc/resources/texture_mailbox.cc b/cc/resources/texture_mailbox.cc new file mode 100644 index 0000000..b08ba6c --- /dev/null +++ b/cc/resources/texture_mailbox.cc @@ -0,0 +1,69 @@ +// 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/resources/texture_mailbox.h" + +namespace cc { + +TextureMailbox::TextureMailbox() + : sync_point_(0) { +} + +TextureMailbox::TextureMailbox( + const std::string& mailbox_name, + const ReleaseCallback& mailbox_callback) + : callback_(mailbox_callback), + sync_point_(0) { + DCHECK(mailbox_name.empty() == mailbox_callback.is_null()); + if (!mailbox_name.empty()) { + CHECK(mailbox_name.size() == sizeof(name_.name)); + name_.SetName(reinterpret_cast<const int8*>(mailbox_name.data())); + } +} + +TextureMailbox::TextureMailbox( + const gpu::Mailbox& mailbox_name, + const ReleaseCallback& mailbox_callback) + : callback_(mailbox_callback), + sync_point_(0) { + DCHECK(mailbox_name.IsZero() == mailbox_callback.is_null()); + name_.SetName(mailbox_name.name); +} + +TextureMailbox::TextureMailbox( + const gpu::Mailbox& mailbox_name, + const ReleaseCallback& mailbox_callback, + unsigned sync_point) + : callback_(mailbox_callback), + sync_point_(sync_point) { + DCHECK(mailbox_name.IsZero() == mailbox_callback.is_null()); + name_.SetName(mailbox_name.name); +} + +TextureMailbox::~TextureMailbox() { +} + +bool TextureMailbox::Equals(const gpu::Mailbox& other) const { + return !memcmp(data(), other.name, sizeof(name_.name)); +} + +bool TextureMailbox::Equals(const TextureMailbox& other) const { + return Equals(other.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 gpu::Mailbox& other) { + name_.SetName(other.name); +} + +} // namespace cc |