Upstream version 7.36.149.0
[platform/framework/web/crosswalk.git] / src / mojo / aura / context_factory_mojo.cc
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/aura/context_factory_mojo.h"
6
7 #include "cc/output/output_surface.h"
8 #include "mojo/aura/window_tree_host_mojo.h"
9 #include "mojo/cc/context_provider_mojo.h"
10 #include "ui/compositor/reflector.h"
11 #include "ui/gl/gl_implementation.h"
12 #include "ui/gl/gl_surface.h"
13 #include "webkit/common/gpu/context_provider_in_process.h"
14 #include "webkit/common/gpu/grcontext_for_webgraphicscontext3d.h"
15 #include "webkit/common/gpu/webgraphicscontext3d_in_process_command_buffer_impl.h"
16
17 namespace mojo {
18
19 ContextFactoryMojo::ContextFactoryMojo(ScopedMessagePipeHandle gles2_handle)
20     : gles2_handle_(gles2_handle.Pass()) {
21 }
22
23 ContextFactoryMojo::~ContextFactoryMojo() {
24 }
25
26 scoped_ptr<cc::OutputSurface> ContextFactoryMojo::CreateOutputSurface(
27     ui::Compositor* compositor, bool software_fallback) {
28   return make_scoped_ptr(new cc::OutputSurface(
29                              new ContextProviderMojo(gles2_handle_.Pass())));
30 }
31
32 scoped_refptr<ui::Reflector> ContextFactoryMojo::CreateReflector(
33     ui::Compositor* mirroed_compositor,
34     ui::Layer* mirroring_layer) {
35   return NULL;
36 }
37
38 void ContextFactoryMojo::RemoveReflector(
39     scoped_refptr<ui::Reflector> reflector) {
40 }
41
42 scoped_refptr<cc::ContextProvider>
43 ContextFactoryMojo::SharedMainThreadContextProvider() {
44   if (!shared_main_thread_contexts_ ||
45       shared_main_thread_contexts_->DestroyedOnMainThread()) {
46     bool lose_context_when_out_of_memory = false;
47     shared_main_thread_contexts_ =
48         webkit::gpu::ContextProviderInProcess::CreateOffscreen(
49             lose_context_when_out_of_memory);
50     if (shared_main_thread_contexts_ &&
51         !shared_main_thread_contexts_->BindToCurrentThread())
52       shared_main_thread_contexts_ = NULL;
53   }
54   return shared_main_thread_contexts_;
55 }
56
57 void ContextFactoryMojo::RemoveCompositor(ui::Compositor* compositor) {
58 }
59
60 bool ContextFactoryMojo::DoesCreateTestContexts() { return false; }
61
62 cc::SharedBitmapManager* ContextFactoryMojo::GetSharedBitmapManager() {
63   return NULL;
64 }
65
66 }  // namespace mojo