diff options
author | piman@chromium.org <piman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-05-09 02:21:58 +0000 |
---|---|---|
committer | piman@chromium.org <piman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-05-09 02:21:58 +0000 |
commit | 8cd6c223ca41a6788783db5ab2ea90f774e8c10f (patch) | |
tree | c743c2b47705a8b91836d7955d7eb4a96a919193 /ui | |
parent | 1eab4e9e04c773022b3e24f251fa384396d48aa5 (diff) | |
download | chromium_src-8cd6c223ca41a6788783db5ab2ea90f774e8c10f.zip chromium_src-8cd6c223ca41a6788783db5ab2ea90f774e8c10f.tar.gz chromium_src-8cd6c223ca41a6788783db5ab2ea90f774e8c10f.tar.bz2 |
Remove SharedBitmapManager global in ui/compositor
Globals prevent ui::Compositor from being used in multiple threads.
BUG=None
R=jbauman@chromium.org, sky@chromium.org
Review URL: https://codereview.chromium.org/271843002
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@269153 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ui')
-rw-r--r-- | ui/compositor/compositor.cc | 10 | ||||
-rw-r--r-- | ui/compositor/compositor.h | 4 | ||||
-rw-r--r-- | ui/compositor/test/context_factories_for_test.cc | 7 | ||||
-rw-r--r-- | ui/compositor/test/in_process_context_factory.cc | 8 | ||||
-rw-r--r-- | ui/compositor/test/in_process_context_factory.h | 2 |
5 files changed, 14 insertions, 17 deletions
diff --git a/ui/compositor/compositor.cc b/ui/compositor/compositor.cc index 423f2bf..788cd48 100644 --- a/ui/compositor/compositor.cc +++ b/ui/compositor/compositor.cc @@ -41,7 +41,6 @@ const double kTestRefreshRate = 200.0; bool g_compositor_initialized = false; base::Thread* g_compositor_thread = NULL; -cc::SharedBitmapManager* g_shared_bitmap_manager; ui::ContextFactory* g_context_factory = NULL; @@ -160,12 +159,12 @@ Compositor::Compositor(gfx::AcceleratedWidget widget) if (!!g_compositor_thread) { host_ = cc::LayerTreeHost::CreateThreaded( this, - g_shared_bitmap_manager, + g_context_factory->GetSharedBitmapManager(), settings, g_compositor_thread->message_loop_proxy()); } else { host_ = cc::LayerTreeHost::CreateSingleThreaded( - this, this, g_shared_bitmap_manager, settings); + this, this, g_context_factory->GetSharedBitmapManager(), settings); } UMA_HISTOGRAM_TIMES("GPU.CreateBrowserCompositor", base::TimeTicks::Now() - before_create); @@ -234,11 +233,6 @@ void Compositor::Terminate() { g_compositor_initialized = false; } -// static -void Compositor::SetSharedBitmapManager(cc::SharedBitmapManager* manager) { - g_shared_bitmap_manager = manager; -} - void Compositor::ScheduleDraw() { if (g_compositor_thread) { host_->Composite(gfx::FrameTime::Now()); diff --git a/ui/compositor/compositor.h b/ui/compositor/compositor.h index 13e6e1a..3cc0269 100644 --- a/ui/compositor/compositor.h +++ b/ui/compositor/compositor.h @@ -93,6 +93,9 @@ class COMPOSITOR_EXPORT ContextFactory { // When true, the factory uses test contexts that do not do real GL // operations. virtual bool DoesCreateTestContexts() = 0; + + // Gets the shared bitmap manager for software mode. + virtual cc::SharedBitmapManager* GetSharedBitmapManager() = 0; }; // This class represents a lock on the compositor, that can be used to prevent @@ -136,7 +139,6 @@ class COMPOSITOR_EXPORT Compositor static bool WasInitializedWithThread(); static scoped_refptr<base::MessageLoopProxy> GetCompositorMessageLoop(); static void Terminate(); - static void SetSharedBitmapManager(cc::SharedBitmapManager* manager); // Schedules a redraw of the layer tree associated with this compositor. void ScheduleDraw(); diff --git a/ui/compositor/test/context_factories_for_test.cc b/ui/compositor/test/context_factories_for_test.cc index 6e842dd..045739d 100644 --- a/ui/compositor/test/context_factories_for_test.cc +++ b/ui/compositor/test/context_factories_for_test.cc @@ -6,7 +6,6 @@ #include "base/command_line.h" #include "base/sys_info.h" -#include "cc/test/test_shared_bitmap_manager.h" #include "ui/compositor/compositor.h" #include "ui/compositor/compositor_switches.h" #include "ui/compositor/test/in_process_context_factory.h" @@ -16,7 +15,6 @@ namespace { static ui::ContextFactory* g_implicit_factory = NULL; static gfx::DisableNullDrawGLBindings* g_disable_null_draw = NULL; -static cc::TestSharedBitmapManager* g_shared_bitmap_manager = NULL; } // namespace @@ -33,17 +31,12 @@ void InitializeContextFactoryForTests(bool enable_pixel_output) { g_disable_null_draw = new gfx::DisableNullDrawGLBindings; g_implicit_factory = new InProcessContextFactory(); ContextFactory::SetInstance(g_implicit_factory); - g_shared_bitmap_manager = new cc::TestSharedBitmapManager(); - Compositor::SetSharedBitmapManager(g_shared_bitmap_manager); } void TerminateContextFactoryForTests() { ContextFactory::SetInstance(NULL); delete g_implicit_factory; g_implicit_factory = NULL; - Compositor::SetSharedBitmapManager(NULL); - delete g_shared_bitmap_manager; - g_shared_bitmap_manager = NULL; delete g_disable_null_draw; g_disable_null_draw = NULL; } diff --git a/ui/compositor/test/in_process_context_factory.cc b/ui/compositor/test/in_process_context_factory.cc index 959d984..7aa8098 100644 --- a/ui/compositor/test/in_process_context_factory.cc +++ b/ui/compositor/test/in_process_context_factory.cc @@ -5,6 +5,7 @@ #include "ui/compositor/test/in_process_context_factory.h" #include "cc/output/output_surface.h" +#include "cc/test/test_shared_bitmap_manager.h" #include "ui/compositor/reflector.h" #include "ui/gl/gl_implementation.h" #include "ui/gl/gl_surface.h" @@ -14,7 +15,8 @@ namespace ui { -InProcessContextFactory::InProcessContextFactory() { +InProcessContextFactory::InProcessContextFactory() + : shared_bitmap_manager_(new cc::TestSharedBitmapManager()) { DCHECK_NE(gfx::GetGLImplementation(), gfx::kGLImplementationNone); } @@ -74,4 +76,8 @@ void InProcessContextFactory::RemoveCompositor(Compositor* compositor) {} bool InProcessContextFactory::DoesCreateTestContexts() { return false; } +cc::SharedBitmapManager* InProcessContextFactory::GetSharedBitmapManager() { + return shared_bitmap_manager_.get(); +} + } // namespace ui diff --git a/ui/compositor/test/in_process_context_factory.h b/ui/compositor/test/in_process_context_factory.h index ae44c94..5c7cf8b 100644 --- a/ui/compositor/test/in_process_context_factory.h +++ b/ui/compositor/test/in_process_context_factory.h @@ -34,10 +34,12 @@ class InProcessContextFactory : public ContextFactory { OVERRIDE; virtual void RemoveCompositor(Compositor* compositor) OVERRIDE; virtual bool DoesCreateTestContexts() OVERRIDE; + virtual cc::SharedBitmapManager* GetSharedBitmapManager() OVERRIDE; private: scoped_refptr<webkit::gpu::ContextProviderInProcess> shared_main_thread_contexts_; + scoped_ptr<cc::SharedBitmapManager> shared_bitmap_manager_; DISALLOW_COPY_AND_ASSIGN(InProcessContextFactory); }; |