Commit 7db0709d authored by pilgrim's avatar pilgrim Committed by Commit bot

Move InitializeOnCurrentThread down from WebGraphicsContext3DImpl to...

Move InitializeOnCurrentThread down from WebGraphicsContext3DImpl to WebGraphicsContext3DCommandBufferImpl and WebGraphicsContext3DInProcessCommandBufferImpl

in preparation for dis-inheriting these classes

BUG=338338
TBR=darin@chromium.org

Review URL: https://codereview.chromium.org/609973002

Cr-Commit-Position: refs/heads/master@{#297362}
parent 1a815bc3
...@@ -223,7 +223,7 @@ SynchronousCompositorFactoryImpl::CreateStreamTextureFactory(int frame_id) { ...@@ -223,7 +223,7 @@ SynchronousCompositorFactoryImpl::CreateStreamTextureFactory(int frame_id) {
return factory; return factory;
} }
webkit::gpu::WebGraphicsContext3DImpl* webkit::gpu::WebGraphicsContext3DInProcessCommandBufferImpl*
SynchronousCompositorFactoryImpl::CreateOffscreenGraphicsContext3D( SynchronousCompositorFactoryImpl::CreateOffscreenGraphicsContext3D(
const blink::WebGraphicsContext3D::Attributes& attributes) { const blink::WebGraphicsContext3D::Attributes& attributes) {
return WrapContextWithAttributes(CreateOffscreenContext(attributes), return WrapContextWithAttributes(CreateOffscreenContext(attributes),
......
...@@ -44,7 +44,7 @@ class SynchronousCompositorFactoryImpl : public SynchronousCompositorFactory { ...@@ -44,7 +44,7 @@ class SynchronousCompositorFactoryImpl : public SynchronousCompositorFactory {
const std::string& debug_name) OVERRIDE; const std::string& debug_name) OVERRIDE;
virtual scoped_refptr<StreamTextureFactory> CreateStreamTextureFactory( virtual scoped_refptr<StreamTextureFactory> CreateStreamTextureFactory(
int view_id) OVERRIDE; int view_id) OVERRIDE;
virtual webkit::gpu::WebGraphicsContext3DImpl* virtual webkit::gpu::WebGraphicsContext3DInProcessCommandBufferImpl*
CreateOffscreenGraphicsContext3D( CreateOffscreenGraphicsContext3D(
const blink::WebGraphicsContext3D::Attributes& attributes) OVERRIDE; const blink::WebGraphicsContext3D::Attributes& attributes) OVERRIDE;
......
...@@ -142,8 +142,7 @@ class WebGraphicsContext3DCommandBufferImpl ...@@ -142,8 +142,7 @@ class WebGraphicsContext3DCommandBufferImpl
return mem_limits_.mapped_memory_reclaim_limit; return mem_limits_.mapped_memory_reclaim_limit;
} }
// WebGraphicsContext3DImpl methods CONTENT_EXPORT bool InitializeOnCurrentThread();
virtual bool InitializeOnCurrentThread() OVERRIDE;
//---------------------------------------------------------------------- //----------------------------------------------------------------------
// WebGraphicsContext3D methods // WebGraphicsContext3D methods
......
...@@ -21,7 +21,7 @@ class OutputSurface; ...@@ -21,7 +21,7 @@ class OutputSurface;
namespace webkit { namespace webkit {
namespace gpu { namespace gpu {
class ContextProviderWebContext; class ContextProviderWebContext;
class WebGraphicsContext3DImpl; class WebGraphicsContext3DInProcessCommandBufferImpl;
} }
} }
...@@ -58,7 +58,7 @@ class SynchronousCompositorFactory { ...@@ -58,7 +58,7 @@ class SynchronousCompositorFactory {
const std::string& debug_name) = 0; const std::string& debug_name) = 0;
virtual scoped_refptr<StreamTextureFactory> CreateStreamTextureFactory( virtual scoped_refptr<StreamTextureFactory> CreateStreamTextureFactory(
int frame_id) = 0; int frame_id) = 0;
virtual webkit::gpu::WebGraphicsContext3DImpl* virtual webkit::gpu::WebGraphicsContext3DInProcessCommandBufferImpl*
CreateOffscreenGraphicsContext3D( CreateOffscreenGraphicsContext3D(
const blink::WebGraphicsContext3D::Attributes& attributes) = 0; const blink::WebGraphicsContext3D::Attributes& attributes) = 0;
......
...@@ -81,6 +81,7 @@ ...@@ -81,6 +81,7 @@
#if defined(OS_ANDROID) #if defined(OS_ANDROID)
#include "content/renderer/android/synchronous_compositor_factory.h" #include "content/renderer/android/synchronous_compositor_factory.h"
#include "content/renderer/media/android/audio_decoder_android.h" #include "content/renderer/media/android/audio_decoder_android.h"
#include "webkit/common/gpu/webgraphicscontext3d_in_process_command_buffer_impl.h"
#endif #endif
#if defined(OS_MACOSX) #if defined(OS_MACOSX)
...@@ -952,30 +953,34 @@ RendererWebKitPlatformSupportImpl::createOffscreenGraphicsContext3D( ...@@ -952,30 +953,34 @@ RendererWebKitPlatformSupportImpl::createOffscreenGraphicsContext3D(
if (!RenderThreadImpl::current()) if (!RenderThreadImpl::current())
return NULL; return NULL;
scoped_ptr<webkit::gpu::WebGraphicsContext3DImpl> context;
bool must_use_synchronous_factory = false;
#if defined(OS_ANDROID) #if defined(OS_ANDROID)
if (SynchronousCompositorFactory* factory = if (SynchronousCompositorFactory* factory =
SynchronousCompositorFactory::GetInstance()) { SynchronousCompositorFactory::GetInstance()) {
context.reset(factory->CreateOffscreenGraphicsContext3D(attributes)); scoped_ptr<webkit::gpu::WebGraphicsContext3DInProcessCommandBufferImpl>
must_use_synchronous_factory = true; in_process_context(
factory->CreateOffscreenGraphicsContext3D(attributes));
if (!in_process_context ||
!in_process_context->InitializeOnCurrentThread())
return NULL;
return in_process_context.release();
} }
#endif #endif
if (!must_use_synchronous_factory) {
scoped_refptr<GpuChannelHost> gpu_channel_host( scoped_refptr<GpuChannelHost> gpu_channel_host(
RenderThreadImpl::current()->EstablishGpuChannelSync( RenderThreadImpl::current()->EstablishGpuChannelSync(
CAUSE_FOR_GPU_LAUNCH_WEBGRAPHICSCONTEXT3DCOMMANDBUFFERIMPL_INITIALIZE)); CAUSE_FOR_GPU_LAUNCH_WEBGRAPHICSCONTEXT3DCOMMANDBUFFERIMPL_INITIALIZE));
WebGraphicsContext3DCommandBufferImpl::SharedMemoryLimits limits; WebGraphicsContext3DCommandBufferImpl::SharedMemoryLimits limits;
bool lose_context_when_out_of_memory = false; bool lose_context_when_out_of_memory = false;
context.reset(WebGraphicsContext3DCommandBufferImpl::CreateOffscreenContext( scoped_ptr<WebGraphicsContext3DCommandBufferImpl> context(
WebGraphicsContext3DCommandBufferImpl::CreateOffscreenContext(
gpu_channel_host.get(), gpu_channel_host.get(),
attributes, attributes,
lose_context_when_out_of_memory, lose_context_when_out_of_memory,
GURL(attributes.topDocumentURL), GURL(attributes.topDocumentURL),
limits, limits,
static_cast<WebGraphicsContext3DCommandBufferImpl*>(share_context))); static_cast<WebGraphicsContext3DCommandBufferImpl*>(share_context)));
}
// Most likely the GPU process exited and the attempt to reconnect to it // Most likely the GPU process exited and the attempt to reconnect to it
// failed. Need to try to restore the context again later. // failed. Need to try to restore the context again later.
if (!context || !context->InitializeOnCurrentThread()) if (!context || !context->InitializeOnCurrentThread())
......
...@@ -48,11 +48,6 @@ class WEBKIT_GPU_EXPORT WebGraphicsContext3DImpl ...@@ -48,11 +48,6 @@ class WEBKIT_GPU_EXPORT WebGraphicsContext3DImpl
public: public:
virtual ~WebGraphicsContext3DImpl(); virtual ~WebGraphicsContext3DImpl();
// Must be called before any of the following methods. Permanently binds to
// the first calling thread. Returns false if the graphics context fails to
// initialize. Do not call from more than one thread.
virtual bool InitializeOnCurrentThread() = 0;
//---------------------------------------------------------------------- //----------------------------------------------------------------------
// WebGraphicsContext3D methods // WebGraphicsContext3D methods
......
...@@ -60,8 +60,7 @@ class WEBKIT_GPU_EXPORT WebGraphicsContext3DInProcessCommandBufferImpl ...@@ -60,8 +60,7 @@ class WEBKIT_GPU_EXPORT WebGraphicsContext3DInProcessCommandBufferImpl
size_t GetMappedMemoryLimit(); size_t GetMappedMemoryLimit();
// WebGraphicsContext3DImpl methods bool InitializeOnCurrentThread();
virtual bool InitializeOnCurrentThread() OVERRIDE;
//---------------------------------------------------------------------- //----------------------------------------------------------------------
// WebGraphicsContext3D methods // WebGraphicsContext3D methods
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment