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.

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

mercurial