2 * Copyright 2011 Google Inc.
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
9 #ifndef GrGLTexture_DEFINED
10 #define GrGLTexture_DEFINED
13 #include "GrTexture.h"
17 class GrGLTexture : public GrTexture {
25 GrGLenum fSwizzleRGBA[4];
26 void invalidate() { memset(this, 0xff, sizeof(TexParams)); }
34 GrGLTexture(GrGpuGL*, const GrSurfaceDesc&, const IDDesc&);
36 virtual ~GrGLTexture() { this->release(); }
38 virtual GrBackendObject getTextureHandle() const SK_OVERRIDE;
40 virtual void textureParamsModified() SK_OVERRIDE { fTexParams.invalidate(); }
42 // These functions are used to track the texture parameters associated with the texture.
43 const TexParams& getCachedTexParams(GrGpu::ResetTimestamp* timestamp) const {
44 *timestamp = fTexParamsTimestamp;
48 void setCachedTexParams(const TexParams& texParams,
49 GrGpu::ResetTimestamp timestamp) {
50 fTexParams = texParams;
51 fTexParamsTimestamp = timestamp;
54 GrGLuint textureID() const { return fTextureID; }
57 // The public constructor registers this object with the cache. However, only the most derived
58 // class should register with the cache. This constructor does not do the registration and
59 // rather moves that burden onto the derived class.
60 enum Derived { kDerived };
61 GrGLTexture(GrGpuGL*, const GrSurfaceDesc&, const IDDesc&, Derived);
63 void init(const GrSurfaceDesc&, const IDDesc&);
65 virtual void onAbandon() SK_OVERRIDE;
66 virtual void onRelease() SK_OVERRIDE;
70 GrGpu::ResetTimestamp fTexParamsTimestamp;
73 typedef GrTexture INHERITED;