diff options
author | ccameron@chromium.org <ccameron@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-02-28 10:27:33 +0000 |
---|---|---|
committer | ccameron@chromium.org <ccameron@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-02-28 10:27:33 +0000 |
commit | 69b5fbd510c42bac5b7589e7a70ac554d6bba6c6 (patch) | |
tree | 1ea296fe08fdef7ca039515a2ce75d7e4deecc9d | |
parent | a2170872e380d54c0c3ec4b775bf1d89667bff33 (diff) | |
download | chromium_src-69b5fbd510c42bac5b7589e7a70ac554d6bba6c6.zip chromium_src-69b5fbd510c42bac5b7589e7a70ac554d6bba6c6.tar.gz chromium_src-69b5fbd510c42bac5b7589e7a70ac554d6bba6c6.tar.bz2 |
Enable CoreAnimation by default
Replace the flag --use-core-animation with --disable-core-animation
TBR=avi@chromium.org
BUG=245900
Review URL: https://codereview.chromium.org/182443002
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@254084 0039d316-1c4b-4281-b951-d872f2087c98
6 files changed, 64 insertions, 30 deletions
diff --git a/chrome/browser/ui/cocoa/dev_tools_controller.mm b/chrome/browser/ui/cocoa/dev_tools_controller.mm index 03f3bf4..27c5aa3 100644 --- a/chrome/browser/ui/cocoa/dev_tools_controller.mm +++ b/chrome/browser/ui/cocoa/dev_tools_controller.mm @@ -26,8 +26,8 @@ namespace { bool CoreAnimationIsEnabled() { - static bool is_enabled = CommandLine::ForCurrentProcess()->HasSwitch( - switches::kUseCoreAnimation); + static bool is_enabled = !CommandLine::ForCurrentProcess()->HasSwitch( + switches::kDisableCoreAnimation); return is_enabled; } @@ -80,13 +80,14 @@ using content::WebContents; } - (void)hideDevTools { - DCHECK_EQ(2u, [[self subviews] count]); if (CoreAnimationIsEnabled()) { // Make sure we do not draw any transient arrangements of views. gfx::ScopedNSDisableScreenUpdates disabler; + DCHECK_EQ(1u, [[self subviews] count]); [contentsView_ removeFromSuperview]; [self replaceSubview:devToolsView_ with:contentsView_]; } else { + DCHECK_EQ(2u, [[self subviews] count]); [devToolsView_ removeFromSuperview]; } contentsView_ = nil; @@ -104,7 +105,12 @@ using content::WebContents; return; } - DCHECK_EQ(2u, [[self subviews] count]); + if (CoreAnimationIsEnabled()) { + DCHECK_EQ(1u, [[self subviews] count]); + } else { + DCHECK_EQ(2u, [[self subviews] count]); + } + gfx::Rect new_devtools_bounds; gfx::Rect new_contents_bounds; ApplyDevToolsContentsResizingStrategy( diff --git a/chrome/browser/ui/cocoa/nsview_additions.mm b/chrome/browser/ui/cocoa/nsview_additions.mm index bd85460..d985a64 100644 --- a/chrome/browser/ui/cocoa/nsview_additions.mm +++ b/chrome/browser/ui/cocoa/nsview_additions.mm @@ -89,15 +89,15 @@ } - (void)cr_setWantsLayer:(BOOL)wantsLayer { - if (!CommandLine::ForCurrentProcess()->HasSwitch( - switches::kUseCoreAnimation)) + if (CommandLine::ForCurrentProcess()->HasSwitch( + switches::kDisableCoreAnimation)) return; [self setWantsLayer:wantsLayer]; } - (void)cr_setWantsSquashedLayer { - if (!CommandLine::ForCurrentProcess()->HasSwitch( - switches::kUseCoreAnimation)) + if (CommandLine::ForCurrentProcess()->HasSwitch( + switches::kDisableCoreAnimation)) return; if (CommandLine::ForCurrentProcess()->HasSwitch( switches::kDisableCoreAnimationLayerSquashing)) diff --git a/content/browser/renderer_host/compositing_iosurface_context_mac.mm b/content/browser/renderer_host/compositing_iosurface_context_mac.mm index cd27ef3..9ac36e5 100644 --- a/content/browser/renderer_host/compositing_iosurface_context_mac.mm +++ b/content/browser/renderer_host/compositing_iosurface_context_mac.mm @@ -20,8 +20,9 @@ namespace content { CoreAnimationStatus GetCoreAnimationStatus() { static CoreAnimationStatus status = - CommandLine::ForCurrentProcess()->HasSwitch(switches::kUseCoreAnimation) ? - CORE_ANIMATION_ENABLED : CORE_ANIMATION_DISABLED; + CommandLine::ForCurrentProcess()->HasSwitch( + switches::kDisableCoreAnimation) ? + CORE_ANIMATION_DISABLED : CORE_ANIMATION_ENABLED; return status; } 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 66e4c3c..3d87d39 100644 --- a/content/browser/renderer_host/render_widget_host_view_mac.mm +++ b/content/browser/renderer_host/render_widget_host_view_mac.mm @@ -439,7 +439,7 @@ RenderWidgetHostViewMac::RenderWidgetHostViewMac(RenderWidgetHost* widget) RenderWidgetHostViewMac::~RenderWidgetHostViewMac() { // If a caller has set this, then when the caller tries to re-set it sometime // in the future, we will crash. - DCHECK(!about_to_validate_and_paint_); + CHECK(!about_to_validate_and_paint_); // This is being called from |cocoa_view_|'s destructor, so invalidate the // pointer. @@ -2135,11 +2135,26 @@ void RenderWidgetHostViewMac::SendPendingLatencyInfoToHost() { } void RenderWidgetHostViewMac::TickPendingLatencyInfoDelay() { - // Keep calling setNeedsDisplay in a loop until enough display calls come in. - base::MessageLoop::current()->PostTask(FROM_HERE, - base::Bind(&RenderWidgetHostViewMac::TickPendingLatencyInfoDelay, - pending_latency_info_delay_weak_ptr_factory_.GetWeakPtr())); - [[cocoa_view_ layer] setNeedsDisplay]; + if (compositing_iosurface_layer_) { + // Keep calling gotNewFrame in a loop until enough display calls come in. + // Each call will be separated by about a vsync. + base::MessageLoop::current()->PostTask( + FROM_HERE, + base::Bind(&RenderWidgetHostViewMac::TickPendingLatencyInfoDelay, + pending_latency_info_delay_weak_ptr_factory_.GetWeakPtr())); + [compositing_iosurface_layer_ gotNewFrame]; + } + if (software_layer_) { + // In software mode, setNeedsDisplay will almost immediately result in the + // layer's draw function being called, so manually insert a pretend-vsync + // at 60 Hz. + base::MessageLoop::current()->PostDelayedTask( + FROM_HERE, + base::Bind(&RenderWidgetHostViewMac::TickPendingLatencyInfoDelay, + pending_latency_info_delay_weak_ptr_factory_.GetWeakPtr()), + base::TimeDelta::FromMilliseconds(1000/60)); + [software_layer_ setNeedsDisplay]; + } } void RenderWidgetHostViewMac::AddPendingSwapAck( @@ -2986,11 +3001,10 @@ void RenderWidgetHostViewMac::SendPendingSwapAck() { return; } - DCHECK(!renderWidgetHostView_->about_to_validate_and_paint_); - // GetBackingStore works for both software and accelerated frames. If a // SwapBuffers occurs while GetBackingStore is blocking, we will continue to // blit the IOSurface below. + DCHECK(!renderWidgetHostView_->about_to_validate_and_paint_); renderWidgetHostView_->about_to_validate_and_paint_ = true; BackingStoreMac* backingStore = static_cast<BackingStoreMac*>( renderWidgetHostView_->render_widget_host_->GetBackingStore(true)); @@ -4177,19 +4191,32 @@ extern NSString *NSTextInputReplacementRangeAttributeName; - (void)drawInContext:(CGContextRef)context { TRACE_EVENT0("browser", "SoftwareLayer::drawInContext"); + // Call GetBackingStore to stall until a software frame of the same size as + // the window comes in from the renderer. + BackingStoreMac* backingStore = NULL; + if (renderWidgetHostView_ && + renderWidgetHostView_->render_widget_host_ && + !renderWidgetHostView_->render_widget_host_->is_hidden()) { + // GetBackingStore will dispatch some messages from the run loop, so make + // sure that this is robust to having disableRendering called, which would + // invalidate renderWidgetHostView_. + RenderWidgetHostViewMac* cachedView = renderWidgetHostView_; + DCHECK(!cachedView->about_to_validate_and_paint_); + cachedView->about_to_validate_and_paint_ = true; + backingStore = static_cast<BackingStoreMac*>( + cachedView->render_widget_host_->GetBackingStore(true)); + cachedView->about_to_validate_and_paint_ = false; + } + CGRect clipRect = CGContextGetClipBoundingBox(context); - if (!renderWidgetHostView_) { - CGContextSetFillColorWithColor(context, - CGColorGetConstantColor(kCGColorWhite)); - CGContextFillRect(context, clipRect); - } else { - renderWidgetHostView_->about_to_validate_and_paint_ = true; - BackingStoreMac* backingStore = static_cast<BackingStoreMac*>( - renderWidgetHostView_->render_widget_host_->GetBackingStore(true)); - renderWidgetHostView_->about_to_validate_and_paint_ = false; + if (renderWidgetHostView_) { [renderWidgetHostView_->cocoa_view() drawBackingStore:backingStore dirtyRect:clipRect inContext:context]; + } else { + CGContextSetFillColorWithColor(context, + CGColorGetConstantColor(kCGColorWhite)); + CGContextFillRect(context, clipRect); } } diff --git a/content/public/common/content_switches.cc b/content/public/common/content_switches.cc index c9e7c102..c6dbcb9 100644 --- a/content/public/common/content_switches.cc +++ b/content/public/common/content_switches.cc @@ -1050,8 +1050,8 @@ const char kEnableCarbonInterposing[] = "enable-carbon-interposing"; const char kDisableCoreAnimationPlugins[] = "disable-core-animation-plugins"; -// Use core animation to draw the RenderWidgetHostView on Mac. -const char kUseCoreAnimation[] = "use-core-animation"; +// Disable use of core animation to draw the RenderWidgetHostView on Mac. +const char kDisableCoreAnimation[] = "disable-core-animation"; #endif #if defined(OS_POSIX) diff --git a/content/public/common/content_switches.h b/content/public/common/content_switches.h index ead159f..f0bc735 100644 --- a/content/public/common/content_switches.h +++ b/content/public/common/content_switches.h @@ -310,7 +310,7 @@ CONTENT_EXPORT extern const char kDisablePanelFitting[]; #if defined(OS_MACOSX) && !defined(OS_IOS) extern const char kEnableCarbonInterposing[]; extern const char kDisableCoreAnimationPlugins[]; -CONTENT_EXPORT extern const char kUseCoreAnimation[]; +CONTENT_EXPORT extern const char kDisableCoreAnimation[]; #endif #if defined(OS_POSIX) |