diff options
Diffstat (limited to 'content/browser')
5 files changed, 30 insertions, 116 deletions
diff --git a/content/browser/aura/gpu_process_transport_factory.cc b/content/browser/aura/gpu_process_transport_factory.cc index f958ae9..4b8e8ef 100644 --- a/content/browser/aura/gpu_process_transport_factory.cc +++ b/content/browser/aura/gpu_process_transport_factory.cc @@ -46,7 +46,6 @@ namespace content { struct GpuProcessTransportFactory::PerCompositorData { int surface_id; - scoped_ptr<CompositorSwapClient> swap_client; #if defined(OS_WIN) scoped_ptr<AcceleratedSurface> accelerated_surface; #endif @@ -143,48 +142,6 @@ class ImageTransportClientTexture : public OwnedTexture { DISALLOW_COPY_AND_ASSIGN(ImageTransportClientTexture); }; -class CompositorSwapClient - : public base::SupportsWeakPtr<CompositorSwapClient>, - public WebGraphicsContext3DSwapBuffersClient { - public: - CompositorSwapClient(ui::Compositor* compositor, - GpuProcessTransportFactory* factory) - : compositor_(compositor), - factory_(factory) { - } - - virtual ~CompositorSwapClient() { - } - - virtual void OnViewContextSwapBuffersPosted() OVERRIDE { - compositor_->OnSwapBuffersPosted(); - } - - virtual void OnViewContextSwapBuffersComplete() OVERRIDE { - compositor_->OnSwapBuffersComplete(); - } - - virtual void OnViewContextSwapBuffersAborted() OVERRIDE { - // Recreating contexts directly from here causes issues, so post a task - // instead. - // TODO(piman): Fix the underlying issues. - base::MessageLoop::current()->PostTask( - FROM_HERE, - base::Bind(&CompositorSwapClient::OnLostContext, this->AsWeakPtr())); - } - - private: - void OnLostContext() { - factory_->OnLostContext(compositor_); - // Note: previous line destroyed this. Don't access members from now on. - } - - ui::Compositor* compositor_; - GpuProcessTransportFactory* factory_; - - DISALLOW_COPY_AND_ASSIGN(CompositorSwapClient); -}; - GpuProcessTransportFactory::GpuProcessTransportFactory() : callback_factory_(this) { output_surface_proxy_ = new BrowserCompositorOutputSurfaceProxy( @@ -200,8 +157,7 @@ GpuProcessTransportFactory::~GpuProcessTransportFactory() { scoped_ptr<WebGraphicsContext3DCommandBufferImpl> GpuProcessTransportFactory::CreateOffscreenCommandBufferContext() { - base::WeakPtr<WebGraphicsContext3DSwapBuffersClient> swap_client; - return CreateContextCommon(swap_client, 0); + return CreateContextCommon(0); } scoped_ptr<cc::SoftwareOutputDevice> CreateSoftwareOutputDevice( @@ -228,17 +184,12 @@ scoped_ptr<cc::OutputSurface> GpuProcessTransportFactory::CreateOutputSurface( data = CreatePerCompositorData(compositor); scoped_refptr<ContextProviderCommandBuffer> context_provider; - base::WeakPtr<WebGraphicsContext3DSwapBuffersClient> swap_client_weak_ptr; - if (data->swap_client) - swap_client_weak_ptr = data->swap_client->AsWeakPtr(); CommandLine* command_line = CommandLine::ForCurrentProcess(); if (!command_line->HasSwitch(switches::kUIEnableSoftwareCompositing)) { context_provider = ContextProviderCommandBuffer::Create( - GpuProcessTransportFactory::CreateContextCommon( - swap_client_weak_ptr, - data->surface_id), - "Compositor"); + GpuProcessTransportFactory::CreateContextCommon(data->surface_id), + "Compositor"); } UMA_HISTOGRAM_BOOLEAN("Aura.CreatedGpuBrowserCompositor", !!context_provider); @@ -454,18 +405,6 @@ GpuProcessTransportFactory::SharedMainThreadContextProvider() { return shared_main_thread_contexts_; } -void GpuProcessTransportFactory::OnLostContext(ui::Compositor* compositor) { - LOG(ERROR) << "Lost UI compositor context."; - PerCompositorData* data = per_compositor_data_[compositor]; - DCHECK(data); - - // Prevent callbacks from other contexts in the same share group from - // calling us again. - if (data->swap_client.get()) - data->swap_client.reset(new CompositorSwapClient(compositor, this)); - compositor->OnSwapBuffersAborted(); -} - GpuProcessTransportFactory::PerCompositorData* GpuProcessTransportFactory::CreatePerCompositorData( ui::Compositor* compositor) { @@ -476,8 +415,6 @@ GpuProcessTransportFactory::CreatePerCompositorData( PerCompositorData* data = new PerCompositorData; data->surface_id = tracker->AddSurfaceForNativeWidget(widget); - if (!ui::Compositor::WasInitializedWithThread()) - data->swap_client.reset(new CompositorSwapClient(compositor, this)); #if defined(OS_WIN) if (GpuDataManagerImpl::GetInstance()->IsUsingAcceleratedSurface()) data->accelerated_surface.reset(new AcceleratedSurface(widget)); @@ -492,9 +429,7 @@ GpuProcessTransportFactory::CreatePerCompositorData( } scoped_ptr<WebGraphicsContext3DCommandBufferImpl> -GpuProcessTransportFactory::CreateContextCommon( - const base::WeakPtr<WebGraphicsContext3DSwapBuffersClient>& swap_client, - int surface_id) { +GpuProcessTransportFactory::CreateContextCommon(int surface_id) { if (!GpuDataManagerImpl::GetInstance()->CanUseGpuBrowserCompositor()) return scoped_ptr<WebGraphicsContext3DCommandBufferImpl>(); blink::WebGraphicsContext3D::Attributes attrs; @@ -503,9 +438,10 @@ GpuProcessTransportFactory::CreateContextCommon( attrs.stencil = false; attrs.antialias = false; attrs.noAutomaticFlushes = true; + CauseForGpuLaunch cause = + CAUSE_FOR_GPU_LAUNCH_WEBGRAPHICSCONTEXT3DCOMMANDBUFFERIMPL_INITIALIZE; scoped_refptr<GpuChannelHost> gpu_channel_host( - BrowserGpuChannelHostFactory::instance()->EstablishGpuChannelSync( - CAUSE_FOR_GPU_LAUNCH_WEBGRAPHICSCONTEXT3DCOMMANDBUFFERIMPL_INITIALIZE)); + BrowserGpuChannelHostFactory::instance()->EstablishGpuChannelSync(cause)); if (!gpu_channel_host) return scoped_ptr<WebGraphicsContext3DCommandBufferImpl>(); GURL url("chrome://gpu/GpuProcessTransportFactory::CreateContextCommon"); @@ -515,7 +451,6 @@ GpuProcessTransportFactory::CreateContextCommon( surface_id, url, gpu_channel_host.get(), - swap_client, use_echo_for_swap_ack, attrs, false, diff --git a/content/browser/aura/gpu_process_transport_factory.h b/content/browser/aura/gpu_process_transport_factory.h index dd6e79a..36ebb00 100644 --- a/content/browser/aura/gpu_process_transport_factory.h +++ b/content/browser/aura/gpu_process_transport_factory.h @@ -22,7 +22,6 @@ class CompositorSwapClient; class ContextProviderCommandBuffer; class ReflectorImpl; class WebGraphicsContext3DCommandBufferImpl; -class WebGraphicsContext3DSwapBuffersClient; class GpuProcessTransportFactory : public ui::ContextFactory, @@ -68,15 +67,12 @@ class GpuProcessTransportFactory virtual void RemoveObserver( ImageTransportFactoryObserver* observer) OVERRIDE; - void OnLostContext(ui::Compositor* compositor); - private: struct PerCompositorData; PerCompositorData* CreatePerCompositorData(ui::Compositor* compositor); - scoped_ptr<WebGraphicsContext3DCommandBufferImpl> CreateContextCommon( - const base::WeakPtr<WebGraphicsContext3DSwapBuffersClient>& swap_client, - int surface_id); + scoped_ptr<WebGraphicsContext3DCommandBufferImpl> + CreateContextCommon(int surface_id); void OnLostMainThreadSharedContextInsideCallback(); void OnLostMainThreadSharedContext(); diff --git a/content/browser/renderer_host/compositor_impl_android.cc b/content/browser/renderer_host/compositor_impl_android.cc index 3189e9f..86acf38 100644 --- a/content/browser/renderer_host/compositor_impl_android.cc +++ b/content/browser/renderer_host/compositor_impl_android.cc @@ -134,8 +134,7 @@ CompositorImpl::CompositorImpl(CompositorClient* client) has_transparent_background_(false), window_(NULL), surface_id_(0), - client_(client), - weak_factory_(this) { + client_(client) { DCHECK(client); ImageTransportFactoryAndroid::AddObserver(this); } @@ -347,12 +346,13 @@ bool CompositorImpl::CopyTextureToBitmap(blink::WebGLId texture_id, static scoped_ptr<WebGraphicsContext3DCommandBufferImpl> CreateGpuProcessViewContext( const blink::WebGraphicsContext3D::Attributes attributes, - int surface_id, - base::WeakPtr<CompositorImpl> compositor_impl) { + int surface_id) { BrowserGpuChannelHostFactory* factory = BrowserGpuChannelHostFactory::instance(); - scoped_refptr<GpuChannelHost> gpu_channel_host(factory->EstablishGpuChannelSync( - CAUSE_FOR_GPU_LAUNCH_WEBGRAPHICSCONTEXT3DCOMMANDBUFFERIMPL_INITIALIZE)); + CauseForGpuLaunch cause = + CAUSE_FOR_GPU_LAUNCH_WEBGRAPHICSCONTEXT3DCOMMANDBUFFERIMPL_INITIALIZE; + scoped_refptr<GpuChannelHost> gpu_channel_host( + factory->EstablishGpuChannelSync(cause)); if (!gpu_channel_host) return scoped_ptr<WebGraphicsContext3DCommandBufferImpl>(); @@ -375,7 +375,6 @@ CreateGpuProcessViewContext( new WebGraphicsContext3DCommandBufferImpl(surface_id, url, gpu_channel_host.get(), - compositor_impl, use_echo_for_swap_ack, attributes, false, @@ -392,8 +391,8 @@ scoped_ptr<cc::OutputSurface> CompositorImpl::CreateOutputSurface( DCHECK(surface_id_); scoped_refptr<ContextProviderCommandBuffer> context_provider = - ContextProviderCommandBuffer::Create(CreateGpuProcessViewContext( - attrs, surface_id_, weak_factory_.GetWeakPtr()), "BrowserCompositor"); + ContextProviderCommandBuffer::Create( + CreateGpuProcessViewContext(attrs, surface_id_), "BrowserCompositor"); if (!context_provider.get()) { LOG(ERROR) << "Failed to create 3D context for compositor."; return scoped_ptr<cc::OutputSurface>(); @@ -407,14 +406,6 @@ void CompositorImpl::OnLostResources() { client_->DidLoseResources(); } -void CompositorImpl::DidCompleteSwapBuffers() { - client_->OnSwapBuffersCompleted(); -} - -void CompositorImpl::ScheduleComposite() { - client_->ScheduleComposite(); -} - scoped_refptr<cc::ContextProvider> CompositorImpl::OffscreenContextProvider() { // There is no support for offscreen contexts, or compositor filters that // would require them in this compositor instance. If they are needed, @@ -423,19 +414,21 @@ scoped_refptr<cc::ContextProvider> CompositorImpl::OffscreenContextProvider() { return NULL; } -void CompositorImpl::OnViewContextSwapBuffersPosted() { - TRACE_EVENT0("compositor", "CompositorImpl::OnViewContextSwapBuffersPosted"); - client_->OnSwapBuffersPosted(); +void CompositorImpl::DidCompleteSwapBuffers() { + client_->OnSwapBuffersCompleted(); } -void CompositorImpl::OnViewContextSwapBuffersComplete() { - TRACE_EVENT0("compositor", - "CompositorImpl::OnViewContextSwapBuffersComplete"); - client_->OnSwapBuffersCompleted(); +void CompositorImpl::ScheduleComposite() { + client_->ScheduleComposite(); +} + +void CompositorImpl::DidPostSwapBuffers() { + TRACE_EVENT0("compositor", "CompositorImpl::DidPostSwapBuffers"); + client_->OnSwapBuffersPosted(); } -void CompositorImpl::OnViewContextSwapBuffersAborted() { - TRACE_EVENT0("compositor", "CompositorImpl::OnViewContextSwapBuffersAborted"); +void CompositorImpl::DidAbortSwapBuffers() { + TRACE_EVENT0("compositor", "CompositorImpl::DidAbortSwapBuffers"); client_->OnSwapBuffersCompleted(); } diff --git a/content/browser/renderer_host/compositor_impl_android.h b/content/browser/renderer_host/compositor_impl_android.h index 95546000..04ae395 100644 --- a/content/browser/renderer_host/compositor_impl_android.h +++ b/content/browser/renderer_host/compositor_impl_android.h @@ -9,7 +9,6 @@ #include "base/compiler_specific.h" #include "base/containers/scoped_ptr_hash_map.h" #include "base/memory/scoped_ptr.h" -#include "base/memory/weak_ptr.h" #include "cc/resources/ui_resource_client.h" #include "cc/trees/layer_tree_host_client.h" #include "cc/trees/layer_tree_host_single_thread_client.h" @@ -38,7 +37,6 @@ class CONTENT_EXPORT CompositorImpl : public Compositor, public cc::LayerTreeHostClient, public cc::LayerTreeHostSingleThreadClient, - public WebGraphicsContext3DSwapBuffersClient, public ImageTransportFactoryAndroidObserver { public: explicit CompositorImpl(CompositorClient* client); @@ -91,13 +89,8 @@ class CONTENT_EXPORT CompositorImpl // LayerTreeHostSingleThreadClient implementation. virtual void ScheduleComposite() OVERRIDE; - virtual void DidPostSwapBuffers() OVERRIDE {} - virtual void DidAbortSwapBuffers() OVERRIDE {} - - // WebGraphicsContext3DSwapBuffersClient implementation. - virtual void OnViewContextSwapBuffersPosted() OVERRIDE; - virtual void OnViewContextSwapBuffersComplete() OVERRIDE; - virtual void OnViewContextSwapBuffersAborted() OVERRIDE; + virtual void DidPostSwapBuffers() OVERRIDE; + virtual void DidAbortSwapBuffers() OVERRIDE; // ImageTransportFactoryAndroidObserver implementation. virtual void OnLostResources() OVERRIDE; @@ -117,7 +110,6 @@ class CONTENT_EXPORT CompositorImpl int surface_id_; CompositorClient* client_; - base::WeakPtrFactory<CompositorImpl> weak_factory_; scoped_refptr<cc::ContextProvider> null_offscreen_context_provider_; diff --git a/content/browser/renderer_host/image_transport_factory_android.cc b/content/browser/renderer_host/image_transport_factory_android.cc index 380cc7a..80c5e84 100644 --- a/content/browser/renderer_host/image_transport_factory_android.cc +++ b/content/browser/renderer_host/image_transport_factory_android.cc @@ -65,7 +65,6 @@ CmdBufferImageTransportFactory::CmdBufferImageTransportFactory() { blink::WebGraphicsContext3D::Attributes attrs; attrs.shareResources = true; GURL url("chrome://gpu/ImageTransportFactoryAndroid"); - base::WeakPtr<WebGraphicsContext3DSwapBuffersClient> swap_client; static const size_t kBytesPerPixel = 4; gfx::DeviceDisplayInfo display_info; size_t full_screen_texture_size_in_bytes = display_info.GetDisplayHeight() * @@ -84,7 +83,6 @@ CmdBufferImageTransportFactory::CmdBufferImageTransportFactory() { new WebGraphicsContext3DCommandBufferImpl(0, // offscreen url, gpu_channel_host.get(), - swap_client, use_echo_for_swap_ack, attrs, false, |