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 17 matching lines...) Expand all Loading... |
28 #include "base/sys_info.h" | 28 #include "base/sys_info.h" |
29 #import "content/browser/accessibility/browser_accessibility_cocoa.h" | 29 #import "content/browser/accessibility/browser_accessibility_cocoa.h" |
30 #include "content/browser/accessibility/browser_accessibility_manager_mac.h" | 30 #include "content/browser/accessibility/browser_accessibility_manager_mac.h" |
31 #import "content/browser/cocoa/system_hotkey_helper_mac.h" | 31 #import "content/browser/cocoa/system_hotkey_helper_mac.h" |
32 #import "content/browser/cocoa/system_hotkey_map.h" | 32 #import "content/browser/cocoa/system_hotkey_map.h" |
33 #include "content/browser/compositor/resize_lock.h" | 33 #include "content/browser/compositor/resize_lock.h" |
34 #include "content/browser/frame_host/frame_tree.h" | 34 #include "content/browser/frame_host/frame_tree.h" |
35 #include "content/browser/frame_host/frame_tree_node.h" | 35 #include "content/browser/frame_host/frame_tree_node.h" |
36 #include "content/browser/frame_host/render_frame_host_impl.h" | 36 #include "content/browser/frame_host/render_frame_host_impl.h" |
37 #include "content/browser/gpu/compositor_util.h" | 37 #include "content/browser/gpu/compositor_util.h" |
38 #include "content/browser/renderer_host/compositing_iosurface_context_mac.h" | |
39 #include "content/browser/renderer_host/compositing_iosurface_layer_mac.h" | |
40 #include "content/browser/renderer_host/compositing_iosurface_mac.h" | |
41 #include "content/browser/renderer_host/render_widget_helper.h" | 38 #include "content/browser/renderer_host/render_widget_helper.h" |
42 #include "content/browser/renderer_host/render_view_host_impl.h" | 39 #include "content/browser/renderer_host/render_view_host_impl.h" |
43 #import "content/browser/renderer_host/render_widget_host_view_mac_dictionary_he
lper.h" | 40 #import "content/browser/renderer_host/render_widget_host_view_mac_dictionary_he
lper.h" |
44 #import "content/browser/renderer_host/render_widget_host_view_mac_editcommand_h
elper.h" | 41 #import "content/browser/renderer_host/render_widget_host_view_mac_editcommand_h
elper.h" |
45 #import "content/browser/renderer_host/software_layer_mac.h" | |
46 #import "content/browser/renderer_host/text_input_client_mac.h" | 42 #import "content/browser/renderer_host/text_input_client_mac.h" |
47 #include "content/common/accessibility_messages.h" | 43 #include "content/common/accessibility_messages.h" |
48 #include "content/common/edit_command.h" | 44 #include "content/common/edit_command.h" |
49 #include "content/common/gpu/gpu_messages.h" | 45 #include "content/common/gpu/gpu_messages.h" |
50 #include "content/common/gpu/surface_handle_types_mac.h" | 46 #include "content/common/gpu/surface_handle_types_mac.h" |
51 #include "content/common/input_messages.h" | 47 #include "content/common/input_messages.h" |
52 #include "content/common/view_messages.h" | 48 #include "content/common/view_messages.h" |
53 #include "content/common/webplugin_geometry.h" | 49 #include "content/common/webplugin_geometry.h" |
54 #include "content/public/browser/browser_thread.h" | 50 #include "content/public/browser/browser_thread.h" |
55 #include "content/public/browser/native_web_keyboard_event.h" | 51 #include "content/public/browser/native_web_keyboard_event.h" |
(...skipping 395 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
451 | 447 |
452 DelegatedFrameHost* RenderWidgetHostViewMac::GetDelegatedFrameHost() const { | 448 DelegatedFrameHost* RenderWidgetHostViewMac::GetDelegatedFrameHost() const { |
453 return delegated_frame_host_.get(); | 449 return delegated_frame_host_.get(); |
454 } | 450 } |
455 | 451 |
456 //////////////////////////////////////////////////////////////////////////////// | 452 //////////////////////////////////////////////////////////////////////////////// |
457 // BrowserCompositorViewMacClient, public: | 453 // BrowserCompositorViewMacClient, public: |
458 | 454 |
459 bool RenderWidgetHostViewMac::BrowserCompositorViewShouldAckImmediately() | 455 bool RenderWidgetHostViewMac::BrowserCompositorViewShouldAckImmediately() |
460 const { | 456 const { |
461 // The logic for delegated and non-delegated rendering is the same. | 457 // If vsync is disabled, then always draw and ack frames immediately. |
462 return AcceleratedLayerShouldAckImmediately(); | 458 static bool is_vsync_disabled = |
| 459 base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 460 switches::kDisableGpuVsync); |
| 461 if (is_vsync_disabled) |
| 462 return true; |
| 463 |
| 464 // If the window is occluded, then this frame's display call may be severely |
| 465 // throttled. This is a good thing, unless tab capture may be active, because |
| 466 // the broadcast will be inappropriately throttled. |
| 467 // http://crbug.com/350410 |
| 468 |
| 469 // If tab capture isn't active then only ack frames when we draw them. |
| 470 if (delegated_frame_host_ && !delegated_frame_host_->HasFrameSubscriber()) |
| 471 return false; |
| 472 |
| 473 NSWindow* window = [cocoa_view_ window]; |
| 474 // If the view isn't even in the heirarchy then frames will never be drawn, |
| 475 // so ack them immediately. |
| 476 if (!window) |
| 477 return true; |
| 478 |
| 479 // Check the window occlusion API. |
| 480 if ([window respondsToSelector:@selector(occlusionState)]) { |
| 481 if ([window occlusionState] & NSWindowOcclusionStateVisible) { |
| 482 // If the window is visible then it is safe to wait until frames are |
| 483 // drawn to ack them. |
| 484 return false; |
| 485 } else { |
| 486 // If the window is occluded then frames may never be drawn, so ack them |
| 487 // immediately. |
| 488 return true; |
| 489 } |
| 490 } |
| 491 |
| 492 // If the window occlusion API is not present then ack frames when we draw |
| 493 // them. |
| 494 return false; |
463 } | 495 } |
464 | 496 |
465 void RenderWidgetHostViewMac::BrowserCompositorViewFrameSwapped( | 497 void RenderWidgetHostViewMac::BrowserCompositorViewFrameSwapped( |
466 const std::vector<ui::LatencyInfo>& all_latency_info) { | 498 const std::vector<ui::LatencyInfo>& all_latency_info) { |
467 if (!render_widget_host_) | 499 if (!render_widget_host_) |
468 return; | 500 return; |
469 for (auto latency_info : all_latency_info) { | 501 for (auto latency_info : all_latency_info) { |
470 latency_info.AddLatencyNumber( | 502 latency_info.AddLatencyNumber( |
471 ui::INPUT_EVENT_LATENCY_TERMINATED_FRAME_SWAP_COMPONENT, 0, 0); | 503 ui::INPUT_EVENT_LATENCY_TERMINATED_FRAME_SWAP_COMPONENT, 0, 0); |
472 render_widget_host_->FrameSwapped(latency_info); | 504 render_widget_host_->FrameSwapped(latency_info); |
(...skipping 1120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1593 render_widget_host_->PauseForPendingResizeOrRepaints(); | 1625 render_widget_host_->PauseForPendingResizeOrRepaints(); |
1594 if (browser_compositor_view_) | 1626 if (browser_compositor_view_) |
1595 browser_compositor_view_->EndPumpingFrames(); | 1627 browser_compositor_view_->EndPumpingFrames(); |
1596 } | 1628 } |
1597 | 1629 |
1598 SkColorType RenderWidgetHostViewMac::PreferredReadbackFormat() { | 1630 SkColorType RenderWidgetHostViewMac::PreferredReadbackFormat() { |
1599 return kN32_SkColorType; | 1631 return kN32_SkColorType; |
1600 } | 1632 } |
1601 | 1633 |
1602 //////////////////////////////////////////////////////////////////////////////// | 1634 //////////////////////////////////////////////////////////////////////////////// |
1603 // CompositingIOSurfaceLayerClient, public: | |
1604 | |
1605 bool RenderWidgetHostViewMac::AcceleratedLayerShouldAckImmediately() const { | |
1606 // If vsync is disabled, then always draw and ack frames immediately. | |
1607 static bool is_vsync_disabled = | |
1608 base::CommandLine::ForCurrentProcess()->HasSwitch( | |
1609 switches::kDisableGpuVsync); | |
1610 if (is_vsync_disabled) | |
1611 return true; | |
1612 | |
1613 // If the window is occluded, then this frame's display call may be severely | |
1614 // throttled. This is a good thing, unless tab capture may be active, because | |
1615 // the broadcast will be inappropriately throttled. | |
1616 // http://crbug.com/350410 | |
1617 | |
1618 // If tab capture isn't active then only ack frames when we draw them. | |
1619 if (delegated_frame_host_ && !delegated_frame_host_->HasFrameSubscriber()) | |
1620 return false; | |
1621 | |
1622 NSWindow* window = [cocoa_view_ window]; | |
1623 // If the view isn't even in the heirarchy then frames will never be drawn, | |
1624 // so ack them immediately. | |
1625 if (!window) | |
1626 return true; | |
1627 | |
1628 // Check the window occlusion API. | |
1629 if ([window respondsToSelector:@selector(occlusionState)]) { | |
1630 if ([window occlusionState] & NSWindowOcclusionStateVisible) { | |
1631 // If the window is visible then it is safe to wait until frames are | |
1632 // drawn to ack them. | |
1633 return false; | |
1634 } else { | |
1635 // If the window is occluded then frames may never be drawn, so ack them | |
1636 // immediately. | |
1637 return true; | |
1638 } | |
1639 } | |
1640 | |
1641 // If the window occlusion API is not present then ack frames when we draw | |
1642 // them. | |
1643 return false; | |
1644 } | |
1645 | |
1646 void RenderWidgetHostViewMac::AcceleratedLayerDidDrawFrame() { | |
1647 } | |
1648 | |
1649 void RenderWidgetHostViewMac::AcceleratedLayerHitError() { | |
1650 } | |
1651 | |
1652 //////////////////////////////////////////////////////////////////////////////// | |
1653 // gfx::DisplayObserver, public: | 1635 // gfx::DisplayObserver, public: |
1654 | 1636 |
1655 void RenderWidgetHostViewMac::OnDisplayAdded(const gfx::Display& display) { | 1637 void RenderWidgetHostViewMac::OnDisplayAdded(const gfx::Display& display) { |
1656 } | 1638 } |
1657 | 1639 |
1658 void RenderWidgetHostViewMac::OnDisplayRemoved(const gfx::Display& display) { | 1640 void RenderWidgetHostViewMac::OnDisplayRemoved(const gfx::Display& display) { |
1659 } | 1641 } |
1660 | 1642 |
1661 void RenderWidgetHostViewMac::OnDisplayMetricsChanged( | 1643 void RenderWidgetHostViewMac::OnDisplayMetricsChanged( |
1662 const gfx::Display& display, uint32_t metrics) { | 1644 const gfx::Display& display, uint32_t metrics) { |
(...skipping 1691 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3354 | 3336 |
3355 // "-webkit-app-region: drag | no-drag" is implemented on Mac by excluding | 3337 // "-webkit-app-region: drag | no-drag" is implemented on Mac by excluding |
3356 // regions that are not draggable. (See ControlRegionView in | 3338 // regions that are not draggable. (See ControlRegionView in |
3357 // native_app_window_cocoa.mm). This requires the render host view to be | 3339 // native_app_window_cocoa.mm). This requires the render host view to be |
3358 // draggable by default. | 3340 // draggable by default. |
3359 - (BOOL)mouseDownCanMoveWindow { | 3341 - (BOOL)mouseDownCanMoveWindow { |
3360 return YES; | 3342 return YES; |
3361 } | 3343 } |
3362 | 3344 |
3363 @end | 3345 @end |
OLD | NEW |