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 | } |
Ben Murdoch | ca12bfa | 2013-07-23 11:17:05 +0100 | [diff] [blame] | 32 | virtual gfx::VSyncProvider* GetVSyncProvider( |
| 33 | gfx::AcceleratedWidget w) OVERRIDE { |
| 34 | return NULL; |
| 35 | } |
| 36 | }; |
| 37 | |
Torne (Richard Coles) | 90dce4d | 2013-05-29 14:40:03 +0100 | [diff] [blame] | 38 | SurfaceFactoryOzone::SurfaceFactoryOzone() { |
| 39 | } |
| 40 | |
| 41 | SurfaceFactoryOzone::~SurfaceFactoryOzone() { |
| 42 | } |
| 43 | |
| 44 | SurfaceFactoryOzone* SurfaceFactoryOzone::GetInstance() { |
Ben Murdoch | eb525c5 | 2013-07-10 11:40:50 +0100 | [diff] [blame] | 45 | CHECK(impl_) << "SurfaceFactoryOzone accessed before constructed"; |
| 46 | return impl_; |
Torne (Richard Coles) | 90dce4d | 2013-05-29 14:40:03 +0100 | [diff] [blame] | 47 | } |
| 48 | |
| 49 | void SurfaceFactoryOzone::SetInstance(SurfaceFactoryOzone* impl) { |
Ben Murdoch | eb525c5 | 2013-07-10 11:40:50 +0100 | [diff] [blame] | 50 | impl_ = impl; |
Torne (Richard Coles) | 90dce4d | 2013-05-29 14:40:03 +0100 | [diff] [blame] | 51 | } |
| 52 | |
| 53 | const char* SurfaceFactoryOzone::DefaultDisplaySpec() { |
| 54 | char* envvar = getenv("ASH_DISPLAY_SPEC"); |
| 55 | if (envvar) |
| 56 | return envvar; |
| 57 | return "720x1280*2"; |
| 58 | } |
| 59 | |
Ben Murdoch | ca12bfa | 2013-07-23 11:17:05 +0100 | [diff] [blame] | 60 | // static |
| 61 | SurfaceFactoryOzone* SurfaceFactoryOzone::CreateTestHelper() { |
| 62 | return new SurfaceFactoryOzoneStub; |
| 63 | } |
| 64 | |
Torne (Richard Coles) | 90dce4d | 2013-05-29 14:40:03 +0100 | [diff] [blame] | 65 | } // namespace ui |