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 class SharedBitmap; |
17 | 17 |
18 // TODO(skaslev, danakj) Rename this class more apropriately since now it | 18 // TODO(skaslev, danakj) Rename this class more apropriately since now it |
19 // 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. |
20 class CC_EXPORT TextureMailbox { | 20 class CC_EXPORT TextureMailbox { |
21 public: | 21 public: |
22 TextureMailbox(); | 22 TextureMailbox(); |
23 explicit TextureMailbox(const gpu::MailboxHolder& mailbox_holder); | 23 explicit TextureMailbox(const gpu::MailboxHolder& mailbox_holder); |
24 TextureMailbox(const gpu::Mailbox& mailbox, uint32 target, uint32 sync_point); | |
25 TextureMailbox(const gpu::Mailbox& mailbox, | 24 TextureMailbox(const gpu::Mailbox& mailbox, |
26 uint32 target, | 25 uint32 target, |
27 uint32 sync_point, | 26 uint32 sync_point, |
| 27 const gpu::SyncToken& sync_token); |
| 28 TextureMailbox(const gpu::Mailbox& mailbox, |
| 29 uint32 target, |
| 30 uint32 sync_point, |
| 31 const gpu::SyncToken& sync_token, |
28 const gfx::Size& size_in_pixels, | 32 const gfx::Size& size_in_pixels, |
29 bool is_overlay_candidate); | 33 bool is_overlay_candidate); |
30 TextureMailbox(SharedBitmap* shared_bitmap, const gfx::Size& size_in_pixels); | 34 TextureMailbox(SharedBitmap* shared_bitmap, const gfx::Size& size_in_pixels); |
31 | 35 |
32 ~TextureMailbox(); | 36 ~TextureMailbox(); |
33 | 37 |
34 bool IsValid() const { return IsTexture() || IsSharedMemory(); } | 38 bool IsValid() const { return IsTexture() || IsSharedMemory(); } |
35 bool IsTexture() const { return !mailbox_holder_.mailbox.IsZero(); } | 39 bool IsTexture() const { return !mailbox_holder_.mailbox.IsZero(); } |
36 bool IsSharedMemory() const { return shared_bitmap_ != NULL; } | 40 bool IsSharedMemory() const { return shared_bitmap_ != NULL; } |
37 | 41 |
38 bool Equals(const TextureMailbox&) const; | 42 bool Equals(const TextureMailbox&) const; |
39 | 43 |
40 const gpu::Mailbox& mailbox() const { return mailbox_holder_.mailbox; } | 44 const gpu::Mailbox& mailbox() const { return mailbox_holder_.mailbox; } |
41 const int8* name() const { return mailbox().name; } | 45 const int8* name() const { return mailbox().name; } |
42 uint32 target() const { return mailbox_holder_.texture_target; } | 46 uint32 target() const { return mailbox_holder_.texture_target; } |
43 uint32 sync_point() const { return mailbox_holder_.sync_point; } | 47 uint32 sync_point() const { return mailbox_holder_.sync_point; } |
44 void set_sync_point(int32 sync_point) { | 48 const gpu::SyncToken& sync_token() const { |
| 49 return mailbox_holder_.sync_token; |
| 50 } |
| 51 void set_sync_point(int32 sync_point, const gpu::SyncToken& sync_token) { |
45 mailbox_holder_.sync_point = sync_point; | 52 mailbox_holder_.sync_point = sync_point; |
| 53 mailbox_holder_.sync_token = sync_token; |
46 } | 54 } |
47 | 55 |
48 bool is_overlay_candidate() const { return is_overlay_candidate_; } | 56 bool is_overlay_candidate() const { return is_overlay_candidate_; } |
49 bool nearest_neighbor() const { return nearest_neighbor_; } | 57 bool nearest_neighbor() const { return nearest_neighbor_; } |
50 void set_nearest_neighbor(bool nearest_neighbor) { | 58 void set_nearest_neighbor(bool nearest_neighbor) { |
51 nearest_neighbor_ = nearest_neighbor; | 59 nearest_neighbor_ = nearest_neighbor; |
52 } | 60 } |
53 | 61 |
54 // This is valid if allow_overlau() or IsSharedMemory() is true. | 62 // This is valid if allow_overlau() or IsSharedMemory() is true. |
55 gfx::Size size_in_pixels() const { return size_in_pixels_; } | 63 gfx::Size size_in_pixels() const { return size_in_pixels_; } |
56 | 64 |
57 SharedBitmap* shared_bitmap() const { return shared_bitmap_; } | 65 SharedBitmap* shared_bitmap() const { return shared_bitmap_; } |
58 size_t SharedMemorySizeInBytes() const; | 66 size_t SharedMemorySizeInBytes() const; |
59 | 67 |
60 private: | 68 private: |
61 gpu::MailboxHolder mailbox_holder_; | 69 gpu::MailboxHolder mailbox_holder_; |
62 SharedBitmap* shared_bitmap_; | 70 SharedBitmap* shared_bitmap_; |
63 gfx::Size size_in_pixels_; | 71 gfx::Size size_in_pixels_; |
64 bool is_overlay_candidate_; | 72 bool is_overlay_candidate_; |
65 bool nearest_neighbor_; | 73 bool nearest_neighbor_; |
66 }; | 74 }; |
67 | 75 |
68 } // namespace cc | 76 } // namespace cc |
69 | 77 |
70 #endif // CC_RESOURCES_TEXTURE_MAILBOX_H_ | 78 #endif // CC_RESOURCES_TEXTURE_MAILBOX_H_ |
OLD | NEW |