Chromium Code Reviews| 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 CompositorFrameSinkHolder* compositor_frame_sink_holder); | |
| 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 |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 116 // instead of creating a new texture when possible. | 119 // instead of creating a new texture when possible. |
| 117 std::unique_ptr<Texture> texture_; | 120 std::unique_ptr<Texture> texture_; |
| 118 | 121 |
| 119 // The last used contents texture. ProduceTextureMailbox() will use this | 122 // The last used contents texture. ProduceTextureMailbox() will use this |
| 120 // instead of creating a new texture when possible. | 123 // instead of creating a new texture when possible. |
| 121 std::unique_ptr<Texture> contents_texture_; | 124 std::unique_ptr<Texture> contents_texture_; |
| 122 | 125 |
| 123 // The client release callback. | 126 // The client release callback. |
| 124 base::Closure release_callback_; | 127 base::Closure release_callback_; |
| 125 | 128 |
| 129 // The CompositorFrameSinkHolder that has the ReleaseCallback of this buffer | |
|
reveman
2017/01/02 19:57:56
please updated this comment after addressing my ot
| |
| 130 // produced in ProduceTextureMailbox(). | |
| 131 // Buffer holds a reference to the CompositorFrameSinkHolder to keep it alive. | |
| 132 // The refptr is reset when the release callback is called. | |
| 133 scoped_refptr<CompositorFrameSinkHolder> compositor_frame_sink_holder_; | |
| 134 | |
| 126 DISALLOW_COPY_AND_ASSIGN(Buffer); | 135 DISALLOW_COPY_AND_ASSIGN(Buffer); |
| 127 }; | 136 }; |
| 128 | 137 |
| 129 } // namespace exo | 138 } // namespace exo |
| 130 | 139 |
| 131 #endif // COMPONENTS_EXO_BUFFER_H_ | 140 #endif // COMPONENTS_EXO_BUFFER_H_ |
| OLD | NEW |