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