- add sources.
[platform/framework/web/crosswalk.git] / src / ui / gfx / ozone / surface_factory_ozone.cc
1 // Copyright (c) 2013 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 "ui/gfx/ozone/surface_factory_ozone.h"
6
7 #include <stdlib.h>
8
9 #include "base/command_line.h"
10 #include "ui/gfx/ozone/impl/file_surface_factory_ozone.h"
11 #include "ui/gfx/ozone/impl/software_surface_factory_ozone.h"
12
13 namespace gfx {
14
15 // static
16 SurfaceFactoryOzone* SurfaceFactoryOzone::impl_ = NULL;
17
18 class SurfaceFactoryOzoneStub : public SurfaceFactoryOzone {
19  public:
20   SurfaceFactoryOzoneStub() {}
21   virtual ~SurfaceFactoryOzoneStub() {}
22
23   virtual HardwareState InitializeHardware() OVERRIDE { return INITIALIZED; }
24   virtual void ShutdownHardware() OVERRIDE {}
25   virtual gfx::AcceleratedWidget GetAcceleratedWidget() OVERRIDE { return 0; }
26   virtual gfx::AcceleratedWidget RealizeAcceleratedWidget(
27       gfx::AcceleratedWidget w) OVERRIDE {
28     return 0;
29   }
30   virtual bool LoadEGLGLES2Bindings(
31       AddGLLibraryCallback add_gl_library,
32       SetGLGetProcAddressProcCallback set_gl_get_proc_address) OVERRIDE {
33     return true;
34   }
35   virtual bool AttemptToResizeAcceleratedWidget(
36       gfx::AcceleratedWidget w,
37       const gfx::Rect& bounds) OVERRIDE {
38     return false;
39   }
40   virtual gfx::VSyncProvider* GetVSyncProvider(
41       gfx::AcceleratedWidget w) OVERRIDE {
42     return NULL;
43   }
44 };
45
46 SurfaceFactoryOzone::SurfaceFactoryOzone() {
47 }
48
49 SurfaceFactoryOzone::~SurfaceFactoryOzone() {
50 }
51
52 SurfaceFactoryOzone* SurfaceFactoryOzone::GetInstance() {
53   CHECK(impl_) << "No SurfaceFactoryOzone implementation set.";
54   return impl_;
55 }
56
57 void SurfaceFactoryOzone::SetInstance(SurfaceFactoryOzone* impl) {
58   impl_ = impl;
59 }
60
61 const char* SurfaceFactoryOzone::DefaultDisplaySpec() {
62   char* envvar = getenv("ASH_DISPLAY_SPEC");
63   if (envvar)
64     return envvar;
65   return  "720x1280*2";
66 }
67
68 gfx::Screen* SurfaceFactoryOzone::CreateDesktopScreen() {
69   return NULL;
70 }
71
72 intptr_t SurfaceFactoryOzone::GetNativeDisplay() {
73   return 0;
74 }
75
76 bool SurfaceFactoryOzone::SchedulePageFlip(gfx::AcceleratedWidget w) {
77   return true;
78 }
79
80 SkCanvas* SurfaceFactoryOzone::GetCanvasForWidget(gfx::AcceleratedWidget w) {
81   return NULL;
82 }
83
84 const int32* SurfaceFactoryOzone::GetEGLSurfaceProperties(
85     const int32* desired_attributes) {
86   return desired_attributes;
87 }
88
89 // static
90 SurfaceFactoryOzone* SurfaceFactoryOzone::CreateTestHelper() {
91   return new SurfaceFactoryOzoneStub;
92 }
93
94 }  // namespace gfx