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