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)); }
31 GrGpuResource::LifeCycle fLifeCycle;
34 GrGLTexture(GrGLGpu*, const GrSurfaceDesc&, const IDDesc&);
36 GrBackendObject getTextureHandle() const SK_OVERRIDE;
38 void textureParamsModified() SK_OVERRIDE { fTexParams.invalidate(); }
40 // These functions are used to track the texture parameters associated with the texture.
41 const TexParams& getCachedTexParams(GrGpu::ResetTimestamp* timestamp) const {
42 *timestamp = fTexParamsTimestamp;
46 void setCachedTexParams(const TexParams& texParams,
47 GrGpu::ResetTimestamp timestamp) {
48 fTexParams = texParams;
49 fTexParamsTimestamp = timestamp;
52 GrGLuint textureID() const { return fTextureID; }
55 // The public constructor registers this object with the cache. However, only the most derived
56 // class should register with the cache. This constructor does not do the registration and
57 // rather moves that burden onto the derived class.
58 enum Derived { kDerived };
59 GrGLTexture(GrGLGpu*, const GrSurfaceDesc&, const IDDesc&, Derived);
61 void init(const GrSurfaceDesc&, const IDDesc&);
63 void onAbandon() SK_OVERRIDE;
64 void onRelease() SK_OVERRIDE;
68 GrGpu::ResetTimestamp fTexParamsTimestamp;
71 // We track this separately from GrGpuResource because this may be both a texture and a render
72 // target, and the texture may be wrapped while the render target is not.
75 typedef GrTexture INHERITED;