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

Side by Side Diff: content/browser/renderer_host/render_widget_host_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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/render_widget_host_view_mac.h" 5 #include "content/browser/renderer_host/render_widget_host_view_mac.h"
6 6
7 #import <Carbon/Carbon.h> 7 #import <Carbon/Carbon.h>
8 #import <objc/runtime.h> 8 #import <objc/runtime.h>
9 #include <OpenGL/gl.h> 9 #include <OpenGL/gl.h>
10 #include <QuartzCore/QuartzCore.h> 10 #include <QuartzCore/QuartzCore.h>
11 #include <stdint.h> 11 #include <stdint.h>
12 12
13 #include <limits> 13 #include <limits>
14 #include <utility> 14 #include <utility>
15 15
16 #include "base/bind.h" 16 #include "base/bind.h"
17 #include "base/callback_helpers.h" 17 #include "base/callback_helpers.h"
18 #include "base/command_line.h" 18 #include "base/command_line.h"
19 #include "base/debug/crash_logging.h" 19 #include "base/debug/crash_logging.h"
20 #include "base/logging.h" 20 #include "base/logging.h"
21 #include "base/mac/scoped_cftyperef.h" 21 #include "base/mac/scoped_cftyperef.h"
22 #import "base/mac/scoped_nsobject.h"
22 #include "base/mac/sdk_forward_declarations.h" 23 #include "base/mac/sdk_forward_declarations.h"
23 #include "base/macros.h" 24 #include "base/macros.h"
24 #import "base/mac/scoped_nsobject.h"
25 #include "base/memory/ref_counted.h" 25 #include "base/memory/ref_counted.h"
26 #include "base/metrics/histogram_macros.h" 26 #include "base/metrics/histogram_macros.h"
27 #include "base/numerics/safe_conversions.h" 27 #include "base/numerics/safe_conversions.h"
28 #include "base/strings/string_util.h" 28 #include "base/strings/string_util.h"
29 #include "base/strings/stringprintf.h" 29 #include "base/strings/stringprintf.h"
30 #include "base/strings/sys_string_conversions.h" 30 #include "base/strings/sys_string_conversions.h"
31 #include "base/strings/utf_string_conversions.h" 31 #include "base/strings/utf_string_conversions.h"
32 #include "base/sys_info.h" 32 #include "base/sys_info.h"
33 #include "base/threading/thread_task_runner_handle.h" 33 #include "base/threading/thread_task_runner_handle.h"
34 #include "base/trace_event/trace_event.h" 34 #include "base/trace_event/trace_event.h"
(...skipping 23 matching lines...) Expand all
58 #include "content/common/text_input_state.h" 58 #include "content/common/text_input_state.h"
59 #include "content/common/view_messages.h" 59 #include "content/common/view_messages.h"
60 #include "content/public/browser/browser_context.h" 60 #include "content/public/browser/browser_context.h"
61 #include "content/public/browser/browser_plugin_guest_manager.h" 61 #include "content/public/browser/browser_plugin_guest_manager.h"
62 #include "content/public/browser/browser_thread.h" 62 #include "content/public/browser/browser_thread.h"
63 #include "content/public/browser/native_web_keyboard_event.h" 63 #include "content/public/browser/native_web_keyboard_event.h"
64 #include "content/public/browser/render_widget_host.h" 64 #include "content/public/browser/render_widget_host.h"
65 #import "content/public/browser/render_widget_host_view_mac_delegate.h" 65 #import "content/public/browser/render_widget_host_view_mac_delegate.h"
66 #include "content/public/browser/web_contents.h" 66 #include "content/public/browser/web_contents.h"
67 #include "gpu/ipc/common/gpu_messages.h" 67 #include "gpu/ipc/common/gpu_messages.h"
68 #include "media/base/video_frame.h"
68 #include "skia/ext/platform_canvas.h" 69 #include "skia/ext/platform_canvas.h"
69 #include "skia/ext/skia_utils_mac.h" 70 #include "skia/ext/skia_utils_mac.h"
70 #include "third_party/WebKit/public/platform/WebInputEvent.h" 71 #include "third_party/WebKit/public/platform/WebInputEvent.h"
71 #import "ui/base/clipboard/clipboard_util_mac.h" 72 #import "ui/base/clipboard/clipboard_util_mac.h"
72 #include "ui/base/cocoa/animation_utils.h" 73 #include "ui/base/cocoa/animation_utils.h"
73 #import "ui/base/cocoa/appkit_utils.h" 74 #import "ui/base/cocoa/appkit_utils.h"
74 #include "ui/base/cocoa/cocoa_base_utils.h" 75 #include "ui/base/cocoa/cocoa_base_utils.h"
75 #import "ui/base/cocoa/fullscreen_window_manager.h" 76 #import "ui/base/cocoa/fullscreen_window_manager.h"
76 #import "ui/base/cocoa/underlay_opengl_hosting_window.h" 77 #import "ui/base/cocoa/underlay_opengl_hosting_window.h"
77 #include "ui/base/layout.h" 78 #include "ui/base/layout.h"
(...skipping 776 matching lines...) Expand 10 before | Expand all | Expand 10 after
854 855
855 void RenderWidgetHostViewMac::Focus() { 856 void RenderWidgetHostViewMac::Focus() {
856 [[cocoa_view_ window] makeFirstResponder:cocoa_view_]; 857 [[cocoa_view_ window] makeFirstResponder:cocoa_view_];
857 } 858 }
858 859
859 bool RenderWidgetHostViewMac::HasFocus() const { 860 bool RenderWidgetHostViewMac::HasFocus() const {
860 return [[cocoa_view_ window] firstResponder] == cocoa_view_; 861 return [[cocoa_view_ window] firstResponder] == cocoa_view_;
861 } 862 }
862 863
863 bool RenderWidgetHostViewMac::IsSurfaceAvailableForCopy() const { 864 bool RenderWidgetHostViewMac::IsSurfaceAvailableForCopy() const {
864 return browser_compositor_->GetDelegatedFrameHost()->CanCopyToBitmap(); 865 return browser_compositor_->GetDelegatedFrameHost()
866 ->CanCopyFromCompositingSurface();
865 } 867 }
866 868
867 bool RenderWidgetHostViewMac::IsShowing() { 869 bool RenderWidgetHostViewMac::IsShowing() {
868 return ![cocoa_view_ isHidden]; 870 return ![cocoa_view_ isHidden];
869 } 871 }
870 872
871 gfx::Rect RenderWidgetHostViewMac::GetViewBounds() const { 873 gfx::Rect RenderWidgetHostViewMac::GetViewBounds() const {
872 NSRect bounds = [cocoa_view_ bounds]; 874 NSRect bounds = [cocoa_view_ bounds];
873 // TODO(shess): In case of !window, the view has been removed from 875 // TODO(shess): In case of !window, the view has been removed from
874 // the view hierarchy because the tab isn't main. Could retrieve 876 // the view hierarchy because the tab isn't main. Could retrieve
(...skipping 292 matching lines...) Expand 10 before | Expand all | Expand 10 after
1167 WebMouseEvent web_event = WebMouseEventBuilder::Build(event, cocoa_view_); 1169 WebMouseEvent web_event = WebMouseEventBuilder::Build(event, cocoa_view_);
1168 if (showing) 1170 if (showing)
1169 web_event.setType(WebInputEvent::MouseLeave); 1171 web_event.setType(WebInputEvent::MouseLeave);
1170 ForwardMouseEvent(web_event); 1172 ForwardMouseEvent(web_event);
1171 } 1173 }
1172 1174
1173 bool RenderWidgetHostViewMac::IsPopup() const { 1175 bool RenderWidgetHostViewMac::IsPopup() const {
1174 return popup_type_ != blink::WebPopupTypeNone; 1176 return popup_type_ != blink::WebPopupTypeNone;
1175 } 1177 }
1176 1178
1177 void RenderWidgetHostViewMac::CopyFromCompositingSurface( 1179 void RenderWidgetHostViewMac::CopyFromSurface(
1178 const gfx::Rect& src_subrect, 1180 const gfx::Rect& src_subrect,
1179 const gfx::Size& dst_size, 1181 const gfx::Size& dst_size,
1180 const ReadbackRequestCallback& callback, 1182 const ReadbackRequestCallback& callback,
1181 const SkColorType preferred_color_type) { 1183 const SkColorType preferred_color_type) {
1182 browser_compositor_->CopyFromCompositingSurface( 1184 browser_compositor_->CopyFromCompositingSurface(
1183 src_subrect, dst_size, callback, preferred_color_type); 1185 src_subrect, dst_size, callback, preferred_color_type);
1184 } 1186 }
1185 1187
1186 void RenderWidgetHostViewMac::CopyFromCompositingSurfaceToVideoFrame( 1188 void RenderWidgetHostViewMac::CopyFromSurfaceToVideoFrame(
1187 const gfx::Rect& src_subrect, 1189 const gfx::Rect& src_subrect,
1188 const scoped_refptr<media::VideoFrame>& target, 1190 scoped_refptr<media::VideoFrame> target,
1189 const base::Callback<void(const gfx::Rect&, bool)>& callback) { 1191 const base::Callback<void(const gfx::Rect&, bool)>& callback) {
1190 browser_compositor_->CopyFromCompositingSurfaceToVideoFrame(src_subrect, 1192 browser_compositor_->CopyFromCompositingSurfaceToVideoFrame(
1191 target, callback); 1193 src_subrect, std::move(target), callback);
1192 }
1193
1194 bool RenderWidgetHostViewMac::CanCopyToVideoFrame() const {
1195 return browser_compositor_->GetDelegatedFrameHost()->CanCopyToVideoFrame();
1196 } 1194 }
1197 1195
1198 void RenderWidgetHostViewMac::BeginFrameSubscription( 1196 void RenderWidgetHostViewMac::BeginFrameSubscription(
1199 std::unique_ptr<RenderWidgetHostViewFrameSubscriber> subscriber) { 1197 std::unique_ptr<RenderWidgetHostViewFrameSubscriber> subscriber) {
1200 browser_compositor_->GetDelegatedFrameHost()->BeginFrameSubscription( 1198 browser_compositor_->GetDelegatedFrameHost()->BeginFrameSubscription(
1201 std::move(subscriber)); 1199 std::move(subscriber));
1202 } 1200 }
1203 1201
1204 void RenderWidgetHostViewMac::EndFrameSubscription() { 1202 void RenderWidgetHostViewMac::EndFrameSubscription() {
1205 browser_compositor_->GetDelegatedFrameHost()->EndFrameSubscription(); 1203 browser_compositor_->GetDelegatedFrameHost()->EndFrameSubscription();
(...skipping 2255 matching lines...) Expand 10 before | Expand all | Expand 10 after
3461 3459
3462 // "-webkit-app-region: drag | no-drag" is implemented on Mac by excluding 3460 // "-webkit-app-region: drag | no-drag" is implemented on Mac by excluding
3463 // regions that are not draggable. (See ControlRegionView in 3461 // regions that are not draggable. (See ControlRegionView in
3464 // native_app_window_cocoa.mm). This requires the render host view to be 3462 // native_app_window_cocoa.mm). This requires the render host view to be
3465 // draggable by default. 3463 // draggable by default.
3466 - (BOOL)mouseDownCanMoveWindow { 3464 - (BOOL)mouseDownCanMoveWindow {
3467 return YES; 3465 return YES;
3468 } 3466 }
3469 3467
3470 @end 3468 @end
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698