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