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

Side by Side Diff: content/browser/compositor/delegated_frame_host.cc

Issue 1545243002: Convert Pass()→std::move() in //content/browser (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 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
OLDNEW
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 "content/browser/compositor/delegated_frame_host.h" 5 #include "content/browser/compositor/delegated_frame_host.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <string> 8 #include <string>
9 #include <utility> 9 #include <utility>
10 #include <vector> 10 #include <vector>
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
148 callback.Run(SkBitmap(), content::READBACK_SURFACE_UNAVAILABLE); 148 callback.Run(SkBitmap(), content::READBACK_SURFACE_UNAVAILABLE);
149 return; 149 return;
150 } 150 }
151 151
152 scoped_ptr<cc::CopyOutputRequest> request = 152 scoped_ptr<cc::CopyOutputRequest> request =
153 cc::CopyOutputRequest::CreateRequest( 153 cc::CopyOutputRequest::CreateRequest(
154 base::Bind(&DelegatedFrameHost::CopyFromCompositingSurfaceHasResult, 154 base::Bind(&DelegatedFrameHost::CopyFromCompositingSurfaceHasResult,
155 output_size, preferred_color_type, callback)); 155 output_size, preferred_color_type, callback));
156 if (!src_subrect.IsEmpty()) 156 if (!src_subrect.IsEmpty())
157 request->set_area(src_subrect); 157 request->set_area(src_subrect);
158 RequestCopyOfOutput(request.Pass()); 158 RequestCopyOfOutput(std::move(request));
159 } 159 }
160 160
161 void DelegatedFrameHost::CopyFromCompositingSurfaceToVideoFrame( 161 void DelegatedFrameHost::CopyFromCompositingSurfaceToVideoFrame(
162 const gfx::Rect& src_subrect, 162 const gfx::Rect& src_subrect,
163 const scoped_refptr<media::VideoFrame>& target, 163 const scoped_refptr<media::VideoFrame>& target,
164 const base::Callback<void(const gfx::Rect&, bool)>& callback) { 164 const base::Callback<void(const gfx::Rect&, bool)>& callback) {
165 if (!CanCopyToVideoFrame()) { 165 if (!CanCopyToVideoFrame()) {
166 callback.Run(gfx::Rect(), false); 166 callback.Run(gfx::Rect(), false);
167 return; 167 return;
168 } 168 }
169 169
170 scoped_ptr<cc::CopyOutputRequest> request = 170 scoped_ptr<cc::CopyOutputRequest> request =
171 cc::CopyOutputRequest::CreateRequest(base::Bind( 171 cc::CopyOutputRequest::CreateRequest(base::Bind(
172 &DelegatedFrameHost:: 172 &DelegatedFrameHost::
173 CopyFromCompositingSurfaceHasResultForVideo, 173 CopyFromCompositingSurfaceHasResultForVideo,
174 AsWeakPtr(), // For caching the ReadbackYUVInterface on this class. 174 AsWeakPtr(), // For caching the ReadbackYUVInterface on this class.
175 nullptr, 175 nullptr,
176 target, 176 target,
177 callback)); 177 callback));
178 request->set_area(src_subrect); 178 request->set_area(src_subrect);
179 RequestCopyOfOutput(request.Pass()); 179 RequestCopyOfOutput(std::move(request));
180 } 180 }
181 181
182 bool DelegatedFrameHost::CanCopyToBitmap() const { 182 bool DelegatedFrameHost::CanCopyToBitmap() const {
183 return compositor_ && 183 return compositor_ &&
184 client_->DelegatedFrameHostGetLayer()->has_external_content(); 184 client_->DelegatedFrameHostGetLayer()->has_external_content();
185 } 185 }
186 186
187 bool DelegatedFrameHost::CanCopyToVideoFrame() const { 187 bool DelegatedFrameHost::CanCopyToVideoFrame() const {
188 return compositor_ && 188 return compositor_ &&
189 client_->DelegatedFrameHostGetLayer()->has_external_content(); 189 client_->DelegatedFrameHostGetLayer()->has_external_content();
190 } 190 }
191 191
192 void DelegatedFrameHost::BeginFrameSubscription( 192 void DelegatedFrameHost::BeginFrameSubscription(
193 scoped_ptr<RenderWidgetHostViewFrameSubscriber> subscriber) { 193 scoped_ptr<RenderWidgetHostViewFrameSubscriber> subscriber) {
194 frame_subscriber_ = subscriber.Pass(); 194 frame_subscriber_ = std::move(subscriber);
195 } 195 }
196 196
197 void DelegatedFrameHost::EndFrameSubscription() { 197 void DelegatedFrameHost::EndFrameSubscription() {
198 idle_frame_subscriber_textures_.clear(); 198 idle_frame_subscriber_textures_.clear();
199 frame_subscriber_.reset(); 199 frame_subscriber_.reset();
200 } 200 }
201 201
202 uint32_t DelegatedFrameHost::GetSurfaceIdNamespace() { 202 uint32_t DelegatedFrameHost::GetSurfaceIdNamespace() {
203 if (!use_surfaces_) 203 if (!use_surfaces_)
204 return 0; 204 return 0;
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
324 request->SetTextureMailbox(cc::TextureMailbox( 324 request->SetTextureMailbox(cc::TextureMailbox(
325 subscriber_texture->mailbox(), subscriber_texture->sync_token(), 325 subscriber_texture->mailbox(), subscriber_texture->sync_token(),
326 subscriber_texture->target())); 326 subscriber_texture->target()));
327 } 327 }
328 328
329 if (surface_factory_.get()) { 329 if (surface_factory_.get()) {
330 // To avoid unnecessary composites, go directly to the Surface rather than 330 // To avoid unnecessary composites, go directly to the Surface rather than
331 // through RequestCopyOfOutput (which goes through the browser 331 // through RequestCopyOfOutput (which goes through the browser
332 // compositor). 332 // compositor).
333 if (!request_copy_of_output_callback_for_testing_.is_null()) 333 if (!request_copy_of_output_callback_for_testing_.is_null())
334 request_copy_of_output_callback_for_testing_.Run(request.Pass()); 334 request_copy_of_output_callback_for_testing_.Run(std::move(request));
335 else 335 else
336 surface_factory_->RequestCopyOfSurface(surface_id_, request.Pass()); 336 surface_factory_->RequestCopyOfSurface(surface_id_, std::move(request));
337 } else { 337 } else {
338 request->set_area(gfx::Rect(current_frame_size_in_dip_)); 338 request->set_area(gfx::Rect(current_frame_size_in_dip_));
339 RequestCopyOfOutput(request.Pass()); 339 RequestCopyOfOutput(std::move(request));
340 } 340 }
341 } 341 }
342 342
343 void DelegatedFrameHost::SwapDelegatedFrame( 343 void DelegatedFrameHost::SwapDelegatedFrame(
344 uint32_t output_surface_id, 344 uint32_t output_surface_id,
345 scoped_ptr<cc::CompositorFrame> frame) { 345 scoped_ptr<cc::CompositorFrame> frame) {
346 DCHECK(frame->delegated_frame_data.get()); 346 DCHECK(frame->delegated_frame_data.get());
347 cc::DelegatedFrameData* frame_data = frame->delegated_frame_data.get(); 347 cc::DelegatedFrameData* frame_data = frame->delegated_frame_data.get();
348 float frame_device_scale_factor = frame->metadata.device_scale_factor; 348 float frame_device_scale_factor = frame->metadata.device_scale_factor;
349 349
(...skipping 254 matching lines...) Expand 10 before | Expand all | Expand 10 after
604 } 604 }
605 605
606 gfx::Size output_size_in_pixel; 606 gfx::Size output_size_in_pixel;
607 if (dst_size_in_pixel.IsEmpty()) 607 if (dst_size_in_pixel.IsEmpty())
608 output_size_in_pixel = result->size(); 608 output_size_in_pixel = result->size();
609 else 609 else
610 output_size_in_pixel = dst_size_in_pixel; 610 output_size_in_pixel = dst_size_in_pixel;
611 611
612 if (result->HasTexture()) { 612 if (result->HasTexture()) {
613 // GPU-accelerated path 613 // GPU-accelerated path
614 PrepareTextureCopyOutputResult(output_size_in_pixel, color_type, 614 PrepareTextureCopyOutputResult(output_size_in_pixel, color_type, callback,
615 callback, 615 std::move(result));
616 result.Pass());
617 return; 616 return;
618 } 617 }
619 618
620 DCHECK(result->HasBitmap()); 619 DCHECK(result->HasBitmap());
621 // Software path 620 // Software path
622 PrepareBitmapCopyOutputResult(output_size_in_pixel, color_type, callback, 621 PrepareBitmapCopyOutputResult(output_size_in_pixel, color_type, callback,
623 result.Pass()); 622 std::move(result));
624 } 623 }
625 624
626 static void CopyFromCompositingSurfaceFinished( 625 static void CopyFromCompositingSurfaceFinished(
627 const ReadbackRequestCallback& callback, 626 const ReadbackRequestCallback& callback,
628 scoped_ptr<cc::SingleReleaseCallback> release_callback, 627 scoped_ptr<cc::SingleReleaseCallback> release_callback,
629 scoped_ptr<SkBitmap> bitmap, 628 scoped_ptr<SkBitmap> bitmap,
630 scoped_ptr<SkAutoLockPixels> bitmap_pixels_lock, 629 scoped_ptr<SkAutoLockPixels> bitmap_pixels_lock,
631 bool result) { 630 bool result) {
632 bitmap_pixels_lock.reset(); 631 bitmap_pixels_lock.reset();
633 632
(...skipping 408 matching lines...) Expand 10 before | Expand all | Expand 10 after
1042 } 1041 }
1043 1042
1044 void DelegatedFrameHost::LockResources() { 1043 void DelegatedFrameHost::LockResources() {
1045 DCHECK(frame_provider_.get() || !surface_id_.is_null()); 1044 DCHECK(frame_provider_.get() || !surface_id_.is_null());
1046 delegated_frame_evictor_->LockFrame(); 1045 delegated_frame_evictor_->LockFrame();
1047 } 1046 }
1048 1047
1049 void DelegatedFrameHost::RequestCopyOfOutput( 1048 void DelegatedFrameHost::RequestCopyOfOutput(
1050 scoped_ptr<cc::CopyOutputRequest> request) { 1049 scoped_ptr<cc::CopyOutputRequest> request) {
1051 if (!request_copy_of_output_callback_for_testing_.is_null()) 1050 if (!request_copy_of_output_callback_for_testing_.is_null())
1052 request_copy_of_output_callback_for_testing_.Run(request.Pass()); 1051 request_copy_of_output_callback_for_testing_.Run(std::move(request));
1053 else 1052 else
1054 client_->DelegatedFrameHostGetLayer()->RequestCopyOfOutput(request.Pass()); 1053 client_->DelegatedFrameHostGetLayer()->RequestCopyOfOutput(
1054 std::move(request));
1055 } 1055 }
1056 1056
1057 void DelegatedFrameHost::UnlockResources() { 1057 void DelegatedFrameHost::UnlockResources() {
1058 DCHECK(frame_provider_.get() || !surface_id_.is_null()); 1058 DCHECK(frame_provider_.get() || !surface_id_.is_null());
1059 delegated_frame_evictor_->UnlockFrame(); 1059 delegated_frame_evictor_->UnlockFrame();
1060 } 1060 }
1061 1061
1062 //////////////////////////////////////////////////////////////////////////////// 1062 ////////////////////////////////////////////////////////////////////////////////
1063 // DelegatedFrameHost, ui::LayerOwnerDelegate implementation: 1063 // DelegatedFrameHost, ui::LayerOwnerDelegate implementation:
1064 1064
(...skipping 11 matching lines...) Expand all
1076 cc::SurfaceManager* manager = factory->GetSurfaceManager(); 1076 cc::SurfaceManager* manager = factory->GetSurfaceManager();
1077 new_layer->SetShowSurface( 1077 new_layer->SetShowSurface(
1078 surface_id_, base::Bind(&SatisfyCallback, base::Unretained(manager)), 1078 surface_id_, base::Bind(&SatisfyCallback, base::Unretained(manager)),
1079 base::Bind(&RequireCallback, base::Unretained(manager)), 1079 base::Bind(&RequireCallback, base::Unretained(manager)),
1080 current_surface_size_, current_scale_factor_, 1080 current_surface_size_, current_scale_factor_,
1081 current_frame_size_in_dip_); 1081 current_frame_size_in_dip_);
1082 } 1082 }
1083 } 1083 }
1084 1084
1085 } // namespace content 1085 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698