daniel@transgaming.com | b9d7e6f | 2012-10-31 19:08:32 +0000 | [diff] [blame] | 1 | // |
| 2 | // Copyright (c) 2002-2012 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 | // Image.h: Defines the gl::Image class, which acts as the interface to |
| 8 | // the actual underlying surfaces of a Texture. |
| 9 | |
| 10 | #ifndef LIBGLESV2_RENDERER_IMAGE_H_ |
| 11 | #define LIBGLESV2_RENDERER_IMAGE_H_ |
| 12 | |
| 13 | #define GL_APICALL |
| 14 | #include <GLES2/gl2.h> |
| 15 | #include <d3d9.h> |
| 16 | |
| 17 | #include "common/debug.h" |
| 18 | |
| 19 | namespace gl |
| 20 | { |
daniel@transgaming.com | 0f195ad | 2012-10-31 19:51:59 +0000 | [diff] [blame] | 21 | class TextureStorage2D; |
| 22 | class TextureStorageCubeMap; |
| 23 | |
daniel@transgaming.com | b9d7e6f | 2012-10-31 19:08:32 +0000 | [diff] [blame] | 24 | class Image |
| 25 | { |
| 26 | public: |
| 27 | Image(); |
| 28 | ~Image(); |
| 29 | |
daniel@transgaming.com | 0ad830b | 2012-10-31 19:52:12 +0000 | [diff] [blame^] | 30 | static void GenerateMipmap(Image *dest, Image *source); |
daniel@transgaming.com | b9d7e6f | 2012-10-31 19:08:32 +0000 | [diff] [blame] | 31 | static void Image::CopyLockableSurfaces(IDirect3DSurface9 *dest, IDirect3DSurface9 *source); |
| 32 | |
| 33 | bool redefine(GLint internalformat, GLsizei width, GLsizei height, bool forceRelease); |
| 34 | void markDirty() {mDirty = true;} |
| 35 | void markClean() {mDirty = false;} |
| 36 | |
| 37 | bool isRenderableFormat() const; |
| 38 | D3DFORMAT getD3DFormat() const; |
daniel@transgaming.com | 20d3666 | 2012-10-31 19:51:43 +0000 | [diff] [blame] | 39 | GLenum getActualFormat() const; |
daniel@transgaming.com | b9d7e6f | 2012-10-31 19:08:32 +0000 | [diff] [blame] | 40 | |
| 41 | GLsizei getWidth() const {return mWidth;} |
| 42 | GLsizei getHeight() const {return mHeight;} |
| 43 | GLenum getInternalFormat() const {return mInternalFormat;} |
| 44 | bool isDirty() const {return mSurface && mDirty;} |
| 45 | IDirect3DSurface9 *getSurface(); |
| 46 | |
daniel@transgaming.com | 0f195ad | 2012-10-31 19:51:59 +0000 | [diff] [blame] | 47 | void setManagedSurface(TextureStorage2D *storage, int level); |
| 48 | void setManagedSurface(TextureStorageCubeMap *storage, int face, int level); |
| 49 | bool updateSurface(TextureStorage2D *storage, int level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height); |
| 50 | bool updateSurface(TextureStorageCubeMap *storage, int face, int level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height); |
daniel@transgaming.com | b9d7e6f | 2012-10-31 19:08:32 +0000 | [diff] [blame] | 51 | |
| 52 | void loadData(GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, |
| 53 | GLint unpackAlignment, const void *input); |
| 54 | |
| 55 | void loadAlphaData(GLsizei width, GLsizei height, |
| 56 | int inputPitch, const void *input, size_t outputPitch, void *output) const; |
| 57 | void loadAlphaDataSSE2(GLsizei width, GLsizei height, |
| 58 | int inputPitch, const void *input, size_t outputPitch, void *output) const; |
| 59 | void loadAlphaFloatData(GLsizei width, GLsizei height, |
| 60 | int inputPitch, const void *input, size_t outputPitch, void *output) const; |
| 61 | void loadAlphaHalfFloatData(GLsizei width, GLsizei height, |
| 62 | int inputPitch, const void *input, size_t outputPitch, void *output) const; |
| 63 | void loadLuminanceData(GLsizei width, GLsizei height, |
| 64 | int inputPitch, const void *input, size_t outputPitch, void *output, bool native) const; |
| 65 | void loadLuminanceFloatData(GLsizei width, GLsizei height, |
| 66 | int inputPitch, const void *input, size_t outputPitch, void *output) const; |
| 67 | void loadLuminanceHalfFloatData(GLsizei width, GLsizei height, |
| 68 | int inputPitch, const void *input, size_t outputPitch, void *output) const; |
| 69 | void loadLuminanceAlphaData(GLsizei width, GLsizei height, |
| 70 | int inputPitch, const void *input, size_t outputPitch, void *output, bool native) const; |
| 71 | void loadLuminanceAlphaFloatData(GLsizei width, GLsizei height, |
| 72 | int inputPitch, const void *input, size_t outputPitch, void *output) const; |
| 73 | void loadLuminanceAlphaHalfFloatData(GLsizei width, GLsizei height, |
| 74 | int inputPitch, const void *input, size_t outputPitch, void *output) const; |
| 75 | void loadRGBUByteData(GLsizei width, GLsizei height, |
| 76 | int inputPitch, const void *input, size_t outputPitch, void *output) const; |
| 77 | void loadRGB565Data(GLsizei width, GLsizei height, |
| 78 | int inputPitch, const void *input, size_t outputPitch, void *output) const; |
| 79 | void loadRGBFloatData(GLsizei width, GLsizei height, |
| 80 | int inputPitch, const void *input, size_t outputPitch, void *output) const; |
| 81 | void loadRGBHalfFloatData(GLsizei width, GLsizei height, |
| 82 | int inputPitch, const void *input, size_t outputPitch, void *output) const; |
| 83 | void loadRGBAUByteDataSSE2(GLsizei width, GLsizei height, |
| 84 | int inputPitch, const void *input, size_t outputPitch, void *output) const; |
| 85 | void loadRGBAUByteData(GLsizei width, GLsizei height, |
| 86 | int inputPitch, const void *input, size_t outputPitch, void *output) const; |
| 87 | void loadRGBA4444Data(GLsizei width, GLsizei height, |
| 88 | int inputPitch, const void *input, size_t outputPitch, void *output) const; |
| 89 | void loadRGBA5551Data(GLsizei width, GLsizei height, |
| 90 | int inputPitch, const void *input, size_t outputPitch, void *output) const; |
| 91 | void loadRGBAFloatData(GLsizei width, GLsizei height, |
| 92 | int inputPitch, const void *input, size_t outputPitch, void *output) const; |
| 93 | void loadRGBAHalfFloatData(GLsizei width, GLsizei height, |
| 94 | int inputPitch, const void *input, size_t outputPitch, void *output) const; |
| 95 | void loadBGRAData(GLsizei width, GLsizei height, |
| 96 | int inputPitch, const void *input, size_t outputPitch, void *output) const; |
| 97 | void loadCompressedData(GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, |
| 98 | const void *input); |
| 99 | |
| 100 | void copy(GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height, IDirect3DSurface9 *renderTarget); |
| 101 | |
| 102 | private: |
| 103 | DISALLOW_COPY_AND_ASSIGN(Image); |
| 104 | |
| 105 | void createSurface(); |
daniel@transgaming.com | 0f195ad | 2012-10-31 19:51:59 +0000 | [diff] [blame] | 106 | void setManagedSurface(IDirect3DSurface9 *surface); |
| 107 | bool updateSurface(IDirect3DSurface9 *dest, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height); |
daniel@transgaming.com | b9d7e6f | 2012-10-31 19:08:32 +0000 | [diff] [blame] | 108 | |
| 109 | HRESULT lock(D3DLOCKED_RECT *lockedRect, const RECT *rect); |
| 110 | void unlock(); |
| 111 | |
| 112 | GLsizei mWidth; |
| 113 | GLsizei mHeight; |
| 114 | GLint mInternalFormat; |
| 115 | |
| 116 | bool mDirty; |
| 117 | |
| 118 | D3DPOOL mD3DPool; // can only be D3DPOOL_SYSTEMMEM or D3DPOOL_MANAGED since it needs to be lockable. |
| 119 | D3DFORMAT mD3DFormat; |
daniel@transgaming.com | 20d3666 | 2012-10-31 19:51:43 +0000 | [diff] [blame] | 120 | GLenum mActualFormat; |
daniel@transgaming.com | b9d7e6f | 2012-10-31 19:08:32 +0000 | [diff] [blame] | 121 | |
| 122 | IDirect3DSurface9 *mSurface; |
| 123 | }; |
| 124 | } |
| 125 | |
| 126 | #endif // LIBGLESV2_RENDERER_IMAGE_H_ |