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 const uint8_t *pixels) = 0; 60 virtual angle::Result setSubImage(const gl::Context *context, 61 const gl::ImageIndex &index, 62 const gl::Box &area, 63 GLenum format, 64 GLenum type, 65 const gl::PixelUnpackState &unpack, 66 gl::Buffer *unpackBuffer, 67 const uint8_t *pixels) = 0; 68 69 virtual angle::Result setCompressedImage(const gl::Context *context, 70 const gl::ImageIndex &index, 71 GLenum internalFormat, 72 const gl::Extents &size, 73 const gl::PixelUnpackState &unpack, 74 size_t imageSize, 75 const uint8_t *pixels) = 0; 76 virtual angle::Result setCompressedSubImage(const gl::Context *context, 77 const gl::ImageIndex &index, 78 const gl::Box &area, 79 GLenum format, 80 const gl::PixelUnpackState &unpack, 81 size_t imageSize, 82 const uint8_t *pixels) = 0; 83 84 virtual angle::Result copyImage(const gl::Context *context, 85 const gl::ImageIndex &index, 86 const gl::Rectangle &sourceArea, 87 GLenum internalFormat, 88 gl::Framebuffer *source) = 0; 89 virtual angle::Result copySubImage(const gl::Context *context, 90 const gl::ImageIndex &index, 91 const gl::Offset &destOffset, 92 const gl::Rectangle &sourceArea, 93 gl::Framebuffer *source) = 0; 94 95 virtual angle::Result copyTexture(const gl::Context *context, 96 const gl::ImageIndex &index, 97 GLenum internalFormat, 98 GLenum type, 99 size_t sourceLevel, 100 bool unpackFlipY, 101 bool unpackPremultiplyAlpha, 102 bool unpackUnmultiplyAlpha, 103 const gl::Texture *source); 104 virtual angle::Result copySubTexture(const gl::Context *context, 105 const gl::ImageIndex &index, 106 const gl::Offset &destOffset, 107 size_t sourceLevel, 108 const gl::Box &sourceBox, 109 bool unpackFlipY, 110 bool unpackPremultiplyAlpha, 111 bool unpackUnmultiplyAlpha, 112 const gl::Texture *source); 113 114 virtual angle::Result copyCompressedTexture(const gl::Context *context, 115 const gl::Texture *source); 116 117 virtual angle::Result copy3DTexture(const gl::Context *context, 118 gl::TextureTarget target, 119 GLenum internalFormat, 120 GLenum type, 121 size_t sourceLevel, 122 size_t destLevel, 123 bool unpackFlipY, 124 bool unpackPremultiplyAlpha, 125 bool unpackUnmultiplyAlpha, 126 const gl::Texture *source); 127 virtual angle::Result copy3DSubTexture(const gl::Context *context, 128 const gl::TextureTarget target, 129 const gl::Offset &destOffset, 130 size_t sourceLevel, 131 size_t destLevel, 132 const gl::Box &srcBox, 133 bool unpackFlipY, 134 bool unpackPremultiplyAlpha, 135 bool unpackUnmultiplyAlpha, 136 const gl::Texture *source); 137 138 virtual angle::Result setStorage(const gl::Context *context, 139 gl::TextureType type, 140 size_t levels, 141 GLenum internalFormat, 142 const gl::Extents &size) = 0; 143 144 virtual angle::Result setStorageMultisample(const gl::Context *context, 145 gl::TextureType type, 146 GLsizei samples, 147 GLint internalformat, 148 const gl::Extents &size, 149 bool fixedSampleLocations) = 0; 150 151 virtual angle::Result setStorageExternalMemory(const gl::Context *context, 152 gl::TextureType type, 153 size_t levels, 154 GLenum internalFormat, 155 const gl::Extents &size, 156 gl::MemoryObject *memoryObject, 157 GLuint64 offset) = 0; 158 159 virtual angle::Result setImageExternal(const gl::Context *context, 160 const gl::ImageIndex &index, 161 GLenum internalFormat, 162 const gl::Extents &size, 163 GLenum format, 164 GLenum type); 165 166 virtual angle::Result setEGLImageTarget(const gl::Context *context, 167 gl::TextureType type, 168 egl::Image *image) = 0; 169 170 virtual angle::Result setImageExternal(const gl::Context *context, 171 gl::TextureType type, 172 egl::Stream *stream, 173 const egl::Stream::GLTextureDescription &desc) = 0; 174 175 virtual angle::Result generateMipmap(const gl::Context *context) = 0; 176 177 virtual angle::Result setBaseLevel(const gl::Context *context, GLuint baseLevel) = 0; 178 179 virtual angle::Result bindTexImage(const gl::Context *context, egl::Surface *surface) = 0; 180 virtual angle::Result releaseTexImage(const gl::Context *context) = 0; 181 182 // Override if accurate native memory size information is available 183 virtual GLint getMemorySize() const; 184 virtual GLint getLevelMemorySize(gl::TextureTarget target, GLint level); 185 186 virtual GLint getNativeID() const; 187 188 virtual angle::Result syncState(const gl::Context *context, 189 const gl::Texture::DirtyBits &dirtyBits) = 0; 190 191 protected: 192 const gl::TextureState &mState; 193 }; 194 195 } // namespace rx 196 197 #endif // LIBANGLE_RENDERER_TEXTUREIMPL_H_ 198