diff --git a/android_webview/browser/aw_render_thread_context_provider.cc b/android_webview/browser/aw_render_thread_context_provider.cc index 563bce645e6241..a3ed6c8d225782 100644 --- a/android_webview/browser/aw_render_thread_context_provider.cc +++ b/android_webview/browser/aw_render_thread_context_provider.cc @@ -6,12 +6,15 @@ #include "base/bind.h" #include "base/callback_helpers.h" +#include "base/command_line.h" #include "base/lazy_instance.h" #include "base/trace_event/trace_event.h" #include "cc/output/context_cache_controller.h" #include "cc/output/managed_memory_policy.h" #include "gpu/command_buffer/client/gles2_implementation.h" #include "gpu/command_buffer/client/gles2_lib.h" +#include "gpu/command_buffer/client/gles2_trace_implementation.h" +#include "gpu/command_buffer/client/gpu_switches.h" #include "gpu/command_buffer/client/shared_memory_limits.h" #include "gpu/ipc/gl_in_process_context.h" #include "gpu/skia_bindings/gl_bindings_skia_cmd_buffer.h" @@ -69,6 +72,14 @@ AwRenderThreadContextProvider::AwRenderThreadContextProvider( context_->GetImplementation()->SetLostContextCallback(base::Bind( &AwRenderThreadContextProvider::OnLostContext, base::Unretained(this))); + if (base::CommandLine::ForCurrentProcess()->HasSwitch( + switches::kEnableGpuClientTracing)) { + // This wraps the real GLES2Implementation and we should always use this + // instead when it's present. + trace_impl_.reset(new gpu::gles2::GLES2TraceImplementation( + context_->GetImplementation())); + } + cache_controller_.reset( new cc::ContextCacheController(context_->GetImplementation(), nullptr)); } @@ -98,7 +109,8 @@ gpu::Capabilities AwRenderThreadContextProvider::ContextCapabilities() { gpu::gles2::GLES2Interface* AwRenderThreadContextProvider::ContextGL() { DCHECK(main_thread_checker_.CalledOnValidThread()); - + if (trace_impl_) + return trace_impl_.get(); return context_->GetImplementation(); } diff --git a/android_webview/browser/aw_render_thread_context_provider.h b/android_webview/browser/aw_render_thread_context_provider.h index c146b9a8030cfa..44301a3135b5bd 100644 --- a/android_webview/browser/aw_render_thread_context_provider.h +++ b/android_webview/browser/aw_render_thread_context_provider.h @@ -22,7 +22,10 @@ class GLSurface; namespace gpu { class GLInProcessContext; -} +namespace gles2 { +class GLES2TraceImplementation; +} // namespace gles2 +} // namespace gpu namespace android_webview { @@ -59,6 +62,7 @@ class AwRenderThreadContextProvider : public cc::ContextProvider { base::ThreadChecker main_thread_checker_; std::unique_ptr context_; + std::unique_ptr trace_impl_; sk_sp gr_context_; std::unique_ptr cache_controller_;