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 "cc/resources/texture_mailbox.h" | 5 #include "cc/resources/texture_mailbox.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "cc/resources/shared_bitmap.h" | 8 #include "cc/resources/shared_bitmap.h" |
9 | 9 |
10 namespace cc { | 10 namespace cc { |
11 | 11 |
12 TextureMailbox::TextureMailbox() : shared_memory_(NULL) {} | 12 TextureMailbox::TextureMailbox() : shared_memory_(NULL) {} |
13 | 13 |
14 TextureMailbox::TextureMailbox(const gpu::MailboxHolder& mailbox_holder) | 14 TextureMailbox::TextureMailbox(const gpu::MailboxHolder& mailbox_holder) |
15 : mailbox_holder_(mailbox_holder), | 15 : mailbox_holder_(mailbox_holder), |
16 shared_memory_(NULL), | 16 shared_memory_(NULL), |
17 allow_overlay_(false) {} | 17 allow_overlay_(false), |
| 18 nearest_neighbor_(false) {} |
18 | 19 |
19 TextureMailbox::TextureMailbox(const gpu::Mailbox& mailbox, | 20 TextureMailbox::TextureMailbox(const gpu::Mailbox& mailbox, |
20 uint32 target, | 21 uint32 target, |
21 uint32 sync_point) | 22 uint32 sync_point) |
22 : mailbox_holder_(mailbox, target, sync_point), | 23 : mailbox_holder_(mailbox, target, sync_point), |
23 shared_memory_(NULL), | 24 shared_memory_(NULL), |
24 allow_overlay_(false) {} | 25 allow_overlay_(false), |
| 26 nearest_neighbor_(false) {} |
25 | 27 |
26 TextureMailbox::TextureMailbox(base::SharedMemory* shared_memory, | 28 TextureMailbox::TextureMailbox(base::SharedMemory* shared_memory, |
27 const gfx::Size& size) | 29 const gfx::Size& size) |
28 : shared_memory_(shared_memory), | 30 : shared_memory_(shared_memory), |
29 shared_memory_size_(size), | 31 shared_memory_size_(size), |
30 allow_overlay_(false) { | 32 allow_overlay_(false), |
| 33 nearest_neighbor_(false) { |
31 // If an embedder of cc gives an invalid TextureMailbox, we should crash | 34 // If an embedder of cc gives an invalid TextureMailbox, we should crash |
32 // here to identify the offender. | 35 // here to identify the offender. |
33 CHECK(SharedBitmap::VerifySizeInBytes(shared_memory_size_)); | 36 CHECK(SharedBitmap::VerifySizeInBytes(shared_memory_size_)); |
34 } | 37 } |
35 | 38 |
36 TextureMailbox::~TextureMailbox() {} | 39 TextureMailbox::~TextureMailbox() {} |
37 | 40 |
38 bool TextureMailbox::Equals(const TextureMailbox& other) const { | 41 bool TextureMailbox::Equals(const TextureMailbox& other) const { |
39 if (other.IsTexture()) { | 42 if (other.IsTexture()) { |
40 return IsTexture() && !memcmp(mailbox_holder_.mailbox.name, | 43 return IsTexture() && !memcmp(mailbox_holder_.mailbox.name, |
41 other.mailbox_holder_.mailbox.name, | 44 other.mailbox_holder_.mailbox.name, |
42 sizeof(mailbox_holder_.mailbox.name)); | 45 sizeof(mailbox_holder_.mailbox.name)); |
43 } else if (other.IsSharedMemory()) { | 46 } else if (other.IsSharedMemory()) { |
44 return IsSharedMemory() && | 47 return IsSharedMemory() && |
45 shared_memory_->handle() == other.shared_memory_->handle(); | 48 shared_memory_->handle() == other.shared_memory_->handle(); |
46 } | 49 } |
47 | 50 |
48 DCHECK(!other.IsValid()); | 51 DCHECK(!other.IsValid()); |
49 return !IsValid(); | 52 return !IsValid(); |
50 } | 53 } |
51 | 54 |
52 size_t TextureMailbox::SharedMemorySizeInBytes() const { | 55 size_t TextureMailbox::SharedMemorySizeInBytes() const { |
53 // UncheckedSizeInBytes is okay because we VerifySizeInBytes in the | 56 // UncheckedSizeInBytes is okay because we VerifySizeInBytes in the |
54 // constructor and the field is immutable. | 57 // constructor and the field is immutable. |
55 return SharedBitmap::UncheckedSizeInBytes(shared_memory_size_); | 58 return SharedBitmap::UncheckedSizeInBytes(shared_memory_size_); |
56 } | 59 } |
57 | 60 |
58 } // namespace cc | 61 } // namespace cc |
OLD | NEW |