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