| 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 #ifndef CC_RESOURCES_TEXTURE_MAILBOX_H_ | 5 #ifndef CC_RESOURCES_TEXTURE_MAILBOX_H_ |
| 6 #define CC_RESOURCES_TEXTURE_MAILBOX_H_ | 6 #define CC_RESOURCES_TEXTURE_MAILBOX_H_ |
| 7 | 7 |
| 8 #include <stddef.h> | 8 #include <stddef.h> |
| 9 #include <stdint.h> | 9 #include <stdint.h> |
| 10 | 10 |
| 11 #include <string> | 11 #include <string> |
| 12 | 12 |
| 13 #include "base/memory/shared_memory.h" | 13 #include "base/memory/shared_memory.h" |
| 14 #include "cc/base/cc_export.h" | 14 #include "cc/base/cc_export.h" |
| 15 #include "gpu/command_buffer/common/mailbox_holder.h" | 15 #include "gpu/command_buffer/common/mailbox_holder.h" |
| 16 #include "ui/gfx/geometry/size.h" | 16 #include "ui/gfx/geometry/size.h" |
| 17 #include "ui/gfx/gpu_memory_buffer.h" |
| 17 | 18 |
| 18 namespace cc { | 19 namespace cc { |
| 19 class SharedBitmap; | 20 class SharedBitmap; |
| 20 | 21 |
| 21 // TODO(skaslev, danakj) Rename this class more apropriately since now it | 22 // TODO(skaslev, danakj) Rename this class more apropriately since now it |
| 22 // can hold a shared memory resource as well as a texture mailbox. | 23 // can hold a shared memory resource as well as a texture mailbox. |
| 23 class CC_EXPORT TextureMailbox { | 24 class CC_EXPORT TextureMailbox { |
| 24 public: | 25 public: |
| 25 TextureMailbox(); | 26 TextureMailbox(); |
| 26 explicit TextureMailbox(const gpu::MailboxHolder& mailbox_holder); | 27 explicit TextureMailbox(const gpu::MailboxHolder& mailbox_holder); |
| 27 TextureMailbox(const gpu::Mailbox& mailbox, | 28 TextureMailbox(const gpu::Mailbox& mailbox, |
| 28 const gpu::SyncToken& sync_token, | 29 const gpu::SyncToken& sync_token, |
| 29 uint32_t target); | 30 uint32_t target); |
| 30 TextureMailbox(const gpu::Mailbox& mailbox, | 31 TextureMailbox(const gpu::Mailbox& mailbox, |
| 31 const gpu::SyncToken& sync_token, | 32 const gpu::SyncToken& sync_token, |
| 32 uint32_t target, | 33 uint32_t target, |
| 33 const gfx::Size& size_in_pixels, | 34 const gfx::Size& size_in_pixels, |
| 35 const gfx::GpuMemoryBufferId& gpu_memory_buffer_id, |
| 34 bool is_overlay_candidate, | 36 bool is_overlay_candidate, |
| 35 bool secure_output_only); | 37 bool secure_output_only); |
| 36 TextureMailbox(SharedBitmap* shared_bitmap, const gfx::Size& size_in_pixels); | 38 TextureMailbox(SharedBitmap* shared_bitmap, const gfx::Size& size_in_pixels); |
| 37 | 39 |
| 38 ~TextureMailbox(); | 40 ~TextureMailbox(); |
| 39 | 41 |
| 40 bool IsValid() const { return IsTexture() || IsSharedMemory(); } | 42 bool IsValid() const { return IsTexture() || IsSharedMemory(); } |
| 41 bool IsTexture() const { return !mailbox_holder_.mailbox.IsZero(); } | 43 bool IsTexture() const { return !mailbox_holder_.mailbox.IsZero(); } |
| 42 bool IsSharedMemory() const { return shared_bitmap_ != NULL; } | 44 bool IsSharedMemory() const { return shared_bitmap_ != NULL; } |
| 43 bool HasSyncToken() const { return mailbox_holder_.sync_token.HasData(); } | 45 bool HasSyncToken() const { return mailbox_holder_.sync_token.HasData(); } |
| 44 | 46 |
| 45 int8_t* GetSyncTokenData() { return mailbox_holder_.sync_token.GetData(); } | 47 int8_t* GetSyncTokenData() { return mailbox_holder_.sync_token.GetData(); } |
| 46 | 48 |
| 47 bool Equals(const TextureMailbox&) const; | 49 bool Equals(const TextureMailbox&) const; |
| 48 | 50 |
| 49 const gpu::Mailbox& mailbox() const { return mailbox_holder_.mailbox; } | 51 const gpu::Mailbox& mailbox() const { return mailbox_holder_.mailbox; } |
| 50 const int8_t* name() const { return mailbox().name; } | 52 const int8_t* name() const { return mailbox().name; } |
| 51 uint32_t target() const { return mailbox_holder_.texture_target; } | 53 uint32_t target() const { return mailbox_holder_.texture_target; } |
| 52 const gpu::SyncToken& sync_token() const { | 54 const gpu::SyncToken& sync_token() const { |
| 53 return mailbox_holder_.sync_token; | 55 return mailbox_holder_.sync_token; |
| 54 } | 56 } |
| 55 void set_sync_token(const gpu::SyncToken& sync_token) { | 57 void set_sync_token(const gpu::SyncToken& sync_token) { |
| 56 mailbox_holder_.sync_token = sync_token; | 58 mailbox_holder_.sync_token = sync_token; |
| 57 } | 59 } |
| 58 | 60 |
| 61 gfx::GpuMemoryBufferId gpu_memory_buffer_id() const { |
| 62 return gpu_memory_buffer_id_; |
| 63 } |
| 59 bool is_overlay_candidate() const { return is_overlay_candidate_; } | 64 bool is_overlay_candidate() const { return is_overlay_candidate_; } |
| 60 bool secure_output_only() const { return secure_output_only_; } | 65 bool secure_output_only() const { return secure_output_only_; } |
| 61 bool nearest_neighbor() const { return nearest_neighbor_; } | 66 bool nearest_neighbor() const { return nearest_neighbor_; } |
| 62 void set_nearest_neighbor(bool nearest_neighbor) { | 67 void set_nearest_neighbor(bool nearest_neighbor) { |
| 63 nearest_neighbor_ = nearest_neighbor; | 68 nearest_neighbor_ = nearest_neighbor; |
| 64 } | 69 } |
| 65 | 70 |
| 66 // This is valid if allow_overlau() or IsSharedMemory() is true. | 71 // This is valid if allow_overlau() or IsSharedMemory() is true. |
| 67 gfx::Size size_in_pixels() const { return size_in_pixels_; } | 72 gfx::Size size_in_pixels() const { return size_in_pixels_; } |
| 68 | 73 |
| 69 SharedBitmap* shared_bitmap() const { return shared_bitmap_; } | 74 SharedBitmap* shared_bitmap() const { return shared_bitmap_; } |
| 70 size_t SharedMemorySizeInBytes() const; | 75 size_t SharedMemorySizeInBytes() const; |
| 71 | 76 |
| 72 private: | 77 private: |
| 73 gpu::MailboxHolder mailbox_holder_; | 78 gpu::MailboxHolder mailbox_holder_; |
| 74 SharedBitmap* shared_bitmap_; | 79 SharedBitmap* shared_bitmap_; |
| 75 gfx::Size size_in_pixels_; | 80 gfx::Size size_in_pixels_; |
| 81 gfx::GpuMemoryBufferId gpu_memory_buffer_id_; |
| 76 bool is_overlay_candidate_; | 82 bool is_overlay_candidate_; |
| 77 bool secure_output_only_; | 83 bool secure_output_only_; |
| 78 bool nearest_neighbor_; | 84 bool nearest_neighbor_; |
| 79 }; | 85 }; |
| 80 | 86 |
| 81 } // namespace cc | 87 } // namespace cc |
| 82 | 88 |
| 83 #endif // CC_RESOURCES_TEXTURE_MAILBOX_H_ | 89 #endif // CC_RESOURCES_TEXTURE_MAILBOX_H_ |
| OLD | NEW |