2 // Copyright (c) 2002-2010 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 INCLUDE_SURFACE_H_
12 #define INCLUDE_SURFACE_H_
18 #include "common/angleutils.h"
28 Surface(Display *display, const egl::Config *config, HWND window);
33 void resetSwapChain();
35 HWND getWindowHandle();
38 virtual EGLint getWidth() const;
39 virtual EGLint getHeight() const;
41 virtual IDirect3DSurface9 *getRenderTarget();
42 virtual IDirect3DSurface9 *getDepthStencil();
44 void setSwapInterval(EGLint interval);
45 bool checkForOutOfDateSwapChain(); // Returns true if swapchain changed due to resize or interval update
48 DISALLOW_COPY_AND_ASSIGN(Surface);
50 Display *const mDisplay;
51 IDirect3DSwapChain9 *mSwapChain;
52 IDirect3DSurface9 *mBackBuffer;
53 IDirect3DSurface9 *mDepthStencil;
54 IDirect3DTexture9 *mFlipTexture;
56 void subclassWindow();
57 void unsubclassWindow();
58 void resetSwapChain(int backbufferWidth, int backbufferHeight);
59 static DWORD convertInterval(EGLint interval);
61 void applyFlipState(IDirect3DDevice9 *device);
62 void restoreState(IDirect3DDevice9 *device);
63 void writeRecordableFlipState(IDirect3DDevice9 *device);
64 void releaseRecordedState(IDirect3DDevice9 *device);
65 IDirect3DStateBlock9 *mFlipState;
66 IDirect3DStateBlock9 *mPreFlipState;
67 IDirect3DSurface9 *mPreFlipBackBuffer;
68 IDirect3DSurface9 *mPreFlipDepthStencil;
70 const HWND mWindow; // Window that the surface is created for.
71 bool mWindowSubclassed; // Indicates whether we successfully subclassed mWindow for WM_RESIZE hooking
72 const egl::Config *mConfig; // EGL config surface was created with
73 EGLint mHeight; // Height of surface
74 EGLint mWidth; // Width of surface
75 // EGLint horizontalResolution; // Horizontal dot pitch
76 // EGLint verticalResolution; // Vertical dot pitch
77 // EGLBoolean largestPBuffer; // If true, create largest pbuffer possible
78 // EGLBoolean mipmapTexture; // True if texture has mipmaps
79 // EGLint mipmapLevel; // Mipmap level to render to
80 // EGLenum multisampleResolve; // Multisample resolve behavior
81 EGLint mPixelAspectRatio; // Display aspect ratio
82 EGLenum mRenderBuffer; // Render buffer
83 EGLenum mSwapBehavior; // Buffer swap behavior
84 // EGLenum textureFormat; // Format of texture: RGB, RGBA, or no texture
85 // EGLenum textureTarget; // Type of texture: 2D or no texture
86 // EGLenum vgAlphaFormat; // Alpha format for OpenVG
87 // EGLenum vgColorSpace; // Color space for OpenVG
89 DWORD mPresentInterval;
90 bool mPresentIntervalDirty;
94 #endif // INCLUDE_SURFACE_H_