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

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

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

Powered by Google App Engine
This is Rietveld 408576698