| 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 <stddef.h> | 7 #include <stddef.h> |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| 11 #include "cc/resources/shared_bitmap.h" | 11 #include "cc/resources/shared_bitmap.h" |
| 12 | 12 |
| 13 namespace cc { | 13 namespace cc { |
| 14 | 14 |
| 15 TextureMailbox::TextureMailbox() : shared_bitmap_(NULL) { | 15 TextureMailbox::TextureMailbox() : shared_bitmap_(NULL) { |
| 16 } | 16 } |
| 17 | 17 |
| 18 TextureMailbox::TextureMailbox(const gpu::MailboxHolder& mailbox_holder) | 18 TextureMailbox::TextureMailbox(const gpu::MailboxHolder& mailbox_holder) |
| 19 : mailbox_holder_(mailbox_holder), | 19 : mailbox_holder_(mailbox_holder), |
| 20 shared_bitmap_(NULL), | 20 shared_bitmap_(NULL), |
| 21 is_overlay_candidate_(false), | 21 is_overlay_candidate_(false), |
| 22 #if defined(OS_ANDROID) |
| 23 is_backed_by_surface_texture_(false), |
| 24 #endif |
| 22 secure_output_only_(false), | 25 secure_output_only_(false), |
| 23 nearest_neighbor_(false) {} | 26 nearest_neighbor_(false) { |
| 27 } |
| 24 | 28 |
| 25 TextureMailbox::TextureMailbox(const gpu::Mailbox& mailbox, | 29 TextureMailbox::TextureMailbox(const gpu::Mailbox& mailbox, |
| 26 const gpu::SyncToken& sync_token, | 30 const gpu::SyncToken& sync_token, |
| 27 uint32_t target) | 31 uint32_t target) |
| 28 : mailbox_holder_(mailbox, sync_token, target), | 32 : mailbox_holder_(mailbox, sync_token, target), |
| 29 shared_bitmap_(NULL), | 33 shared_bitmap_(NULL), |
| 30 is_overlay_candidate_(false), | 34 is_overlay_candidate_(false), |
| 35 #if defined(OS_ANDROID) |
| 36 is_backed_by_surface_texture_(false), |
| 37 #endif |
| 31 secure_output_only_(false), | 38 secure_output_only_(false), |
| 32 nearest_neighbor_(false) {} | 39 nearest_neighbor_(false) { |
| 40 } |
| 33 | 41 |
| 34 TextureMailbox::TextureMailbox( | 42 TextureMailbox::TextureMailbox(const gpu::Mailbox& mailbox, |
| 35 const gpu::Mailbox& mailbox, | 43 const gpu::SyncToken& sync_token, |
| 36 const gpu::SyncToken& sync_token, | 44 uint32_t target, |
| 37 uint32_t target, | 45 const gfx::Size& size_in_pixels, |
| 38 const gfx::Size& size_in_pixels, | 46 bool is_overlay_candidate, |
| 39 bool is_overlay_candidate, | 47 bool secure_output_only) |
| 40 bool secure_output_only) | |
| 41 : mailbox_holder_(mailbox, sync_token, target), | 48 : mailbox_holder_(mailbox, sync_token, target), |
| 42 shared_bitmap_(nullptr), | 49 shared_bitmap_(nullptr), |
| 43 size_in_pixels_(size_in_pixels), | 50 size_in_pixels_(size_in_pixels), |
| 44 is_overlay_candidate_(is_overlay_candidate), | 51 is_overlay_candidate_(is_overlay_candidate), |
| 52 #if defined(OS_ANDROID) |
| 53 is_backed_by_surface_texture_(false), |
| 54 #endif |
| 45 secure_output_only_(secure_output_only), | 55 secure_output_only_(secure_output_only), |
| 46 nearest_neighbor_(false) { | 56 nearest_neighbor_(false) { |
| 47 DCHECK(!is_overlay_candidate || !size_in_pixels.IsEmpty()); | 57 DCHECK(!is_overlay_candidate || !size_in_pixels.IsEmpty()); |
| 48 } | 58 } |
| 49 | 59 |
| 50 TextureMailbox::TextureMailbox(SharedBitmap* shared_bitmap, | 60 TextureMailbox::TextureMailbox(SharedBitmap* shared_bitmap, |
| 51 const gfx::Size& size_in_pixels) | 61 const gfx::Size& size_in_pixels) |
| 52 : shared_bitmap_(shared_bitmap), | 62 : shared_bitmap_(shared_bitmap), |
| 53 size_in_pixels_(size_in_pixels), | 63 size_in_pixels_(size_in_pixels), |
| 54 is_overlay_candidate_(false), | 64 is_overlay_candidate_(false), |
| 65 #if defined(OS_ANDROID) |
| 66 is_backed_by_surface_texture_(false), |
| 67 #endif |
| 55 secure_output_only_(false), | 68 secure_output_only_(false), |
| 56 nearest_neighbor_(false) { | 69 nearest_neighbor_(false) { |
| 57 // If an embedder of cc gives an invalid TextureMailbox, we should crash | 70 // If an embedder of cc gives an invalid TextureMailbox, we should crash |
| 58 // here to identify the offender. | 71 // here to identify the offender. |
| 59 CHECK(SharedBitmap::VerifySizeInBytes(size_in_pixels_)); | 72 CHECK(SharedBitmap::VerifySizeInBytes(size_in_pixels_)); |
| 60 } | 73 } |
| 61 | 74 |
| 62 TextureMailbox::~TextureMailbox() {} | 75 TextureMailbox::~TextureMailbox() {} |
| 63 | 76 |
| 64 bool TextureMailbox::Equals(const TextureMailbox& other) const { | 77 bool TextureMailbox::Equals(const TextureMailbox& other) const { |
| 65 if (other.IsTexture()) { | 78 if (other.IsTexture()) { |
| 66 return IsTexture() && !memcmp(mailbox_holder_.mailbox.name, | 79 return IsTexture() && !memcmp(mailbox_holder_.mailbox.name, |
| 67 other.mailbox_holder_.mailbox.name, | 80 other.mailbox_holder_.mailbox.name, |
| 68 sizeof(mailbox_holder_.mailbox.name)); | 81 sizeof(mailbox_holder_.mailbox.name)); |
| 69 } else if (other.IsSharedMemory()) { | 82 } else if (other.IsSharedMemory()) { |
| 70 return IsSharedMemory() && (shared_bitmap_ == other.shared_bitmap_); | 83 return IsSharedMemory() && (shared_bitmap_ == other.shared_bitmap_); |
| 71 } | 84 } |
| 72 | 85 |
| 73 DCHECK(!other.IsValid()); | 86 DCHECK(!other.IsValid()); |
| 74 return !IsValid(); | 87 return !IsValid(); |
| 75 } | 88 } |
| 76 | 89 |
| 77 size_t TextureMailbox::SharedMemorySizeInBytes() const { | 90 size_t TextureMailbox::SharedMemorySizeInBytes() const { |
| 78 // UncheckedSizeInBytes is okay because we VerifySizeInBytes in the | 91 // UncheckedSizeInBytes is okay because we VerifySizeInBytes in the |
| 79 // constructor and the field is immutable. | 92 // constructor and the field is immutable. |
| 80 return SharedBitmap::UncheckedSizeInBytes(size_in_pixels_); | 93 return SharedBitmap::UncheckedSizeInBytes(size_in_pixels_); |
| 81 } | 94 } |
| 82 | 95 |
| 83 } // namespace cc | 96 } // namespace cc |
| OLD | NEW |