Update To 11.40.268.0
[platform/framework/web/crosswalk.git] / src / ui / compositor / test / in_process_context_factory.cc
index 7aa8098..31f8b57 100644 (file)
@@ -4,8 +4,12 @@
 
 #include "ui/compositor/test/in_process_context_factory.h"
 
-#include "cc/output/output_surface.h"
+#include "base/command_line.h"
+#include "base/threading/thread.h"
+#include "cc/surfaces/surface_id_allocator.h"
+#include "cc/test/pixel_test_output_surface.h"
 #include "cc/test/test_shared_bitmap_manager.h"
+#include "ui/compositor/compositor_switches.h"
 #include "ui/compositor/reflector.h"
 #include "ui/gl/gl_implementation.h"
 #include "ui/gl/gl_surface.h"
 namespace ui {
 
 InProcessContextFactory::InProcessContextFactory()
-    : shared_bitmap_manager_(new cc::TestSharedBitmapManager()) {
-  DCHECK_NE(gfx::GetGLImplementation(), gfx::kGLImplementationNone);
+    : next_surface_id_namespace_(1u) {
+  DCHECK_NE(gfx::GetGLImplementation(), gfx::kGLImplementationNone)
+      << "If running tests, ensure that main() is calling "
+      << "gfx::GLSurface::InitializeOneOffForTests()";
+
+#if defined(OS_CHROMEOS)
+  bool use_thread = !CommandLine::ForCurrentProcess()->HasSwitch(
+      switches::kUIDisableThreadedCompositing);
+#else
+  bool use_thread = false;
+#endif
+  if (use_thread) {
+    compositor_thread_.reset(new base::Thread("Browser Compositor"));
+    compositor_thread_->Start();
+  }
 }
 
 InProcessContextFactory::~InProcessContextFactory() {}
 
-scoped_ptr<cc::OutputSurface> InProcessContextFactory::CreateOutputSurface(
-    Compositor* compositor,
+void InProcessContextFactory::CreateOutputSurface(
+    base::WeakPtr<Compositor> compositor,
     bool software_fallback) {
   DCHECK(!software_fallback);
   blink::WebGraphicsContext3D::Attributes attrs;
@@ -43,7 +60,9 @@ scoped_ptr<cc::OutputSurface> InProcessContextFactory::CreateOutputSurface(
   scoped_refptr<ContextProviderInProcess> context_provider =
       ContextProviderInProcess::Create(context3d.Pass(), "UICompositor");
 
-  return make_scoped_ptr(new cc::OutputSurface(context_provider));
+  bool flipped_output_surface = false;
+  compositor->SetOutputSurface(make_scoped_ptr(new cc::PixelTestOutputSurface(
+      context_provider, flipped_output_surface)));
 }
 
 scoped_refptr<Reflector> InProcessContextFactory::CreateReflector(
@@ -57,7 +76,7 @@ void InProcessContextFactory::RemoveReflector(
 
 scoped_refptr<cc::ContextProvider>
 InProcessContextFactory::SharedMainThreadContextProvider() {
-  if (shared_main_thread_contexts_ &&
+  if (shared_main_thread_contexts_.get() &&
       !shared_main_thread_contexts_->DestroyedOnMainThread())
     return shared_main_thread_contexts_;
 
@@ -65,7 +84,7 @@ InProcessContextFactory::SharedMainThreadContextProvider() {
   shared_main_thread_contexts_ =
       webkit::gpu::ContextProviderInProcess::CreateOffscreen(
           lose_context_when_out_of_memory);
-  if (shared_main_thread_contexts_ &&
+  if (shared_main_thread_contexts_.get() &&
       !shared_main_thread_contexts_->BindToCurrentThread())
     shared_main_thread_contexts_ = NULL;
 
@@ -77,7 +96,24 @@ void InProcessContextFactory::RemoveCompositor(Compositor* compositor) {}
 bool InProcessContextFactory::DoesCreateTestContexts() { return false; }
 
 cc::SharedBitmapManager* InProcessContextFactory::GetSharedBitmapManager() {
-  return shared_bitmap_manager_.get();
+  return &shared_bitmap_manager_;
+}
+
+gpu::GpuMemoryBufferManager*
+InProcessContextFactory::GetGpuMemoryBufferManager() {
+  return &gpu_memory_buffer_manager_;
+}
+
+base::MessageLoopProxy* InProcessContextFactory::GetCompositorMessageLoop() {
+  if (!compositor_thread_)
+    return NULL;
+  return compositor_thread_->message_loop_proxy().get();
+}
+
+scoped_ptr<cc::SurfaceIdAllocator>
+InProcessContextFactory::CreateSurfaceIdAllocator() {
+  return make_scoped_ptr(
+      new cc::SurfaceIdAllocator(next_surface_id_namespace_++));
 }
 
 }  // namespace ui