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.
5 #include "cc/resources/texture_mailbox.h"
7 #include "base/logging.h"
8 #include "third_party/khronos/GLES2/gl2.h"
12 TextureMailbox::TextureMailbox() : shared_memory_(NULL) {}
14 TextureMailbox::TextureMailbox(const gpu::MailboxHolder& mailbox_holder)
15 : mailbox_holder_(mailbox_holder), shared_memory_(NULL) {}
17 TextureMailbox::TextureMailbox(const gpu::Mailbox& mailbox,
20 : mailbox_holder_(mailbox, target, sync_point), shared_memory_(NULL) {}
22 TextureMailbox::TextureMailbox(base::SharedMemory* shared_memory,
23 const gfx::Size& size)
24 : shared_memory_(shared_memory), shared_memory_size_(size) {}
26 TextureMailbox::~TextureMailbox() {}
28 bool TextureMailbox::Equals(const TextureMailbox& other) const {
29 if (other.IsTexture()) {
30 return IsTexture() && !memcmp(mailbox_holder_.mailbox.name,
31 other.mailbox_holder_.mailbox.name,
32 sizeof(mailbox_holder_.mailbox.name));
33 } else if (other.IsSharedMemory()) {
34 return IsSharedMemory() &&
35 shared_memory_->handle() == other.shared_memory_->handle();
38 DCHECK(!other.IsValid());
42 size_t TextureMailbox::shared_memory_size_in_bytes() const {
43 return 4 * shared_memory_size_.GetArea();