• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 //
2 // Copyright 2014 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 // TextureImpl.h: Defines the abstract rx::TextureImpl classes.
8 
9 #ifndef LIBANGLE_RENDERER_TEXTUREIMPL_H_
10 #define LIBANGLE_RENDERER_TEXTUREIMPL_H_
11 
12 #include <stdint.h>
13 
14 #include "angle_gl.h"
15 #include "common/angleutils.h"
16 #include "libANGLE/Error.h"
17 #include "libANGLE/ImageIndex.h"
18 #include "libANGLE/Stream.h"
19 #include "libANGLE/Texture.h"
20 #include "libANGLE/renderer/FramebufferAttachmentObjectImpl.h"
21 
22 namespace egl
23 {
24 class Surface;
25 class Image;
26 }  // namespace egl
27 
28 namespace gl
29 {
30 struct Box;
31 struct Extents;
32 struct Offset;
33 struct Rectangle;
34 class Framebuffer;
35 class MemoryObject;
36 struct PixelUnpackState;
37 class TextureState;
38 }  // namespace gl
39 
40 namespace rx
41 {
42 class ContextImpl;
43 
44 class TextureImpl : public FramebufferAttachmentObjectImpl
45 {
46   public:
47     TextureImpl(const gl::TextureState &state);
48     ~TextureImpl() override;
49 
50     virtual void onDestroy(const gl::Context *context);
51 
52     virtual angle::Result setImage(const gl::Context *context,
53                                    const gl::ImageIndex &index,
54                                    GLenum internalFormat,
55                                    const gl::Extents &size,
56                                    GLenum format,
57                                    GLenum type,
58                                    const gl::PixelUnpackState &unpack,
59                                    gl::Buffer *unpackBuffer,
60                                    const uint8_t *pixels)    = 0;
61     virtual angle::Result setSubImage(const gl::Context *context,
62                                       const gl::ImageIndex &index,
63                                       const gl::Box &area,
64                                       GLenum format,
65                                       GLenum type,
66                                       const gl::PixelUnpackState &unpack,
67                                       gl::Buffer *unpackBuffer,
68                                       const uint8_t *pixels) = 0;
69 
70     virtual angle::Result setCompressedImage(const gl::Context *context,
71                                              const gl::ImageIndex &index,
72                                              GLenum internalFormat,
73                                              const gl::Extents &size,
74                                              const gl::PixelUnpackState &unpack,
75                                              size_t imageSize,
76                                              const uint8_t *pixels)    = 0;
77     virtual angle::Result setCompressedSubImage(const gl::Context *context,
78                                                 const gl::ImageIndex &index,
79                                                 const gl::Box &area,
80                                                 GLenum format,
81                                                 const gl::PixelUnpackState &unpack,
82                                                 size_t imageSize,
83                                                 const uint8_t *pixels) = 0;
84 
85     virtual angle::Result copyImage(const gl::Context *context,
86                                     const gl::ImageIndex &index,
87                                     const gl::Rectangle &sourceArea,
88                                     GLenum internalFormat,
89                                     gl::Framebuffer *source)    = 0;
90     virtual angle::Result copySubImage(const gl::Context *context,
91                                        const gl::ImageIndex &index,
92                                        const gl::Offset &destOffset,
93                                        const gl::Rectangle &sourceArea,
94                                        gl::Framebuffer *source) = 0;
95 
96     virtual angle::Result copyTexture(const gl::Context *context,
97                                       const gl::ImageIndex &index,
98                                       GLenum internalFormat,
99                                       GLenum type,
100                                       GLint sourceLevel,
101                                       bool unpackFlipY,
102                                       bool unpackPremultiplyAlpha,
103                                       bool unpackUnmultiplyAlpha,
104                                       const gl::Texture *source);
105     virtual angle::Result copySubTexture(const gl::Context *context,
106                                          const gl::ImageIndex &index,
107                                          const gl::Offset &destOffset,
108                                          GLint sourceLevel,
109                                          const gl::Box &sourceBox,
110                                          bool unpackFlipY,
111                                          bool unpackPremultiplyAlpha,
112                                          bool unpackUnmultiplyAlpha,
113                                          const gl::Texture *source);
114 
115     virtual angle::Result copyRenderbufferSubData(const gl::Context *context,
116                                                   const gl::Renderbuffer *srcBuffer,
117                                                   GLint srcLevel,
118                                                   GLint srcX,
119                                                   GLint srcY,
120                                                   GLint srcZ,
121                                                   GLint dstLevel,
122                                                   GLint dstX,
123                                                   GLint dstY,
124                                                   GLint dstZ,
125                                                   GLsizei srcWidth,
126                                                   GLsizei srcHeight,
127                                                   GLsizei srcDepth);
128 
129     virtual angle::Result copyTextureSubData(const gl::Context *context,
130                                              const gl::Texture *srcTexture,
131                                              GLint srcLevel,
132                                              GLint srcX,
133                                              GLint srcY,
134                                              GLint srcZ,
135                                              GLint dstLevel,
136                                              GLint dstX,
137                                              GLint dstY,
138                                              GLint dstZ,
139                                              GLsizei srcWidth,
140                                              GLsizei srcHeight,
141                                              GLsizei srcDepth);
142 
143     virtual angle::Result copyCompressedTexture(const gl::Context *context,
144                                                 const gl::Texture *source);
145 
146     virtual angle::Result copy3DTexture(const gl::Context *context,
147                                         gl::TextureTarget target,
148                                         GLenum internalFormat,
149                                         GLenum type,
150                                         GLint sourceLevel,
151                                         GLint destLevel,
152                                         bool unpackFlipY,
153                                         bool unpackPremultiplyAlpha,
154                                         bool unpackUnmultiplyAlpha,
155                                         const gl::Texture *source);
156     virtual angle::Result copy3DSubTexture(const gl::Context *context,
157                                            const gl::TextureTarget target,
158                                            const gl::Offset &destOffset,
159                                            GLint sourceLevel,
160                                            GLint destLevel,
161                                            const gl::Box &srcBox,
162                                            bool unpackFlipY,
163                                            bool unpackPremultiplyAlpha,
164                                            bool unpackUnmultiplyAlpha,
165                                            const gl::Texture *source);
166 
167     virtual angle::Result setStorage(const gl::Context *context,
168                                      gl::TextureType type,
169                                      size_t levels,
170                                      GLenum internalFormat,
171                                      const gl::Extents &size) = 0;
172 
173     virtual angle::Result setStorageMultisample(const gl::Context *context,
174                                                 gl::TextureType type,
175                                                 GLsizei samples,
176                                                 GLint internalformat,
177                                                 const gl::Extents &size,
178                                                 bool fixedSampleLocations) = 0;
179 
180     virtual angle::Result setStorageExternalMemory(const gl::Context *context,
181                                                    gl::TextureType type,
182                                                    size_t levels,
183                                                    GLenum internalFormat,
184                                                    const gl::Extents &size,
185                                                    gl::MemoryObject *memoryObject,
186                                                    GLuint64 offset,
187                                                    GLbitfield createFlags,
188                                                    GLbitfield usageFlags) = 0;
189 
190     virtual angle::Result setImageExternal(const gl::Context *context,
191                                            const gl::ImageIndex &index,
192                                            GLenum internalFormat,
193                                            const gl::Extents &size,
194                                            GLenum format,
195                                            GLenum type);
196 
197     virtual angle::Result setEGLImageTarget(const gl::Context *context,
198                                             gl::TextureType type,
199                                             egl::Image *image) = 0;
200 
201     virtual angle::Result setImageExternal(const gl::Context *context,
202                                            gl::TextureType type,
203                                            egl::Stream *stream,
204                                            const egl::Stream::GLTextureDescription &desc) = 0;
205 
206     virtual angle::Result setBuffer(const gl::Context *context, GLenum internalFormat);
207 
208     virtual angle::Result generateMipmap(const gl::Context *context) = 0;
209 
210     virtual angle::Result setBaseLevel(const gl::Context *context, GLuint baseLevel) = 0;
211 
212     virtual angle::Result bindTexImage(const gl::Context *context, egl::Surface *surface) = 0;
213     virtual angle::Result releaseTexImage(const gl::Context *context)                     = 0;
214 
215     // Override if accurate native memory size information is available
216     virtual GLint getMemorySize() const;
217     virtual GLint getLevelMemorySize(gl::TextureTarget target, GLint level);
218 
219     virtual GLint getNativeID() const;
220 
221     virtual angle::Result syncState(const gl::Context *context,
222                                     const gl::Texture::DirtyBits &dirtyBits,
223                                     gl::Command source) = 0;
224 
225     virtual GLenum getColorReadFormat(const gl::Context *context);
226     virtual GLenum getColorReadType(const gl::Context *context);
227 
228     virtual angle::Result getTexImage(const gl::Context *context,
229                                       const gl::PixelPackState &packState,
230                                       gl::Buffer *packBuffer,
231                                       gl::TextureTarget target,
232                                       GLint level,
233                                       GLenum format,
234                                       GLenum type,
235                                       void *pixels);
236 
237     virtual GLint getRequiredExternalTextureImageUnits(const gl::Context *context);
238 
239   protected:
240     const gl::TextureState &mState;
241 };
242 
243 }  // namespace rx
244 
245 #endif  // LIBANGLE_RENDERER_TEXTUREIMPL_H_
246