OLD | NEW |
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 <objc/runtime.h> | 7 #import <objc/runtime.h> |
8 #include <QuartzCore/QuartzCore.h> | 8 #include <QuartzCore/QuartzCore.h> |
9 | 9 |
| 10 #include "base/basictypes.h" |
10 #include "base/bind.h" | 11 #include "base/bind.h" |
11 #include "base/bind_helpers.h" | 12 #include "base/callback_helpers.h" |
12 #include "base/command_line.h" | 13 #include "base/command_line.h" |
13 #include "base/debug/crash_logging.h" | 14 #include "base/debug/crash_logging.h" |
14 #include "base/debug/trace_event.h" | 15 #include "base/debug/trace_event.h" |
15 #include "base/logging.h" | 16 #include "base/logging.h" |
16 #include "base/mac/mac_util.h" | 17 #include "base/mac/mac_util.h" |
17 #include "base/mac/scoped_cftyperef.h" | 18 #include "base/mac/scoped_cftyperef.h" |
18 #import "base/mac/scoped_nsobject.h" | 19 #import "base/mac/scoped_nsobject.h" |
19 #include "base/mac/sdk_forward_declarations.h" | 20 #include "base/mac/sdk_forward_declarations.h" |
20 #include "base/message_loop/message_loop.h" | 21 #include "base/message_loop/message_loop.h" |
21 #include "base/metrics/histogram.h" | 22 #include "base/metrics/histogram.h" |
(...skipping 1132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1154 base::ScopedClosureRunner scoped_callback_runner( | 1155 base::ScopedClosureRunner scoped_callback_runner( |
1155 base::Bind(callback, false, SkBitmap())); | 1156 base::Bind(callback, false, SkBitmap())); |
1156 if (!compositing_iosurface_ || | 1157 if (!compositing_iosurface_ || |
1157 !compositing_iosurface_->HasIOSurface()) | 1158 !compositing_iosurface_->HasIOSurface()) |
1158 return; | 1159 return; |
1159 | 1160 |
1160 float scale = ScaleFactor(cocoa_view_); | 1161 float scale = ScaleFactor(cocoa_view_); |
1161 gfx::Size dst_pixel_size = gfx::ToFlooredSize( | 1162 gfx::Size dst_pixel_size = gfx::ToFlooredSize( |
1162 gfx::ScaleSize(dst_size, scale)); | 1163 gfx::ScaleSize(dst_size, scale)); |
1163 | 1164 |
1164 scoped_callback_runner.Release(); | 1165 ignore_result(scoped_callback_runner.Release()); |
1165 | 1166 |
1166 compositing_iosurface_->CopyTo(GetScaledOpenGLPixelRect(src_subrect), | 1167 compositing_iosurface_->CopyTo(GetScaledOpenGLPixelRect(src_subrect), |
1167 dst_pixel_size, | 1168 dst_pixel_size, |
1168 callback); | 1169 callback); |
1169 } | 1170 } |
1170 | 1171 |
1171 void RenderWidgetHostViewMac::CopyFromCompositingSurfaceToVideoFrame( | 1172 void RenderWidgetHostViewMac::CopyFromCompositingSurfaceToVideoFrame( |
1172 const gfx::Rect& src_subrect, | 1173 const gfx::Rect& src_subrect, |
1173 const scoped_refptr<media::VideoFrame>& target, | 1174 const scoped_refptr<media::VideoFrame>& target, |
1174 const base::Callback<void(bool)>& callback) { | 1175 const base::Callback<void(bool)>& callback) { |
(...skipping 10 matching lines...) Expand all Loading... |
1185 | 1186 |
1186 if (target->format() != media::VideoFrame::YV12 && | 1187 if (target->format() != media::VideoFrame::YV12 && |
1187 target->format() != media::VideoFrame::I420) { | 1188 target->format() != media::VideoFrame::I420) { |
1188 NOTREACHED(); | 1189 NOTREACHED(); |
1189 return; | 1190 return; |
1190 } | 1191 } |
1191 | 1192 |
1192 if (src_subrect.IsEmpty()) | 1193 if (src_subrect.IsEmpty()) |
1193 return; | 1194 return; |
1194 | 1195 |
1195 scoped_callback_runner.Release(); | 1196 ignore_result(scoped_callback_runner.Release()); |
1196 compositing_iosurface_->CopyToVideoFrame( | 1197 compositing_iosurface_->CopyToVideoFrame( |
1197 GetScaledOpenGLPixelRect(src_subrect), | 1198 GetScaledOpenGLPixelRect(src_subrect), |
1198 target, | 1199 target, |
1199 callback); | 1200 callback); |
1200 } | 1201 } |
1201 | 1202 |
1202 bool RenderWidgetHostViewMac::CanCopyToVideoFrame() const { | 1203 bool RenderWidgetHostViewMac::CanCopyToVideoFrame() const { |
1203 return (!render_widget_host_->GetBackingStore(false) && | 1204 return (!render_widget_host_->GetBackingStore(false) && |
1204 render_widget_host_->is_accelerated_compositing_active() && | 1205 render_widget_host_->is_accelerated_compositing_active() && |
1205 compositing_iosurface_ && | 1206 compositing_iosurface_ && |
(...skipping 2639 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3845 return YES; | 3846 return YES; |
3846 } | 3847 } |
3847 | 3848 |
3848 - (BOOL)isOpaque { | 3849 - (BOOL)isOpaque { |
3849 if (renderWidgetHostView_->use_core_animation_) | 3850 if (renderWidgetHostView_->use_core_animation_) |
3850 return YES; | 3851 return YES; |
3851 return [super isOpaque]; | 3852 return [super isOpaque]; |
3852 } | 3853 } |
3853 | 3854 |
3854 @end | 3855 @end |
OLD | NEW |