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 10 matching lines...) Expand all Loading... |
21 struct TexParams { | 21 struct TexParams { |
22 GrGLenum fMinFilter; | 22 GrGLenum fMinFilter; |
23 GrGLenum fMagFilter; | 23 GrGLenum fMagFilter; |
24 GrGLenum fWrapS; | 24 GrGLenum fWrapS; |
25 GrGLenum fWrapT; | 25 GrGLenum fWrapT; |
26 GrGLenum fSwizzleRGBA[4]; | 26 GrGLenum fSwizzleRGBA[4]; |
27 void invalidate() { memset(this, 0xff, sizeof(TexParams)); } | 27 void invalidate() { memset(this, 0xff, sizeof(TexParams)); } |
28 }; | 28 }; |
29 | 29 |
30 struct IDDesc { | 30 struct IDDesc { |
31 GrGLenum fTarget; | 31 GrGLTextureInfo fInfo; |
32 GrGLuint fTextureID; | |
33 GrGpuResource::LifeCycle fLifeCycle; | 32 GrGpuResource::LifeCycle fLifeCycle; |
34 }; | 33 }; |
35 | 34 |
36 GrGLTexture(GrGLGpu*, const GrSurfaceDesc&, const IDDesc&); | 35 GrGLTexture(GrGLGpu*, const GrSurfaceDesc&, const IDDesc&); |
37 | 36 |
38 GrBackendObject getTextureHandle() const override; | 37 GrBackendObject getTextureHandle() const override; |
39 | 38 |
40 void textureParamsModified() override { fTexParams.invalidate(); } | 39 void textureParamsModified() override { fTexParams.invalidate(); } |
41 | 40 |
42 // These functions are used to track the texture parameters associated with
the texture. | 41 // These functions are used to track the texture parameters associated with
the texture. |
43 const TexParams& getCachedTexParams(GrGpu::ResetTimestamp* timestamp) const
{ | 42 const TexParams& getCachedTexParams(GrGpu::ResetTimestamp* timestamp) const
{ |
44 *timestamp = fTexParamsTimestamp; | 43 *timestamp = fTexParamsTimestamp; |
45 return fTexParams; | 44 return fTexParams; |
46 } | 45 } |
47 | 46 |
48 void setCachedTexParams(const TexParams& texParams, | 47 void setCachedTexParams(const TexParams& texParams, |
49 GrGpu::ResetTimestamp timestamp) { | 48 GrGpu::ResetTimestamp timestamp) { |
50 fTexParams = texParams; | 49 fTexParams = texParams; |
51 fTexParamsTimestamp = timestamp; | 50 fTexParamsTimestamp = timestamp; |
52 } | 51 } |
53 | 52 |
54 GrGLuint textureID() const { return fTextureID; } | 53 GrGLuint textureID() const { return fInfo.fID; } |
55 | 54 |
56 GrGLenum target() const { return fTarget; } | 55 GrGLenum target() const { return fInfo.fTarget; } |
57 | 56 |
58 protected: | 57 protected: |
59 // The public constructor registers this object with the cache. However, onl
y the most derived | 58 // The public constructor registers this object with the cache. However, onl
y the most derived |
60 // class should register with the cache. This constructor does not do the re
gistration and | 59 // class should register with the cache. This constructor does not do the re
gistration and |
61 // rather moves that burden onto the derived class. | 60 // rather moves that burden onto the derived class. |
62 enum Derived { kDerived }; | 61 enum Derived { kDerived }; |
63 GrGLTexture(GrGLGpu*, const GrSurfaceDesc&, const IDDesc&, Derived); | 62 GrGLTexture(GrGLGpu*, const GrSurfaceDesc&, const IDDesc&, Derived); |
64 | 63 |
65 void init(const GrSurfaceDesc&, const IDDesc&); | 64 void init(const GrSurfaceDesc&, const IDDesc&); |
66 | 65 |
67 void onAbandon() override; | 66 void onAbandon() override; |
68 void onRelease() override; | 67 void onRelease() override; |
69 void setMemoryBacking(SkTraceMemoryDump* traceMemoryDump, | 68 void setMemoryBacking(SkTraceMemoryDump* traceMemoryDump, |
70 const SkString& dumpName) const override; | 69 const SkString& dumpName) const override; |
71 | 70 |
72 private: | 71 private: |
73 TexParams fTexParams; | 72 TexParams fTexParams; |
74 GrGpu::ResetTimestamp fTexParamsTimestamp; | 73 GrGpu::ResetTimestamp fTexParamsTimestamp; |
75 GrGLenum fTarget; | 74 // Holds the texture target and ID. A pointer to this may be shared to exter
nal clients for |
76 GrGLuint fTextureID; | 75 // direct interaction with the GL object. |
| 76 GrGLTextureInfo fInfo; |
77 | 77 |
78 // We track this separately from GrGpuResource because this may be both a te
xture and a render | 78 // We track this separately from GrGpuResource because this may be both a te
xture and a render |
79 // target, and the texture may be wrapped while the render target is not. | 79 // target, and the texture may be wrapped while the render target is not. |
80 LifeCycle fTextureIDLifecycle; | 80 LifeCycle fTextureIDLifecycle; |
81 | 81 |
82 typedef GrTexture INHERITED; | 82 typedef GrTexture INHERITED; |
83 }; | 83 }; |
84 | 84 |
85 #endif | 85 #endif |
OLD | NEW |