Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(39)

Side by Side Diff: src/gpu/gl/GrGLTexture.h

Issue 695813003: Add class GrGLTextureRenderTarget for GL texture/rendertarget objects (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: cleanup Created 6 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
11 11
12 #include "GrGpu.h" 12 #include "GrGpu.h"
13 #include "GrGLRenderTarget.h" 13 #include "GrTexture.h"
14 #include "GrGLUtil.h"
14 15
robertphillips 2014/11/03 13:58:54 Can we move GrGLTexID into GrGLTexture.cpp ?
bsalomon 2014/11/03 15:20:14 Yup, forthcoming.
15 /** 16 /**
16 * A ref counted tex id that deletes the texture in its destructor. 17 * A ref counted tex id that deletes the texture in its destructor.
17 */ 18 */
18 class GrGLTexID : public SkRefCnt { 19 class GrGLTexID : public SkRefCnt {
19 public: 20 public:
20 SK_DECLARE_INST_COUNT(GrGLTexID) 21 SK_DECLARE_INST_COUNT(GrGLTexID)
21 22
22 GrGLTexID(const GrGLInterface* gl, GrGLuint texID, bool isWrapped) 23 GrGLTexID(const GrGLInterface* gl, GrGLuint texID, bool isWrapped)
23 : fGL(gl) 24 : fGL(gl)
24 , fTexID(texID) 25 , fTexID(texID)
(...skipping 30 matching lines...) Expand all
55 GrGLenum fWrapT; 56 GrGLenum fWrapT;
56 GrGLenum fSwizzleRGBA[4]; 57 GrGLenum fSwizzleRGBA[4];
57 void invalidate() { memset(this, 0xff, sizeof(TexParams)); } 58 void invalidate() { memset(this, 0xff, sizeof(TexParams)); }
58 }; 59 };
59 60
60 struct IDDesc { 61 struct IDDesc {
61 GrGLuint fTextureID; 62 GrGLuint fTextureID;
62 bool fIsWrapped; 63 bool fIsWrapped;
63 }; 64 };
64 65
65 // creates a texture that is also an RT
66 GrGLTexture(GrGpuGL* gpu, const GrSurfaceDesc&, const IDDesc&, const GrGLRen derTarget::IDDesc&);
67
68 // creates a non-RT texture
69 GrGLTexture(GrGpuGL* gpu, const GrSurfaceDesc&, const IDDesc&); 66 GrGLTexture(GrGpuGL* gpu, const GrSurfaceDesc&, const IDDesc&);
70 67
71 virtual ~GrGLTexture() { this->release(); } 68 virtual ~GrGLTexture() { this->release(); }
72 69
73 virtual GrBackendObject getTextureHandle() const SK_OVERRIDE; 70 virtual GrBackendObject getTextureHandle() const SK_OVERRIDE;
74 71
75 virtual void textureParamsModified() SK_OVERRIDE { fTexParams.invalidate(); } 72 virtual void textureParamsModified() SK_OVERRIDE { fTexParams.invalidate(); }
76 73
77 // These functions are used to track the texture parameters associated with the texture. 74 // These functions are used to track the texture parameters associated with the texture.
78 const TexParams& getCachedTexParams(GrGpu::ResetTimestamp* timestamp) const { 75 const TexParams& getCachedTexParams(GrGpu::ResetTimestamp* timestamp) const {
79 *timestamp = fTexParamsTimestamp; 76 *timestamp = fTexParamsTimestamp;
80 return fTexParams; 77 return fTexParams;
81 } 78 }
82 79
83 void setCachedTexParams(const TexParams& texParams, 80 void setCachedTexParams(const TexParams& texParams,
84 GrGpu::ResetTimestamp timestamp) { 81 GrGpu::ResetTimestamp timestamp) {
85 fTexParams = texParams; 82 fTexParams = texParams;
86 fTexParamsTimestamp = timestamp; 83 fTexParamsTimestamp = timestamp;
87 } 84 }
88 85
89 GrGLuint textureID() const { return (fTexIDObj.get()) ? fTexIDObj->id() : 0; } 86 GrGLuint textureID() const { return (fTexIDObj.get()) ? fTexIDObj->id() : 0; }
90 87
91 protected: 88 protected:
92 // overrides of GrTexture 89 // The public constructor registers this object with the cache. However, onl y the most derived
90 // class should register with the cache. This constructor does not do the re gistration and
91 // rather moves that burden onto the derived class.
92 enum Derived { kDerived };
93 GrGLTexture(GrGpuGL* gpu, const GrSurfaceDesc&, const IDDesc&, Derived);
94
93 virtual void onAbandon() SK_OVERRIDE; 95 virtual void onAbandon() SK_OVERRIDE;
94 virtual void onRelease() SK_OVERRIDE; 96 virtual void onRelease() SK_OVERRIDE;
95 97
96 private: 98 private:
97 TexParams fTexParams; 99 TexParams fTexParams;
98 GrGpu::ResetTimestamp fTexParamsTimestamp; 100 GrGpu::ResetTimestamp fTexParamsTimestamp;
99 SkAutoTUnref<GrGLTexID> fTexIDObj; 101 SkAutoTUnref<GrGLTexID> fTexIDObj;
100 102
101 void init(GrGpuGL* gpu, const GrSurfaceDesc&, const IDDesc&, const GrGLRende rTarget::IDDesc*);
102
103 typedef GrTexture INHERITED; 103 typedef GrTexture INHERITED;
104 }; 104 };
105 105
106 #endif 106 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698