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