1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/gfx/angle/src/libGLESv2/renderer/Blit.h Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,94 @@ 1.4 +// 1.5 +// Copyright (c) 2002-2010 The ANGLE Project Authors. All rights reserved. 1.6 +// Use of this source code is governed by a BSD-style license that can be 1.7 +// found in the LICENSE file. 1.8 +// 1.9 + 1.10 +// Blit.cpp: Surface copy utility class. 1.11 + 1.12 +#ifndef LIBGLESV2_BLIT_H_ 1.13 +#define LIBGLESV2_BLIT_H_ 1.14 + 1.15 +#include "common/angleutils.h" 1.16 + 1.17 +namespace gl 1.18 +{ 1.19 +class Framebuffer; 1.20 +} 1.21 + 1.22 +namespace rx 1.23 +{ 1.24 +class Renderer9; 1.25 +class TextureStorageInterface2D; 1.26 +class TextureStorageInterfaceCube; 1.27 + 1.28 +class Blit 1.29 +{ 1.30 + public: 1.31 + explicit Blit(Renderer9 *renderer); 1.32 + ~Blit(); 1.33 + 1.34 + // Copy from source surface to dest surface. 1.35 + // sourceRect, xoffset, yoffset are in D3D coordinates (0,0 in upper-left) 1.36 + bool copy(gl::Framebuffer *framebuffer, const RECT &sourceRect, GLenum destFormat, GLint xoffset, GLint yoffset, TextureStorageInterface2D *storage, GLint level); 1.37 + bool copy(gl::Framebuffer *framebuffer, const RECT &sourceRect, GLenum destFormat, GLint xoffset, GLint yoffset, TextureStorageInterfaceCube *storage, GLenum target, GLint level); 1.38 + 1.39 + // Copy from source surface to dest surface. 1.40 + // sourceRect, xoffset, yoffset are in D3D coordinates (0,0 in upper-left) 1.41 + // source is interpreted as RGBA and destFormat specifies the desired result format. For example, if destFormat = GL_RGB, the alpha channel will be forced to 0. 1.42 + bool formatConvert(IDirect3DSurface9 *source, const RECT &sourceRect, GLenum destFormat, GLint xoffset, GLint yoffset, IDirect3DSurface9 *dest); 1.43 + 1.44 + // 2x2 box filter sample from source to dest. 1.45 + // Requires that source is RGB(A) and dest has the same format as source. 1.46 + bool boxFilter(IDirect3DSurface9 *source, IDirect3DSurface9 *dest); 1.47 + 1.48 + private: 1.49 + rx::Renderer9 *mRenderer; 1.50 + 1.51 + IDirect3DVertexBuffer9 *mQuadVertexBuffer; 1.52 + IDirect3DVertexDeclaration9 *mQuadVertexDeclaration; 1.53 + 1.54 + void initGeometry(); 1.55 + 1.56 + bool setFormatConvertShaders(GLenum destFormat); 1.57 + 1.58 + bool copy(IDirect3DSurface9 *source, const RECT &sourceRect, GLenum destFormat, GLint xoffset, GLint yoffset, IDirect3DSurface9 *dest); 1.59 + IDirect3DTexture9 *copySurfaceToTexture(IDirect3DSurface9 *surface, const RECT &sourceRect); 1.60 + void setViewport(const RECT &sourceRect, GLint xoffset, GLint yoffset); 1.61 + void setCommonBlitState(); 1.62 + RECT getSurfaceRect(IDirect3DSurface9 *surface) const; 1.63 + 1.64 + // This enum is used to index mCompiledShaders and mShaderSource. 1.65 + enum ShaderId 1.66 + { 1.67 + SHADER_VS_STANDARD, 1.68 + SHADER_VS_FLIPY, 1.69 + SHADER_PS_PASSTHROUGH, 1.70 + SHADER_PS_LUMINANCE, 1.71 + SHADER_PS_COMPONENTMASK, 1.72 + SHADER_COUNT 1.73 + }; 1.74 + 1.75 + // This actually contains IDirect3DVertexShader9 or IDirect3DPixelShader9 casted to IUnknown. 1.76 + IUnknown *mCompiledShaders[SHADER_COUNT]; 1.77 + 1.78 + template <class D3DShaderType> 1.79 + bool setShader(ShaderId source, const char *profile, 1.80 + D3DShaderType *(Renderer9::*createShader)(const DWORD *, size_t length), 1.81 + HRESULT (WINAPI IDirect3DDevice9::*setShader)(D3DShaderType*)); 1.82 + 1.83 + bool setVertexShader(ShaderId shader); 1.84 + bool setPixelShader(ShaderId shader); 1.85 + void render(); 1.86 + 1.87 + void saveState(); 1.88 + void restoreState(); 1.89 + IDirect3DStateBlock9 *mSavedStateBlock; 1.90 + IDirect3DSurface9 *mSavedRenderTarget; 1.91 + IDirect3DSurface9 *mSavedDepthStencil; 1.92 + 1.93 + DISALLOW_COPY_AND_ASSIGN(Blit); 1.94 +}; 1.95 +} 1.96 + 1.97 +#endif // LIBGLESV2_BLIT_H_