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