diff options
author | jamesr@chromium.org <jamesr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-02-01 21:54:20 +0000 |
---|---|---|
committer | jamesr@chromium.org <jamesr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-02-01 21:54:20 +0000 |
commit | 858a0f0a7d0d7ee4efff67e10250adb9648a8219 (patch) | |
tree | 7314bf13475f3c688317b3841e10d68f1de70cd7 /content | |
parent | fc127acd4a2b24b728f78e3f7975ad54548b9209 (diff) | |
download | chromium_src-858a0f0a7d0d7ee4efff67e10250adb9648a8219.zip chromium_src-858a0f0a7d0d7ee4efff67e10250adb9648a8219.tar.gz chromium_src-858a0f0a7d0d7ee4efff67e10250adb9648a8219.tar.bz2 |
Defer render_widget draw until host window is available
In accelerated compositing mode we can't start rendering until the
native window (HWND/gtk widget) are created on Windows and GTK without
aura. For most render_widgets the code today is racy, but for
window.open() and similar creation paths this is a race that we pretty
much always lose. This defers the first DoDeferredUpdate on a render_widget
until its host_window_ is available.
Also defers querying for GL_CHROMIUM_supports_swapbuffers_callback
extension until the first draw, since the context isn't ready until the
host window is available.
BUG=106815
TEST=start with --force-compositing-mode and --show-fps-counter, load up
a page that uses window.open() to open a popup, and confirm that the
popup is in compositing mode
Committed: http://src.chromium.org/viewvc/chrome?view=rev&revision=119977
Review URL: http://codereview.chromium.org/9225050
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@120111 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'content')
-rw-r--r-- | content/renderer/render_view_impl.cc | 21 | ||||
-rw-r--r-- | content/renderer/render_view_impl.h | 7 | ||||
-rw-r--r-- | content/renderer/render_widget.cc | 14 |
3 files changed, 33 insertions, 9 deletions
diff --git a/content/renderer/render_view_impl.cc b/content/renderer/render_view_impl.cc index c8eb610..69bfb28 100644 --- a/content/renderer/render_view_impl.cc +++ b/content/renderer/render_view_impl.cc @@ -397,6 +397,8 @@ RenderViewImpl::RenderViewImpl( cached_is_main_frame_pinned_to_right_(false), cached_has_main_frame_horizontal_scrollbar_(false), cached_has_main_frame_vertical_scrollbar_(false), + context_has_swapbuffers_complete_callback_(false), + queried_for_swapbuffers_complete_callback_(false), ALLOW_THIS_IN_INITIALIZER_LIST(cookie_jar_(this)), geolocation_dispatcher_(NULL), speech_input_dispatcher_(NULL), @@ -4495,12 +4497,21 @@ bool RenderViewImpl::SupportsAsynchronousSwapBuffers() { if (WebWidgetHandlesCompositorScheduling()) return false; + if (queried_for_swapbuffers_complete_callback_) + return context_has_swapbuffers_complete_callback_; + + queried_for_swapbuffers_complete_callback_ = true; + WebKit::WebGraphicsContext3D* context = webview()->graphicsContext3D(); - if (!context) - return false; - std::string extensions(context->getRequestableExtensionsCHROMIUM().utf8()); - return extensions.find("GL_CHROMIUM_swapbuffers_complete_callback") != - std::string::npos; + if (context) { + context->makeContextCurrent(); + std::string extensions(context->getRequestableExtensionsCHROMIUM().utf8()); + context_has_swapbuffers_complete_callback_ = + extensions.find("GL_CHROMIUM_swapbuffers_complete_callback") + != std::string::npos; + } + + return context_has_swapbuffers_complete_callback_; } void RenderViewImpl::OnSetFocus(bool enable) { diff --git a/content/renderer/render_view_impl.h b/content/renderer/render_view_impl.h index b892a80..083ab85 100644 --- a/content/renderer/render_view_impl.h +++ b/content/renderer/render_view_impl.h @@ -1135,6 +1135,13 @@ class RenderViewImpl : public RenderWidget, std::set<gfx::PluginWindowHandle> fake_plugin_window_handles_; #endif + // When this view is composited, the context used for compositing may or may + // not support the GL_CHROMIUM_swapbuffers_complete_callback extension. Since + // querying for the existence of this extension is expensive we cache the + // result. These are used to implement SupportsAsynchronousSwapBuffers(). + bool context_has_swapbuffers_complete_callback_; + bool queried_for_swapbuffers_complete_callback_; + // Helper objects ------------------------------------------------------------ RendererWebCookieJarImpl cookie_jar_; diff --git a/content/renderer/render_widget.cc b/content/renderer/render_widget.cc index 3df2a99..6b16fa7 100644 --- a/content/renderer/render_widget.cc +++ b/content/renderer/render_widget.cc @@ -175,6 +175,8 @@ void RenderWidget::CompleteInit(gfx::NativeViewId parent_hwnd) { host_window_ = parent_hwnd; + DoDeferredUpdate(); + Send(new ViewHostMsg_RenderViewReady(routing_id_)); } @@ -737,6 +739,11 @@ void RenderWidget::DoDeferredUpdate() { if (!webwidget_) return; + + if (!host_window_) { + TRACE_EVENT0("renderer", "EarlyOut_NoHostWindow"); + return; + } if (update_reply_pending_) { TRACE_EVENT0("renderer", "EarlyOut_UpdateReplyPending"); return; @@ -755,6 +762,9 @@ void RenderWidget::DoDeferredUpdate() { return; } + if (is_accelerated_compositing_active_) + using_asynchronous_swapbuffers_ = SupportsAsynchronousSwapBuffers(); + // Tracking of frame rate jitter base::TimeTicks frame_begin_ticks = base::TimeTicks::Now(); AnimateIfNeeded(); @@ -1010,10 +1020,6 @@ void RenderWidget::didActivateCompositor(int compositor_identifier) { is_accelerated_compositing_active_ = true; Send(new ViewHostMsg_DidActivateAcceleratedCompositing( routing_id_, is_accelerated_compositing_active_)); - - // Note: asynchronous swapbuffer support currently only matters if - // compositing scheduling happens on the RenderWidget. - using_asynchronous_swapbuffers_ = SupportsAsynchronousSwapBuffers(); } void RenderWidget::didDeactivateCompositor() { |