Commit b4007aa9 authored by sky@chromium.org's avatar sky@chromium.org

Removes ContextFactory::Get/SetInstance

BUG=379399
TEST=none
TBR=piman@chromium.org

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

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@274283 0039d316-1c4b-4281-b951-d872f2087c98
parent 76d134f2
...@@ -20,7 +20,6 @@ static gfx::DisableNullDrawGLBindings* g_disable_null_draw = NULL; ...@@ -20,7 +20,6 @@ static gfx::DisableNullDrawGLBindings* g_disable_null_draw = NULL;
void SetFactory(ImageTransportFactory* factory) { void SetFactory(ImageTransportFactory* factory) {
g_factory = factory; g_factory = factory;
ui::ContextFactory::SetInstance(factory->GetContextFactory());
} }
} }
...@@ -48,7 +47,6 @@ void ImageTransportFactory::InitializeForUnitTests( ...@@ -48,7 +47,6 @@ void ImageTransportFactory::InitializeForUnitTests(
// static // static
void ImageTransportFactory::Terminate() { void ImageTransportFactory::Terminate() {
ui::ContextFactory::SetInstance(NULL);
delete g_factory; delete g_factory;
g_factory = NULL; g_factory = NULL;
delete g_disable_null_draw; delete g_disable_null_draw;
......
...@@ -148,7 +148,10 @@ void ReturnMailbox(scoped_refptr<cc::ContextProvider> context_provider, ...@@ -148,7 +148,10 @@ void ReturnMailbox(scoped_refptr<cc::ContextProvider> context_provider,
// A benchmark that adds a texture layer that is updated every frame. // A benchmark that adds a texture layer that is updated every frame.
class WebGLBench : public BenchCompositorObserver { class WebGLBench : public BenchCompositorObserver {
public: public:
WebGLBench(Layer* parent, Compositor* compositor, int max_frames) WebGLBench(ui::ContextFactory* context_factory,
Layer* parent,
Compositor* compositor,
int max_frames)
: BenchCompositorObserver(max_frames), : BenchCompositorObserver(max_frames),
parent_(parent), parent_(parent),
webgl_(ui::LAYER_TEXTURED), webgl_(ui::LAYER_TEXTURED),
...@@ -177,8 +180,7 @@ class WebGLBench : public BenchCompositorObserver { ...@@ -177,8 +180,7 @@ class WebGLBench : public BenchCompositorObserver {
webgl_.SetBounds(bounds); webgl_.SetBounds(bounds);
parent_->Add(&webgl_); parent_->Add(&webgl_);
context_provider_ = context_provider_ = context_factory->SharedMainThreadContextProvider();
ui::ContextFactory::GetInstance()->SharedMainThreadContextProvider();
gpu::gles2::GLES2Interface* gl = context_provider_->ContextGL(); gpu::gles2::GLES2Interface* gl = context_provider_->ContextGL();
GLuint texture = 0; GLuint texture = 0;
gl->GenTextures(1, &texture); gl->GenTextures(1, &texture);
...@@ -349,7 +351,8 @@ int main(int argc, char** argv) { ...@@ -349,7 +351,8 @@ int main(int argc, char** argv) {
host->compositor(), host->compositor(),
frames)); frames));
} else { } else {
bench.reset(new WebGLBench(&page_background, bench.reset(new WebGLBench(context_factory.get(),
&page_background,
host->compositor(), host->compositor(),
frames)); frames));
} }
......
...@@ -35,26 +35,12 @@ namespace { ...@@ -35,26 +35,12 @@ namespace {
const double kDefaultRefreshRate = 60.0; const double kDefaultRefreshRate = 60.0;
const double kTestRefreshRate = 200.0; const double kTestRefreshRate = 200.0;
ui::ContextFactory* g_context_factory = NULL;
const int kCompositorLockTimeoutMs = 67; const int kCompositorLockTimeoutMs = 67;
} // namespace } // namespace
namespace ui { namespace ui {
// static
ContextFactory* ContextFactory::GetInstance() {
DCHECK(g_context_factory);
return g_context_factory;
}
// static
void ContextFactory::SetInstance(ContextFactory* instance) {
DCHECK_NE(!!g_context_factory, !!instance);
g_context_factory = instance;
}
CompositorLock::CompositorLock(Compositor* compositor) CompositorLock::CompositorLock(Compositor* compositor)
: compositor_(compositor) { : compositor_(compositor) {
base::MessageLoop::current()->PostDelayedTask( base::MessageLoop::current()->PostDelayedTask(
...@@ -82,25 +68,6 @@ namespace { ...@@ -82,25 +68,6 @@ namespace {
namespace ui { namespace ui {
Compositor::Compositor(gfx::AcceleratedWidget widget)
: context_factory_(g_context_factory),
root_layer_(NULL),
widget_(widget),
compositor_thread_loop_(g_context_factory->GetCompositorMessageLoop()),
vsync_manager_(new CompositorVSyncManager()),
device_scale_factor_(0.0f),
last_started_frame_(0),
last_ended_frame_(0),
disable_schedule_composite_(false),
compositor_lock_(NULL),
defer_draw_scheduling_(false),
waiting_on_compositing_end_(false),
draw_on_compositing_end_(false),
swap_state_(SWAP_NONE),
schedule_draw_factory_(this) {
Init();
}
Compositor::Compositor(gfx::AcceleratedWidget widget, Compositor::Compositor(gfx::AcceleratedWidget widget,
ui::ContextFactory* context_factory) ui::ContextFactory* context_factory)
: context_factory_(context_factory), : context_factory_(context_factory),
...@@ -118,12 +85,6 @@ Compositor::Compositor(gfx::AcceleratedWidget widget, ...@@ -118,12 +85,6 @@ Compositor::Compositor(gfx::AcceleratedWidget widget,
draw_on_compositing_end_(false), draw_on_compositing_end_(false),
swap_state_(SWAP_NONE), swap_state_(SWAP_NONE),
schedule_draw_factory_(this) { schedule_draw_factory_(this) {
Init();
}
// Yes, this is the wrong place. I'm leaving here to minimize diffs since this
// function will be nuked soonish.
void Compositor::Init() {
root_web_layer_ = cc::Layer::Create(); root_web_layer_ = cc::Layer::Create();
root_web_layer_->SetAnchorPoint(gfx::PointF(0.f, 0.f)); root_web_layer_->SetAnchorPoint(gfx::PointF(0.f, 0.f));
......
...@@ -60,14 +60,6 @@ class COMPOSITOR_EXPORT ContextFactory { ...@@ -60,14 +60,6 @@ class COMPOSITOR_EXPORT ContextFactory {
public: public:
virtual ~ContextFactory() {} virtual ~ContextFactory() {}
// Gets the global instance.
static ContextFactory* GetInstance();
// Sets the global instance. Caller keeps ownership.
// If this function isn't called (for tests), a "default" factory will be
// created on the first call of GetInstance.
static void SetInstance(ContextFactory* instance);
// Creates an output surface for the given compositor. The factory may keep // Creates an output surface for the given compositor. The factory may keep
// per-compositor data (e.g. a shared context), that needs to be cleaned up // per-compositor data (e.g. a shared context), that needs to be cleaned up
// by calling RemoveCompositor when the compositor gets destroyed. // by calling RemoveCompositor when the compositor gets destroyed.
...@@ -136,9 +128,6 @@ class COMPOSITOR_EXPORT Compositor ...@@ -136,9 +128,6 @@ class COMPOSITOR_EXPORT Compositor
: NON_EXPORTED_BASE(public cc::LayerTreeHostClient), : NON_EXPORTED_BASE(public cc::LayerTreeHostClient),
NON_EXPORTED_BASE(public cc::LayerTreeHostSingleThreadClient) { NON_EXPORTED_BASE(public cc::LayerTreeHostSingleThreadClient) {
public: public:
// This is deprecated, and will be removed shortly.
// TODO(sky): remove this.
explicit Compositor(gfx::AcceleratedWidget widget);
Compositor(gfx::AcceleratedWidget widget, Compositor(gfx::AcceleratedWidget widget,
ui::ContextFactory* context_factory); ui::ContextFactory* context_factory);
virtual ~Compositor(); virtual ~Compositor();
...@@ -254,11 +243,6 @@ class COMPOSITOR_EXPORT Compositor ...@@ -254,11 +243,6 @@ class COMPOSITOR_EXPORT Compositor
friend class base::RefCounted<Compositor>; friend class base::RefCounted<Compositor>;
friend class CompositorLock; friend class CompositorLock;
// Called from both constructors. It's temporary while we have both
// constructors.
// TODO(sky): nuke this.
void Init();
// Called by CompositorLock. // Called by CompositorLock.
void UnlockCompositor(); void UnlockCompositor();
......
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