1 // 2 // Copyright (c) 2002-2012 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 postSubBufferSupported); 38 Surface(Display *display, const egl::Config *config, HANDLE shareHandle, EGLint width, EGLint height, EGLenum textureFormat, EGLenum textureTarget); 39 40 ~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 getWidth() const; 51 virtual EGLint getHeight() const; 52 53 virtual EGLint isPostSubBufferSupported() const; 54 55 virtual rx::SwapChain *getSwapChain() const; 56 57 void setSwapInterval(EGLint interval); 58 bool checkForOutOfDateSwapChain(); // Returns true if swapchain changed due to resize or interval update 59 60 virtual EGLenum getTextureFormat() const; 61 virtual EGLenum getTextureTarget() const; 62 virtual EGLenum getFormat() const; 63 64 virtual void setBoundTexture(gl::Texture2D *texture); 65 virtual gl::Texture2D *getBoundTexture() const; 66 67 private: 68 DISALLOW_COPY_AND_ASSIGN(Surface); 69 70 Display *const mDisplay; 71 rx::Renderer *mRenderer; 72 73 HANDLE mShareHandle; 74 rx::SwapChain *mSwapChain; 75 76 void subclassWindow(); 77 void unsubclassWindow(); 78 bool resizeSwapChain(int backbufferWidth, int backbufferHeight); 79 bool resetSwapChain(int backbufferWidth, int backbufferHeight); 80 bool swapRect(EGLint x, EGLint y, EGLint width, EGLint height); 81 82 const HWND mWindow; // Window that the surface is created for. 83 bool mWindowSubclassed; // Indicates whether we successfully subclassed mWindow for WM_RESIZE hooking 84 const egl::Config *mConfig; // EGL config surface was created with 85 EGLint mHeight; // Height of surface 86 EGLint mWidth; // Width of surface 87 // EGLint horizontalResolution; // Horizontal dot pitch 88 // EGLint verticalResolution; // Vertical dot pitch 89 // EGLBoolean largestPBuffer; // If true, create largest pbuffer possible 90 // EGLBoolean mipmapTexture; // True if texture has mipmaps 91 // EGLint mipmapLevel; // Mipmap level to render to 92 // EGLenum multisampleResolve; // Multisample resolve behavior 93 EGLint mPixelAspectRatio; // Display aspect ratio 94 EGLenum mRenderBuffer; // Render buffer 95 EGLenum mSwapBehavior; // Buffer swap behavior 96 EGLenum mTextureFormat; // Format of texture: RGB, RGBA, or no texture 97 EGLenum mTextureTarget; // Type of texture: 2D or no texture 98 // EGLenum vgAlphaFormat; // Alpha format for OpenVG 99 // EGLenum vgColorSpace; // Color space for OpenVG 100 EGLint mSwapInterval; 101 EGLint mPostSubBufferSupported; 102 103 bool mSwapIntervalDirty; 104 gl::Texture2D *mTexture; 105 }; 106 } 107 108 #endif // LIBEGL_SURFACE_H_ 109