gfx/angle/src/libGLESv2/Texture.h

Sat, 03 Jan 2015 20:18:00 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Sat, 03 Jan 2015 20:18:00 +0100
branch
TOR_BUG_3246
changeset 7
129ffea94266
permissions
-rw-r--r--

Conditionally enable double key logic according to:
private browsing mode or privacy.thirdparty.isolate preference and
implement in GetCookieStringCommon and FindCookie where it counts...
With some reservations of how to convince FindCookie users to test
condition and pass a nullptr when disabling double key logic.

     1 //
     2 // Copyright (c) 2002-2013 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 //
     7 // Texture.h: Defines the abstract gl::Texture class and its concrete derived
     8 // classes Texture2D and TextureCubeMap. Implements GL texture objects and
     9 // related functionality. [OpenGL ES 2.0.24] section 3.7 page 63.
    11 #ifndef LIBGLESV2_TEXTURE_H_
    12 #define LIBGLESV2_TEXTURE_H_
    14 #include <vector>
    16 #define GL_APICALL
    17 #include <GLES2/gl2.h>
    19 #include "common/debug.h"
    20 #include "common/RefCountObject.h"
    21 #include "libGLESv2/angletypes.h"
    23 namespace egl
    24 {
    25 class Surface;
    26 }
    28 namespace rx
    29 {
    30 class Renderer;
    31 class TextureStorageInterface;
    32 class TextureStorageInterface2D;
    33 class TextureStorageInterfaceCube;
    34 class RenderTarget;
    35 class Image;
    36 }
    38 namespace gl
    39 {
    40 class Framebuffer;
    41 class Renderbuffer;
    43 enum
    44 {
    45     // These are the maximums the implementation can support
    46     // The actual GL caps are limited by the device caps
    47     // and should be queried from the Context
    48     IMPLEMENTATION_MAX_TEXTURE_SIZE = 16384,
    49     IMPLEMENTATION_MAX_CUBE_MAP_TEXTURE_SIZE = 16384,
    51     IMPLEMENTATION_MAX_TEXTURE_LEVELS = 15   // 1+log2 of MAX_TEXTURE_SIZE
    52 };
    54 class Texture : public RefCountObject
    55 {
    56   public:
    57     Texture(rx::Renderer *renderer, GLuint id);
    59     virtual ~Texture();
    61     virtual void addProxyRef(const Renderbuffer *proxy) = 0;
    62     virtual void releaseProxy(const Renderbuffer *proxy) = 0;
    64     virtual GLenum getTarget() const = 0;
    66     bool setMinFilter(GLenum filter);
    67     bool setMagFilter(GLenum filter);
    68     bool setWrapS(GLenum wrap);
    69     bool setWrapT(GLenum wrap);
    70     bool setMaxAnisotropy(float textureMaxAnisotropy, float contextMaxAnisotropy);
    71     bool setUsage(GLenum usage);
    73     GLenum getMinFilter() const;
    74     GLenum getMagFilter() const;
    75     GLenum getWrapS() const;
    76     GLenum getWrapT() const;
    77     float getMaxAnisotropy() const;
    78     int getLodOffset();
    79     void getSamplerState(SamplerState *sampler);
    80     GLenum getUsage() const;
    81     bool isMipmapFiltered() const;
    83     virtual bool isSamplerComplete() const = 0;
    85     rx::TextureStorageInterface *getNativeTexture();
    86     virtual Renderbuffer *getRenderbuffer(GLenum target) = 0;
    88     virtual void generateMipmaps() = 0;
    89     virtual void copySubImage(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height, Framebuffer *source) = 0;
    91     bool hasDirtyParameters() const;
    92     bool hasDirtyImages() const;
    93     void resetDirty();
    94     unsigned int getTextureSerial();
    95     unsigned int getRenderTargetSerial(GLenum target);
    97     bool isImmutable() const;
    99     static const GLuint INCOMPLETE_TEXTURE_ID = static_cast<GLuint>(-1);   // Every texture takes an id at creation time. The value is arbitrary because it is never registered with the resource manager.
   101   protected:
   102     void setImage(GLint unpackAlignment, const void *pixels, rx::Image *image);
   103     bool subImage(GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, GLint unpackAlignment, const void *pixels, rx::Image *image);
   104     void setCompressedImage(GLsizei imageSize, const void *pixels, rx::Image *image);
   105     bool subImageCompressed(GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const void *pixels, rx::Image *image);
   107     GLint creationLevels(GLsizei width, GLsizei height) const;
   108     GLint creationLevels(GLsizei size) const;
   110     virtual void createTexture() = 0;
   111     virtual void updateTexture() = 0;
   112     virtual void convertToRenderTarget() = 0;
   113     virtual rx::RenderTarget *getRenderTarget(GLenum target) = 0;
   115     virtual int levelCount() = 0;
   117     rx::Renderer *mRenderer;
   119     SamplerState mSamplerState;
   120     GLenum mUsage;
   122     bool mDirtyImages;
   124     bool mImmutable;
   126   private:
   127     DISALLOW_COPY_AND_ASSIGN(Texture);
   129     virtual rx::TextureStorageInterface *getStorage(bool renderTarget) = 0;
   130 };
   132 class Texture2D : public Texture
   133 {
   134   public:
   135     Texture2D(rx::Renderer *renderer, GLuint id);
   137     ~Texture2D();
   139     void addProxyRef(const Renderbuffer *proxy);
   140     void releaseProxy(const Renderbuffer *proxy);
   142     virtual GLenum getTarget() const;
   144     GLsizei getWidth(GLint level) const;
   145     GLsizei getHeight(GLint level) const;
   146     GLenum getInternalFormat(GLint level) const;
   147     GLenum getActualFormat(GLint level) const;
   148     bool isCompressed(GLint level) const;
   149     bool isDepth(GLint level) const;
   151     void setImage(GLint level, GLsizei width, GLsizei height, GLenum format, GLenum type, GLint unpackAlignment, const void *pixels);
   152     void setCompressedImage(GLint level, GLenum format, GLsizei width, GLsizei height, GLsizei imageSize, const void *pixels);
   153     void subImage(GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, GLint unpackAlignment, const void *pixels);
   154     void subImageCompressed(GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const void *pixels);
   155     void copyImage(GLint level, GLenum format, GLint x, GLint y, GLsizei width, GLsizei height, Framebuffer *source);
   156     virtual void copySubImage(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height, Framebuffer *source);
   157     void storage(GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height);
   159     virtual bool isSamplerComplete() const;
   160     virtual void bindTexImage(egl::Surface *surface);
   161     virtual void releaseTexImage();
   163     virtual void generateMipmaps();
   165     virtual Renderbuffer *getRenderbuffer(GLenum target);
   167   protected:
   168     friend class RenderbufferTexture2D;
   169     virtual rx::RenderTarget *getRenderTarget(GLenum target);
   170     virtual rx::RenderTarget *getDepthStencil(GLenum target);
   171     virtual int levelCount();
   173   private:
   174     DISALLOW_COPY_AND_ASSIGN(Texture2D);
   176     virtual void createTexture();
   177     virtual void updateTexture();
   178     virtual void convertToRenderTarget();
   179     virtual rx::TextureStorageInterface *getStorage(bool renderTarget);
   181     bool isMipmapComplete() const;
   183     void redefineImage(GLint level, GLint internalformat, GLsizei width, GLsizei height);
   184     void commitRect(GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height);
   186     rx::Image *mImageArray[IMPLEMENTATION_MAX_TEXTURE_LEVELS];
   188     rx::TextureStorageInterface2D *mTexStorage;
   189     egl::Surface *mSurface;
   191     // A specific internal reference count is kept for colorbuffer proxy references,
   192     // because, as the renderbuffer acting as proxy will maintain a binding pointer
   193     // back to this texture, there would be a circular reference if we used a binding
   194     // pointer here. This reference count will cause the pointer to be set to NULL if
   195     // the count drops to zero, but will not cause deletion of the Renderbuffer.
   196     Renderbuffer *mColorbufferProxy;
   197     unsigned int mProxyRefs;
   198 };
   200 class TextureCubeMap : public Texture
   201 {
   202   public:
   203     TextureCubeMap(rx::Renderer *renderer, GLuint id);
   205     ~TextureCubeMap();
   207     void addProxyRef(const Renderbuffer *proxy);
   208     void releaseProxy(const Renderbuffer *proxy);
   210     virtual GLenum getTarget() const;
   212     GLsizei getWidth(GLenum target, GLint level) const;
   213     GLsizei getHeight(GLenum target, GLint level) const;
   214     GLenum getInternalFormat(GLenum target, GLint level) const;
   215     GLenum getActualFormat(GLenum target, GLint level) const;
   216     bool isCompressed(GLenum target, GLint level) const;
   218     void setImagePosX(GLint level, GLsizei width, GLsizei height, GLenum format, GLenum type, GLint unpackAlignment, const void *pixels);
   219     void setImageNegX(GLint level, GLsizei width, GLsizei height, GLenum format, GLenum type, GLint unpackAlignment, const void *pixels);
   220     void setImagePosY(GLint level, GLsizei width, GLsizei height, GLenum format, GLenum type, GLint unpackAlignment, const void *pixels);
   221     void setImageNegY(GLint level, GLsizei width, GLsizei height, GLenum format, GLenum type, GLint unpackAlignment, const void *pixels);
   222     void setImagePosZ(GLint level, GLsizei width, GLsizei height, GLenum format, GLenum type, GLint unpackAlignment, const void *pixels);
   223     void setImageNegZ(GLint level, GLsizei width, GLsizei height, GLenum format, GLenum type, GLint unpackAlignment, const void *pixels);
   225     void setCompressedImage(GLenum face, GLint level, GLenum format, GLsizei width, GLsizei height, GLsizei imageSize, const void *pixels);
   227     void subImage(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, GLint unpackAlignment, const void *pixels);
   228     void subImageCompressed(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const void *pixels);
   229     void copyImage(GLenum target, GLint level, GLenum format, GLint x, GLint y, GLsizei width, GLsizei height, Framebuffer *source);
   230     virtual void copySubImage(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height, Framebuffer *source);
   231     void storage(GLsizei levels, GLenum internalformat, GLsizei size);
   233     virtual bool isSamplerComplete() const;
   235     virtual void generateMipmaps();
   237     virtual Renderbuffer *getRenderbuffer(GLenum target);
   239     static unsigned int faceIndex(GLenum face);
   241   protected:
   242     friend class RenderbufferTextureCubeMap;
   243     virtual rx::RenderTarget *getRenderTarget(GLenum target);
   244     virtual int levelCount();
   246   private:
   247     DISALLOW_COPY_AND_ASSIGN(TextureCubeMap);
   249     virtual void createTexture();
   250     virtual void updateTexture();
   251     virtual void convertToRenderTarget();
   252     virtual rx::TextureStorageInterface *getStorage(bool renderTarget);
   254     bool isCubeComplete() const;
   255     bool isMipmapCubeComplete() const;
   257     void setImage(int faceIndex, GLint level, GLsizei width, GLsizei height, GLenum format, GLenum type, GLint unpackAlignment, const void *pixels);
   258     void commitRect(int faceIndex, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height);
   259     void redefineImage(int faceIndex, GLint level, GLint internalformat, GLsizei width, GLsizei height);
   261     rx::Image *mImageArray[6][IMPLEMENTATION_MAX_TEXTURE_LEVELS];
   263     rx::TextureStorageInterfaceCube *mTexStorage;
   265     // A specific internal reference count is kept for colorbuffer proxy references,
   266     // because, as the renderbuffer acting as proxy will maintain a binding pointer
   267     // back to this texture, there would be a circular reference if we used a binding
   268     // pointer here. This reference count will cause the pointer to be set to NULL if
   269     // the count drops to zero, but will not cause deletion of the Renderbuffer.
   270     Renderbuffer *mFaceProxies[6];
   271     unsigned int *mFaceProxyRefs[6];
   272 };
   273 }
   275 #endif   // LIBGLESV2_TEXTURE_H_

mercurial