Skip to content

Commit

Permalink
Remove support for WebGraphicsContext3DInProcessImpl.
Browse files Browse the repository at this point in the history
This drops support for the InProcessImpl version from the offscreen
context provider, as well as the compositor context creation methods
for DumpRenderTree.

R=jamesr,piman
BUG=


Review URL: https://chromiumcodereview.appspot.com/12545044

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@189019 0039d316-1c4b-4281-b951-d872f2087c98
  • Loading branch information
danakj@chromium.org committed Mar 19, 2013
1 parent 642b22e commit 85fe98e
Show file tree
Hide file tree
Showing 9 changed files with 39 additions and 135 deletions.
6 changes: 2 additions & 4 deletions cc/test/layer_tree_pixel_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -32,17 +32,15 @@ scoped_ptr<OutputSurface> LayerTreePixelTest::createOutputSurface() {
scoped_refptr<cc::ContextProvider>
LayerTreePixelTest::OffscreenContextProviderForMainThread() {
scoped_refptr<webkit::gpu::ContextProviderInProcess> provider =
webkit::gpu::ContextProviderInProcess::Create(
webkit::gpu::ContextProviderInProcess::IN_PROCESS_COMMAND_BUFFER);
webkit::gpu::ContextProviderInProcess::Create();
CHECK(provider->BindToCurrentThread());
return provider;
}

scoped_refptr<cc::ContextProvider>
LayerTreePixelTest::OffscreenContextProviderForCompositorThread() {
scoped_refptr<webkit::gpu::ContextProviderInProcess> provider =
webkit::gpu::ContextProviderInProcess::Create(
webkit::gpu::ContextProviderInProcess::IN_PROCESS_COMMAND_BUFFER);
webkit::gpu::ContextProviderInProcess::Create();
CHECK(provider);
return provider;
}
Expand Down
3 changes: 1 addition & 2 deletions cc/test/pixel_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,7 @@ void PixelTest::SetUp() {
resource_provider_.get());

scoped_refptr<webkit::gpu::ContextProviderInProcess> offscreen_contexts =
webkit::gpu::ContextProviderInProcess::Create(
webkit::gpu::ContextProviderInProcess::IN_PROCESS_COMMAND_BUFFER);
webkit::gpu::ContextProviderInProcess::Create();
ASSERT_TRUE(offscreen_contexts->BindToCurrentThread());
resource_provider_->set_offscreen_context_provider(offscreen_contexts);
}
Expand Down
58 changes: 16 additions & 42 deletions webkit/gpu/context_provider_in_process.cc
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@
#include "webkit/gpu/context_provider_in_process.h"

#include "webkit/gpu/grcontext_for_webgraphicscontext3d.h"
#include "webkit/gpu/webgraphicscontext3d_in_process_command_buffer_impl.h"
#include "webkit/gpu/webgraphicscontext3d_in_process_impl.h"

namespace webkit {
namespace gpu {
Expand Down Expand Up @@ -45,17 +43,28 @@ class ContextProviderInProcess::MemoryAllocationCallbackProxy
ContextProviderInProcess* provider_;
};

ContextProviderInProcess::ContextProviderInProcess(InProcessType type)
: type_(type),
destroyed_(false) {
ContextProviderInProcess::ContextProviderInProcess()
: destroyed_(false) {
}

ContextProviderInProcess::~ContextProviderInProcess() {}

bool ContextProviderInProcess::InitializeOnMainThread() {
DCHECK(!context3d_);
context3d_ = CreateOffscreenContext3d().Pass();
return !!context3d_;

WebKit::WebGraphicsContext3D::Attributes attributes;
attributes.depth = false;
attributes.stencil = true;
attributes.antialias = false;
attributes.shareResources = true;
attributes.noAutomaticFlushes = true;

context3d_.reset(
new webkit::gpu::WebGraphicsContext3DInProcessCommandBufferImpl());
if (!context3d_->Initialize(attributes, NULL))
context3d_.reset();

return context3d_;
}

bool ContextProviderInProcess::BindToCurrentThread() {
Expand Down Expand Up @@ -121,40 +130,5 @@ void ContextProviderInProcess::OnMemoryAllocationChanged(
gr_context_->SetMemoryLimit(nonzero_allocation);
}

static scoped_ptr<WebKit::WebGraphicsContext3D> CreateInProcessImpl(
const WebKit::WebGraphicsContext3D::Attributes& attributes) {
return make_scoped_ptr(
webkit::gpu::WebGraphicsContext3DInProcessImpl::CreateForWebView(
attributes, false)).PassAs<WebKit::WebGraphicsContext3D>();
}

static scoped_ptr<WebKit::WebGraphicsContext3D> CreateCommandBufferImpl(
const WebKit::WebGraphicsContext3D::Attributes& attributes) {
scoped_ptr<webkit::gpu::WebGraphicsContext3DInProcessCommandBufferImpl> ctx(
new webkit::gpu::WebGraphicsContext3DInProcessCommandBufferImpl());
if (!ctx->Initialize(attributes, NULL))
return scoped_ptr<WebKit::WebGraphicsContext3D>();
return ctx.PassAs<WebKit::WebGraphicsContext3D>();
}

scoped_ptr<WebKit::WebGraphicsContext3D>
ContextProviderInProcess::CreateOffscreenContext3d() {
WebKit::WebGraphicsContext3D::Attributes attributes;
attributes.depth = false;
attributes.stencil = true;
attributes.antialias = false;
attributes.shareResources = true;
attributes.noAutomaticFlushes = true;

switch (type_) {
case IN_PROCESS:
return CreateInProcessImpl(attributes).Pass();
case IN_PROCESS_COMMAND_BUFFER:
return CreateCommandBufferImpl(attributes).Pass();
}
NOTREACHED();
return CreateInProcessImpl(attributes).Pass();
}

} // namespace gpu
} // namespace webkit
17 changes: 6 additions & 11 deletions webkit/gpu/context_provider_in_process.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#include "base/memory/scoped_ptr.h"
#include "base/synchronization/lock.h"
#include "cc/output/context_provider.h"
#include "webkit/gpu/webgraphicscontext3d_in_process_command_buffer_impl.h"
#include "webkit/gpu/webkit_gpu_export.h"

namespace webkit {
Expand All @@ -18,13 +19,9 @@ class GrContextForWebGraphicsContext3D;
class WEBKIT_GPU_EXPORT ContextProviderInProcess
: NON_EXPORTED_BASE(public cc::ContextProvider) {
public:
enum InProcessType {
IN_PROCESS,
IN_PROCESS_COMMAND_BUFFER,
};
static scoped_refptr<ContextProviderInProcess> Create(InProcessType type) {
static scoped_refptr<ContextProviderInProcess> Create() {
scoped_refptr<ContextProviderInProcess> provider =
new ContextProviderInProcess(type);
new ContextProviderInProcess;
if (!provider->InitializeOnMainThread())
return NULL;
return provider;
Expand All @@ -37,20 +34,18 @@ class WEBKIT_GPU_EXPORT ContextProviderInProcess
virtual bool DestroyedOnMainThread() OVERRIDE;

protected:
explicit ContextProviderInProcess(InProcessType type);
ContextProviderInProcess();
virtual ~ContextProviderInProcess();

bool InitializeOnMainThread();

scoped_ptr<WebKit::WebGraphicsContext3D> CreateOffscreenContext3d();

void OnLostContextInternal();
virtual void OnLostContext() {}
virtual void OnMemoryAllocationChanged(bool nonzero_allocation);

private:
InProcessType type_;
scoped_ptr<WebKit::WebGraphicsContext3D> context3d_;
scoped_ptr<webkit::gpu::WebGraphicsContext3DInProcessCommandBufferImpl>
context3d_;
scoped_ptr<webkit::gpu::GrContextForWebGraphicsContext3D> gr_context_;

base::Lock destroyed_lock_;
Expand Down
29 changes: 3 additions & 26 deletions webkit/gpu/test_context_provider_factory.cc
Original file line number Diff line number Diff line change
Expand Up @@ -14,29 +14,8 @@ namespace gpu {
#ifndef NDEBUG
static bool factory_set_up = false;
#endif
static ContextProviderInProcess::InProcessType context_provider_type;
static TestContextProviderFactory* context_provider_instance = NULL;

// static
void TestContextProviderFactory::SetUpFactoryForTesting(
webkit_support::GraphicsContext3DImplementation implementation) {
#ifndef NDEBUG
factory_set_up = true;
#endif

switch (implementation) {
case webkit_support::IN_PROCESS:
context_provider_type = webkit::gpu::ContextProviderInProcess::IN_PROCESS;
return;
case webkit_support::IN_PROCESS_COMMAND_BUFFER:
context_provider_type =
webkit::gpu::ContextProviderInProcess::IN_PROCESS_COMMAND_BUFFER;
return;
}
NOTREACHED();
context_provider_type = webkit::gpu::ContextProviderInProcess::IN_PROCESS;
}

// static
TestContextProviderFactory* TestContextProviderFactory::GetInstance() {
#ifndef NDEBUG
Expand All @@ -54,7 +33,7 @@ TestContextProviderFactory::~TestContextProviderFactory() {}
scoped_refptr<cc::ContextProvider> TestContextProviderFactory::
OffscreenContextProviderForMainThread() {
if (!main_thread_ || main_thread_->DestroyedOnMainThread()) {
main_thread_ = ContextProviderInProcess::Create(context_provider_type);
main_thread_ = ContextProviderInProcess::Create();
if (main_thread_ && !main_thread_->BindToCurrentThread())
main_thread_ = NULL;
}
Expand All @@ -64,10 +43,8 @@ scoped_refptr<cc::ContextProvider> TestContextProviderFactory::
scoped_refptr<cc::ContextProvider> TestContextProviderFactory::
OffscreenContextProviderForCompositorThread() {
if (!compositor_thread_ ||
compositor_thread_->DestroyedOnMainThread()) {
compositor_thread_ = ContextProviderInProcess::Create(
context_provider_type);
}
compositor_thread_->DestroyedOnMainThread())
compositor_thread_ = ContextProviderInProcess::Create();
return compositor_thread_;
}

Expand Down
4 changes: 0 additions & 4 deletions webkit/gpu/test_context_provider_factory.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,6 @@ class ContextProviderInProcess;

class WEBKIT_GPU_EXPORT TestContextProviderFactory {
public:
static void SetUpFactoryForTesting(
webkit_support::GraphicsContext3DImplementation implementation);

// SetUpFactoryForTesting() must be called before GetInstance can be called.
// The returned pointer is static and should not be deleted by the caller.
static TestContextProviderFactory* GetInstance();

Expand Down
21 changes: 6 additions & 15 deletions webkit/support/test_webkit_platform_support.cc
Original file line number Diff line number Diff line change
Expand Up @@ -373,21 +373,12 @@ WebKit::WebThemeEngine* TestWebKitPlatformSupport::themeEngine() {
WebKit::WebGraphicsContext3D*
TestWebKitPlatformSupport::createOffscreenGraphicsContext3D(
const WebKit::WebGraphicsContext3D::Attributes& attributes) {
switch (webkit_support::GetGraphicsContext3DImplementation()) {
case webkit_support::IN_PROCESS:
return webkit::gpu::WebGraphicsContext3DInProcessImpl::CreateForWebView(
attributes, false);
case webkit_support::IN_PROCESS_COMMAND_BUFFER: {
scoped_ptr<webkit::gpu::WebGraphicsContext3DInProcessCommandBufferImpl>
context(new
webkit::gpu::WebGraphicsContext3DInProcessCommandBufferImpl());
if (!context->Initialize(attributes, NULL))
return NULL;
return context.release();
}
}
NOTREACHED();
return NULL;
using webkit::gpu::WebGraphicsContext3DInProcessCommandBufferImpl;
scoped_ptr<WebGraphicsContext3DInProcessCommandBufferImpl> context(
new WebGraphicsContext3DInProcessCommandBufferImpl());
if (!context->Initialize(attributes, NULL))
return NULL;
return context.release();
}

WebKit::WebGraphicsContext3D*
Expand Down
33 changes: 5 additions & 28 deletions webkit/support/webkit_support.cc
Original file line number Diff line number Diff line change
Expand Up @@ -305,10 +305,6 @@ class WebKitClientMessageLoopImpl
MessageLoop* message_loop_;
};

webkit_support::GraphicsContext3DImplementation
g_graphics_context_3d_implementation =
webkit_support::IN_PROCESS_COMMAND_BUFFER;

TestEnvironment* test_environment;

void SetUpTestEnvironmentImpl(bool unit_test_mode,
Expand Down Expand Up @@ -497,35 +493,16 @@ void SetUpGLBindings(GLBindingPreferences bindingPref) {
default:
NOTREACHED();
}
webkit::gpu::TestContextProviderFactory::SetUpFactoryForTesting(
g_graphics_context_3d_implementation);
}

void SetGraphicsContext3DImplementation(GraphicsContext3DImplementation impl) {
g_graphics_context_3d_implementation = impl;
}

GraphicsContext3DImplementation GetGraphicsContext3DImplementation() {
return g_graphics_context_3d_implementation;
}

WebKit::WebGraphicsContext3D* CreateGraphicsContext3D(
const WebKit::WebGraphicsContext3D::Attributes& attributes,
WebKit::WebView* web_view) {
switch (webkit_support::GetGraphicsContext3DImplementation()) {
case webkit_support::IN_PROCESS:
return WebGraphicsContext3DInProcessImpl::CreateForWebView(
attributes, true /* direct */);
case webkit_support::IN_PROCESS_COMMAND_BUFFER: {
scoped_ptr<WebGraphicsContext3DInProcessCommandBufferImpl> context(
new WebGraphicsContext3DInProcessCommandBufferImpl());
if (!context->Initialize(attributes, NULL))
return NULL;
return context.release();
}
}
NOTREACHED();
return NULL;
scoped_ptr<WebGraphicsContext3DInProcessCommandBufferImpl> context(
new WebGraphicsContext3DInProcessCommandBufferImpl());
if (!context->Initialize(attributes, NULL))
return NULL;
return context.release();
}

WebKit::WebLayerTreeView* CreateLayerTreeView(
Expand Down
3 changes: 0 additions & 3 deletions webkit/support/webkit_support.h
Original file line number Diff line number Diff line change
Expand Up @@ -125,9 +125,6 @@ enum GraphicsContext3DImplementation {
IN_PROCESS,
IN_PROCESS_COMMAND_BUFFER
};
// Registers which GraphicsContext3D Implementation to use.
void SetGraphicsContext3DImplementation(GraphicsContext3DImplementation);
GraphicsContext3DImplementation GetGraphicsContext3DImplementation();

WebKit::WebGraphicsContext3D* CreateGraphicsContext3D(
const WebKit::WebGraphicsContext3D::Attributes& attributes,
Expand Down

0 comments on commit 85fe98e

Please sign in to comment.