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.
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.
11 #ifndef LIBEGL_SURFACE_H_
12 #define LIBEGL_SURFACE_H_
16 #include "common/angleutils.h"
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);
43 bool resetSwapChain();
45 HWND getWindowHandle();
47 bool postSubBuffer(EGLint x, EGLint y, EGLint width, EGLint height);
49 virtual EGLint isPostSubBufferSupported() const;
51 virtual rx::SwapChain *getSwapChain() const;
53 void setSwapInterval(EGLint interval);
54 bool checkForOutOfDateSwapChain(); // Returns true if swapchain changed due to resize or interval update
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;
66 virtual void setBoundTexture(gl::Texture2D *texture);
67 virtual gl::Texture2D *getBoundTexture() const;
69 EGLint isFixedSize() const;
72 DISALLOW_COPY_AND_ASSIGN(Surface);
74 Display *const mDisplay;
75 rx::Renderer *mRenderer;
78 rx::SwapChain *mSwapChain;
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);
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;
108 bool mSwapIntervalDirty;
109 gl::Texture2D *mTexture;
113 #endif // LIBEGL_SURFACE_H_