OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2011 Google Inc. | 2 * Copyright 2011 Google Inc. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
6 */ | 6 */ |
7 | 7 |
8 | 8 |
9 #ifndef GrGLTexture_DEFINED | 9 #ifndef GrGLTexture_DEFINED |
10 #define GrGLTexture_DEFINED | 10 #define GrGLTexture_DEFINED |
(...skipping 27 matching lines...) Expand all Loading... |
38 const GrGLInterface* fGL; | 38 const GrGLInterface* fGL; |
39 GrGLuint fTexID; | 39 GrGLuint fTexID; |
40 bool fIsWrapped; | 40 bool fIsWrapped; |
41 | 41 |
42 typedef SkRefCnt INHERITED; | 42 typedef SkRefCnt INHERITED; |
43 }; | 43 }; |
44 | 44 |
45 //////////////////////////////////////////////////////////////////////////////// | 45 //////////////////////////////////////////////////////////////////////////////// |
46 | 46 |
47 | 47 |
48 class GrGLTexture : public GrTexture { | 48 class GrGLTexture : public GrTextureImpl { |
49 | 49 |
50 public: | 50 public: |
51 struct TexParams { | 51 struct TexParams { |
52 GrGLenum fMinFilter; | 52 GrGLenum fMinFilter; |
53 GrGLenum fMagFilter; | 53 GrGLenum fMagFilter; |
54 GrGLenum fWrapS; | 54 GrGLenum fWrapS; |
55 GrGLenum fWrapT; | 55 GrGLenum fWrapT; |
56 GrGLenum fSwizzleRGBA[4]; | 56 GrGLenum fSwizzleRGBA[4]; |
57 void invalidate() { memset(this, 0xff, sizeof(TexParams)); } | 57 void invalidate() { memset(this, 0xff, sizeof(TexParams)); } |
58 }; | 58 }; |
59 | 59 |
60 struct Desc : public GrTextureDesc { | 60 struct Desc : public GrTextureDesc { |
61 GrGLuint fTextureID; | 61 GrGLuint fTextureID; |
62 bool fIsWrapped; | 62 bool fIsWrapped; |
63 }; | 63 }; |
64 | 64 |
65 // creates a texture that is also an RT | 65 // creates a texture that is also an RT |
66 GrGLTexture(GrGpuGL* gpu, | 66 GrGLTexture(GrGpuGL* gpu, |
67 const Desc& textureDesc, | 67 const Desc& textureDesc, |
68 const GrGLRenderTarget::Desc& rtDesc); | 68 const GrGLRenderTarget::Desc& rtDesc); |
69 | 69 |
70 // creates a non-RT texture | 70 // creates a non-RT texture |
71 GrGLTexture(GrGpuGL* gpu, | 71 GrGLTexture(GrGpuGL* gpu, |
72 const Desc& textureDesc); | 72 const Desc& textureDesc); |
73 | 73 |
74 virtual ~GrGLTexture() { this->release(); } | 74 virtual ~GrGLTexture() { this->release(); } |
75 | 75 |
76 virtual GrBackendObject getTextureHandle() const SK_OVERRIDE; | 76 virtual GrBackendObject getTextureHandle() const SK_OVERRIDE; |
77 | 77 |
78 virtual void invalidateCachedState() SK_OVERRIDE { fTexParams.invalidate();
} | 78 virtual void textureParamsModified() SK_OVERRIDE { fTexParams.invalidate();
} |
79 | 79 |
80 // These functions are used to track the texture parameters associated with
the texture. | 80 // These functions are used to track the texture parameters associated with
the texture. |
81 const TexParams& getCachedTexParams(GrGpu::ResetTimestamp* timestamp) const
{ | 81 const TexParams& getCachedTexParams(GrGpu::ResetTimestamp* timestamp) const
{ |
82 *timestamp = fTexParamsTimestamp; | 82 *timestamp = fTexParamsTimestamp; |
83 return fTexParams; | 83 return fTexParams; |
84 } | 84 } |
85 | 85 |
86 void setCachedTexParams(const TexParams& texParams, | 86 void setCachedTexParams(const TexParams& texParams, |
87 GrGpu::ResetTimestamp timestamp) { | 87 GrGpu::ResetTimestamp timestamp) { |
88 fTexParams = texParams; | 88 fTexParams = texParams; |
89 fTexParamsTimestamp = timestamp; | 89 fTexParamsTimestamp = timestamp; |
90 } | 90 } |
91 | 91 |
92 GrGLuint textureID() const { return (NULL != fTexIDObj.get()) ? fTexIDObj->i
d() : 0; } | 92 GrGLuint textureID() const { return (NULL != fTexIDObj.get()) ? fTexIDObj->i
d() : 0; } |
93 | 93 |
94 protected: | 94 protected: |
95 // overrides of GrTexture | 95 // overrides of GrTexture |
96 virtual void onAbandon() SK_OVERRIDE; | 96 virtual void onAbandon() SK_OVERRIDE; |
97 virtual void onRelease() SK_OVERRIDE; | 97 virtual void onRelease() SK_OVERRIDE; |
98 | 98 |
99 private: | 99 private: |
100 TexParams fTexParams; | 100 TexParams fTexParams; |
101 GrGpu::ResetTimestamp fTexParamsTimestamp; | 101 GrGpu::ResetTimestamp fTexParamsTimestamp; |
102 SkAutoTUnref<GrGLTexID> fTexIDObj; | 102 SkAutoTUnref<GrGLTexID> fTexIDObj; |
103 | 103 |
104 void init(GrGpuGL* gpu, | 104 void init(GrGpuGL* gpu, |
105 const Desc& textureDesc, | 105 const Desc& textureDesc, |
106 const GrGLRenderTarget::Desc* rtDesc); | 106 const GrGLRenderTarget::Desc* rtDesc); |
107 | 107 |
108 typedef GrTexture INHERITED; | 108 typedef GrTextureImpl INHERITED; |
109 }; | 109 }; |
110 | 110 |
111 #endif | 111 #endif |
OLD | NEW |