Home | History | Annotate | Download | only in view_manager
      1 // Copyright 2014 The Chromium Authors. All rights reserved.
      2 // Use of this source code is governed by a BSD-style license that can be
      3 // found in the LICENSE file.
      4 
      5 #include "mojo/services/view_manager/context_factory_impl.h"
      6 
      7 #include "cc/output/output_surface.h"
      8 #include "mojo/cc/context_provider_mojo.h"
      9 #include "ui/compositor/reflector.h"
     10 #include "ui/gl/gl_implementation.h"
     11 #include "ui/gl/gl_surface.h"
     12 #include "webkit/common/gpu/context_provider_in_process.h"
     13 #include "webkit/common/gpu/grcontext_for_webgraphicscontext3d.h"
     14 #include "webkit/common/gpu/webgraphicscontext3d_in_process_command_buffer_impl.h"
     15 
     16 namespace mojo {
     17 namespace view_manager {
     18 namespace service {
     19 
     20 ContextFactoryImpl::ContextFactoryImpl(
     21     ScopedMessagePipeHandle command_buffer_handle)
     22     : command_buffer_handle_(command_buffer_handle.Pass()) {
     23 }
     24 
     25 ContextFactoryImpl::~ContextFactoryImpl() {
     26 }
     27 
     28 scoped_ptr<cc::OutputSurface> ContextFactoryImpl::CreateOutputSurface(
     29     ui::Compositor* compositor, bool software_fallback) {
     30   return make_scoped_ptr(
     31       new cc::OutputSurface(
     32           new ContextProviderMojo(command_buffer_handle_.Pass())));
     33 }
     34 
     35 scoped_refptr<ui::Reflector> ContextFactoryImpl::CreateReflector(
     36     ui::Compositor* mirroed_compositor,
     37     ui::Layer* mirroring_layer) {
     38   return NULL;
     39 }
     40 
     41 void ContextFactoryImpl::RemoveReflector(
     42     scoped_refptr<ui::Reflector> reflector) {
     43 }
     44 
     45 scoped_refptr<cc::ContextProvider>
     46 ContextFactoryImpl::SharedMainThreadContextProvider() {
     47   if (!shared_main_thread_contexts_ ||
     48       shared_main_thread_contexts_->DestroyedOnMainThread()) {
     49     bool lose_context_when_out_of_memory = false;
     50     shared_main_thread_contexts_ =
     51         webkit::gpu::ContextProviderInProcess::CreateOffscreen(
     52             lose_context_when_out_of_memory);
     53     if (shared_main_thread_contexts_ &&
     54         !shared_main_thread_contexts_->BindToCurrentThread())
     55       shared_main_thread_contexts_ = NULL;
     56   }
     57   return shared_main_thread_contexts_;
     58 }
     59 
     60 void ContextFactoryImpl::RemoveCompositor(ui::Compositor* compositor) {
     61 }
     62 
     63 bool ContextFactoryImpl::DoesCreateTestContexts() { return false; }
     64 
     65 cc::SharedBitmapManager* ContextFactoryImpl::GetSharedBitmapManager() {
     66   return NULL;
     67 }
     68 
     69 base::MessageLoopProxy* ContextFactoryImpl::GetCompositorMessageLoop() {
     70   return NULL;
     71 }
     72 
     73 }  // namespace service
     74 }  // namespace view_manager
     75 }  // namespace mojo
     76