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

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

Issue 2584953002: exo::CompositorFrameSinkHolder's release callbacks hold ref (Closed)
Patch Set: NOT FOR COMMIT: SEGV_MAPERR in Callback::Run() Created 3 years, 11 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') | no next file with comments »
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"
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 namespace cc {
22 class SingleReleaseCallback; 23 class SingleReleaseCallback;
23 class TextureMailbox; 24 class TextureMailbox;
24 } 25 }
25 26
26 namespace gfx { 27 namespace gfx {
27 class GpuMemoryBuffer; 28 class GpuMemoryBuffer;
28 } 29 }
29 30
30 namespace exo { 31 namespace exo {
31 32
33 class CompositorFrameSinkHolder;
34
32 // This class provides the content for a Surface. The mechanism by which a 35 // 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 36 // client provides and updates the contents is the responsibility of the client
34 // and not defined as part of this class. 37 // and not defined as part of this class.
35 class Buffer : public base::SupportsWeakPtr<Buffer> { 38 class Buffer : public base::SupportsWeakPtr<Buffer> {
36 public: 39 public:
37 explicit Buffer(std::unique_ptr<gfx::GpuMemoryBuffer> gpu_memory_buffer); 40 explicit Buffer(std::unique_ptr<gfx::GpuMemoryBuffer> gpu_memory_buffer);
38 Buffer(std::unique_ptr<gfx::GpuMemoryBuffer> gpu_memory_buffer, 41 Buffer(std::unique_ptr<gfx::GpuMemoryBuffer> gpu_memory_buffer,
39 unsigned texture_target, 42 unsigned texture_target,
40 unsigned query_type, 43 unsigned query_type,
41 bool use_zero_copy, 44 bool use_zero_copy,
42 bool is_overlay_candidate); 45 bool is_overlay_candidate);
43 ~Buffer(); 46 ~Buffer();
44 47
45 // Set the callback to run when the buffer is no longer used by the 48 // 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 49 // compositor. The client is free to re-use or destroy this buffer and
47 // its backing storage after this has been called. 50 // its backing storage after this has been called.
48 void set_release_callback(const base::Closure& release_callback) { 51 void set_release_callback(const base::Closure& release_callback) {
49 release_callback_ = release_callback; 52 release_callback_ = release_callback;
50 } 53 }
51 54
52 // This function can be used to acquire a texture mailbox for the contents of 55 // 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 56 // buffer. Returns a release callback on success. The release callback should
54 // be called before a new texture mailbox can be acquired unless 57 // be called before a new texture mailbox can be acquired unless
55 // |non_client_usage| is true. 58 // |non_client_usage| is true.
56 std::unique_ptr<cc::SingleReleaseCallback> ProduceTextureMailbox( 59 bool ProduceTransferableResource(
57 cc::TextureMailbox* mailbox, 60 CompositorFrameSinkHolder* compositor_frame_sink_holder,
61 cc::ResourceId resource_id,
58 bool secure_output_only, 62 bool secure_output_only,
59 bool client_usage); 63 bool client_usage,
64 cc::TransferableResource* resource);
60 65
61 // This should be called when the buffer is attached to a Surface. 66 // This should be called when the buffer is attached to a Surface.
62 void OnAttach(); 67 void OnAttach();
63 68
64 // This should be called when the buffer is detached from a surface. 69 // This should be called when the buffer is detached from a surface.
65 void OnDetach(); 70 void OnDetach();
66 71
67 // Returns the size of the buffer. 72 // Returns the size of the buffer.
68 gfx::Size GetSize() const; 73 gfx::Size GetSize() const;
69 74
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
116 // instead of creating a new texture when possible. 121 // instead of creating a new texture when possible.
117 std::unique_ptr<Texture> texture_; 122 std::unique_ptr<Texture> texture_;
118 123
119 // The last used contents texture. ProduceTextureMailbox() will use this 124 // The last used contents texture. ProduceTextureMailbox() will use this
120 // instead of creating a new texture when possible. 125 // instead of creating a new texture when possible.
121 std::unique_ptr<Texture> contents_texture_; 126 std::unique_ptr<Texture> contents_texture_;
122 127
123 // The client release callback. 128 // The client release callback.
124 base::Closure release_callback_; 129 base::Closure release_callback_;
125 130
131 // The CompositorFrameSinkHolder that has the ReleaseCallback of this buffer
132 // produced in ProduceTextureMailbox().
133 // Buffer holds a reference to the CompositorFrameSinkHolder to keep it alive.
134 // The refptr is reset when the release callback is called.
reveman 2017/01/03 23:24:46 remove this line?
135 scoped_refptr<CompositorFrameSinkHolder> compositor_frame_sink_holder_;
136
126 DISALLOW_COPY_AND_ASSIGN(Buffer); 137 DISALLOW_COPY_AND_ASSIGN(Buffer);
127 }; 138 };
128 139
129 } // namespace exo 140 } // namespace exo
130 141
131 #endif // COMPONENTS_EXO_BUFFER_H_ 142 #endif // COMPONENTS_EXO_BUFFER_H_
OLDNEW
« no previous file with comments | « no previous file | components/exo/buffer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698