1 // 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 rx::Image class, an abstract base class for the 8 // renderer-specific classes which will define the interface to the underlying 9 // surfaces or resources. 10 11 #ifndef LIBGLESV2_RENDERER_IMAGE_H_ 12 #define LIBGLESV2_RENDERER_IMAGE_H_ 13 14 #include "common/debug.h" 15 16 namespace gl 17 { 18 class Framebuffer; 19 } 20 21 namespace rx 22 { 23 class Renderer; 24 class TextureStorageInterface2D; 25 class TextureStorageInterfaceCube; 26 27 class Image 28 { 29 public: 30 Image(); ~Image()31 virtual ~Image() {}; 32 getWidth()33 GLsizei getWidth() const { return mWidth; } getHeight()34 GLsizei getHeight() const { return mHeight; } getInternalFormat()35 GLenum getInternalFormat() const { return mInternalFormat; } getActualFormat()36 GLenum getActualFormat() const { return mActualFormat; } 37 markDirty()38 void markDirty() {mDirty = true;} markClean()39 void markClean() {mDirty = false;} 40 virtual bool isDirty() const = 0; 41 setManagedSurface(TextureStorageInterface2D * storage,int level)42 virtual void setManagedSurface(TextureStorageInterface2D *storage, int level) {}; setManagedSurface(TextureStorageInterfaceCube * storage,int face,int level)43 virtual void setManagedSurface(TextureStorageInterfaceCube *storage, int face, int level) {}; 44 virtual bool updateSurface(TextureStorageInterface2D *storage, int level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height) = 0; 45 virtual bool updateSurface(TextureStorageInterfaceCube *storage, int face, int level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height) = 0; 46 47 virtual bool redefine(Renderer *renderer, GLint internalformat, GLsizei width, GLsizei height, bool forceRelease) = 0; 48 49 virtual bool isRenderableFormat() const = 0; 50 51 virtual void loadData(GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, 52 GLint unpackAlignment, const void *input) = 0; 53 virtual void loadCompressedData(GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, 54 const void *input) = 0; 55 56 virtual void copy(GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height, gl::Framebuffer *source) = 0; 57 58 static void loadAlphaDataToBGRA(GLsizei width, GLsizei height, 59 int inputPitch, const void *input, size_t outputPitch, void *output); 60 static void loadAlphaDataToNative(GLsizei width, GLsizei height, 61 int inputPitch, const void *input, size_t outputPitch, void *output); 62 static void loadAlphaDataToBGRASSE2(GLsizei width, GLsizei height, 63 int inputPitch, const void *input, size_t outputPitch, void *output); 64 static void loadAlphaFloatDataToRGBA(GLsizei width, GLsizei height, 65 int inputPitch, const void *input, size_t outputPitch, void *output); 66 static void loadAlphaHalfFloatDataToRGBA(GLsizei width, GLsizei height, 67 int inputPitch, const void *input, size_t outputPitch, void *output); 68 static void loadLuminanceDataToNativeOrBGRA(GLsizei width, GLsizei height, 69 int inputPitch, const void *input, size_t outputPitch, void *output, bool native); 70 static void loadLuminanceFloatDataToRGBA(GLsizei width, GLsizei height, 71 int inputPitch, const void *input, size_t outputPitch, void *output); 72 static void loadLuminanceFloatDataToRGB(GLsizei width, GLsizei height, 73 int inputPitch, const void *input, size_t outputPitch, void *output); 74 static void loadLuminanceHalfFloatDataToRGBA(GLsizei width, GLsizei height, 75 int inputPitch, const void *input, size_t outputPitch, void *output); 76 static void loadLuminanceAlphaDataToNativeOrBGRA(GLsizei width, GLsizei height, 77 int inputPitch, const void *input, size_t outputPitch, void *output, bool native); 78 static void loadLuminanceAlphaFloatDataToRGBA(GLsizei width, GLsizei height, 79 int inputPitch, const void *input, size_t outputPitch, void *output); 80 static void loadLuminanceAlphaHalfFloatDataToRGBA(GLsizei width, GLsizei height, 81 int inputPitch, const void *input, size_t outputPitch, void *output); 82 static void loadRGBUByteDataToBGRX(GLsizei width, GLsizei height, 83 int inputPitch, const void *input, size_t outputPitch, void *output); 84 static void loadRGBUByteDataToRGBA(GLsizei width, GLsizei height, 85 int inputPitch, const void *input, size_t outputPitch, void *output); 86 static void loadRGB565DataToBGRA(GLsizei width, GLsizei height, 87 int inputPitch, const void *input, size_t outputPitch, void *output); 88 static void loadRGB565DataToRGBA(GLsizei width, GLsizei height, 89 int inputPitch, const void *input, size_t outputPitch, void *output); 90 static void loadRGBFloatDataToRGBA(GLsizei width, GLsizei height, 91 int inputPitch, const void *input, size_t outputPitch, void *output); 92 static void loadRGBFloatDataToNative(GLsizei width, GLsizei height, 93 int inputPitch, const void *input, size_t outputPitch, void *output); 94 static void loadRGBHalfFloatDataToRGBA(GLsizei width, GLsizei height, 95 int inputPitch, const void *input, size_t outputPitch, void *output); 96 static void loadRGBAUByteDataToBGRASSE2(GLsizei width, GLsizei height, 97 int inputPitch, const void *input, size_t outputPitch, void *output); 98 static void loadRGBAUByteDataToBGRA(GLsizei width, GLsizei height, 99 int inputPitch, const void *input, size_t outputPitch, void *output); 100 static void loadRGBAUByteDataToNative(GLsizei width, GLsizei height, 101 int inputPitch, const void *input, size_t outputPitch, void *output); 102 static void loadRGBA4444DataToBGRA(GLsizei width, GLsizei height, 103 int inputPitch, const void *input, size_t outputPitch, void *output); 104 static void loadRGBA4444DataToRGBA(GLsizei width, GLsizei height, 105 int inputPitch, const void *input, size_t outputPitch, void *output); 106 static void loadRGBA5551DataToBGRA(GLsizei width, GLsizei height, 107 int inputPitch, const void *input, size_t outputPitch, void *output); 108 static void loadRGBA5551DataToRGBA(GLsizei width, GLsizei height, 109 int inputPitch, const void *input, size_t outputPitch, void *output); 110 static void loadRGBAFloatDataToRGBA(GLsizei width, GLsizei height, 111 int inputPitch, const void *input, size_t outputPitch, void *output); 112 static void loadRGBAHalfFloatDataToRGBA(GLsizei width, GLsizei height, 113 int inputPitch, const void *input, size_t outputPitch, void *output); 114 static void loadBGRADataToBGRA(GLsizei width, GLsizei height, 115 int inputPitch, const void *input, size_t outputPitch, void *output); 116 117 protected: 118 GLsizei mWidth; 119 GLsizei mHeight; 120 GLint mInternalFormat; 121 GLenum mActualFormat; 122 123 bool mDirty; 124 125 private: 126 DISALLOW_COPY_AND_ASSIGN(Image); 127 }; 128 129 } 130 131 #endif // LIBGLESV2_RENDERER_IMAGE_H_ 132