Skip to content

Commit

Permalink
Removes ContextFactory::Get/SetInstance
Browse files Browse the repository at this point in the history
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
  • Loading branch information
sky@chromium.org committed Jun 2, 2014
1 parent 76d134f commit b4007aa
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 61 deletions.
2 changes: 0 additions & 2 deletions content/browser/compositor/image_transport_factory.cc
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ static gfx::DisableNullDrawGLBindings* g_disable_null_draw = NULL;

void SetFactory(ImageTransportFactory* factory) {
g_factory = factory;
ui::ContextFactory::SetInstance(factory->GetContextFactory());
}

}
Expand Down Expand Up @@ -48,7 +47,6 @@ void ImageTransportFactory::InitializeForUnitTests(

// static
void ImageTransportFactory::Terminate() {
ui::ContextFactory::SetInstance(NULL);
delete g_factory;
g_factory = NULL;
delete g_disable_null_draw;
Expand Down
11 changes: 7 additions & 4 deletions ui/aura/bench/bench_main.cc
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,10 @@ void ReturnMailbox(scoped_refptr<cc::ContextProvider> context_provider,
// A benchmark that adds a texture layer that is updated every frame.
class WebGLBench : public BenchCompositorObserver {
public:
WebGLBench(Layer* parent, Compositor* compositor, int max_frames)
WebGLBench(ui::ContextFactory* context_factory,
Layer* parent,
Compositor* compositor,
int max_frames)
: BenchCompositorObserver(max_frames),
parent_(parent),
webgl_(ui::LAYER_TEXTURED),
Expand Down Expand Up @@ -177,8 +180,7 @@ class WebGLBench : public BenchCompositorObserver {
webgl_.SetBounds(bounds);
parent_->Add(&webgl_);

context_provider_ =
ui::ContextFactory::GetInstance()->SharedMainThreadContextProvider();
context_provider_ = context_factory->SharedMainThreadContextProvider();
gpu::gles2::GLES2Interface* gl = context_provider_->ContextGL();
GLuint texture = 0;
gl->GenTextures(1, &texture);
Expand Down Expand Up @@ -349,7 +351,8 @@ int main(int argc, char** argv) {
host->compositor(),
frames));
} else {
bench.reset(new WebGLBench(&page_background,
bench.reset(new WebGLBench(context_factory.get(),
&page_background,
host->compositor(),
frames));
}
Expand Down
39 changes: 0 additions & 39 deletions ui/compositor/compositor.cc
Original file line number Diff line number Diff line change
Expand Up @@ -35,26 +35,12 @@ namespace {
const double kDefaultRefreshRate = 60.0;
const double kTestRefreshRate = 200.0;

ui::ContextFactory* g_context_factory = NULL;

const int kCompositorLockTimeoutMs = 67;

} // namespace

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)
: compositor_(compositor) {
base::MessageLoop::current()->PostDelayedTask(
Expand Down Expand Up @@ -82,25 +68,6 @@ namespace {

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,
ui::ContextFactory* context_factory)
: context_factory_(context_factory),
Expand All @@ -118,12 +85,6 @@ Compositor::Compositor(gfx::AcceleratedWidget widget,
draw_on_compositing_end_(false),
swap_state_(SWAP_NONE),
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_->SetAnchorPoint(gfx::PointF(0.f, 0.f));

Expand Down
16 changes: 0 additions & 16 deletions ui/compositor/compositor.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,14 +60,6 @@ class COMPOSITOR_EXPORT ContextFactory {
public:
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
// per-compositor data (e.g. a shared context), that needs to be cleaned up
// by calling RemoveCompositor when the compositor gets destroyed.
Expand Down Expand Up @@ -136,9 +128,6 @@ class COMPOSITOR_EXPORT Compositor
: NON_EXPORTED_BASE(public cc::LayerTreeHostClient),
NON_EXPORTED_BASE(public cc::LayerTreeHostSingleThreadClient) {
public:
// This is deprecated, and will be removed shortly.
// TODO(sky): remove this.
explicit Compositor(gfx::AcceleratedWidget widget);
Compositor(gfx::AcceleratedWidget widget,
ui::ContextFactory* context_factory);
virtual ~Compositor();
Expand Down Expand Up @@ -254,11 +243,6 @@ class COMPOSITOR_EXPORT Compositor
friend class base::RefCounted<Compositor>;
friend class CompositorLock;

// Called from both constructors. It's temporary while we have both
// constructors.
// TODO(sky): nuke this.
void Init();

// Called by CompositorLock.
void UnlockCompositor();

Expand Down

0 comments on commit b4007aa

Please sign in to comment.