2010-09-01 Zhenyao Mo <zmo@google.com>
[WebKit-https.git] / ANGLE / src / libEGL / Surface.h
1 //
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.
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 INCLUDE_SURFACE_H_
12 #define INCLUDE_SURFACE_H_
13
14 #define EGLAPI
15 #include <EGL/egl.h>
16 #include <d3d9.h>
17
18 #include "common/angleutils.h"
19
20 namespace egl
21 {
22 class Display;
23 class Config;
24
25 class Surface
26 {
27   public:
28     Surface(Display *display, const egl::Config *config, HWND window);
29
30     ~Surface();
31
32     HWND getWindowHandle();
33     bool swap();
34
35     virtual EGLint getWidth() const;
36     virtual EGLint getHeight() const;
37
38     virtual IDirect3DSurface9 *getRenderTarget();
39     virtual IDirect3DSurface9 *getDepthStencil();
40
41   private:
42     DISALLOW_COPY_AND_ASSIGN(Surface);
43
44     Display *const mDisplay;
45     IDirect3DSwapChain9 *mSwapChain;
46     IDirect3DSurface9 *mBackBuffer;
47     IDirect3DSurface9 *mRenderTarget;
48     IDirect3DSurface9 *mDepthStencil;
49     IDirect3DTexture9 *mFlipTexture;
50
51     void resetSwapChain();
52     bool checkForWindowResize();
53
54     void applyFlipState(IDirect3DDevice9 *device);
55     void restoreState(IDirect3DDevice9 *device);
56     void writeRecordableFlipState(IDirect3DDevice9 *device);
57     void releaseRecordedState(IDirect3DDevice9 *device);
58     IDirect3DStateBlock9 *mFlipState;
59     IDirect3DStateBlock9 *mPreFlipState;
60     IDirect3DSurface9 *mPreFlipBackBuffer;
61     IDirect3DSurface9 *mPreFlipDepthStencil;
62
63     const HWND mWindow;            // Window that the surface is created for.
64     const egl::Config *mConfig;    // EGL config surface was created with
65     EGLint mHeight;                // Height of surface
66     EGLint mWidth;                 // Width of surface
67 //  EGLint horizontalResolution;   // Horizontal dot pitch
68 //  EGLint verticalResolution;     // Vertical dot pitch
69 //  EGLBoolean largestPBuffer;     // If true, create largest pbuffer possible
70 //  EGLBoolean mipmapTexture;      // True if texture has mipmaps
71 //  EGLint mipmapLevel;            // Mipmap level to render to
72 //  EGLenum multisampleResolve;    // Multisample resolve behavior
73     EGLint mPixelAspectRatio;      // Display aspect ratio
74     EGLenum mRenderBuffer;         // Render buffer
75     EGLenum mSwapBehavior;         // Buffer swap behavior
76 //  EGLenum textureFormat;         // Format of texture: RGB, RGBA, or no texture
77 //  EGLenum textureTarget;         // Type of texture: 2D or no texture
78 //  EGLenum vgAlphaFormat;         // Alpha format for OpenVG
79 //  EGLenum vgColorSpace;          // Color space for OpenVG
80 };
81 }
82
83 #endif   // INCLUDE_SURFACE_H_