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" |
(...skipping 11 matching lines...) Expand all Loading... | |
22 class SingleReleaseCallback; | 22 class SingleReleaseCallback; |
23 class TextureMailbox; | 23 class TextureMailbox; |
24 } | 24 } |
25 | 25 |
26 namespace gfx { | 26 namespace gfx { |
27 class GpuMemoryBuffer; | 27 class GpuMemoryBuffer; |
28 } | 28 } |
29 | 29 |
30 namespace exo { | 30 namespace exo { |
31 | 31 |
32 class CompositorFrameSinkHolder; | |
33 | |
32 // This class provides the content for a Surface. The mechanism by which a | 34 // 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 | 35 // client provides and updates the contents is the responsibility of the client |
34 // and not defined as part of this class. | 36 // and not defined as part of this class. |
35 class Buffer : public base::SupportsWeakPtr<Buffer> { | 37 class Buffer : public base::SupportsWeakPtr<Buffer> { |
36 public: | 38 public: |
37 explicit Buffer(std::unique_ptr<gfx::GpuMemoryBuffer> gpu_memory_buffer); | 39 explicit Buffer(std::unique_ptr<gfx::GpuMemoryBuffer> gpu_memory_buffer); |
38 Buffer(std::unique_ptr<gfx::GpuMemoryBuffer> gpu_memory_buffer, | 40 Buffer(std::unique_ptr<gfx::GpuMemoryBuffer> gpu_memory_buffer, |
39 unsigned texture_target, | 41 unsigned texture_target, |
40 unsigned query_type, | 42 unsigned query_type, |
41 bool use_zero_copy, | 43 bool use_zero_copy, |
42 bool is_overlay_candidate); | 44 bool is_overlay_candidate); |
43 ~Buffer(); | 45 ~Buffer(); |
44 | 46 |
45 // Set the callback to run when the buffer is no longer used by the | 47 // 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 | 48 // compositor. The client is free to re-use or destroy this buffer and |
47 // its backing storage after this has been called. | 49 // its backing storage after this has been called. |
48 void set_release_callback(const base::Closure& release_callback) { | 50 void set_release_callback(const base::Closure& release_callback) { |
49 release_callback_ = release_callback; | 51 release_callback_ = release_callback; |
50 } | 52 } |
51 | 53 |
52 // This function can be used to acquire a texture mailbox for the contents of | 54 // 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 | 55 // buffer. Returns a release callback on success. The release callback should |
54 // be called before a new texture mailbox can be acquired unless | 56 // be called before a new texture mailbox can be acquired unless |
55 // |non_client_usage| is true. | 57 // |non_client_usage| is true. |
56 std::unique_ptr<cc::SingleReleaseCallback> ProduceTextureMailbox( | 58 std::unique_ptr<cc::SingleReleaseCallback> ProduceTextureMailbox( |
57 cc::TextureMailbox* mailbox, | 59 cc::TextureMailbox* mailbox, |
58 bool secure_output_only, | 60 bool secure_output_only, |
59 bool client_usage); | 61 bool client_usage, |
62 scoped_refptr<CompositorFrameSinkHolder> compositor_frame_sink_holder); | |
reveman
2016/12/22 17:00:53
nit: s/scoped_refptr<CompositorFrameSinkHolder>/Co
Alex Z.
2016/12/22 18:08:48
Done.
| |
60 | 63 |
61 // This should be called when the buffer is attached to a Surface. | 64 // This should be called when the buffer is attached to a Surface. |
62 void OnAttach(); | 65 void OnAttach(); |
63 | 66 |
64 // This should be called when the buffer is detached from a surface. | 67 // This should be called when the buffer is detached from a surface. |
65 void OnDetach(); | 68 void OnDetach(); |
66 | 69 |
67 // Returns the size of the buffer. | 70 // Returns the size of the buffer. |
68 gfx::Size GetSize() const; | 71 gfx::Size GetSize() const; |
69 | 72 |
70 // Returns a trace value representing the state of the buffer. | 73 // Returns a trace value representing the state of the buffer. |
71 std::unique_ptr<base::trace_event::TracedValue> AsTracedValue() const; | 74 std::unique_ptr<base::trace_event::TracedValue> AsTracedValue() const; |
72 | 75 |
73 private: | 76 private: |
74 class Texture; | 77 class Texture; |
75 | 78 |
76 // Decrements the use count of buffer and notifies the client that buffer | 79 // Decrements the use count of buffer and notifies the client that buffer |
77 // as been released if it reached 0. | 80 // as been released if it reached 0. |
78 void Release(); | 81 void Release(); |
79 | 82 |
80 // Runs the release callback if the buffer isn't attached or in use. | 83 // Runs the release callback if the buffer isn't attached or in use. |
81 void CheckReleaseCallback(); | 84 void CheckReleaseCallback(); |
82 | 85 |
86 // This is a wrapper function for ReleaseTexture. It holds onto a ref to | |
87 // CompositorFrameSinkHolder to keep it alive and calls | |
88 // ReleaseTexture(texture). | |
89 void ReleaseTextureAndCompositorFrameSinkHolder( | |
90 std::unique_ptr<Texture> texture, | |
91 CompositorFrameSinkHolder* compositor_frame_sink_holder); | |
92 | |
83 // This is used by ProduceTextureMailbox() to produce a release callback | 93 // This is used by ProduceTextureMailbox() to produce a release callback |
84 // that releases a texture so it can be destroyed or reused. | 94 // that releases a texture so it can be destroyed or reused. |
85 void ReleaseTexture(std::unique_ptr<Texture> texture); | 95 void ReleaseTexture(std::unique_ptr<Texture> texture); |
86 | 96 |
97 // This is a wrapper function for ReleaseContentsTexture. It holds onto a ref | |
98 // to CompositorFrameSinkHolder to keep it alive and calls | |
99 // ReleaseTexture(texture). | |
100 void ReleaseContentsTextureAndCompositorFrameSinkHolder( | |
101 std::unique_ptr<Texture> texture, | |
102 CompositorFrameSinkHolder* compositor_frame_sink_holder); | |
103 | |
87 // This is used by ProduceTextureMailbox() to produce a release callback | 104 // This is used by ProduceTextureMailbox() to produce a release callback |
88 // that releases the buffer contents referenced by a texture before the | 105 // that releases the buffer contents referenced by a texture before the |
89 // texture is destroyed or reused. | 106 // texture is destroyed or reused. |
90 void ReleaseContentsTexture(std::unique_ptr<Texture> texture); | 107 void ReleaseContentsTexture(std::unique_ptr<Texture> texture); |
91 | 108 |
92 // The GPU memory buffer that contains the contents of this buffer. | 109 // The GPU memory buffer that contains the contents of this buffer. |
93 std::unique_ptr<gfx::GpuMemoryBuffer> gpu_memory_buffer_; | 110 std::unique_ptr<gfx::GpuMemoryBuffer> gpu_memory_buffer_; |
94 | 111 |
95 // Texture target that must be used when creating a texture for buffer. | 112 // Texture target that must be used when creating a texture for buffer. |
96 const unsigned texture_target_; | 113 const unsigned texture_target_; |
(...skipping 25 matching lines...) Expand all Loading... | |
122 | 139 |
123 // The client release callback. | 140 // The client release callback. |
124 base::Closure release_callback_; | 141 base::Closure release_callback_; |
125 | 142 |
126 DISALLOW_COPY_AND_ASSIGN(Buffer); | 143 DISALLOW_COPY_AND_ASSIGN(Buffer); |
127 }; | 144 }; |
128 | 145 |
129 } // namespace exo | 146 } // namespace exo |
130 | 147 |
131 #endif // COMPONENTS_EXO_BUFFER_H_ | 148 #endif // COMPONENTS_EXO_BUFFER_H_ |
OLD | NEW |