gfx/skia/trunk/src/gpu/gl/GrGLTexture.h

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

     1 /*
     2  * Copyright 2011 Google Inc.
     3  *
     4  * Use of this source code is governed by a BSD-style license that can be
     5  * found in the LICENSE file.
     6  */
     9 #ifndef GrGLTexture_DEFINED
    10 #define GrGLTexture_DEFINED
    12 #include "GrGpu.h"
    13 #include "GrGLRenderTarget.h"
    15 /**
    16  * A ref counted tex id that deletes the texture in its destructor.
    17  */
    18 class GrGLTexID : public SkRefCnt {
    19 public:
    20     SK_DECLARE_INST_COUNT(GrGLTexID)
    22     GrGLTexID(const GrGLInterface* gl, GrGLuint texID, bool isWrapped)
    23         : fGL(gl)
    24         , fTexID(texID)
    25         , fIsWrapped(isWrapped) {
    26     }
    28     virtual ~GrGLTexID() {
    29         if (0 != fTexID && !fIsWrapped) {
    30             GR_GL_CALL(fGL, DeleteTextures(1, &fTexID));
    31         }
    32     }
    34     void abandon() { fTexID = 0; }
    35     GrGLuint id() const { return fTexID; }
    37 private:
    38     const GrGLInterface* fGL;
    39     GrGLuint             fTexID;
    40     bool                 fIsWrapped;
    42     typedef SkRefCnt INHERITED;
    43 };
    45 ////////////////////////////////////////////////////////////////////////////////
    48 class GrGLTexture : public GrTexture {
    50 public:
    51     struct TexParams {
    52         GrGLenum fMinFilter;
    53         GrGLenum fMagFilter;
    54         GrGLenum fWrapS;
    55         GrGLenum fWrapT;
    56         GrGLenum fSwizzleRGBA[4];
    57         void invalidate() { memset(this, 0xff, sizeof(TexParams)); }
    58     };
    60     struct Desc : public GrTextureDesc {
    61         GrGLuint        fTextureID;
    62         bool            fIsWrapped;
    63     };
    65     // creates a texture that is also an RT
    66     GrGLTexture(GrGpuGL* gpu,
    67                 const Desc& textureDesc,
    68                 const GrGLRenderTarget::Desc& rtDesc);
    70     // creates a non-RT texture
    71     GrGLTexture(GrGpuGL* gpu,
    72                 const Desc& textureDesc);
    74     virtual ~GrGLTexture() { this->release(); }
    76     virtual GrBackendObject getTextureHandle() const SK_OVERRIDE;
    78     virtual void invalidateCachedState() SK_OVERRIDE { fTexParams.invalidate(); }
    80     // These functions are used to track the texture parameters associated with the texture.
    81     const TexParams& getCachedTexParams(GrGpu::ResetTimestamp* timestamp) const {
    82         *timestamp = fTexParamsTimestamp;
    83         return fTexParams;
    84     }
    86     void setCachedTexParams(const TexParams& texParams,
    87                             GrGpu::ResetTimestamp timestamp) {
    88         fTexParams = texParams;
    89         fTexParamsTimestamp = timestamp;
    90     }
    92     GrGLuint textureID() const { return (NULL != fTexIDObj.get()) ? fTexIDObj->id() : 0; }
    94 protected:
    95     // overrides of GrTexture
    96     virtual void onAbandon() SK_OVERRIDE;
    97     virtual void onRelease() SK_OVERRIDE;
    99 private:
   100     TexParams                       fTexParams;
   101     GrGpu::ResetTimestamp           fTexParamsTimestamp;
   102     SkAutoTUnref<GrGLTexID>         fTexIDObj;
   104     void init(GrGpuGL* gpu,
   105               const Desc& textureDesc,
   106               const GrGLRenderTarget::Desc* rtDesc);
   108     typedef GrTexture INHERITED;
   109 };
   111 #endif

mercurial