Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(55)

Side by Side Diff: components/exo/buffer.h

Issue 2584953002: exo::CompositorFrameSinkHolder's release callbacks hold ref (Closed)
Patch Set: Use ScopedClosureRunner Created 3 years, 12 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | components/exo/buffer.cc » ('j') | components/exo/buffer.cc » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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/21 20:05:42 nit: CompositorFrameSinkHolder* compositor_frame_s
Alex Z. 2016/12/22 16:33:25 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
83 // This is used by ProduceTextureMailbox() to produce a release callback 86 // This is used by ProduceTextureMailbox() to produce a release callback
84 // that releases a texture so it can be destroyed or reused. 87 // that releases a texture so it can be destroyed or reused.
85 void ReleaseTexture(std::unique_ptr<Texture> texture); 88 void ReleaseTexture(
89 std::unique_ptr<Texture> texture,
90 scoped_refptr<CompositorFrameSinkHolder> compositor_frame_sink_holder);
reveman 2016/12/21 20:05:42 these Release(Contents)Texture functions don't act
Alex Z. 2016/12/21 21:53:20 I'm not sure if I understand. SinkHolder doesn't g
reveman 2016/12/21 22:46:00 Yes, it's confusing that a function named "Release
Alex Z. 2016/12/22 16:33:25 Done.
86 91
87 // This is used by ProduceTextureMailbox() to produce a release callback 92 // This is used by ProduceTextureMailbox() to produce a release callback
88 // that releases the buffer contents referenced by a texture before the 93 // that releases the buffer contents referenced by a texture before the
89 // texture is destroyed or reused. 94 // texture is destroyed or reused.
90 void ReleaseContentsTexture(std::unique_ptr<Texture> texture); 95 void ReleaseContentsTexture(
96 std::unique_ptr<Texture> texture,
97 scoped_refptr<CompositorFrameSinkHolder> compositor_frame_sink_holder);
91 98
92 // The GPU memory buffer that contains the contents of this buffer. 99 // The GPU memory buffer that contains the contents of this buffer.
93 std::unique_ptr<gfx::GpuMemoryBuffer> gpu_memory_buffer_; 100 std::unique_ptr<gfx::GpuMemoryBuffer> gpu_memory_buffer_;
94 101
95 // Texture target that must be used when creating a texture for buffer. 102 // Texture target that must be used when creating a texture for buffer.
96 const unsigned texture_target_; 103 const unsigned texture_target_;
97 104
98 // Query type that must be used when releasing buffer from a texture. 105 // Query type that must be used when releasing buffer from a texture.
99 const unsigned query_type_; 106 const unsigned query_type_;
100 107
(...skipping 21 matching lines...) Expand all
122 129
123 // The client release callback. 130 // The client release callback.
124 base::Closure release_callback_; 131 base::Closure release_callback_;
125 132
126 DISALLOW_COPY_AND_ASSIGN(Buffer); 133 DISALLOW_COPY_AND_ASSIGN(Buffer);
127 }; 134 };
128 135
129 } // namespace exo 136 } // namespace exo
130 137
131 #endif // COMPONENTS_EXO_BUFFER_H_ 138 #endif // COMPONENTS_EXO_BUFFER_H_
OLDNEW
« no previous file with comments | « no previous file | components/exo/buffer.cc » ('j') | components/exo/buffer.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698