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