michael@0: // michael@0: // Copyright (c) 2002-2012 The ANGLE Project Authors. All rights reserved. michael@0: // Use of this source code is governed by a BSD-style license that can be michael@0: // found in the LICENSE file. michael@0: // michael@0: michael@0: // Surface.h: Defines the egl::Surface class, representing a drawing surface michael@0: // such as the client area of a window, including any back buffers. michael@0: // Implements EGLSurface and related functionality. [EGL 1.4] section 2.2 page 3. michael@0: michael@0: #ifndef LIBEGL_SURFACE_H_ michael@0: #define LIBEGL_SURFACE_H_ michael@0: michael@0: #define EGLAPI michael@0: #include michael@0: michael@0: #include "common/angleutils.h" michael@0: michael@0: namespace gl michael@0: { michael@0: class Texture2D; michael@0: } michael@0: namespace rx michael@0: { michael@0: class Renderer; michael@0: class SwapChain; michael@0: } michael@0: michael@0: namespace egl michael@0: { michael@0: class Display; michael@0: class Config; michael@0: michael@0: class Surface michael@0: { michael@0: public: michael@0: Surface(Display *display, const egl::Config *config, HWND window, EGLint postSubBufferSupported); michael@0: Surface(Display *display, const egl::Config *config, HANDLE shareHandle, EGLint width, EGLint height, EGLenum textureFormat, EGLenum textureTarget); michael@0: michael@0: ~Surface(); michael@0: michael@0: bool initialize(); michael@0: void release(); michael@0: bool resetSwapChain(); michael@0: michael@0: HWND getWindowHandle(); michael@0: bool swap(); michael@0: bool postSubBuffer(EGLint x, EGLint y, EGLint width, EGLint height); michael@0: michael@0: virtual EGLint getWidth() const; michael@0: virtual EGLint getHeight() const; michael@0: michael@0: virtual EGLint isPostSubBufferSupported() const; michael@0: michael@0: virtual rx::SwapChain *getSwapChain() const; michael@0: michael@0: void setSwapInterval(EGLint interval); michael@0: bool checkForOutOfDateSwapChain(); // Returns true if swapchain changed due to resize or interval update michael@0: michael@0: virtual EGLenum getTextureFormat() const; michael@0: virtual EGLenum getTextureTarget() const; michael@0: virtual EGLenum getFormat() const; michael@0: michael@0: virtual void setBoundTexture(gl::Texture2D *texture); michael@0: virtual gl::Texture2D *getBoundTexture() const; michael@0: michael@0: private: michael@0: DISALLOW_COPY_AND_ASSIGN(Surface); michael@0: michael@0: Display *const mDisplay; michael@0: rx::Renderer *mRenderer; michael@0: michael@0: HANDLE mShareHandle; michael@0: rx::SwapChain *mSwapChain; michael@0: michael@0: void subclassWindow(); michael@0: void unsubclassWindow(); michael@0: bool resizeSwapChain(int backbufferWidth, int backbufferHeight); michael@0: bool resetSwapChain(int backbufferWidth, int backbufferHeight); michael@0: bool swapRect(EGLint x, EGLint y, EGLint width, EGLint height); michael@0: michael@0: const HWND mWindow; // Window that the surface is created for. michael@0: bool mWindowSubclassed; // Indicates whether we successfully subclassed mWindow for WM_RESIZE hooking michael@0: const egl::Config *mConfig; // EGL config surface was created with michael@0: EGLint mHeight; // Height of surface michael@0: EGLint mWidth; // Width of surface michael@0: // EGLint horizontalResolution; // Horizontal dot pitch michael@0: // EGLint verticalResolution; // Vertical dot pitch michael@0: // EGLBoolean largestPBuffer; // If true, create largest pbuffer possible michael@0: // EGLBoolean mipmapTexture; // True if texture has mipmaps michael@0: // EGLint mipmapLevel; // Mipmap level to render to michael@0: // EGLenum multisampleResolve; // Multisample resolve behavior michael@0: EGLint mPixelAspectRatio; // Display aspect ratio michael@0: EGLenum mRenderBuffer; // Render buffer michael@0: EGLenum mSwapBehavior; // Buffer swap behavior michael@0: EGLenum mTextureFormat; // Format of texture: RGB, RGBA, or no texture michael@0: EGLenum mTextureTarget; // Type of texture: 2D or no texture michael@0: // EGLenum vgAlphaFormat; // Alpha format for OpenVG michael@0: // EGLenum vgColorSpace; // Color space for OpenVG michael@0: EGLint mSwapInterval; michael@0: EGLint mPostSubBufferSupported; michael@0: michael@0: bool mSwapIntervalDirty; michael@0: gl::Texture2D *mTexture; michael@0: }; michael@0: } michael@0: michael@0: #endif // LIBEGL_SURFACE_H_