OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 COMPONENTS_EXO_BUFFER_H_ | 5 #ifndef COMPONENTS_EXO_BUFFER_H_ |
6 #define COMPONENTS_EXO_BUFFER_H_ | 6 #define COMPONENTS_EXO_BUFFER_H_ |
7 | 7 |
8 #include <memory> | 8 #include <memory> |
9 | 9 |
10 #include "base/callback.h" | 10 #include "base/callback.h" |
11 #include "base/macros.h" | 11 #include "base/macros.h" |
12 #include "base/memory/weak_ptr.h" | 12 #include "base/memory/weak_ptr.h" |
| 13 #include "cc/resources/transferable_resource.h" |
13 #include "ui/gfx/geometry/size.h" | 14 #include "ui/gfx/geometry/size.h" |
14 | 15 |
15 namespace base { | 16 namespace base { |
16 namespace trace_event { | 17 namespace trace_event { |
17 class TracedValue; | 18 class TracedValue; |
18 } | 19 } |
19 } | 20 } |
20 | 21 |
21 namespace cc { | |
22 class SingleReleaseCallback; | |
23 class TextureMailbox; | |
24 } | |
25 | |
26 namespace gfx { | 22 namespace gfx { |
27 class GpuMemoryBuffer; | 23 class GpuMemoryBuffer; |
28 } | 24 } |
29 | 25 |
30 namespace exo { | 26 namespace exo { |
31 | 27 |
| 28 class CompositorFrameSinkHolder; |
| 29 |
32 // This class provides the content for a Surface. The mechanism by which a | 30 // This class provides the content for a Surface. The mechanism by which a |
33 // client provides and updates the contents is the responsibility of the client | 31 // client provides and updates the contents is the responsibility of the client |
34 // and not defined as part of this class. | 32 // and not defined as part of this class. |
35 class Buffer : public base::SupportsWeakPtr<Buffer> { | 33 class Buffer : public base::SupportsWeakPtr<Buffer> { |
36 public: | 34 public: |
37 explicit Buffer(std::unique_ptr<gfx::GpuMemoryBuffer> gpu_memory_buffer); | 35 explicit Buffer(std::unique_ptr<gfx::GpuMemoryBuffer> gpu_memory_buffer); |
38 Buffer(std::unique_ptr<gfx::GpuMemoryBuffer> gpu_memory_buffer, | 36 Buffer(std::unique_ptr<gfx::GpuMemoryBuffer> gpu_memory_buffer, |
39 unsigned texture_target, | 37 unsigned texture_target, |
40 unsigned query_type, | 38 unsigned query_type, |
41 bool use_zero_copy, | 39 bool use_zero_copy, |
42 bool is_overlay_candidate); | 40 bool is_overlay_candidate); |
43 ~Buffer(); | 41 ~Buffer(); |
44 | 42 |
45 // Set the callback to run when the buffer is no longer used by the | 43 // Set the callback to run when the buffer is no longer used by the |
46 // compositor. The client is free to re-use or destroy this buffer and | 44 // compositor. The client is free to re-use or destroy this buffer and |
47 // its backing storage after this has been called. | 45 // its backing storage after this has been called. |
48 void set_release_callback(const base::Closure& release_callback) { | 46 void set_release_callback(const base::Closure& release_callback) { |
49 release_callback_ = release_callback; | 47 release_callback_ = release_callback; |
50 } | 48 } |
51 | 49 |
52 // This function can be used to acquire a texture mailbox for the contents of | 50 // This function can be used to acquire a texture mailbox for the contents of |
53 // buffer. Returns a release callback on success. The release callback should | 51 // buffer. Returns a release callback on success. The release callback should |
54 // be called before a new texture mailbox can be acquired unless | 52 // be called before a new texture mailbox can be acquired unless |
55 // |non_client_usage| is true. | 53 // |non_client_usage| is true. |
56 std::unique_ptr<cc::SingleReleaseCallback> ProduceTextureMailbox( | 54 bool ProduceTransferableResource( |
57 cc::TextureMailbox* mailbox, | 55 CompositorFrameSinkHolder* compositor_frame_sink_holder, |
| 56 cc::ResourceId resource_id, |
58 bool secure_output_only, | 57 bool secure_output_only, |
59 bool client_usage); | 58 bool client_usage, |
| 59 cc::TransferableResource* resource); |
60 | 60 |
61 // This should be called when the buffer is attached to a Surface. | 61 // This should be called when the buffer is attached to a Surface. |
62 void OnAttach(); | 62 void OnAttach(); |
63 | 63 |
64 // This should be called when the buffer is detached from a surface. | 64 // This should be called when the buffer is detached from a surface. |
65 void OnDetach(); | 65 void OnDetach(); |
66 | 66 |
67 // Returns the size of the buffer. | 67 // Returns the size of the buffer. |
68 gfx::Size GetSize() const; | 68 gfx::Size GetSize() const; |
69 | 69 |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
116 // instead of creating a new texture when possible. | 116 // instead of creating a new texture when possible. |
117 std::unique_ptr<Texture> texture_; | 117 std::unique_ptr<Texture> texture_; |
118 | 118 |
119 // The last used contents texture. ProduceTextureMailbox() will use this | 119 // The last used contents texture. ProduceTextureMailbox() will use this |
120 // instead of creating a new texture when possible. | 120 // instead of creating a new texture when possible. |
121 std::unique_ptr<Texture> contents_texture_; | 121 std::unique_ptr<Texture> contents_texture_; |
122 | 122 |
123 // The client release callback. | 123 // The client release callback. |
124 base::Closure release_callback_; | 124 base::Closure release_callback_; |
125 | 125 |
| 126 // The CompositorFrameSinkHolder that has the ReleaseCallback of this buffer |
| 127 // produced in ProduceTextureMailbox(). |
| 128 // Buffer holds a reference to the CompositorFrameSinkHolder to keep it alive. |
| 129 // The refptr is reset when the release callback is called. |
| 130 scoped_refptr<CompositorFrameSinkHolder> compositor_frame_sink_holder_; |
| 131 |
126 DISALLOW_COPY_AND_ASSIGN(Buffer); | 132 DISALLOW_COPY_AND_ASSIGN(Buffer); |
127 }; | 133 }; |
128 | 134 |
129 } // namespace exo | 135 } // namespace exo |
130 | 136 |
131 #endif // COMPONENTS_EXO_BUFFER_H_ | 137 #endif // COMPONENTS_EXO_BUFFER_H_ |
OLD | NEW |