Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1558)

Unified Diff: content/browser/renderer_host/render_widget_host_view_mac.mm

Issue 408103004: Mac: Fix bad framerate when capturing tab (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « content/browser/renderer_host/render_widget_host_view_mac.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/browser/renderer_host/render_widget_host_view_mac.mm
diff --git a/content/browser/renderer_host/render_widget_host_view_mac.mm b/content/browser/renderer_host/render_widget_host_view_mac.mm
index 0c7150b7163d89e916a590ed5d1731c14f885f97..800693e55152609bc6a829a1dfc7c09f0de4f255 100644
--- a/content/browser/renderer_host/render_widget_host_view_mac.mm
+++ b/content/browser/renderer_host/render_widget_host_view_mac.mm
@@ -449,6 +449,12 @@ DelegatedFrameHost* RenderWidgetHostViewMac::GetDelegatedFrameHost() const {
////////////////////////////////////////////////////////////////////////////////
// BrowserCompositorViewMacClient, public:
+bool RenderWidgetHostViewMac::BrowserCompositorViewShouldAckImmediately()
+ const {
+ // The logic for delegated and non-delegated rendering is the same.
+ return AcceleratedLayerShouldAckImmediately();
+}
+
void RenderWidgetHostViewMac::BrowserCompositorViewFrameSwapped(
const std::vector<ui::LatencyInfo>& all_latency_info) {
if (!render_widget_host_)
@@ -1526,20 +1532,6 @@ void RenderWidgetHostViewMac::CompositorSwapBuffers(
return;
}
- // If the window is occluded, then this frame's display call may be severely
- // throttled. This is a good thing, unless tab capture may be active,
- // because the broadcast will be inappropriately throttled.
- // http://crbug.com/350410
- NSWindow* window = [cocoa_view_ window];
- if (window && [window respondsToSelector:@selector(occlusionState)]) {
- bool window_is_occluded =
- !([window occlusionState] & NSWindowOcclusionStateVisible);
- // Note that we aggressively ack even if this particular frame is not being
- // captured.
- if (window_is_occluded && frame_subscriber_)
- scoped_ack.Reset();
- }
-
// If we reach here, then the frame will be displayed by a future draw
// call, so don't make the callback.
ignore_result(scoped_ack.Release());
@@ -2244,6 +2236,51 @@ SkColorType RenderWidgetHostViewMac::PreferredReadbackFormat() {
////////////////////////////////////////////////////////////////////////////////
// CompositingIOSurfaceLayerClient, public:
+bool RenderWidgetHostViewMac::AcceleratedLayerShouldAckImmediately() const {
+ // If vsync is disabled, then always draw and ack frames immediately.
+ static bool is_vsync_disabled =
+ CommandLine::ForCurrentProcess()->HasSwitch(switches::kDisableGpuVsync);
+ if (is_vsync_disabled)
+ return true;
+
+ // If the window is occluded, then this frame's display call may be severely
+ // throttled. This is a good thing, unless tab capture may be active, because
+ // the broadcast will be inappropriately throttled.
+ // http://crbug.com/350410
+
+ // If tab capture isn't active then only ack frames when we draw them.
+ if (delegated_frame_host_) {
+ if (!delegated_frame_host_->HasFrameSubscriber())
+ return false;
+ } else {
+ if (!frame_subscriber_)
+ return false;
+ }
+
+ NSWindow* window = [cocoa_view_ window];
+ // If the view isn't even in the heirarchy then frames will never be drawn,
+ // so ack them immediately.
+ if (!window)
+ return true;
+
+ // Check the window occlusion API.
+ if ([window respondsToSelector:@selector(occlusionState)]) {
+ if ([window occlusionState] & NSWindowOcclusionStateVisible) {
+ // If the window is visible then it is safe to wait until frames are
+ // drawn to ack them.
+ return false;
+ } else {
+ // If the window is occluded then frames may never be drawn, so ack them
+ // immediately.
+ return true;
+ }
+ }
+
+ // If the window occlusion API is not present then ack frames when we draw
+ // them.
+ return false;
+}
+
void RenderWidgetHostViewMac::AcceleratedLayerDidDrawFrame(bool succeeded) {
if (!render_widget_host_)
return;
« no previous file with comments | « content/browser/renderer_host/render_widget_host_view_mac.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698