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 <OpenGL/gl.h> | 8 #include <OpenGL/gl.h> |
9 #include <QuartzCore/QuartzCore.h> | 9 #include <QuartzCore/QuartzCore.h> |
10 | 10 |
(...skipping 1347 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1358 request_range_in_composition, | 1358 request_range_in_composition, |
1359 &ui_actual_range).ToCGRect()); | 1359 &ui_actual_range).ToCGRect()); |
1360 if (actual_range) { | 1360 if (actual_range) { |
1361 *actual_range = gfx::Range( | 1361 *actual_range = gfx::Range( |
1362 composition_range_.start() + ui_actual_range.start(), | 1362 composition_range_.start() + ui_actual_range.start(), |
1363 composition_range_.start() + ui_actual_range.end()).ToNSRange(); | 1363 composition_range_.start() + ui_actual_range.end()).ToNSRange(); |
1364 } | 1364 } |
1365 return true; | 1365 return true; |
1366 } | 1366 } |
1367 | 1367 |
1368 void RenderWidgetHostViewMac::AcceleratedSurfaceBuffersSwapped( | |
1369 const GpuHostMsg_AcceleratedSurfaceBuffersSwapped_Params& params, | |
1370 int gpu_host_id) { | |
1371 } | |
1372 | |
1373 void RenderWidgetHostViewMac::AcceleratedSurfacePostSubBuffer( | |
1374 const GpuHostMsg_AcceleratedSurfacePostSubBuffer_Params& params, | |
1375 int gpu_host_id) { | |
1376 } | |
1377 | |
1378 void RenderWidgetHostViewMac::AcceleratedSurfaceSuspend() { | |
1379 } | |
1380 | |
1381 void RenderWidgetHostViewMac::AcceleratedSurfaceRelease() { | |
1382 } | |
1383 | |
1384 bool RenderWidgetHostViewMac::HasAcceleratedSurface( | 1368 bool RenderWidgetHostViewMac::HasAcceleratedSurface( |
1385 const gfx::Size& desired_size) { | 1369 const gfx::Size& desired_size) { |
1386 if (browser_compositor_view_) | 1370 if (browser_compositor_view_) |
1387 return browser_compositor_view_->HasFrameOfSize(desired_size); | 1371 return browser_compositor_view_->HasFrameOfSize(desired_size); |
1388 return false; | 1372 return false; |
1389 } | 1373 } |
1390 | 1374 |
1391 void RenderWidgetHostViewMac::OnSwapCompositorFrame( | 1375 void RenderWidgetHostViewMac::OnSwapCompositorFrame( |
1392 uint32 output_surface_id, scoped_ptr<cc::CompositorFrame> frame) { | 1376 uint32 output_surface_id, scoped_ptr<cc::CompositorFrame> frame) { |
1393 TRACE_EVENT0("browser", "RenderWidgetHostViewMac::OnSwapCompositorFrame"); | 1377 TRACE_EVENT0("browser", "RenderWidgetHostViewMac::OnSwapCompositorFrame"); |
(...skipping 24 matching lines...) Expand all Loading... |
1418 frame->metadata.device_scale_factor, | 1402 frame->metadata.device_scale_factor, |
1419 frame->metadata.latency_info); | 1403 frame->metadata.latency_info); |
1420 } else { | 1404 } else { |
1421 DLOG(ERROR) << "Received unexpected frame type."; | 1405 DLOG(ERROR) << "Received unexpected frame type."; |
1422 RecordAction( | 1406 RecordAction( |
1423 base::UserMetricsAction("BadMessageTerminate_UnexpectedFrameType")); | 1407 base::UserMetricsAction("BadMessageTerminate_UnexpectedFrameType")); |
1424 render_widget_host_->GetProcess()->ReceivedBadMessage(); | 1408 render_widget_host_->GetProcess()->ReceivedBadMessage(); |
1425 } | 1409 } |
1426 } | 1410 } |
1427 | 1411 |
1428 void RenderWidgetHostViewMac::AcceleratedSurfaceInitialized(int host_id, | |
1429 int route_id) { | |
1430 } | |
1431 | |
1432 void RenderWidgetHostViewMac::GetScreenInfo(blink::WebScreenInfo* results) { | 1412 void RenderWidgetHostViewMac::GetScreenInfo(blink::WebScreenInfo* results) { |
1433 *results = GetWebScreenInfo(GetNativeView()); | 1413 *results = GetWebScreenInfo(GetNativeView()); |
1434 } | 1414 } |
1435 | 1415 |
1436 gfx::Rect RenderWidgetHostViewMac::GetBoundsInRootWindow() { | 1416 gfx::Rect RenderWidgetHostViewMac::GetBoundsInRootWindow() { |
1437 // TODO(shess): In case of !window, the view has been removed from | 1417 // TODO(shess): In case of !window, the view has been removed from |
1438 // the view hierarchy because the tab isn't main. Could retrieve | 1418 // the view hierarchy because the tab isn't main. Could retrieve |
1439 // the information from the main tab for our window. | 1419 // the information from the main tab for our window. |
1440 NSWindow* enclosing_window = ApparentWindowForView(cocoa_view_); | 1420 NSWindow* enclosing_window = ApparentWindowForView(cocoa_view_); |
1441 if (!enclosing_window) | 1421 if (!enclosing_window) |
1442 return gfx::Rect(); | 1422 return gfx::Rect(); |
1443 | 1423 |
1444 NSRect bounds = [enclosing_window frame]; | 1424 NSRect bounds = [enclosing_window frame]; |
1445 return FlipNSRectToRectScreen(bounds); | 1425 return FlipNSRectToRectScreen(bounds); |
1446 } | 1426 } |
1447 | 1427 |
1448 gfx::GLSurfaceHandle RenderWidgetHostViewMac::GetCompositingSurface() { | 1428 gfx::GLSurfaceHandle RenderWidgetHostViewMac::GetCompositingSurface() { |
1449 // TODO(kbr): may be able to eliminate PluginWindowHandle argument | 1429 // TODO(kbr): may be able to eliminate PluginWindowHandle argument |
1450 // completely on Mac OS. | 1430 // completely on Mac OS. |
1451 return gfx::GLSurfaceHandle(gfx::kNullPluginWindow, gfx::NATIVE_TRANSPORT); | 1431 return gfx::GLSurfaceHandle(gfx::kNullPluginWindow, gfx::NULL_TRANSPORT); |
1452 } | 1432 } |
1453 | 1433 |
1454 bool RenderWidgetHostViewMac::LockMouse() { | 1434 bool RenderWidgetHostViewMac::LockMouse() { |
1455 if (mouse_locked_) | 1435 if (mouse_locked_) |
1456 return true; | 1436 return true; |
1457 | 1437 |
1458 mouse_locked_ = true; | 1438 mouse_locked_ = true; |
1459 | 1439 |
1460 // Lock position of mouse cursor and hide it. | 1440 // Lock position of mouse cursor and hide it. |
1461 CGAssociateMouseAndMouseCursorPosition(NO); | 1441 CGAssociateMouseAndMouseCursorPosition(NO); |
(...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1685 [[NSNotificationCenter defaultCenter] | 1665 [[NSNotificationCenter defaultCenter] |
1686 addObserver:self | 1666 addObserver:self |
1687 selector:@selector(didChangeScreenParameters:) | 1667 selector:@selector(didChangeScreenParameters:) |
1688 name:NSApplicationDidChangeScreenParametersNotification | 1668 name:NSApplicationDidChangeScreenParametersNotification |
1689 object:nil]; | 1669 object:nil]; |
1690 } | 1670 } |
1691 return self; | 1671 return self; |
1692 } | 1672 } |
1693 | 1673 |
1694 - (void)dealloc { | 1674 - (void)dealloc { |
1695 // Unbind the GL context from this view. If this is not done before super's | |
1696 // dealloc is called then the GL context will crash when it reaches into | |
1697 // the view in its destructor. | |
1698 // http://crbug.com/255608 | |
1699 if (renderWidgetHostView_) | |
1700 renderWidgetHostView_->AcceleratedSurfaceRelease(); | |
1701 | |
1702 if (responderDelegate_ && | 1675 if (responderDelegate_ && |
1703 [responderDelegate_ respondsToSelector:@selector(viewGone:)]) | 1676 [responderDelegate_ respondsToSelector:@selector(viewGone:)]) |
1704 [responderDelegate_ viewGone:self]; | 1677 [responderDelegate_ viewGone:self]; |
1705 responderDelegate_.reset(); | 1678 responderDelegate_.reset(); |
1706 | 1679 |
1707 [[NSNotificationCenter defaultCenter] removeObserver:self]; | 1680 [[NSNotificationCenter defaultCenter] removeObserver:self]; |
1708 | 1681 |
1709 [super dealloc]; | 1682 [super dealloc]; |
1710 } | 1683 } |
1711 | 1684 |
(...skipping 1632 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3344 | 3317 |
3345 // "-webkit-app-region: drag | no-drag" is implemented on Mac by excluding | 3318 // "-webkit-app-region: drag | no-drag" is implemented on Mac by excluding |
3346 // regions that are not draggable. (See ControlRegionView in | 3319 // regions that are not draggable. (See ControlRegionView in |
3347 // native_app_window_cocoa.mm). This requires the render host view to be | 3320 // native_app_window_cocoa.mm). This requires the render host view to be |
3348 // draggable by default. | 3321 // draggable by default. |
3349 - (BOOL)mouseDownCanMoveWindow { | 3322 - (BOOL)mouseDownCanMoveWindow { |
3350 return YES; | 3323 return YES; |
3351 } | 3324 } |
3352 | 3325 |
3353 @end | 3326 @end |
OLD | NEW |