Home | History | Annotate | Download | only in libEGL
      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     void release();
     33     void resetSwapChain();
     34 
     35     HWND getWindowHandle();
     36     bool swap();
     37 
     38     virtual EGLint getWidth() const;
     39     virtual EGLint getHeight() const;
     40 
     41     virtual IDirect3DSurface9 *getRenderTarget();
     42     virtual IDirect3DSurface9 *getDepthStencil();
     43 
     44     void setSwapInterval(EGLint interval);
     45     bool checkForOutOfDateSwapChain();   // Returns true if swapchain changed due to resize or interval update
     46 
     47 private:
     48     DISALLOW_COPY_AND_ASSIGN(Surface);
     49 
     50     Display *const mDisplay;
     51     IDirect3DSwapChain9 *mSwapChain;
     52     IDirect3DSurface9 *mBackBuffer;
     53     IDirect3DSurface9 *mDepthStencil;
     54     IDirect3DTexture9 *mFlipTexture;
     55 
     56     void subclassWindow();
     57     void unsubclassWindow();
     58     void resetSwapChain(int backbufferWidth, int backbufferHeight);
     59     static DWORD convertInterval(EGLint interval);
     60 
     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;
     69 
     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
     88     EGLint mSwapInterval;
     89     DWORD mPresentInterval;
     90     bool mPresentIntervalDirty;
     91 };
     92 }
     93 
     94 #endif   // INCLUDE_SURFACE_H_
     95