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

Side by Side Diff: ui/android/delegated_frame_host_android.cc

Issue 2382873002: Replace usage of SurfaceId's client_id with FrameSinkId (Closed)
Patch Set: Rebased Created 4 years, 2 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 | « ui/android/delegated_frame_host_android.h ('k') | ui/android/window_android_compositor.h » ('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 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 "ui/android/delegated_frame_host_android.h" 5 #include "ui/android/delegated_frame_host_android.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "cc/layers/solid_color_layer.h" 9 #include "cc/layers/solid_color_layer.h"
10 #include "cc/layers/surface_layer.h" 10 #include "cc/layers/surface_layer.h"
(...skipping 10 matching lines...) Expand all
21 #include "ui/gfx/geometry/dip_util.h" 21 #include "ui/gfx/geometry/dip_util.h"
22 22
23 namespace ui { 23 namespace ui {
24 24
25 namespace { 25 namespace {
26 26
27 void SatisfyCallback(cc::SurfaceManager* manager, 27 void SatisfyCallback(cc::SurfaceManager* manager,
28 const cc::SurfaceSequence& sequence) { 28 const cc::SurfaceSequence& sequence) {
29 std::vector<uint32_t> sequences; 29 std::vector<uint32_t> sequences;
30 sequences.push_back(sequence.sequence); 30 sequences.push_back(sequence.sequence);
31 manager->DidSatisfySequences(sequence.client_id, &sequences); 31 manager->DidSatisfySequences(sequence.frame_sink_id, &sequences);
32 } 32 }
33 33
34 void RequireCallback(cc::SurfaceManager* manager, 34 void RequireCallback(cc::SurfaceManager* manager,
35 const cc::SurfaceId& id, 35 const cc::SurfaceId& id,
36 const cc::SurfaceSequence& sequence) { 36 const cc::SurfaceSequence& sequence) {
37 cc::Surface* surface = manager->GetSurfaceForId(id); 37 cc::Surface* surface = manager->GetSurfaceForId(id);
38 if (!surface) { 38 if (!surface) {
39 LOG(ERROR) << "Attempting to require callback on nonexistent surface"; 39 LOG(ERROR) << "Attempting to require callback on nonexistent surface";
40 return; 40 return;
41 } 41 }
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
75 ReturnResourcesCallback return_resources_callback) 75 ReturnResourcesCallback return_resources_callback)
76 : view_(view), 76 : view_(view),
77 return_resources_callback_(return_resources_callback), 77 return_resources_callback_(return_resources_callback),
78 background_layer_(cc::SolidColorLayer::Create()) { 78 background_layer_(cc::SolidColorLayer::Create()) {
79 DCHECK(view_); 79 DCHECK(view_);
80 DCHECK(!return_resources_callback_.is_null()); 80 DCHECK(!return_resources_callback_.is_null());
81 81
82 surface_manager_ = 82 surface_manager_ =
83 ui::ContextProviderFactory::GetInstance()->GetSurfaceManager(); 83 ui::ContextProviderFactory::GetInstance()->GetSurfaceManager();
84 surface_id_allocator_.reset(new cc::SurfaceIdAllocator( 84 surface_id_allocator_.reset(new cc::SurfaceIdAllocator(
85 ui::ContextProviderFactory::GetInstance()->AllocateSurfaceClientId())); 85 ui::ContextProviderFactory::GetInstance()->AllocateFrameSinkId()));
86 surface_manager_->RegisterSurfaceClientId(surface_id_allocator_->client_id()); 86 surface_manager_->RegisterFrameSinkId(surface_id_allocator_->frame_sink_id());
87 87
88 background_layer_->SetBackgroundColor(background_color); 88 background_layer_->SetBackgroundColor(background_color);
89 view_->GetLayer()->AddChild(background_layer_); 89 view_->GetLayer()->AddChild(background_layer_);
90 UpdateBackgroundLayer(); 90 UpdateBackgroundLayer();
91 } 91 }
92 92
93 DelegatedFrameHostAndroid::~DelegatedFrameHostAndroid() { 93 DelegatedFrameHostAndroid::~DelegatedFrameHostAndroid() {
94 DestroyDelegatedContent(); 94 DestroyDelegatedContent();
95 surface_factory_.reset(); 95 surface_factory_.reset();
96 UnregisterSurfaceNamespaceHierarchy(); 96 UnregisterFrameSinkHierarchy();
97 surface_manager_->InvalidateSurfaceClientId( 97 surface_manager_->InvalidateFrameSinkId(
98 surface_id_allocator_->client_id()); 98 surface_id_allocator_->frame_sink_id());
99 background_layer_->RemoveFromParent(); 99 background_layer_->RemoveFromParent();
100 } 100 }
101 101
102 DelegatedFrameHostAndroid::FrameData::FrameData() = default; 102 DelegatedFrameHostAndroid::FrameData::FrameData() = default;
103 103
104 DelegatedFrameHostAndroid::FrameData::~FrameData() = default; 104 DelegatedFrameHostAndroid::FrameData::~FrameData() = default;
105 105
106 void DelegatedFrameHostAndroid::SubmitCompositorFrame( 106 void DelegatedFrameHostAndroid::SubmitCompositorFrame(
107 cc::CompositorFrame frame, 107 cc::CompositorFrame frame,
108 cc::SurfaceFactory::DrawCallback draw_callback) { 108 cc::SurfaceFactory::DrawCallback draw_callback) {
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
152 current_frame_->surface_size, 152 current_frame_->surface_size,
153 !current_frame_->has_transparent_background); 153 !current_frame_->has_transparent_background);
154 view_->GetLayer()->AddChild(content_layer_); 154 view_->GetLayer()->AddChild(content_layer_);
155 UpdateBackgroundLayer(); 155 UpdateBackgroundLayer();
156 } 156 }
157 157
158 surface_factory_->SubmitCompositorFrame(current_frame_->surface_id, 158 surface_factory_->SubmitCompositorFrame(current_frame_->surface_id,
159 std::move(frame), draw_callback); 159 std::move(frame), draw_callback);
160 } 160 }
161 161
162 uint32_t DelegatedFrameHostAndroid::GetSurfaceClientId() const { 162 cc::FrameSinkId DelegatedFrameHostAndroid::GetFrameSinkId() const {
163 return surface_id_allocator_->client_id(); 163 return surface_id_allocator_->frame_sink_id();
164 } 164 }
165 165
166 void DelegatedFrameHostAndroid::RequestCopyOfSurface( 166 void DelegatedFrameHostAndroid::RequestCopyOfSurface(
167 WindowAndroidCompositor* compositor, 167 WindowAndroidCompositor* compositor,
168 const gfx::Rect& src_subrect_in_pixel, 168 const gfx::Rect& src_subrect_in_pixel,
169 cc::CopyOutputRequest::CopyOutputRequestCallback result_callback) { 169 cc::CopyOutputRequest::CopyOutputRequestCallback result_callback) {
170 DCHECK(current_frame_); 170 DCHECK(current_frame_);
171 DCHECK(!result_callback.is_null()); 171 DCHECK(!result_callback.is_null());
172 172
173 scoped_refptr<cc::Layer> readback_layer = 173 scoped_refptr<cc::Layer> readback_layer =
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
215 } 215 }
216 216
217 void DelegatedFrameHostAndroid::UpdateContainerSizeinDIP( 217 void DelegatedFrameHostAndroid::UpdateContainerSizeinDIP(
218 const gfx::Size& size_in_dip) { 218 const gfx::Size& size_in_dip) {
219 container_size_in_dip_ = size_in_dip; 219 container_size_in_dip_ = size_in_dip;
220 background_layer_->SetBounds(gfx::ConvertSizeToPixel( 220 background_layer_->SetBounds(gfx::ConvertSizeToPixel(
221 gfx::DeviceDisplayInfo().GetDIPScale(), container_size_in_dip_)); 221 gfx::DeviceDisplayInfo().GetDIPScale(), container_size_in_dip_));
222 UpdateBackgroundLayer(); 222 UpdateBackgroundLayer();
223 } 223 }
224 224
225 void DelegatedFrameHostAndroid::RegisterSurfaceNamespaceHierarchy( 225 void DelegatedFrameHostAndroid::RegisterFrameSinkHierarchy(
226 uint32_t parent_id) { 226 const cc::FrameSinkId& parent_id) {
227 if (registered_parent_client_id_ != 0u) 227 if (!registered_parent_frame_sink_id_.is_null())
228 UnregisterSurfaceNamespaceHierarchy(); 228 UnregisterFrameSinkHierarchy();
229 registered_parent_client_id_ = parent_id; 229 registered_parent_frame_sink_id_ = parent_id;
230 surface_manager_->RegisterSurfaceFactoryClient( 230 surface_manager_->RegisterSurfaceFactoryClient(
231 surface_id_allocator_->client_id(), this); 231 surface_id_allocator_->frame_sink_id(), this);
232 surface_manager_->RegisterSurfaceNamespaceHierarchy( 232 surface_manager_->RegisterFrameSinkHierarchy(
233 parent_id, surface_id_allocator_->client_id()); 233 parent_id, surface_id_allocator_->frame_sink_id());
234 } 234 }
235 235
236 void DelegatedFrameHostAndroid::UnregisterSurfaceNamespaceHierarchy() { 236 void DelegatedFrameHostAndroid::UnregisterFrameSinkHierarchy() {
237 if (registered_parent_client_id_ == 0u) 237 if (registered_parent_frame_sink_id_.is_null())
238 return; 238 return;
239 surface_manager_->UnregisterSurfaceFactoryClient( 239 surface_manager_->UnregisterSurfaceFactoryClient(
240 surface_id_allocator_->client_id()); 240 surface_id_allocator_->frame_sink_id());
241 surface_manager_->UnregisterSurfaceNamespaceHierarchy( 241 surface_manager_->UnregisterFrameSinkHierarchy(
242 registered_parent_client_id_, surface_id_allocator_->client_id()); 242 registered_parent_frame_sink_id_, surface_id_allocator_->frame_sink_id());
243 registered_parent_client_id_ = 0u; 243 registered_parent_frame_sink_id_ = cc::FrameSinkId();
244 } 244 }
245 245
246 void DelegatedFrameHostAndroid::ReturnResources( 246 void DelegatedFrameHostAndroid::ReturnResources(
247 const cc::ReturnedResourceArray& resources) { 247 const cc::ReturnedResourceArray& resources) {
248 return_resources_callback_.Run(resources); 248 return_resources_callback_.Run(resources);
249 } 249 }
250 250
251 void DelegatedFrameHostAndroid::SetBeginFrameSource( 251 void DelegatedFrameHostAndroid::SetBeginFrameSource(
252 cc::BeginFrameSource* begin_frame_source) { 252 cc::BeginFrameSource* begin_frame_source) {
253 // TODO(enne): hook this up instead of making RWHVAndroid a 253 // TODO(enne): hook this up instead of making RWHVAndroid a
(...skipping 15 matching lines...) Expand all
269 content_size_in_dip.width() < container_size_in_dip_.width() || 269 content_size_in_dip.width() < container_size_in_dip_.width() ||
270 content_size_in_dip.height() < container_size_in_dip_.height(); 270 content_size_in_dip.height() < container_size_in_dip_.height();
271 } else { 271 } else {
272 background_is_drawable = true; 272 background_is_drawable = true;
273 } 273 }
274 274
275 background_layer_->SetIsDrawable(background_is_drawable); 275 background_layer_->SetIsDrawable(background_is_drawable);
276 } 276 }
277 277
278 } // namespace ui 278 } // namespace ui
OLDNEW
« no previous file with comments | « ui/android/delegated_frame_host_android.h ('k') | ui/android/window_android_compositor.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698