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

Side by Side Diff: content/browser/renderer_host/browser_compositor_view_mac.mm

Issue 2702093002: Consistent CopyFromSurface() API, consolidated to RWHV (Closed)
Patch Set: REBASE Created 3 years, 9 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/renderer_host/browser_compositor_view_mac.h" 5 #include "content/browser/renderer_host/browser_compositor_view_mac.h"
6 6
7 #include <stdint.h> 7 #include <stdint.h>
8 8
9 #include <utility> 9 #include <utility>
10 10
11 #include "base/lazy_instance.h" 11 #include "base/lazy_instance.h"
12 #include "base/trace_event/trace_event.h" 12 #include "base/trace_event/trace_event.h"
13 #include "content/browser/compositor/image_transport_factory.h" 13 #include "content/browser/compositor/image_transport_factory.h"
14 #include "content/browser/renderer_host/resize_lock.h" 14 #include "content/browser/renderer_host/resize_lock.h"
15 #include "content/public/browser/browser_thread.h" 15 #include "content/public/browser/browser_thread.h"
16 #include "content/public/browser/context_factory.h" 16 #include "content/public/browser/context_factory.h"
17 #include "media/base/video_frame.h"
17 #include "ui/accelerated_widget_mac/accelerated_widget_mac.h" 18 #include "ui/accelerated_widget_mac/accelerated_widget_mac.h"
18 #include "ui/accelerated_widget_mac/window_resize_helper_mac.h" 19 #include "ui/accelerated_widget_mac/window_resize_helper_mac.h"
19 #include "ui/base/layout.h" 20 #include "ui/base/layout.h"
20 #include "ui/gfx/geometry/dip_util.h" 21 #include "ui/gfx/geometry/dip_util.h"
21 22
22 namespace content { 23 namespace content {
23 24
24 namespace { 25 namespace {
25 26
26 // Set when no browser compositors should remain alive. 27 // Set when no browser compositors should remain alive.
(...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after
246 bool result) { 247 bool result) {
247 callback.Run(rect, result); 248 callback.Run(rect, result);
248 if (browser_compositor) { 249 if (browser_compositor) {
249 browser_compositor->outstanding_copy_count_ -= 1; 250 browser_compositor->outstanding_copy_count_ -= 1;
250 browser_compositor->UpdateState(); 251 browser_compositor->UpdateState();
251 } 252 }
252 } 253 }
253 254
254 void BrowserCompositorMac::CopyFromCompositingSurfaceToVideoFrame( 255 void BrowserCompositorMac::CopyFromCompositingSurfaceToVideoFrame(
255 const gfx::Rect& src_subrect, 256 const gfx::Rect& src_subrect,
256 const scoped_refptr<media::VideoFrame>& target, 257 scoped_refptr<media::VideoFrame> target,
257 const base::Callback<void(const gfx::Rect&, bool)>& callback) { 258 const base::Callback<void(const gfx::Rect&, bool)>& callback) {
258 DCHECK(delegated_frame_host_); 259 DCHECK(delegated_frame_host_);
259 DCHECK(state_ == HasAttachedCompositor); 260 DCHECK(state_ == HasAttachedCompositor);
260 outstanding_copy_count_ += 1; 261 outstanding_copy_count_ += 1;
261 262
262 auto callback_with_decrement = 263 auto callback_with_decrement =
263 base::Bind(&BrowserCompositorMac::CopyToVideoFrameCompleted, 264 base::Bind(&BrowserCompositorMac::CopyToVideoFrameCompleted,
264 weak_factory_.GetWeakPtr(), callback); 265 weak_factory_.GetWeakPtr(), callback);
265 266
266 delegated_frame_host_->CopyFromCompositingSurfaceToVideoFrame( 267 delegated_frame_host_->CopyFromCompositingSurfaceToVideoFrame(
267 src_subrect, target, callback_with_decrement); 268 src_subrect, std::move(target), callback_with_decrement);
268 } 269 }
269 270
270 void BrowserCompositorMac::SwapCompositorFrame( 271 void BrowserCompositorMac::SwapCompositorFrame(
271 uint32_t compositor_frame_sink_id, 272 uint32_t compositor_frame_sink_id,
272 cc::CompositorFrame frame) { 273 cc::CompositorFrame frame) {
273 // Compute the frame size based on the root render pass rect size. 274 // Compute the frame size based on the root render pass rect size.
274 cc::RenderPass* root_pass = frame.render_pass_list.back().get(); 275 cc::RenderPass* root_pass = frame.render_pass_list.back().get();
275 float scale_factor = frame.metadata.device_scale_factor; 276 float scale_factor = frame.metadata.device_scale_factor;
276 gfx::Size pixel_size = root_pass->output_rect.size(); 277 gfx::Size pixel_size = root_pass->output_rect.size();
277 gfx::Size dip_size = gfx::ConvertSizeToDIP(scale_factor, pixel_size); 278 gfx::Size dip_size = gfx::ConvertSizeToDIP(scale_factor, pixel_size);
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after
467 468
468 const cc::BeginFrameArgs& BrowserCompositorMac::LastUsedBeginFrameArgs() const { 469 const cc::BeginFrameArgs& BrowserCompositorMac::LastUsedBeginFrameArgs() const {
469 return last_begin_frame_args_; 470 return last_begin_frame_args_;
470 } 471 }
471 472
472 void BrowserCompositorMac::OnBeginFrameSourcePausedChanged(bool paused) { 473 void BrowserCompositorMac::OnBeginFrameSourcePausedChanged(bool paused) {
473 // Only used on Android WebView. 474 // Only used on Android WebView.
474 } 475 }
475 476
476 } // namespace content 477 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/renderer_host/browser_compositor_view_mac.h ('k') | content/browser/renderer_host/delegated_frame_host.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698