Chromium Code Reviews| 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/basictypes.h" |
| (...skipping 1192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1203 src_pixel_rect.width(), src_pixel_rect.height()); | 1203 src_pixel_rect.width(), src_pixel_rect.height()); |
| 1204 target_canvas.drawBitmapRectToRect( | 1204 target_canvas.drawBitmapRectToRect( |
| 1205 source_bitmap, | 1205 source_bitmap, |
| 1206 &src_pixel_skrect, | 1206 &src_pixel_skrect, |
| 1207 SkRect::MakeXYWH(0, 0, dst_pixel_size.width(), dst_pixel_size.height()), | 1207 SkRect::MakeXYWH(0, 0, dst_pixel_size.width(), dst_pixel_size.height()), |
| 1208 NULL, | 1208 NULL, |
| 1209 SkCanvas::kNone_DrawBitmapRectFlag); | 1209 SkCanvas::kNone_DrawBitmapRectFlag); |
| 1210 | 1210 |
| 1211 ignore_result(scoped_callback_runner.Release()); | 1211 ignore_result(scoped_callback_runner.Release()); |
| 1212 callback.Run(true, target_bitmap); | 1212 callback.Run(true, target_bitmap); |
| 1213 } else { | |
| 1214 callback.Run(false, SkBitmap()); | |
|
danakj
2014/05/12 17:37:58
should we NOTREACHED? or is this a valid case
piman
2014/05/13 20:25:40
Won't we get here if we CopyFromCompositingSurface
danakj
2014/05/13 21:23:43
Only if you didn't check IsSurfaceAvailableForCopy
| |
| 1213 } | 1215 } |
| 1214 } | 1216 } |
| 1215 | 1217 |
| 1216 void RenderWidgetHostViewMac::CopyFromCompositingSurfaceToVideoFrame( | 1218 void RenderWidgetHostViewMac::CopyFromCompositingSurfaceToVideoFrame( |
| 1217 const gfx::Rect& src_subrect, | 1219 const gfx::Rect& src_subrect, |
| 1218 const scoped_refptr<media::VideoFrame>& target, | 1220 const scoped_refptr<media::VideoFrame>& target, |
| 1219 const base::Callback<void(bool)>& callback) { | 1221 const base::Callback<void(bool)>& callback) { |
| 1220 base::ScopedClosureRunner scoped_callback_runner(base::Bind(callback, false)); | 1222 base::ScopedClosureRunner scoped_callback_runner(base::Bind(callback, false)); |
| 1221 if (!render_widget_host_->is_accelerated_compositing_active() || | 1223 if (!compositing_iosurface_ || |
| 1222 !compositing_iosurface_ || | |
| 1223 !compositing_iosurface_->HasIOSurface()) | 1224 !compositing_iosurface_->HasIOSurface()) |
| 1224 return; | 1225 return; |
| 1225 | 1226 |
| 1226 if (!target.get()) { | 1227 if (!target.get()) { |
| 1227 NOTREACHED(); | 1228 NOTREACHED(); |
| 1228 return; | 1229 return; |
| 1229 } | 1230 } |
| 1230 | 1231 |
| 1231 if (target->format() != media::VideoFrame::YV12 && | 1232 if (target->format() != media::VideoFrame::YV12 && |
| 1232 target->format() != media::VideoFrame::I420) { | 1233 target->format() != media::VideoFrame::I420) { |
| 1233 NOTREACHED(); | 1234 NOTREACHED(); |
| 1234 return; | 1235 return; |
| 1235 } | 1236 } |
| 1236 | 1237 |
| 1237 if (src_subrect.IsEmpty()) | 1238 if (src_subrect.IsEmpty()) |
| 1238 return; | 1239 return; |
| 1239 | 1240 |
| 1240 ignore_result(scoped_callback_runner.Release()); | 1241 ignore_result(scoped_callback_runner.Release()); |
| 1241 compositing_iosurface_->CopyToVideoFrame( | 1242 compositing_iosurface_->CopyToVideoFrame( |
| 1242 GetScaledOpenGLPixelRect(src_subrect), | 1243 GetScaledOpenGLPixelRect(src_subrect), |
| 1243 target, | 1244 target, |
| 1244 callback); | 1245 callback); |
| 1245 } | 1246 } |
| 1246 | 1247 |
| 1247 bool RenderWidgetHostViewMac::CanCopyToVideoFrame() const { | 1248 bool RenderWidgetHostViewMac::CanCopyToVideoFrame() const { |
| 1248 return (!software_frame_manager_->HasCurrentFrame() && | 1249 return (!software_frame_manager_->HasCurrentFrame() && |
| 1249 render_widget_host_->is_accelerated_compositing_active() && | |
| 1250 compositing_iosurface_ && | 1250 compositing_iosurface_ && |
| 1251 compositing_iosurface_->HasIOSurface()); | 1251 compositing_iosurface_->HasIOSurface()); |
| 1252 } | 1252 } |
| 1253 | 1253 |
| 1254 bool RenderWidgetHostViewMac::CanSubscribeFrame() const { | 1254 bool RenderWidgetHostViewMac::CanSubscribeFrame() const { |
| 1255 return !software_frame_manager_->HasCurrentFrame(); | 1255 return !software_frame_manager_->HasCurrentFrame(); |
| 1256 } | 1256 } |
| 1257 | 1257 |
| 1258 void RenderWidgetHostViewMac::BeginFrameSubscription( | 1258 void RenderWidgetHostViewMac::BeginFrameSubscription( |
| 1259 scoped_ptr<RenderWidgetHostViewFrameSubscriber> subscriber) { | 1259 scoped_ptr<RenderWidgetHostViewFrameSubscriber> subscriber) { |
| (...skipping 550 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1810 !render_widget_host_->is_hidden()); | 1810 !render_widget_host_->is_hidden()); |
| 1811 | 1811 |
| 1812 // Notify observers, tab capture observers in particular, that a new software | 1812 // Notify observers, tab capture observers in particular, that a new software |
| 1813 // frame has come in. | 1813 // frame has come in. |
| 1814 NotificationService::current()->Notify( | 1814 NotificationService::current()->Notify( |
| 1815 NOTIFICATION_RENDER_WIDGET_HOST_DID_UPDATE_BACKING_STORE, | 1815 NOTIFICATION_RENDER_WIDGET_HOST_DID_UPDATE_BACKING_STORE, |
| 1816 Source<RenderWidgetHost>(render_widget_host_), | 1816 Source<RenderWidgetHost>(render_widget_host_), |
| 1817 NotificationService::NoDetails()); | 1817 NotificationService::NoDetails()); |
| 1818 } | 1818 } |
| 1819 | 1819 |
| 1820 void RenderWidgetHostViewMac::OnAcceleratedCompositingStateChange() { | |
| 1821 } | |
| 1822 | |
| 1823 void RenderWidgetHostViewMac::AcceleratedSurfaceInitialized(int host_id, | 1820 void RenderWidgetHostViewMac::AcceleratedSurfaceInitialized(int host_id, |
| 1824 int route_id) { | 1821 int route_id) { |
| 1825 } | 1822 } |
| 1826 | 1823 |
| 1827 void RenderWidgetHostViewMac::GetScreenInfo(blink::WebScreenInfo* results) { | 1824 void RenderWidgetHostViewMac::GetScreenInfo(blink::WebScreenInfo* results) { |
| 1828 *results = GetWebScreenInfo(GetNativeView()); | 1825 *results = GetWebScreenInfo(GetNativeView()); |
| 1829 } | 1826 } |
| 1830 | 1827 |
| 1831 gfx::Rect RenderWidgetHostViewMac::GetBoundsInRootWindow() { | 1828 gfx::Rect RenderWidgetHostViewMac::GetBoundsInRootWindow() { |
| 1832 // TODO(shess): In case of !window, the view has been removed from | 1829 // TODO(shess): In case of !window, the view has been removed from |
| (...skipping 2446 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 4279 } | 4276 } |
| 4280 | 4277 |
| 4281 - (void)disableRendering { | 4278 - (void)disableRendering { |
| 4282 // Disable the fade-out animation as the layer is removed. | 4279 // Disable the fade-out animation as the layer is removed. |
| 4283 ScopedCAActionDisabler disabler; | 4280 ScopedCAActionDisabler disabler; |
| 4284 [self removeFromSuperlayer]; | 4281 [self removeFromSuperlayer]; |
| 4285 renderWidgetHostView_ = nil; | 4282 renderWidgetHostView_ = nil; |
| 4286 } | 4283 } |
| 4287 | 4284 |
| 4288 @end // implementation SoftwareLayer | 4285 @end // implementation SoftwareLayer |
| OLD | NEW |