Home | History | Annotate | Download | only in libEGL
      1 //
      2 // Copyright (c) 2002-2013 The ANGLE Project Authors. All rights reserved.
      3 // Use of this source code is governed by a BSD-style license that can be
      4 // found in the LICENSE file.
      5 //
      6 
      7 // Display.h: Defines the egl::Display class, representing the abstract
      8 // display on which graphics are drawn. Implements EGLDisplay.
      9 // [EGL 1.4] section 2.1.2 page 3.
     10 
     11 #ifndef LIBEGL_DISPLAY_H_
     12 #define LIBEGL_DISPLAY_H_
     13 
     14 #include <set>
     15 #include <vector>
     16 
     17 #include "libEGL/Config.h"
     18 
     19 namespace gl
     20 {
     21 class Context;
     22 }
     23 
     24 namespace egl
     25 {
     26 class Surface;
     27 
     28 class Display
     29 {
     30   public:
     31     ~Display();
     32 
     33     bool initialize();
     34     void terminate();
     35 
     36     static egl::Display *getDisplay(EGLNativeDisplayType displayId);
     37 
     38     bool getConfigs(EGLConfig *configs, const EGLint *attribList, EGLint configSize, EGLint *numConfig);
     39     bool getConfigAttrib(EGLConfig config, EGLint attribute, EGLint *value);
     40 
     41     EGLSurface createWindowSurface(HWND window, EGLConfig config, const EGLint *attribList);
     42     EGLSurface createOffscreenSurface(EGLConfig config, HANDLE shareHandle, const EGLint *attribList);
     43     EGLContext createContext(EGLConfig configHandle, EGLint clientVersion, const gl::Context *shareContext, bool notifyResets, bool robustAccess);
     44 
     45     void destroySurface(egl::Surface *surface);
     46     void destroyContext(gl::Context *context);
     47 
     48     bool isInitialized() const;
     49     bool isValidConfig(EGLConfig config);
     50     bool isValidContext(gl::Context *context);
     51     bool isValidSurface(egl::Surface *surface);
     52     bool hasExistingWindowSurface(HWND window);
     53 
     54     rx::Renderer *getRenderer() { return mRenderer; };
     55 
     56     // exported methods must be virtual
     57     virtual void notifyDeviceLost();
     58     virtual void recreateSwapChains();
     59 
     60     const char *getExtensionString() const;
     61     const char *getVendorString() const;
     62 
     63   private:
     64     DISALLOW_COPY_AND_ASSIGN(Display);
     65 
     66     Display(EGLNativeDisplayType displayId, HDC deviceContext);
     67 
     68     bool restoreLostDevice();
     69 
     70     EGLNativeDisplayType mDisplayId;
     71     const HDC mDc;
     72 
     73     bool mSoftwareDevice;
     74 
     75     typedef std::set<Surface*> SurfaceSet;
     76     SurfaceSet mSurfaceSet;
     77 
     78     ConfigSet mConfigSet;
     79 
     80     typedef std::set<gl::Context*> ContextSet;
     81     ContextSet mContextSet;
     82 
     83     rx::Renderer *mRenderer;
     84 
     85     void initExtensionString();
     86     void initVendorString();
     87     std::string mExtensionString;
     88     std::string mVendorString;
     89 };
     90 }
     91 
     92 #endif   // LIBEGL_DISPLAY_H_
     93