• 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, public angle::Subject
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                                       size_t 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                                          size_t 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 copyCompressedTexture(const gl::Context *context,
116                                                 const gl::Texture *source);
117 
118     virtual angle::Result copy3DTexture(const gl::Context *context,
119                                         gl::TextureTarget target,
120                                         GLenum internalFormat,
121                                         GLenum type,
122                                         size_t sourceLevel,
123                                         size_t destLevel,
124                                         bool unpackFlipY,
125                                         bool unpackPremultiplyAlpha,
126                                         bool unpackUnmultiplyAlpha,
127                                         const gl::Texture *source);
128     virtual angle::Result copy3DSubTexture(const gl::Context *context,
129                                            const gl::TextureTarget target,
130                                            const gl::Offset &destOffset,
131                                            size_t sourceLevel,
132                                            size_t destLevel,
133                                            const gl::Box &srcBox,
134                                            bool unpackFlipY,
135                                            bool unpackPremultiplyAlpha,
136                                            bool unpackUnmultiplyAlpha,
137                                            const gl::Texture *source);
138 
139     virtual angle::Result setStorage(const gl::Context *context,
140                                      gl::TextureType type,
141                                      size_t levels,
142                                      GLenum internalFormat,
143                                      const gl::Extents &size) = 0;
144 
145     virtual angle::Result setStorageMultisample(const gl::Context *context,
146                                                 gl::TextureType type,
147                                                 GLsizei samples,
148                                                 GLint internalformat,
149                                                 const gl::Extents &size,
150                                                 bool fixedSampleLocations) = 0;
151 
152     virtual angle::Result setStorageExternalMemory(const gl::Context *context,
153                                                    gl::TextureType type,
154                                                    size_t levels,
155                                                    GLenum internalFormat,
156                                                    const gl::Extents &size,
157                                                    gl::MemoryObject *memoryObject,
158                                                    GLuint64 offset) = 0;
159 
160     virtual angle::Result setImageExternal(const gl::Context *context,
161                                            const gl::ImageIndex &index,
162                                            GLenum internalFormat,
163                                            const gl::Extents &size,
164                                            GLenum format,
165                                            GLenum type);
166 
167     virtual angle::Result setEGLImageTarget(const gl::Context *context,
168                                             gl::TextureType type,
169                                             egl::Image *image) = 0;
170 
171     virtual angle::Result setImageExternal(const gl::Context *context,
172                                            gl::TextureType type,
173                                            egl::Stream *stream,
174                                            const egl::Stream::GLTextureDescription &desc) = 0;
175 
176     virtual angle::Result generateMipmap(const gl::Context *context) = 0;
177 
178     virtual angle::Result setBaseLevel(const gl::Context *context, GLuint baseLevel) = 0;
179 
180     virtual angle::Result bindTexImage(const gl::Context *context, egl::Surface *surface) = 0;
181     virtual angle::Result releaseTexImage(const gl::Context *context)                     = 0;
182 
183     // Override if accurate native memory size information is available
184     virtual GLint getMemorySize() const;
185     virtual GLint getLevelMemorySize(gl::TextureTarget target, GLint level);
186 
187     virtual GLint getNativeID() const;
188 
189     virtual angle::Result syncState(const gl::Context *context,
190                                     const gl::Texture::DirtyBits &dirtyBits) = 0;
191 
192     virtual GLenum getColorReadFormat(const gl::Context *context);
193     virtual GLenum getColorReadType(const gl::Context *context);
194 
195     virtual angle::Result getTexImage(const gl::Context *context,
196                                       const gl::PixelPackState &packState,
197                                       gl::Buffer *packBuffer,
198                                       gl::TextureTarget target,
199                                       GLint level,
200                                       GLenum format,
201                                       GLenum type,
202                                       void *pixels);
203 
204   protected:
205     const gl::TextureState &mState;
206 };
207 
208 }  // namespace rx
209 
210 #endif  // LIBANGLE_RENDERER_TEXTUREIMPL_H_
211