Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2989)

Unified Diff: cc/resources/texture_mailbox.cc

Issue 15001027: [Aura] Added Support for rendering software compositor frames as cc::TextureLayers. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Passed(&foo) instead for Passed(foo.Pass()). Created 7 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: cc/resources/texture_mailbox.cc
diff --git a/cc/resources/texture_mailbox.cc b/cc/resources/texture_mailbox.cc
index 6900518967a3af3787b2b12d7faac00f4b289386..0d4787438f46b2d5a00488d74087cc42952c79f1 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),
+ shared_memory_(NULL) {
}
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),
+ shared_memory_(NULL) {
+ 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),
+ shared_memory_(NULL) {
+ 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),
+ shared_memory_(NULL) {
+ 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),
+ shared_memory_(NULL) {
+ DCHECK(mailbox_name.IsZero() == callback.is_null());
name_.SetName(mailbox_name.name);
}
-TextureMailbox::~TextureMailbox() {
+TextureMailbox::TextureMailbox(
+ base::SharedMemory* shared_memory,
+ gfx::Size size,
+ const ReleaseCallback& callback)
+ : callback_(callback),
+ target_(GL_TEXTURE_2D),
+ sync_point_(0),
+ shared_memory_(shared_memory),
+ shared_memory_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 ContainsMailbox(other.name());
+ else if (other.IsSharedMemory())
+ return ContainsHandle(other.shared_memory_->handle());
+
+ DCHECK(!other.IsValid());
+ return !IsValid();
}
-bool TextureMailbox::IsEmpty() const {
- return name_.IsZero();
+bool TextureMailbox::ContainsMailbox(const gpu::Mailbox& other) const {
+ return IsTexture() && !memcmp(data(), other.name, sizeof(name_.name));
+}
+
+bool TextureMailbox::ContainsHandle(base::SharedMemoryHandle handle) const {
+ return shared_memory_ && shared_memory_->handle() == handle;
}
void TextureMailbox::RunReleaseCallback(unsigned sync_point,
@@ -82,7 +104,19 @@ void TextureMailbox::RunReleaseCallback(unsigned sync_point,
}
void TextureMailbox::SetName(const gpu::Mailbox& other) {
+ DCHECK(shared_memory_ == NULL);
name_.SetName(other.name);
}
+TextureMailbox TextureMailbox::CopyWithNewCallback(
+ const ReleaseCallback& callback) const {
+ TextureMailbox result(*this);
+ result.callback_ = callback;
+ return result;
+}
+
+size_t TextureMailbox::shared_memory_size_in_bytes() const {
+ return 4 * shared_memory_size_.GetArea();
+}
+
} // namespace cc
« no previous file with comments | « cc/resources/texture_mailbox.h ('k') | content/browser/android/in_process/synchronous_compositor_output_surface.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698