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