| 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 <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/memory/shared_memory.h" | 10 #include "base/memory/shared_memory.h" |
| 11 #include "cc/base/cc_export.h" | 11 #include "cc/base/cc_export.h" |
| 12 #include "gpu/command_buffer/common/mailbox_holder.h" | 12 #include "gpu/command_buffer/common/mailbox_holder.h" |
| 13 #include "ui/gfx/geometry/size.h" | 13 #include "ui/gfx/geometry/size.h" |
| 14 | 14 |
| 15 namespace cc { | 15 namespace cc { |
| 16 class SharedBitmap; |
| 16 | 17 |
| 17 // TODO(skaslev, danakj) Rename this class more apropriately since now it | 18 // TODO(skaslev, danakj) Rename this class more apropriately since now it |
| 18 // can hold a shared memory resource as well as a texture mailbox. | 19 // can hold a shared memory resource as well as a texture mailbox. |
| 19 class CC_EXPORT TextureMailbox { | 20 class CC_EXPORT TextureMailbox { |
| 20 public: | 21 public: |
| 21 TextureMailbox(); | 22 TextureMailbox(); |
| 22 explicit TextureMailbox(const gpu::MailboxHolder& mailbox_holder); | 23 explicit TextureMailbox(const gpu::MailboxHolder& mailbox_holder); |
| 23 TextureMailbox(const gpu::Mailbox& mailbox, uint32 target, uint32 sync_point); | 24 TextureMailbox(const gpu::Mailbox& mailbox, uint32 target, uint32 sync_point); |
| 24 TextureMailbox(base::SharedMemory* shared_memory, const gfx::Size& size); | 25 TextureMailbox(SharedBitmap* shared_bitmap, const gfx::Size& size); |
| 25 | 26 |
| 26 ~TextureMailbox(); | 27 ~TextureMailbox(); |
| 27 | 28 |
| 28 bool IsValid() const { return IsTexture() || IsSharedMemory(); } | 29 bool IsValid() const { return IsTexture() || IsSharedMemory(); } |
| 29 bool IsTexture() const { return !mailbox_holder_.mailbox.IsZero(); } | 30 bool IsTexture() const { return !mailbox_holder_.mailbox.IsZero(); } |
| 30 bool IsSharedMemory() const { return shared_memory_ != NULL; } | 31 bool IsSharedMemory() const { return shared_bitmap_ != NULL; } |
| 31 | 32 |
| 32 bool Equals(const TextureMailbox&) const; | 33 bool Equals(const TextureMailbox&) const; |
| 33 | 34 |
| 34 const gpu::Mailbox& mailbox() const { return mailbox_holder_.mailbox; } | 35 const gpu::Mailbox& mailbox() const { return mailbox_holder_.mailbox; } |
| 35 const int8* name() const { return mailbox().name; } | 36 const int8* name() const { return mailbox().name; } |
| 36 uint32 target() const { return mailbox_holder_.texture_target; } | 37 uint32 target() const { return mailbox_holder_.texture_target; } |
| 37 uint32 sync_point() const { return mailbox_holder_.sync_point; } | 38 uint32 sync_point() const { return mailbox_holder_.sync_point; } |
| 38 void set_sync_point(int32 sync_point) { | 39 void set_sync_point(int32 sync_point) { |
| 39 mailbox_holder_.sync_point = sync_point; | 40 mailbox_holder_.sync_point = sync_point; |
| 40 } | 41 } |
| 41 | 42 |
| 42 bool allow_overlay() const { return allow_overlay_; } | 43 bool allow_overlay() const { return allow_overlay_; } |
| 43 void set_allow_overlay(bool allow_overlay) { allow_overlay_ = allow_overlay; } | 44 void set_allow_overlay(bool allow_overlay) { allow_overlay_ = allow_overlay; } |
| 44 bool nearest_neighbor() const { return nearest_neighbor_; } | 45 bool nearest_neighbor() const { return nearest_neighbor_; } |
| 45 void set_nearest_neighbor(bool nearest_neighbor) { | 46 void set_nearest_neighbor(bool nearest_neighbor) { |
| 46 nearest_neighbor_ = nearest_neighbor; | 47 nearest_neighbor_ = nearest_neighbor; |
| 47 } | 48 } |
| 48 | 49 |
| 49 base::SharedMemory* shared_memory() const { return shared_memory_; } | 50 SharedBitmap* shared_bitmap() const { return shared_bitmap_; } |
| 50 gfx::Size shared_memory_size() const { return shared_memory_size_; } | 51 gfx::Size shared_memory_size() const { return shared_memory_size_; } |
| 51 size_t SharedMemorySizeInBytes() const; | 52 size_t SharedMemorySizeInBytes() const; |
| 52 | 53 |
| 53 private: | 54 private: |
| 54 gpu::MailboxHolder mailbox_holder_; | 55 gpu::MailboxHolder mailbox_holder_; |
| 55 base::SharedMemory* shared_memory_; | 56 SharedBitmap* shared_bitmap_; |
| 56 gfx::Size shared_memory_size_; | 57 gfx::Size shared_memory_size_; |
| 57 bool allow_overlay_; | 58 bool allow_overlay_; |
| 58 bool nearest_neighbor_; | 59 bool nearest_neighbor_; |
| 59 }; | 60 }; |
| 60 | 61 |
| 61 } // namespace cc | 62 } // namespace cc |
| 62 | 63 |
| 63 #endif // CC_RESOURCES_TEXTURE_MAILBOX_H_ | 64 #endif // CC_RESOURCES_TEXTURE_MAILBOX_H_ |
| OLD | NEW |