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

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

Issue 2485473003: Remove SurfaceFactory::Create and SurfaceFactory::Destroy (Closed)
Patch Set: up Created 4 years 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 | « services/ui/surfaces/gpu_compositor_frame_sink.cc ('k') | no next file » | 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 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
122 frame.metadata.bottom_controls_shown_ratio || 122 frame.metadata.bottom_controls_shown_ratio ||
123 current_frame_->viewport_selection != frame.metadata.selection || 123 current_frame_->viewport_selection != frame.metadata.selection ||
124 current_frame_->has_transparent_background != 124 current_frame_->has_transparent_background !=
125 root_pass->has_transparent_background) { 125 root_pass->has_transparent_background) {
126 DestroyDelegatedContent(); 126 DestroyDelegatedContent();
127 DCHECK(!content_layer_); 127 DCHECK(!content_layer_);
128 DCHECK(!current_frame_); 128 DCHECK(!current_frame_);
129 129
130 current_frame_ = base::MakeUnique<FrameData>(); 130 current_frame_ = base::MakeUnique<FrameData>();
131 current_frame_->local_frame_id = surface_id_allocator_->GenerateId(); 131 current_frame_->local_frame_id = surface_id_allocator_->GenerateId();
132 surface_factory_->Create(current_frame_->local_frame_id);
133 132
134 current_frame_->surface_size = surface_size; 133 current_frame_->surface_size = surface_size;
135 current_frame_->top_controls_height = frame.metadata.top_controls_height; 134 current_frame_->top_controls_height = frame.metadata.top_controls_height;
136 current_frame_->top_controls_shown_ratio = 135 current_frame_->top_controls_shown_ratio =
137 frame.metadata.top_controls_shown_ratio; 136 frame.metadata.top_controls_shown_ratio;
138 current_frame_->bottom_controls_height = 137 current_frame_->bottom_controls_height =
139 frame.metadata.bottom_controls_height; 138 frame.metadata.bottom_controls_height;
140 current_frame_->bottom_controls_shown_ratio = 139 current_frame_->bottom_controls_shown_ratio =
141 frame.metadata.bottom_controls_shown_ratio; 140 frame.metadata.bottom_controls_shown_ratio;
142 current_frame_->has_transparent_background = 141 current_frame_->has_transparent_background =
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
174 !current_frame_->has_transparent_background); 173 !current_frame_->has_transparent_background);
175 readback_layer->SetHideLayerAndSubtree(true); 174 readback_layer->SetHideLayerAndSubtree(true);
176 compositor->AttachLayerForReadback(readback_layer); 175 compositor->AttachLayerForReadback(readback_layer);
177 std::unique_ptr<cc::CopyOutputRequest> copy_output_request = 176 std::unique_ptr<cc::CopyOutputRequest> copy_output_request =
178 cc::CopyOutputRequest::CreateRequest(base::Bind( 177 cc::CopyOutputRequest::CreateRequest(base::Bind(
179 &CopyOutputRequestCallback, readback_layer, result_callback)); 178 &CopyOutputRequestCallback, readback_layer, result_callback));
180 179
181 if (!src_subrect_in_pixel.IsEmpty()) 180 if (!src_subrect_in_pixel.IsEmpty())
182 copy_output_request->set_area(src_subrect_in_pixel); 181 copy_output_request->set_area(src_subrect_in_pixel);
183 182
184 surface_factory_->RequestCopyOfSurface(current_frame_->local_frame_id, 183 surface_factory_->RequestCopyOfSurface(std::move(copy_output_request));
185 std::move(copy_output_request));
186 } 184 }
187 185
188 void DelegatedFrameHostAndroid::DestroyDelegatedContent() { 186 void DelegatedFrameHostAndroid::DestroyDelegatedContent() {
189 if (!current_frame_) 187 if (!current_frame_)
190 return; 188 return;
191 189
192 DCHECK(content_layer_); 190 DCHECK(content_layer_);
193 191
194 content_layer_->RemoveFromParent(); 192 content_layer_->RemoveFromParent();
195 content_layer_ = nullptr; 193 content_layer_ = nullptr;
196 surface_factory_->Destroy(current_frame_->local_frame_id); 194 surface_factory_->EvictSurface();
197 current_frame_.reset(); 195 current_frame_.reset();
198 196
199 UpdateBackgroundLayer(); 197 UpdateBackgroundLayer();
200 } 198 }
201 199
202 bool DelegatedFrameHostAndroid::HasDelegatedContent() const { 200 bool DelegatedFrameHostAndroid::HasDelegatedContent() const {
203 return current_frame_.get() != nullptr; 201 return current_frame_.get() != nullptr;
204 } 202 }
205 203
206 void DelegatedFrameHostAndroid::CompositorFrameSinkChanged() { 204 void DelegatedFrameHostAndroid::CompositorFrameSinkChanged() {
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
264 content_size_in_dip.width() < container_size_in_dip_.width() || 262 content_size_in_dip.width() < container_size_in_dip_.width() ||
265 content_size_in_dip.height() < container_size_in_dip_.height(); 263 content_size_in_dip.height() < container_size_in_dip_.height();
266 } else { 264 } else {
267 background_is_drawable = true; 265 background_is_drawable = true;
268 } 266 }
269 267
270 background_layer_->SetIsDrawable(background_is_drawable); 268 background_layer_->SetIsDrawable(background_is_drawable);
271 } 269 }
272 270
273 } // namespace ui 271 } // namespace ui
OLDNEW
« no previous file with comments | « services/ui/surfaces/gpu_compositor_frame_sink.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698