Torne (Richard Coles) | 90dce4d | 2013-05-29 14:40:03 +0100 | [diff] [blame] | 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/base/ozone/surface_factory_ozone.h" |
| 6 | |
Ben Murdoch | ca12bfa | 2013-07-23 11:17:05 +0100 | [diff] [blame^] | 7 | #include <stdlib.h> |
Torne (Richard Coles) | 90dce4d | 2013-05-29 14:40:03 +0100 | [diff] [blame] | 8 | |
| 9 | namespace ui { |
| 10 | |
Ben Murdoch | eb525c5 | 2013-07-10 11:40:50 +0100 | [diff] [blame] | 11 | // static |
| 12 | SurfaceFactoryOzone* SurfaceFactoryOzone::impl_ = NULL; |
Torne (Richard Coles) | 90dce4d | 2013-05-29 14:40:03 +0100 | [diff] [blame] | 13 | |
Ben Murdoch | ca12bfa | 2013-07-23 11:17:05 +0100 | [diff] [blame^] | 14 | class SurfaceFactoryOzoneStub : public SurfaceFactoryOzone { |
| 15 | public: |
| 16 | SurfaceFactoryOzoneStub() {} |
| 17 | virtual ~SurfaceFactoryOzoneStub() {} |
| 18 | |
| 19 | virtual void InitializeHardware() OVERRIDE {} |
| 20 | virtual void ShutdownHardware() OVERRIDE {} |
| 21 | virtual gfx::AcceleratedWidget GetAcceleratedWidget() OVERRIDE { return 0; } |
| 22 | virtual gfx::AcceleratedWidget RealizeAcceleratedWidget( |
| 23 | gfx::AcceleratedWidget w) OVERRIDE { |
| 24 | return 0; |
| 25 | } |
| 26 | virtual bool LoadEGLGLES2Bindings() OVERRIDE { return true; } |
| 27 | virtual bool AttemptToResizeAcceleratedWidget( |
| 28 | gfx::AcceleratedWidget w, |
| 29 | const gfx::Rect& bounds) OVERRIDE { |
| 30 | return false; |
| 31 | } |
| 32 | virtual bool AcceleratedWidgetCanBeResized( |
| 33 | gfx::AcceleratedWidget w) OVERRIDE { |
| 34 | return false; |
| 35 | } |
| 36 | virtual gfx::VSyncProvider* GetVSyncProvider( |
| 37 | gfx::AcceleratedWidget w) OVERRIDE { |
| 38 | return NULL; |
| 39 | } |
| 40 | }; |
| 41 | |
Torne (Richard Coles) | 90dce4d | 2013-05-29 14:40:03 +0100 | [diff] [blame] | 42 | SurfaceFactoryOzone::SurfaceFactoryOzone() { |
| 43 | } |
| 44 | |
| 45 | SurfaceFactoryOzone::~SurfaceFactoryOzone() { |
| 46 | } |
| 47 | |
| 48 | SurfaceFactoryOzone* SurfaceFactoryOzone::GetInstance() { |
Ben Murdoch | eb525c5 | 2013-07-10 11:40:50 +0100 | [diff] [blame] | 49 | CHECK(impl_) << "SurfaceFactoryOzone accessed before constructed"; |
| 50 | return impl_; |
Torne (Richard Coles) | 90dce4d | 2013-05-29 14:40:03 +0100 | [diff] [blame] | 51 | } |
| 52 | |
| 53 | void SurfaceFactoryOzone::SetInstance(SurfaceFactoryOzone* impl) { |
Ben Murdoch | eb525c5 | 2013-07-10 11:40:50 +0100 | [diff] [blame] | 54 | impl_ = impl; |
Torne (Richard Coles) | 90dce4d | 2013-05-29 14:40:03 +0100 | [diff] [blame] | 55 | } |
| 56 | |
| 57 | const char* SurfaceFactoryOzone::DefaultDisplaySpec() { |
| 58 | char* envvar = getenv("ASH_DISPLAY_SPEC"); |
| 59 | if (envvar) |
| 60 | return envvar; |
| 61 | return "720x1280*2"; |
| 62 | } |
| 63 | |
Ben Murdoch | ca12bfa | 2013-07-23 11:17:05 +0100 | [diff] [blame^] | 64 | // static |
| 65 | SurfaceFactoryOzone* SurfaceFactoryOzone::CreateTestHelper() { |
| 66 | return new SurfaceFactoryOzoneStub; |
| 67 | } |
| 68 | |
Torne (Richard Coles) | 90dce4d | 2013-05-29 14:40:03 +0100 | [diff] [blame] | 69 | } // namespace ui |