OLD | NEW |
---|---|
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 #include "cc/surfaces/direct_compositor_frame_sink.h" | 5 #include "cc/surfaces/direct_compositor_frame_sink.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "cc/output/compositor_frame.h" | 8 #include "cc/output/compositor_frame.h" |
9 #include "cc/output/compositor_frame_sink_client.h" | 9 #include "cc/output/compositor_frame_sink_client.h" |
10 #include "cc/surfaces/display.h" | 10 #include "cc/surfaces/display.h" |
(...skipping 14 matching lines...) Expand all Loading... | |
25 SharedBitmapManager* shared_bitmap_manager) | 25 SharedBitmapManager* shared_bitmap_manager) |
26 : CompositorFrameSink(std::move(context_provider), | 26 : CompositorFrameSink(std::move(context_provider), |
27 std::move(worker_context_provider), | 27 std::move(worker_context_provider), |
28 gpu_memory_buffer_manager, | 28 gpu_memory_buffer_manager, |
29 shared_bitmap_manager), | 29 shared_bitmap_manager), |
30 frame_sink_id_(frame_sink_id), | 30 frame_sink_id_(frame_sink_id), |
31 surface_manager_(surface_manager), | 31 surface_manager_(surface_manager), |
32 display_(display), | 32 display_(display), |
33 factory_(frame_sink_id, surface_manager, this) { | 33 factory_(frame_sink_id, surface_manager, this) { |
34 DCHECK(thread_checker_.CalledOnValidThread()); | 34 DCHECK(thread_checker_.CalledOnValidThread()); |
35 capabilities_.can_force_reclaim_resources = true; | |
36 // Display and DirectCompositorFrameSink share a GL context, so sync | 35 // Display and DirectCompositorFrameSink share a GL context, so sync |
37 // points aren't needed when passing resources between them. | 36 // points aren't needed when passing resources between them. |
38 capabilities_.delegated_sync_points_required = false; | 37 capabilities_.delegated_sync_points_required = false; |
39 factory_.set_needs_sync_points(false); | 38 factory_.set_needs_sync_points(false); |
40 } | 39 } |
41 | 40 |
42 DirectCompositorFrameSink::DirectCompositorFrameSink( | 41 DirectCompositorFrameSink::DirectCompositorFrameSink( |
43 const FrameSinkId& frame_sink_id, | 42 const FrameSinkId& frame_sink_id, |
44 SurfaceManager* surface_manager, | 43 SurfaceManager* surface_manager, |
45 Display* display, | 44 Display* display, |
46 scoped_refptr<VulkanContextProvider> vulkan_context_provider) | 45 scoped_refptr<VulkanContextProvider> vulkan_context_provider) |
47 : CompositorFrameSink(std::move(vulkan_context_provider)), | 46 : CompositorFrameSink(std::move(vulkan_context_provider)), |
48 frame_sink_id_(frame_sink_id), | 47 frame_sink_id_(frame_sink_id), |
49 surface_manager_(surface_manager), | 48 surface_manager_(surface_manager), |
50 display_(display), | 49 display_(display), |
51 factory_(frame_sink_id_, surface_manager, this) { | 50 factory_(frame_sink_id_, surface_manager, this) { |
52 DCHECK(thread_checker_.CalledOnValidThread()); | 51 DCHECK(thread_checker_.CalledOnValidThread()); |
53 capabilities_.can_force_reclaim_resources = true; | |
54 } | 52 } |
55 | 53 |
56 DirectCompositorFrameSink::~DirectCompositorFrameSink() { | 54 DirectCompositorFrameSink::~DirectCompositorFrameSink() { |
57 DCHECK(thread_checker_.CalledOnValidThread()); | 55 DCHECK(thread_checker_.CalledOnValidThread()); |
58 } | 56 } |
59 | 57 |
60 bool DirectCompositorFrameSink::BindToClient( | 58 bool DirectCompositorFrameSink::BindToClient( |
61 CompositorFrameSinkClient* client) { | 59 CompositorFrameSinkClient* client) { |
62 DCHECK(thread_checker_.CalledOnValidThread()); | 60 DCHECK(thread_checker_.CalledOnValidThread()); |
63 | 61 |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
95 } | 93 } |
96 display_->SetLocalFrameId(delegated_local_frame_id_, | 94 display_->SetLocalFrameId(delegated_local_frame_id_, |
97 frame.metadata.device_scale_factor); | 95 frame.metadata.device_scale_factor); |
98 | 96 |
99 factory_.SubmitCompositorFrame( | 97 factory_.SubmitCompositorFrame( |
100 delegated_local_frame_id_, std::move(frame), | 98 delegated_local_frame_id_, std::move(frame), |
101 base::Bind(&DirectCompositorFrameSink::DidDrawCallback, | 99 base::Bind(&DirectCompositorFrameSink::DidDrawCallback, |
102 base::Unretained(this))); | 100 base::Unretained(this))); |
103 } | 101 } |
104 | 102 |
105 void DirectCompositorFrameSink::ForceReclaimResources() { | |
106 if (delegated_local_frame_id_.is_valid()) | |
107 factory_.ClearSurface(); | |
danakj
2017/01/04 18:43:38
Good news/bad news. This is the only caller of Cle
ericrk
2017/01/11 19:17:54
Removed this and the now unused "EvictFrame" I fou
| |
108 } | |
109 | |
110 void DirectCompositorFrameSink::ReturnResources( | 103 void DirectCompositorFrameSink::ReturnResources( |
111 const ReturnedResourceArray& resources) { | 104 const ReturnedResourceArray& resources) { |
112 if (client_) | 105 if (client_) |
113 client_->ReclaimResources(resources); | 106 client_->ReclaimResources(resources); |
114 } | 107 } |
115 | 108 |
116 void DirectCompositorFrameSink::SetBeginFrameSource( | 109 void DirectCompositorFrameSink::SetBeginFrameSource( |
117 BeginFrameSource* begin_frame_source) { | 110 BeginFrameSource* begin_frame_source) { |
118 DCHECK(client_); | 111 DCHECK(client_); |
119 client_->SetBeginFrameSource(begin_frame_source); | 112 client_->SetBeginFrameSource(begin_frame_source); |
(...skipping 14 matching lines...) Expand all Loading... | |
134 // This notification is not relevant to our client outside of tests. We | 127 // This notification is not relevant to our client outside of tests. We |
135 // unblock the client from DidDrawCallback() when the surface is going to | 128 // unblock the client from DidDrawCallback() when the surface is going to |
136 // be drawn. | 129 // be drawn. |
137 } | 130 } |
138 | 131 |
139 void DirectCompositorFrameSink::DidDrawCallback() { | 132 void DirectCompositorFrameSink::DidDrawCallback() { |
140 client_->DidReceiveCompositorFrameAck(); | 133 client_->DidReceiveCompositorFrameAck(); |
141 } | 134 } |
142 | 135 |
143 } // namespace cc | 136 } // namespace cc |
OLD | NEW |