1 // 2 // Copyright (c) 2002-2014 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 // Surface.h: Defines the egl::Surface class, representing a drawing surface 8 // such as the client area of a window, including any back buffers. 9 // Implements EGLSurface and related functionality. [EGL 1.4] section 2.2 page 3. 10 11 #ifndef LIBEGL_SURFACE_H_ 12 #define LIBEGL_SURFACE_H_ 13 14 #define EGLAPI 15 #include <EGL/egl.h> 16 17 #include "common/angleutils.h" 18 19 namespace gl 20 { 21 class Texture2D; 22 } 23 namespace rx 24 { 25 class Renderer; 26 class SwapChain; 27 } 28 29 namespace egl 30 { 31 class Display; 32 class Config; 33 34 class Surface 35 { 36 public: 37 Surface(Display *display, const egl::Config *config, HWND window, EGLint fixedSize, EGLint width, EGLint height, EGLint postSubBufferSupported); 38 Surface(Display *display, const egl::Config *config, HANDLE shareHandle, EGLint width, EGLint height, EGLenum textureFormat, EGLenum textureTarget); 39 40 virtual ~Surface(); 41 42 bool initialize(); 43 void release(); 44 bool resetSwapChain(); 45 46 HWND getWindowHandle(); 47 bool swap(); 48 bool postSubBuffer(EGLint x, EGLint y, EGLint width, EGLint height); 49 50 virtual EGLint isPostSubBufferSupported() const; 51 52 virtual rx::SwapChain *getSwapChain() const; 53 54 void setSwapInterval(EGLint interval); 55 bool checkForOutOfDateSwapChain(); // Returns true if swapchain changed due to resize or interval update 56 57 virtual EGLint getConfigID() const; 58 virtual EGLint getWidth() const; 59 virtual EGLint getHeight() const; 60 virtual EGLint getPixelAspectRatio() const; 61 virtual EGLenum getRenderBuffer() const; 62 virtual EGLenum getSwapBehavior() const; 63 virtual EGLenum getTextureFormat() const; 64 virtual EGLenum getTextureTarget() const; 65 virtual EGLenum getFormat() const; 66 67 virtual void setBoundTexture(gl::Texture2D *texture); 68 virtual gl::Texture2D *getBoundTexture() const; 69 70 EGLint isFixedSize() const; 71 72 private: 73 DISALLOW_COPY_AND_ASSIGN(Surface); 74 75 Display *const mDisplay; 76 rx::Renderer *mRenderer; 77 78 HANDLE mShareHandle; 79 rx::SwapChain *mSwapChain; 80 81 void subclassWindow(); 82 void unsubclassWindow(); 83 bool resizeSwapChain(int backbufferWidth, int backbufferHeight); 84 bool resetSwapChain(int backbufferWidth, int backbufferHeight); 85 bool swapRect(EGLint x, EGLint y, EGLint width, EGLint height); 86 87 const HWND mWindow; // Window that the surface is created for. 88 bool mWindowSubclassed; // Indicates whether we successfully subclassed mWindow for WM_RESIZE hooking 89 const egl::Config *mConfig; // EGL config surface was created with 90 EGLint mHeight; // Height of surface 91 EGLint mWidth; // Width of surface 92 // EGLint horizontalResolution; // Horizontal dot pitch 93 // EGLint verticalResolution; // Vertical dot pitch 94 // EGLBoolean largestPBuffer; // If true, create largest pbuffer possible 95 // EGLBoolean mipmapTexture; // True if texture has mipmaps 96 // EGLint mipmapLevel; // Mipmap level to render to 97 // EGLenum multisampleResolve; // Multisample resolve behavior 98 EGLint mPixelAspectRatio; // Display aspect ratio 99 EGLenum mRenderBuffer; // Render buffer 100 EGLenum mSwapBehavior; // Buffer swap behavior 101 EGLenum mTextureFormat; // Format of texture: RGB, RGBA, or no texture 102 EGLenum mTextureTarget; // Type of texture: 2D or no texture 103 // EGLenum vgAlphaFormat; // Alpha format for OpenVG 104 // EGLenum vgColorSpace; // Color space for OpenVG 105 EGLint mSwapInterval; 106 EGLint mPostSubBufferSupported; 107 EGLint mFixedSize; 108 109 bool mSwapIntervalDirty; 110 gl::Texture2D *mTexture; 111 }; 112 } 113 114 #endif // LIBEGL_SURFACE_H_ 115