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 463 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
474 render_widget_host_->UpdateVSyncParameters(timebase, interval); | 474 render_widget_host_->UpdateVSyncParameters(timebase, interval); |
475 } | 475 } |
476 | 476 |
477 //////////////////////////////////////////////////////////////////////////////// | 477 //////////////////////////////////////////////////////////////////////////////// |
478 // AcceleratedWidgetMacNSView, public: | 478 // AcceleratedWidgetMacNSView, public: |
479 | 479 |
480 NSView* RenderWidgetHostViewMac::AcceleratedWidgetGetNSView() const { | 480 NSView* RenderWidgetHostViewMac::AcceleratedWidgetGetNSView() const { |
481 return cocoa_view_; | 481 return cocoa_view_; |
482 } | 482 } |
483 | 483 |
484 bool RenderWidgetHostViewMac::AcceleratedWidgetShouldIgnoreBackpressure() | |
485 const { | |
486 // If vsync is disabled, then always draw and ack frames immediately. | |
487 static bool is_vsync_disabled = | |
488 base::CommandLine::ForCurrentProcess()->HasSwitch( | |
489 switches::kDisableGpuVsync); | |
490 if (is_vsync_disabled) | |
491 return true; | |
492 | |
493 // If the window is occluded, then this frame's display call may be severely | |
494 // throttled. This is a good thing, unless tab capture may be active, because | |
495 // the broadcast will be inappropriately throttled. | |
496 // http://crbug.com/350410 | |
497 | |
498 // If tab capture isn't active then only ack frames when we draw them. | |
499 if (delegated_frame_host_ && !delegated_frame_host_->HasFrameSubscriber()) | |
500 return false; | |
501 | |
502 NSWindow* window = [cocoa_view_ window]; | |
503 // If the view isn't even in the heirarchy then frames will never be drawn, | |
504 // so ack them immediately. | |
505 if (!window) | |
506 return true; | |
507 | |
508 // Check the window occlusion API. | |
509 if ([window respondsToSelector:@selector(occlusionState)]) { | |
510 if ([window occlusionState] & NSWindowOcclusionStateVisible) { | |
511 // If the window is visible then it is safe to wait until frames are | |
512 // drawn to ack them. | |
513 return false; | |
514 } else { | |
515 // If the window is occluded then frames may never be drawn, so ack them | |
516 // immediately. | |
517 return true; | |
518 } | |
519 } | |
520 | |
521 // If the window occlusion API is not present then ack frames when we draw | |
522 // them. | |
523 return false; | |
524 } | |
525 | |
526 void RenderWidgetHostViewMac::AcceleratedWidgetGetVSyncParameters( | 484 void RenderWidgetHostViewMac::AcceleratedWidgetGetVSyncParameters( |
527 base::TimeTicks* timebase, base::TimeDelta* interval) const { | 485 base::TimeTicks* timebase, base::TimeDelta* interval) const { |
528 if (display_link_ && | 486 if (display_link_ && |
529 display_link_->GetVSyncParameters(timebase, interval)) | 487 display_link_->GetVSyncParameters(timebase, interval)) |
530 return; | 488 return; |
531 *timebase = base::TimeTicks(); | 489 *timebase = base::TimeTicks(); |
532 *interval = base::TimeDelta(); | 490 *interval = base::TimeDelta(); |
533 } | 491 } |
534 | 492 |
535 void RenderWidgetHostViewMac::AcceleratedWidgetSwapCompleted( | 493 void RenderWidgetHostViewMac::AcceleratedWidgetSwapCompleted() { |
536 const std::vector<ui::LatencyInfo>& all_latency_info) { | |
537 if (!render_widget_host_) | |
538 return; | |
539 base::TimeTicks swap_time = base::TimeTicks::Now(); | |
540 | |
541 for (auto latency_info : all_latency_info) { | |
542 latency_info.AddLatencyNumberWithTimestamp( | |
jbauman
2015/10/28 22:27:30
Is this currently dead? If not, should these laten
ccameron
2015/10/28 22:37:04
They are added through RenderWidgetHostLatencyTrac
| |
543 ui::INPUT_EVENT_GPU_SWAP_BUFFER_COMPONENT, 0, 0, swap_time, 1); | |
544 latency_info.AddLatencyNumberWithTimestamp( | |
545 ui::INPUT_EVENT_LATENCY_TERMINATED_FRAME_SWAP_COMPONENT, 0, 0, | |
546 swap_time, 1); | |
547 render_widget_host_->FrameSwapped(latency_info); | |
548 } | |
549 | |
550 if (display_link_) | 494 if (display_link_) |
551 display_link_->NotifyCurrentTime(swap_time); | 495 display_link_->NotifyCurrentTime(base::TimeTicks::Now()); |
552 } | |
553 | |
554 void RenderWidgetHostViewMac::AcceleratedWidgetHitError() { | |
555 // Request a new frame be drawn. | |
556 browser_compositor_->compositor()->ScheduleFullRedraw(); | |
557 } | 496 } |
558 | 497 |
559 /////////////////////////////////////////////////////////////////////////////// | 498 /////////////////////////////////////////////////////////////////////////////// |
560 // RenderWidgetHostViewBase, public: | 499 // RenderWidgetHostViewBase, public: |
561 | 500 |
562 // static | 501 // static |
563 void RenderWidgetHostViewBase::GetDefaultScreenInfo( | 502 void RenderWidgetHostViewBase::GetDefaultScreenInfo( |
564 blink::WebScreenInfo* results) { | 503 blink::WebScreenInfo* results) { |
565 *results = GetWebScreenInfo(NULL); | 504 *results = GetWebScreenInfo(NULL); |
566 } | 505 } |
(...skipping 1225 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1792 void RenderWidgetHostViewMac::PauseForPendingResizeOrRepaintsAndDraw() { | 1731 void RenderWidgetHostViewMac::PauseForPendingResizeOrRepaintsAndDraw() { |
1793 if (!render_widget_host_ || render_widget_host_->is_hidden()) | 1732 if (!render_widget_host_ || render_widget_host_->is_hidden()) |
1794 return; | 1733 return; |
1795 | 1734 |
1796 // Pausing for one view prevents others from receiving frames. | 1735 // Pausing for one view prevents others from receiving frames. |
1797 // This may lead to large delays, causing overlaps. See crbug.com/352020. | 1736 // This may lead to large delays, causing overlaps. See crbug.com/352020. |
1798 if (!allow_pause_for_resize_or_repaint_) | 1737 if (!allow_pause_for_resize_or_repaint_) |
1799 return; | 1738 return; |
1800 | 1739 |
1801 // Wait for a frame of the right size to come in. | 1740 // Wait for a frame of the right size to come in. |
1802 if (browser_compositor_) | |
1803 browser_compositor_->accelerated_widget_mac()->BeginPumpingFrames(); | |
1804 render_widget_host_->PauseForPendingResizeOrRepaints(); | 1741 render_widget_host_->PauseForPendingResizeOrRepaints(); |
1805 if (browser_compositor_) | |
1806 browser_compositor_->accelerated_widget_mac()->EndPumpingFrames(); | |
1807 } | 1742 } |
1808 | 1743 |
1809 //////////////////////////////////////////////////////////////////////////////// | 1744 //////////////////////////////////////////////////////////////////////////////// |
1810 // gfx::DisplayObserver, public: | 1745 // gfx::DisplayObserver, public: |
1811 | 1746 |
1812 void RenderWidgetHostViewMac::OnDisplayAdded(const gfx::Display& display) { | 1747 void RenderWidgetHostViewMac::OnDisplayAdded(const gfx::Display& display) { |
1813 } | 1748 } |
1814 | 1749 |
1815 void RenderWidgetHostViewMac::OnDisplayRemoved(const gfx::Display& display) { | 1750 void RenderWidgetHostViewMac::OnDisplayRemoved(const gfx::Display& display) { |
1816 } | 1751 } |
(...skipping 1672 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3489 | 3424 |
3490 // "-webkit-app-region: drag | no-drag" is implemented on Mac by excluding | 3425 // "-webkit-app-region: drag | no-drag" is implemented on Mac by excluding |
3491 // regions that are not draggable. (See ControlRegionView in | 3426 // regions that are not draggable. (See ControlRegionView in |
3492 // native_app_window_cocoa.mm). This requires the render host view to be | 3427 // native_app_window_cocoa.mm). This requires the render host view to be |
3493 // draggable by default. | 3428 // draggable by default. |
3494 - (BOOL)mouseDownCanMoveWindow { | 3429 - (BOOL)mouseDownCanMoveWindow { |
3495 return YES; | 3430 return YES; |
3496 } | 3431 } |
3497 | 3432 |
3498 @end | 3433 @end |
OLD | NEW |