summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--cc/cc.gyp2
-rw-r--r--cc/cc_tests.gyp2
-rw-r--r--cc/debug/fake_context_provider.cc (renamed from cc/test/fake_context_provider.cc)14
-rw-r--r--cc/debug/fake_context_provider.h (renamed from cc/test/fake_context_provider.h)15
-rw-r--r--cc/layers/texture_layer_unittest.cc2
-rw-r--r--cc/test/fake_layer_tree_host_client.cc7
-rw-r--r--cc/test/fake_layer_tree_host_client.h4
-rw-r--r--cc/test/layer_tree_test.cc8
-rw-r--r--cc/test/layer_tree_test.h2
-rw-r--r--cc/test/test_web_graphics_context_3d.cc22
-rw-r--r--cc/test/test_web_graphics_context_3d.h19
-rw-r--r--cc/trees/layer_tree_host_unittest_context.cc10
-rw-r--r--content/browser/aura/gpu_process_transport_factory.cc6
-rw-r--r--content/browser/aura/gpu_process_transport_factory.h14
-rw-r--r--ui/aura/bench/DEPS1
-rw-r--r--ui/aura/bench/bench_main.cc38
-rw-r--r--ui/compositor/compositor.cc66
-rw-r--r--ui/compositor/compositor.gyp2
-rw-r--r--ui/compositor/compositor.h31
-rw-r--r--ui/compositor/context_provider_from_context_factory.cc76
-rw-r--r--ui/compositor/context_provider_from_context_factory.h45
21 files changed, 138 insertions, 248 deletions
diff --git a/cc/cc.gyp b/cc/cc.gyp
index 78060a4..11353ff 100644
--- a/cc/cc.gyp
+++ b/cc/cc.gyp
@@ -71,6 +71,8 @@
'debug/debug_rect_history.cc',
'debug/debug_rect_history.h',
'debug/devtools_instrumentation.h',
+ 'debug/fake_context_provider.cc',
+ 'debug/fake_context_provider.h',
'debug/fake_web_graphics_context_3d.cc',
'debug/fake_web_graphics_context_3d.h',
'debug/frame_rate_counter.cc',
diff --git a/cc/cc_tests.gyp b/cc/cc_tests.gyp
index 7e2ff87..7256836 100644
--- a/cc/cc_tests.gyp
+++ b/cc/cc_tests.gyp
@@ -100,8 +100,6 @@
'test/fake_content_layer_client.h',
'test/fake_content_layer_impl.cc',
'test/fake_content_layer_impl.h',
- 'test/fake_context_provider.cc',
- 'test/fake_context_provider.h',
'test/fake_delegated_renderer_layer.cc',
'test/fake_delegated_renderer_layer.h',
'test/fake_delegated_renderer_layer_impl.cc',
diff --git a/cc/test/fake_context_provider.cc b/cc/debug/fake_context_provider.cc
index d49fa89..e2c78df 100644
--- a/cc/test/fake_context_provider.cc
+++ b/cc/debug/fake_context_provider.cc
@@ -2,9 +2,10 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "cc/test/fake_context_provider.h"
+#include "cc/debug/fake_context_provider.h"
-#include "cc/test/test_web_graphics_context_3d.h"
+#include "base/logging.h"
+#include "third_party/WebKit/public/platform/WebGraphicsContext3D.h"
namespace cc {
@@ -25,10 +26,8 @@ bool FakeContextProvider::InitializeOnMainThread(
DCHECK(main_thread_checker_.CalledOnValidThread());
DCHECK(!context3d_);
- if (create_callback.is_null())
- context3d_ = TestWebGraphicsContext3D::Create().Pass();
- else
- context3d_ = create_callback.Run();
+ DCHECK(!create_callback.is_null());
+ context3d_ = create_callback.Run();
return context3d_;
}
@@ -57,12 +56,13 @@ WebKit::WebGraphicsContext3D* FakeContextProvider::Context3d() {
return context3d_.get();
}
+
class GrContext* FakeContextProvider::GrContext() {
DCHECK(context3d_);
DCHECK(bound_);
DCHECK(context_thread_checker_.CalledOnValidThread());
- // TODO(danakj): Make a fake GrContext.
+ // TODO(danakj): Make a fake GrContext that works with a fake Context3d.
return NULL;
}
diff --git a/cc/test/fake_context_provider.h b/cc/debug/fake_context_provider.h
index 4a18e4a..37311e1 100644
--- a/cc/test/fake_context_provider.h
+++ b/cc/debug/fake_context_provider.h
@@ -2,21 +2,24 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#ifndef CC_TEST_FAKE_CONTEXT_PROVIDER_H_
-#define CC_TEST_FAKE_CONTEXT_PROVIDER_H_
+#ifndef CC_DEBUG_FAKE_CONTEXT_PROVIDER_H_
+#define CC_DEBUG_FAKE_CONTEXT_PROVIDER_H_
#include "base/callback.h"
#include "base/memory/scoped_ptr.h"
#include "base/synchronization/lock.h"
#include "base/threading/thread_checker.h"
+#include "cc/base/cc_export.h"
#include "cc/output/context_provider.h"
+namespace WebKit { class WebGraphicsContext3D; }
+
namespace cc {
-class TestWebGraphicsContext3D;
-class FakeContextProvider : public cc::ContextProvider {
+class CC_EXPORT FakeContextProvider
+ : public NON_EXPORTED_BASE(cc::ContextProvider) {
public:
- typedef base::Callback<scoped_ptr<TestWebGraphicsContext3D>(void)>
+ typedef base::Callback<scoped_ptr<WebKit::WebGraphicsContext3D>(void)>
CreateCallback;
static scoped_refptr<FakeContextProvider> Create() {
@@ -56,5 +59,5 @@ class FakeContextProvider : public cc::ContextProvider {
} // namespace cc
-#endif // CC_TEST_FAKE_CONTEXT_PROVIDER_H_
+#endif // CC_DEBUG_FAKE_CONTEXT_PROVIDER_H_
diff --git a/cc/layers/texture_layer_unittest.cc b/cc/layers/texture_layer_unittest.cc
index aa08e9f..1635591 100644
--- a/cc/layers/texture_layer_unittest.cc
+++ b/cc/layers/texture_layer_unittest.cc
@@ -12,8 +12,10 @@
#include "cc/test/fake_impl_proxy.h"
#include "cc/test/fake_layer_tree_host_client.h"
#include "cc/test/fake_layer_tree_host_impl.h"
+#include "cc/test/fake_output_surface.h"
#include "cc/test/layer_test_common.h"
#include "cc/test/layer_tree_test.h"
+#include "cc/test/test_web_graphics_context_3d.h"
#include "cc/trees/layer_tree_host.h"
#include "cc/trees/layer_tree_impl.h"
#include "cc/trees/single_thread_proxy.h"
diff --git a/cc/test/fake_layer_tree_host_client.cc b/cc/test/fake_layer_tree_host_client.cc
index 40dabe3..d0a1954 100644
--- a/cc/test/fake_layer_tree_host_client.cc
+++ b/cc/test/fake_layer_tree_host_client.cc
@@ -5,6 +5,7 @@
#include "cc/test/fake_layer_tree_host_client.h"
#include "cc/output/context_provider.h"
+#include "cc/test/fake_output_surface.h"
#include "cc/test/test_web_graphics_context_3d.h"
namespace cc {
@@ -39,7 +40,8 @@ scoped_refptr<cc::ContextProvider> FakeLayerTreeHostClient::
OffscreenContextProviderForMainThread() {
if (!main_thread_contexts_.get() ||
main_thread_contexts_->DestroyedOnMainThread()) {
- main_thread_contexts_ = FakeContextProvider::Create();
+ main_thread_contexts_ = FakeContextProvider::Create(
+ TestWebGraphicsContext3D::CreateBaseFactory());
if (!main_thread_contexts_->BindToCurrentThread())
main_thread_contexts_ = NULL;
}
@@ -50,7 +52,8 @@ scoped_refptr<cc::ContextProvider> FakeLayerTreeHostClient::
OffscreenContextProviderForCompositorThread() {
if (!compositor_thread_contexts_.get() ||
compositor_thread_contexts_->DestroyedOnMainThread())
- compositor_thread_contexts_ = FakeContextProvider::Create();
+ compositor_thread_contexts_ = FakeContextProvider::Create(
+ TestWebGraphicsContext3D::CreateBaseFactory());
return compositor_thread_contexts_;
}
diff --git a/cc/test/fake_layer_tree_host_client.h b/cc/test/fake_layer_tree_host_client.h
index 5c174eb..807a727 100644
--- a/cc/test/fake_layer_tree_host_client.h
+++ b/cc/test/fake_layer_tree_host_client.h
@@ -6,12 +6,12 @@
#define CC_TEST_FAKE_LAYER_TREE_HOST_CLIENT_H_
#include "base/memory/scoped_ptr.h"
+#include "cc/debug/fake_context_provider.h"
#include "cc/input/input_handler.h"
-#include "cc/test/fake_context_provider.h"
-#include "cc/test/fake_output_surface.h"
#include "cc/trees/layer_tree_host.h"
namespace cc {
+class OutputSurface;
class FakeLayerTreeHostClient : public LayerTreeHostClient {
public:
diff --git a/cc/test/layer_tree_test.cc b/cc/test/layer_tree_test.cc
index 224e2cf..71ea856 100644
--- a/cc/test/layer_tree_test.cc
+++ b/cc/test/layer_tree_test.cc
@@ -10,12 +10,12 @@
#include "cc/animation/layer_animation_controller.h"
#include "cc/animation/timing_function.h"
#include "cc/base/switches.h"
+#include "cc/debug/fake_context_provider.h"
#include "cc/input/input_handler.h"
#include "cc/layers/content_layer.h"
#include "cc/layers/layer.h"
#include "cc/layers/layer_impl.h"
#include "cc/test/animation_test_common.h"
-#include "cc/test/fake_context_provider.h"
#include "cc/test/fake_layer_tree_host_client.h"
#include "cc/test/fake_output_surface.h"
#include "cc/test/occlusion_tracker_test_common.h"
@@ -615,7 +615,8 @@ scoped_refptr<cc::ContextProvider> LayerTreeTest::
OffscreenContextProviderForMainThread() {
if (!main_thread_contexts_.get() ||
main_thread_contexts_->DestroyedOnMainThread()) {
- main_thread_contexts_ = FakeContextProvider::Create();
+ main_thread_contexts_ = FakeContextProvider::Create(
+ TestWebGraphicsContext3D::CreateBaseFactory());
if (!main_thread_contexts_->BindToCurrentThread())
main_thread_contexts_ = NULL;
}
@@ -626,7 +627,8 @@ scoped_refptr<cc::ContextProvider> LayerTreeTest::
OffscreenContextProviderForCompositorThread() {
if (!compositor_thread_contexts_.get() ||
compositor_thread_contexts_->DestroyedOnMainThread())
- compositor_thread_contexts_ = FakeContextProvider::Create();
+ compositor_thread_contexts_ = FakeContextProvider::Create(
+ TestWebGraphicsContext3D::CreateBaseFactory());
return compositor_thread_contexts_;
}
diff --git a/cc/test/layer_tree_test.h b/cc/test/layer_tree_test.h
index fd46acc..7843577 100644
--- a/cc/test/layer_tree_test.h
+++ b/cc/test/layer_tree_test.h
@@ -17,11 +17,11 @@ namespace Webkit { class WebGraphicsContext3D; }
namespace cc {
class FakeContextProvider;
class FakeLayerTreeHostClient;
+class FakeOutputSurface;
class LayerImpl;
class LayerTreeHost;
class LayerTreeHostClient;
class LayerTreeHostImpl;
-class FakeOutputSurface;
// Used by test stubs to notify the test when something interesting happens.
class TestHooks : public AnimationDelegate {
diff --git a/cc/test/test_web_graphics_context_3d.cc b/cc/test/test_web_graphics_context_3d.cc
index 7e82612..e68f938 100644
--- a/cc/test/test_web_graphics_context_3d.cc
+++ b/cc/test/test_web_graphics_context_3d.cc
@@ -54,6 +54,28 @@ TestWebGraphicsContext3D::Namespace::~Namespace() {
shared_namespace_ = NULL;
}
+// static
+scoped_ptr<TestWebGraphicsContext3D> TestWebGraphicsContext3D::Create() {
+ return make_scoped_ptr(new TestWebGraphicsContext3D());
+}
+
+// static
+base::Callback<scoped_ptr<TestWebGraphicsContext3D>()>
+TestWebGraphicsContext3D::CreateFactory() {
+ return base::Bind(&TestWebGraphicsContext3D::Create);
+}
+
+static scoped_ptr<WebKit::WebGraphicsContext3D> CreateBaseFactory() {
+ return scoped_ptr<WebKit::WebGraphicsContext3D>(
+ TestWebGraphicsContext3D::Create());
+}
+
+// static
+base::Callback<scoped_ptr<WebKit::WebGraphicsContext3D>()>
+TestWebGraphicsContext3D::CreateBaseFactory() {
+ return base::Bind(&cc::CreateBaseFactory);
+}
+
TestWebGraphicsContext3D::TestWebGraphicsContext3D()
: FakeWebGraphicsContext3D(),
context_id_(s_context_id++),
diff --git a/cc/test/test_web_graphics_context_3d.h b/cc/test/test_web_graphics_context_3d.h
index b182fe6..fb278ef 100644
--- a/cc/test/test_web_graphics_context_3d.h
+++ b/cc/test/test_web_graphics_context_3d.h
@@ -7,6 +7,7 @@
#include <vector>
+#include "base/callback.h"
#include "base/compiler_specific.h"
#include "base/containers/hash_tables.h"
#include "base/memory/ref_counted.h"
@@ -18,19 +19,21 @@
#include "cc/debug/fake_web_graphics_context_3d.h"
#include "third_party/khronos/GLES2/gl2.h"
-namespace WebKit { struct WebGraphicsMemoryAllocation; }
+namespace WebKit {
+class WebGraphicsContext3D;
+struct WebGraphicsMemoryAllocation;
+}
namespace cc {
class TestWebGraphicsContext3D : public FakeWebGraphicsContext3D {
public:
- static scoped_ptr<TestWebGraphicsContext3D> Create() {
- return make_scoped_ptr(new TestWebGraphicsContext3D());
- }
- static scoped_ptr<TestWebGraphicsContext3D> Create(
- const WebKit::WebGraphicsContext3D::Attributes& attributes) {
- return make_scoped_ptr(new TestWebGraphicsContext3D(attributes));
- }
+ static scoped_ptr<TestWebGraphicsContext3D> Create();
+ static base::Callback<
+ scoped_ptr<TestWebGraphicsContext3D>()> CreateFactory();
+ static base::Callback<
+ scoped_ptr<WebKit::WebGraphicsContext3D>()> CreateBaseFactory();
+
virtual ~TestWebGraphicsContext3D();
virtual bool makeContextCurrent();
diff --git a/cc/trees/layer_tree_host_unittest_context.cc b/cc/trees/layer_tree_host_unittest_context.cc
index 1787d31..4384369 100644
--- a/cc/trees/layer_tree_host_unittest_context.cc
+++ b/cc/trees/layer_tree_host_unittest_context.cc
@@ -5,6 +5,7 @@
#include "cc/trees/layer_tree_host.h"
#include "base/basictypes.h"
+#include "cc/debug/fake_context_provider.h"
#include "cc/layers/content_layer.h"
#include "cc/layers/heads_up_display_layer.h"
#include "cc/layers/io_surface_layer.h"
@@ -19,7 +20,6 @@
#include "cc/test/fake_content_layer.h"
#include "cc/test/fake_content_layer_client.h"
#include "cc/test/fake_content_layer_impl.h"
-#include "cc/test/fake_context_provider.h"
#include "cc/test/fake_delegated_renderer_layer.h"
#include "cc/test/fake_delegated_renderer_layer_impl.h"
#include "cc/test/fake_layer_tree_host_client.h"
@@ -115,16 +115,16 @@ class LayerTreeHostContextTest : public LayerTreeTest {
context3d.PassAs<WebGraphicsContext3D>()).PassAs<OutputSurface>();
}
- scoped_ptr<TestWebGraphicsContext3D> CreateOffscreenContext3d() {
+ scoped_ptr<WebKit::WebGraphicsContext3D> CreateOffscreenContext3d() {
if (!context3d_)
- return scoped_ptr<TestWebGraphicsContext3D>();
+ return scoped_ptr<WebKit::WebGraphicsContext3D>();
++times_offscreen_created_;
if (times_to_fail_create_offscreen_) {
--times_to_fail_create_offscreen_;
ExpectCreateToFail();
- return scoped_ptr<TestWebGraphicsContext3D>();
+ return scoped_ptr<WebKit::WebGraphicsContext3D>();
}
scoped_ptr<TestWebGraphicsContext3D> offscreen_context3d =
@@ -132,7 +132,7 @@ class LayerTreeHostContextTest : public LayerTreeTest {
DCHECK(offscreen_context3d);
context3d_->add_share_group_context(offscreen_context3d.get());
- return offscreen_context3d.Pass();
+ return offscreen_context3d.PassAs<WebKit::WebGraphicsContext3D>();
}
virtual scoped_refptr<cc::ContextProvider>
diff --git a/content/browser/aura/gpu_process_transport_factory.cc b/content/browser/aura/gpu_process_transport_factory.cc
index 47b1533..eeb6f3b 100644
--- a/content/browser/aura/gpu_process_transport_factory.cc
+++ b/content/browser/aura/gpu_process_transport_factory.cc
@@ -199,12 +199,6 @@ GpuProcessTransportFactory::CreateOffscreenCommandBufferContext() {
return CreateContextCommon(swap_client, 0);
}
-scoped_ptr<WebKit::WebGraphicsContext3D>
-GpuProcessTransportFactory::CreateOffscreenContext() {
- return CreateOffscreenCommandBufferContext()
- .PassAs<WebKit::WebGraphicsContext3D>();
-}
-
scoped_ptr<cc::SoftwareOutputDevice> CreateSoftwareOutputDevice(
ui::Compositor* compositor) {
#if defined(OS_WIN)
diff --git a/content/browser/aura/gpu_process_transport_factory.h b/content/browser/aura/gpu_process_transport_factory.h
index 72b88d5..56d3e55 100644
--- a/content/browser/aura/gpu_process_transport_factory.h
+++ b/content/browser/aura/gpu_process_transport_factory.h
@@ -35,9 +35,7 @@ class GpuProcessTransportFactory
scoped_ptr<WebGraphicsContext3DCommandBufferImpl>
CreateOffscreenCommandBufferContext();
- // ContextFactory implementation.
- virtual scoped_ptr<WebKit::WebGraphicsContext3D> CreateOffscreenContext()
- OVERRIDE;
+ // ui::ContextFactory implementation.
virtual scoped_ptr<cc::OutputSurface> CreateOutputSurface(
ui::Compositor* compositor) OVERRIDE;
virtual scoped_refptr<ui::Reflector> CreateReflector(
@@ -46,6 +44,10 @@ class GpuProcessTransportFactory
virtual void RemoveReflector(
scoped_refptr<ui::Reflector> reflector) OVERRIDE;
virtual void RemoveCompositor(ui::Compositor* compositor) OVERRIDE;
+ virtual scoped_refptr<cc::ContextProvider>
+ OffscreenContextProviderForMainThread() OVERRIDE;
+ virtual scoped_refptr<cc::ContextProvider>
+ OffscreenContextProviderForCompositorThread() OVERRIDE;
virtual bool DoesCreateTestContexts() OVERRIDE;
// ImageTransportFactory implementation.
@@ -66,12 +68,6 @@ class GpuProcessTransportFactory
virtual void RemoveObserver(
ImageTransportFactoryObserver* observer) OVERRIDE;
- // ui::ContextFactory implementation.
- virtual scoped_refptr<cc::ContextProvider>
- OffscreenContextProviderForMainThread() OVERRIDE;
- virtual scoped_refptr<cc::ContextProvider>
- OffscreenContextProviderForCompositorThread() OVERRIDE;
-
void OnLostContext(ui::Compositor* compositor);
private:
diff --git a/ui/aura/bench/DEPS b/ui/aura/bench/DEPS
index 69deb97..1fda554 100644
--- a/ui/aura/bench/DEPS
+++ b/ui/aura/bench/DEPS
@@ -1,4 +1,5 @@
include_rules = [
+ "+cc",
"+third_party/khronos",
"+third_party/WebKit/public/platform",
]
diff --git a/ui/aura/bench/bench_main.cc b/ui/aura/bench/bench_main.cc
index aee7e79..17ed068 100644
--- a/ui/aura/bench/bench_main.cc
+++ b/ui/aura/bench/bench_main.cc
@@ -10,6 +10,7 @@
#include "base/message_loop/message_loop.h"
#include "base/strings/string_split.h"
#include "base/time/time.h"
+#include "cc/output/context_provider.h"
#include "third_party/khronos/GLES2/gl2.h"
#include "third_party/skia/include/core/SkXfermode.h"
#include "ui/aura/client/default_capture_client.h"
@@ -181,7 +182,7 @@ class WebGLBench : public BenchCompositorObserver {
parent_(parent),
webgl_(ui::LAYER_TEXTURED),
compositor_(compositor),
- context_(),
+ context_provider_(),
texture_(),
fbo_(0),
do_draw_(true) {
@@ -207,24 +208,26 @@ class WebGLBench : public BenchCompositorObserver {
webgl_.SetBounds(bounds);
parent_->Add(&webgl_);
- context_ = ui::ContextFactory::GetInstance()->CreateOffscreenContext();
- context_->makeContextCurrent();
- texture_ = new WebGLTexture(context_.get(), bounds.size());
- fbo_ = context_->createFramebuffer();
+ context_provider_ = ui::ContextFactory::GetInstance()
+ ->OffscreenContextProviderForMainThread();
+ WebKit::WebGraphicsContext3D* context = context_provider_->Context3d();
+ context->makeContextCurrent();
+ texture_ = new WebGLTexture(context, bounds.size());
+ fbo_ = context->createFramebuffer();
compositor->AddObserver(this);
webgl_.SetExternalTexture(texture_.get());
- context_->bindFramebuffer(GL_FRAMEBUFFER, fbo_);
- context_->framebufferTexture2D(
+ context->bindFramebuffer(GL_FRAMEBUFFER, fbo_);
+ context->framebufferTexture2D(
GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0,
GL_TEXTURE_2D, texture_->PrepareTexture(), 0);
- context_->clearColor(0.f, 1.f, 0.f, 1.f);
- context_->clear(GL_COLOR_BUFFER_BIT);
- context_->flush();
+ context->clearColor(0.f, 1.f, 0.f, 1.f);
+ context->clear(GL_COLOR_BUFFER_BIT);
+ context->flush();
}
virtual ~WebGLBench() {
- context_->makeContextCurrent();
- context_->deleteFramebuffer(fbo_);
+ context_provider_->Context3d()->makeContextCurrent();
+ context_provider_->Context3d()->deleteFramebuffer(fbo_);
webgl_.SetExternalTexture(NULL);
texture_ = NULL;
compositor_->RemoveObserver(this);
@@ -232,10 +235,11 @@ class WebGLBench : public BenchCompositorObserver {
virtual void Draw() OVERRIDE {
if (do_draw_) {
- context_->makeContextCurrent();
- context_->clearColor((frames() % kFrames)*1.0/kFrames, 1.f, 0.f, 1.f);
- context_->clear(GL_COLOR_BUFFER_BIT);
- context_->flush();
+ WebKit::WebGraphicsContext3D* context = context_provider_->Context3d();
+ context->makeContextCurrent();
+ context->clearColor((frames() % kFrames)*1.0/kFrames, 1.f, 0.f, 1.f);
+ context->clear(GL_COLOR_BUFFER_BIT);
+ context->flush();
}
webgl_.SetExternalTexture(texture_.get());
webgl_.SchedulePaint(gfx::Rect(webgl_.bounds().size()));
@@ -246,7 +250,7 @@ class WebGLBench : public BenchCompositorObserver {
Layer* parent_;
Layer webgl_;
Compositor* compositor_;
- scoped_ptr<WebGraphicsContext3D> context_;
+ scoped_refptr<cc::ContextProvider> context_provider_;
scoped_refptr<WebGLTexture> texture_;
// The FBO that is used to render to the texture.
diff --git a/ui/compositor/compositor.cc b/ui/compositor/compositor.cc
index 5739bbf..6defa97 100644
--- a/ui/compositor/compositor.cc
+++ b/ui/compositor/compositor.cc
@@ -16,6 +16,7 @@
#include "base/threading/thread.h"
#include "base/threading/thread_restrictions.h"
#include "cc/base/switches.h"
+#include "cc/debug/fake_context_provider.h"
#include "cc/input/input_handler.h"
#include "cc/layers/layer.h"
#include "cc/output/context_provider.h"
@@ -24,7 +25,6 @@
#include "third_party/skia/include/core/SkBitmap.h"
#include "ui/compositor/compositor_observer.h"
#include "ui/compositor/compositor_switches.h"
-#include "ui/compositor/context_provider_from_context_factory.h"
#include "ui/compositor/dip_util.h"
#include "ui/compositor/layer.h"
#include "ui/compositor/reflector.h"
@@ -33,6 +33,7 @@
#include "ui/gl/gl_implementation.h"
#include "ui/gl/gl_surface.h"
#include "ui/gl/gl_switches.h"
+#include "webkit/common/gpu/context_provider_in_process.h"
#include "webkit/common/gpu/grcontext_for_webgraphicscontext3d.h"
#include "webkit/common/gpu/webgraphicscontext3d_in_process_command_buffer_impl.h"
@@ -108,13 +109,17 @@ bool DefaultContextFactory::Initialize() {
scoped_ptr<cc::OutputSurface> DefaultContextFactory::CreateOutputSurface(
Compositor* compositor) {
- return make_scoped_ptr(new cc::OutputSurface(
- CreateContextCommon(compositor, false)));
-}
+ WebKit::WebGraphicsContext3D::Attributes attrs;
+ attrs.depth = false;
+ attrs.stencil = false;
+ attrs.antialias = false;
+ attrs.shareResources = true;
-scoped_ptr<WebKit::WebGraphicsContext3D>
-DefaultContextFactory::CreateOffscreenContext() {
- return CreateContextCommon(NULL, true);
+ using webkit::gpu::WebGraphicsContext3DInProcessCommandBufferImpl;
+ scoped_ptr<WebKit::WebGraphicsContext3D> context(
+ WebGraphicsContext3DInProcessCommandBufferImpl::CreateViewContext(
+ attrs, compositor->widget()));
+ return make_scoped_ptr(new cc::OutputSurface(context.Pass()));
}
scoped_refptr<Reflector> DefaultContextFactory::CreateReflector(
@@ -132,7 +137,7 @@ DefaultContextFactory::OffscreenContextProviderForMainThread() {
if (!offscreen_contexts_main_thread_.get() ||
!offscreen_contexts_main_thread_->DestroyedOnMainThread()) {
offscreen_contexts_main_thread_ =
- ContextProviderFromContextFactory::CreateForOffscreen(this);
+ webkit::gpu::ContextProviderInProcess::Create();
if (offscreen_contexts_main_thread_.get() &&
!offscreen_contexts_main_thread_->BindToCurrentThread())
offscreen_contexts_main_thread_ = NULL;
@@ -145,7 +150,7 @@ DefaultContextFactory::OffscreenContextProviderForCompositorThread() {
if (!offscreen_contexts_compositor_thread_.get() ||
!offscreen_contexts_compositor_thread_->DestroyedOnMainThread()) {
offscreen_contexts_compositor_thread_ =
- ContextProviderFromContextFactory::CreateForOffscreen(this);
+ webkit::gpu::ContextProviderInProcess::Create();
}
return offscreen_contexts_compositor_thread_;
}
@@ -155,24 +160,6 @@ void DefaultContextFactory::RemoveCompositor(Compositor* compositor) {
bool DefaultContextFactory::DoesCreateTestContexts() { return false; }
-scoped_ptr<WebKit::WebGraphicsContext3D>
-DefaultContextFactory::CreateContextCommon(Compositor* compositor,
- bool offscreen) {
- DCHECK(offscreen || compositor);
- WebKit::WebGraphicsContext3D::Attributes attrs;
- attrs.depth = false;
- attrs.stencil = false;
- attrs.antialias = false;
- attrs.shareResources = true;
- using webkit::gpu::WebGraphicsContext3DInProcessCommandBufferImpl;
- if (offscreen) {
- return WebGraphicsContext3DInProcessCommandBufferImpl::
- CreateOffscreenContext(attrs);
- }
- return WebGraphicsContext3DInProcessCommandBufferImpl::CreateViewContext(
- attrs, compositor->widget());
-}
-
TestContextFactory::TestContextFactory() {}
TestContextFactory::~TestContextFactory() {}
@@ -182,14 +169,6 @@ scoped_ptr<cc::OutputSurface> TestContextFactory::CreateOutputSurface(
return make_scoped_ptr(new cc::OutputSurface(CreateOffscreenContext()));
}
-scoped_ptr<WebKit::WebGraphicsContext3D>
-TestContextFactory::CreateOffscreenContext() {
- scoped_ptr<ui::TestWebGraphicsContext3D> context(
- new ui::TestWebGraphicsContext3D);
- context->Initialize();
- return context.PassAs<WebKit::WebGraphicsContext3D>();
-}
-
scoped_refptr<Reflector> TestContextFactory::CreateReflector(
Compositor* mirrored_compositor,
Layer* mirroring_layer) {
@@ -203,8 +182,8 @@ scoped_refptr<cc::ContextProvider>
TestContextFactory::OffscreenContextProviderForMainThread() {
if (!offscreen_contexts_main_thread_.get() ||
offscreen_contexts_main_thread_->DestroyedOnMainThread()) {
- offscreen_contexts_main_thread_ =
- ContextProviderFromContextFactory::CreateForOffscreen(this);
+ offscreen_contexts_main_thread_ = cc::FakeContextProvider::Create(
+ base::Bind(&TestContextFactory::CreateOffscreenContext));
CHECK(offscreen_contexts_main_thread_->BindToCurrentThread());
}
return offscreen_contexts_main_thread_;
@@ -214,8 +193,8 @@ scoped_refptr<cc::ContextProvider>
TestContextFactory::OffscreenContextProviderForCompositorThread() {
if (!offscreen_contexts_compositor_thread_.get() ||
offscreen_contexts_compositor_thread_->DestroyedOnMainThread()) {
- offscreen_contexts_compositor_thread_ =
- ContextProviderFromContextFactory::CreateForOffscreen(this);
+ offscreen_contexts_compositor_thread_ = cc::FakeContextProvider::Create(
+ base::Bind(&TestContextFactory::CreateOffscreenContext));
}
return offscreen_contexts_compositor_thread_;
}
@@ -225,6 +204,15 @@ void TestContextFactory::RemoveCompositor(Compositor* compositor) {
bool TestContextFactory::DoesCreateTestContexts() { return true; }
+// static
+scoped_ptr<WebKit::WebGraphicsContext3D>
+TestContextFactory::CreateOffscreenContext() {
+ scoped_ptr<ui::TestWebGraphicsContext3D> context(
+ new ui::TestWebGraphicsContext3D);
+ context->Initialize();
+ return context.PassAs<WebKit::WebGraphicsContext3D>();
+}
+
Texture::Texture(bool flipped, const gfx::Size& size, float device_scale_factor)
: size_(size),
flipped_(flipped),
diff --git a/ui/compositor/compositor.gyp b/ui/compositor/compositor.gyp
index 57a4aaf..4cab1da 100644
--- a/ui/compositor/compositor.gyp
+++ b/ui/compositor/compositor.gyp
@@ -30,8 +30,6 @@
'compositor_observer.h',
'compositor_switches.cc',
'compositor_switches.h',
- 'context_provider_from_context_factory.cc',
- 'context_provider_from_context_factory.h',
'debug_utils.cc',
'debug_utils.h',
'dip_util.cc',
diff --git a/ui/compositor/compositor.h b/ui/compositor/compositor.h
index 92cdd71..b9cdb82 100644
--- a/ui/compositor/compositor.h
+++ b/ui/compositor/compositor.h
@@ -31,6 +31,7 @@ class RunLoop;
namespace cc {
class ContextProvider;
+class FakeContextProvider;
class Layer;
class LayerTreeDebugState;
class LayerTreeHost;
@@ -49,6 +50,12 @@ namespace WebKit {
class WebGraphicsContext3D;
}
+namespace webkit {
+namespace gpu {
+class ContextProviderInProcess;
+}
+}
+
namespace ui {
class Compositor;
@@ -80,10 +87,6 @@ class COMPOSITOR_EXPORT ContextFactory {
virtual scoped_ptr<cc::OutputSurface> CreateOutputSurface(
Compositor* compositor) = 0;
- // Creates a context used for offscreen rendering. This context can be shared
- // with all compositors.
- virtual scoped_ptr<WebKit::WebGraphicsContext3D> CreateOffscreenContext() = 0;
-
// Creates a reflector that copies the content of the |mirrored_compositor|
// onto |mirroing_layer|.
virtual scoped_refptr<Reflector> CreateReflector(
@@ -114,8 +117,6 @@ class COMPOSITOR_EXPORT DefaultContextFactory : public ContextFactory {
// ContextFactory implementation
virtual scoped_ptr<cc::OutputSurface> CreateOutputSurface(
Compositor* compositor) OVERRIDE;
- virtual scoped_ptr<WebKit::WebGraphicsContext3D> CreateOffscreenContext()
- OVERRIDE;
virtual scoped_refptr<Reflector> CreateReflector(
Compositor* compositor,
@@ -132,13 +133,9 @@ class COMPOSITOR_EXPORT DefaultContextFactory : public ContextFactory {
bool Initialize();
private:
- scoped_ptr<WebKit::WebGraphicsContext3D> CreateContextCommon(
- Compositor* compositor,
- bool offscreen);
-
- scoped_refptr<ContextProviderFromContextFactory>
+ scoped_refptr<webkit::gpu::ContextProviderInProcess>
offscreen_contexts_main_thread_;
- scoped_refptr<ContextProviderFromContextFactory>
+ scoped_refptr<webkit::gpu::ContextProviderInProcess>
offscreen_contexts_compositor_thread_;
DISALLOW_COPY_AND_ASSIGN(DefaultContextFactory);
@@ -153,8 +150,6 @@ class COMPOSITOR_EXPORT TestContextFactory : public ContextFactory {
// ContextFactory implementation
virtual scoped_ptr<cc::OutputSurface> CreateOutputSurface(
Compositor* compositor) OVERRIDE;
- virtual scoped_ptr<WebKit::WebGraphicsContext3D> CreateOffscreenContext()
- OVERRIDE;
virtual scoped_refptr<Reflector> CreateReflector(
Compositor* mirrored_compositor,
@@ -169,10 +164,10 @@ class COMPOSITOR_EXPORT TestContextFactory : public ContextFactory {
virtual bool DoesCreateTestContexts() OVERRIDE;
private:
- scoped_refptr<ContextProviderFromContextFactory>
- offscreen_contexts_main_thread_;
- scoped_refptr<ContextProviderFromContextFactory>
- offscreen_contexts_compositor_thread_;
+ static scoped_ptr<WebKit::WebGraphicsContext3D> CreateOffscreenContext();
+
+ scoped_refptr<cc::FakeContextProvider> offscreen_contexts_main_thread_;
+ scoped_refptr<cc::ContextProvider> offscreen_contexts_compositor_thread_;
DISALLOW_COPY_AND_ASSIGN(TestContextFactory);
};
diff --git a/ui/compositor/context_provider_from_context_factory.cc b/ui/compositor/context_provider_from_context_factory.cc
deleted file mode 100644
index 262998a..0000000
--- a/ui/compositor/context_provider_from_context_factory.cc
+++ /dev/null
@@ -1,76 +0,0 @@
-// Copyright (c) 2013 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "context_provider_from_context_factory.h"
-
-#include "base/logging.h"
-
-namespace ui {
-
-// static
-scoped_refptr<ContextProviderFromContextFactory>
-ContextProviderFromContextFactory::CreateForOffscreen(ContextFactory* factory) {
- scoped_refptr<ContextProviderFromContextFactory> provider =
- new ContextProviderFromContextFactory(factory);
- if (!provider->InitializeOnMainThread())
- return NULL;
- return provider;
-}
-
-ContextProviderFromContextFactory::ContextProviderFromContextFactory(
- ContextFactory* factory)
- : factory_(factory),
- destroyed_(false) {
-}
-
-ContextProviderFromContextFactory::~ContextProviderFromContextFactory() {
-}
-
-bool ContextProviderFromContextFactory::BindToCurrentThread() {
- DCHECK(context3d_);
- return context3d_->makeContextCurrent();
-}
-
-WebKit::WebGraphicsContext3D* ContextProviderFromContextFactory::Context3d() {
- DCHECK(context3d_);
- return context3d_.get();
-}
-
-class GrContext* ContextProviderFromContextFactory::GrContext() {
- DCHECK(context3d_);
-
- if (!gr_context_) {
- gr_context_.reset(
- new webkit::gpu::GrContextForWebGraphicsContext3D(context3d_.get()));
- }
- return gr_context_->get();
-}
-
-void ContextProviderFromContextFactory::VerifyContexts() {
- DCHECK(context3d_);
-
- if (context3d_->isContextLost()) {
- base::AutoLock lock(destroyed_lock_);
- destroyed_ = true;
- }
-}
-
-bool ContextProviderFromContextFactory::DestroyedOnMainThread() {
- base::AutoLock lock(destroyed_lock_);
- return destroyed_;
-}
-
-void ContextProviderFromContextFactory::SetLostContextCallback(
- const LostContextCallback& cb) {
- NOTIMPLEMENTED();
-}
-
-bool ContextProviderFromContextFactory::InitializeOnMainThread() {
- if (context3d_)
- return true;
- context3d_ = factory_->CreateOffscreenContext();
- return !!context3d_;
-}
-
-} // namespace ui
diff --git a/ui/compositor/context_provider_from_context_factory.h b/ui/compositor/context_provider_from_context_factory.h
deleted file mode 100644
index 57be7f4..0000000
--- a/ui/compositor/context_provider_from_context_factory.h
+++ /dev/null
@@ -1,45 +0,0 @@
-// Copyright (c) 2013 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef UI_COMPOSITOR_CONTEXT_PROVIDER_FROM_CONTEXT_FACTORY_H_
-#define UI_COMPOSITOR_CONTEXT_PROVIDER_FROM_CONTEXT_FACTORY_H_
-
-#include "base/synchronization/lock.h"
-#include "cc/output/context_provider.h"
-#include "third_party/WebKit/public/platform/WebGraphicsContext3D.h"
-#include "ui/compositor/compositor.h"
-#include "webkit/common/gpu/grcontext_for_webgraphicscontext3d.h"
-
-namespace ui {
-
-class ContextProviderFromContextFactory
- : public cc::ContextProvider {
- public:
- static scoped_refptr<ContextProviderFromContextFactory> CreateForOffscreen(
- ContextFactory* factory);
-
- virtual bool BindToCurrentThread() OVERRIDE;
- virtual WebKit::WebGraphicsContext3D* Context3d() OVERRIDE;
- virtual class GrContext* GrContext() OVERRIDE;
- virtual void VerifyContexts() OVERRIDE;
- virtual bool DestroyedOnMainThread() OVERRIDE;
- virtual void SetLostContextCallback(const LostContextCallback& cb) OVERRIDE;
-
- protected:
- ContextProviderFromContextFactory(ContextFactory* factory);
- virtual ~ContextProviderFromContextFactory();
-
- bool InitializeOnMainThread();
-
- private:
- ContextFactory* factory_;
- base::Lock destroyed_lock_;
- bool destroyed_;
- scoped_ptr<WebKit::WebGraphicsContext3D> context3d_;
- scoped_ptr<webkit::gpu::GrContextForWebGraphicsContext3D> gr_context_;
-};
-
-} // namespace ui
-
-#endif // UI_COMPOSITOR_CONTEXT_PROVIDER_FROM_CONTEXT_FACTORY_H_