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

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

Issue 1862043002: Refactor to separate backend object lifecycle and GpuResource budget decision (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: fix unrelated GrBuffer::onGpuMemorySize() lack of override keyword compile error Created 4 years, 8 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
« no previous file with comments | « src/gpu/gl/GrGLPathRange.cpp ('k') | src/gpu/gl/GrGLRenderTarget.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 GrGLRenderTarget_DEFINED 9 #ifndef GrGLRenderTarget_DEFINED
10 #define GrGLRenderTarget_DEFINED 10 #define GrGLRenderTarget_DEFINED
11 11
12 #include "GrGLIRect.h" 12 #include "GrGLIRect.h"
13 #include "GrRenderTarget.h" 13 #include "GrRenderTarget.h"
14 #include "SkScalar.h" 14 #include "SkScalar.h"
15 15
16 class GrGLGpu; 16 class GrGLGpu;
17 class GrGLStencilAttachment; 17 class GrGLStencilAttachment;
18 18
19 class GrGLRenderTarget : public GrRenderTarget { 19 class GrGLRenderTarget : public GrRenderTarget {
20 public: 20 public:
21 // set fTexFBOID to this value to indicate that it is multisampled but 21 // set fTexFBOID to this value to indicate that it is multisampled but
22 // Gr doesn't know how to resolve it. 22 // Gr doesn't know how to resolve it.
23 enum { kUnresolvableFBOID = 0 }; 23 enum { kUnresolvableFBOID = 0 };
24 24
25 struct IDDesc { 25 struct IDDesc {
26 GrGLuint fRTFBOID; 26 GrGLuint fRTFBOID;
27 GrBackendObjectOwnership fRTFBOOwnership;
27 GrGLuint fTexFBOID; 28 GrGLuint fTexFBOID;
28 GrGLuint fMSColorRenderbufferID; 29 GrGLuint fMSColorRenderbufferID;
29 GrGpuResource::LifeCycle fLifeCycle;
30 GrRenderTarget::SampleConfig fSampleConfig; 30 GrRenderTarget::SampleConfig fSampleConfig;
31 }; 31 };
32 32
33 static GrGLRenderTarget* CreateWrapped(GrGLGpu*, 33 static GrGLRenderTarget* CreateWrapped(GrGLGpu*,
34 const GrSurfaceDesc&, 34 const GrSurfaceDesc&,
35 const IDDesc&, 35 const IDDesc&,
36 int stencilBits); 36 int stencilBits);
37 37
38 void setViewport(const GrGLIRect& rect) { fViewport = rect; } 38 void setViewport(const GrGLIRect& rect) { fViewport = rect; }
39 const GrGLIRect& getViewport() const { return fViewport; } 39 const GrGLIRect& getViewport() const { return fViewport; }
(...skipping 14 matching lines...) Expand all
54 return kAutoResolves_ResolveType; 54 return kAutoResolves_ResolveType;
55 } else if (kUnresolvableFBOID == fTexFBOID) { 55 } else if (kUnresolvableFBOID == fTexFBOID) {
56 return kCantResolve_ResolveType; 56 return kCantResolve_ResolveType;
57 } else { 57 } else {
58 return kCanResolve_ResolveType; 58 return kCanResolve_ResolveType;
59 } 59 }
60 } 60 }
61 61
62 GrBackendObject getRenderTargetHandle() const override { return fRTFBOID; } 62 GrBackendObject getRenderTargetHandle() const override { return fRTFBOID; }
63 63
64 /** When we don't own the FBO ID we don't attempt to modify its attachments. */ 64 bool canAttemptStencilAttachment() const override;
65 bool canAttemptStencilAttachment() const override {
66 return kCached_LifeCycle == fRTLifecycle || kUncached_LifeCycle == fRTLi fecycle;
67 }
68 65
69 // GrGLRenderTarget overrides dumpMemoryStatistics so it can log its texture and renderbuffer 66 // GrGLRenderTarget overrides dumpMemoryStatistics so it can log its texture and renderbuffer
70 // components seperately. 67 // components seperately.
71 void dumpMemoryStatistics(SkTraceMemoryDump* traceMemoryDump) const override ; 68 void dumpMemoryStatistics(SkTraceMemoryDump* traceMemoryDump) const override ;
72 69
73 protected: 70 protected:
74 // The public constructor registers this object with the cache. However, onl y the most derived 71 // Constructor for subclasses.
75 // class should register with the cache. This constructor does not do the re gistration and 72 GrGLRenderTarget(GrGLGpu*, const GrSurfaceDesc&, const IDDesc&);
76 // rather moves that burden onto the derived class.
77 enum Derived { kDerived };
78 GrGLRenderTarget(GrGLGpu*, const GrSurfaceDesc&, const IDDesc&, Derived);
79 73
80 void init(const GrSurfaceDesc&, const IDDesc&); 74 void init(const GrSurfaceDesc&, const IDDesc&);
81 75
82 void onAbandon() override; 76 void onAbandon() override;
83 void onRelease() override; 77 void onRelease() override;
84 78
85 // In protected because subclass GrGLTextureRenderTarget calls this version. 79 // In protected because subclass GrGLTextureRenderTarget calls this version.
86 size_t onGpuMemorySize() const override; 80 size_t onGpuMemorySize() const override;
87 81
88 private: 82 private:
89 // This ctor is used only for creating wrapped render targets and is only ca lled for the static 83 // Constructor for instances wrapping backend objects.
90 // create function CreateWrapped(...).
91 GrGLRenderTarget(GrGLGpu*, const GrSurfaceDesc&, const IDDesc&, GrGLStencilA ttachment*); 84 GrGLRenderTarget(GrGLGpu*, const GrSurfaceDesc&, const IDDesc&, GrGLStencilA ttachment*);
92 85
93 GrGLGpu* getGLGpu() const; 86 GrGLGpu* getGLGpu() const;
94 bool completeStencilAttachment() override; 87 bool completeStencilAttachment() override;
95 88
96 // The total size of the resource (including all pixels) for a single sample . 89 // The total size of the resource (including all pixels) for a single sample .
97 size_t totalBytesPerSample() const; 90 size_t totalBytesPerSample() const;
98 int msaaSamples() const; 91 int msaaSamples() const;
99 // The number total number of samples, including both MSAA and resolve textu re samples. 92 // The number total number of samples, including both MSAA and resolve textu re samples.
100 int totalSamples() const; 93 int totalSamples() const;
101 94
102 GrGLuint fRTFBOID; 95 GrGLuint fRTFBOID;
103 GrGLuint fTexFBOID; 96 GrGLuint fTexFBOID;
104 GrGLuint fMSColorRenderbufferID; 97 GrGLuint fMSColorRenderbufferID;
105 98
106 // We track this separately from GrGpuResource because this may be both a te xture and a render 99 GrBackendObjectOwnership fRTFBOOwnership;
107 // target, and the texture may be wrapped while the render target is not.
108 LifeCycle fRTLifecycle;
109 100
110 // when we switch to this render target we want to set the viewport to 101 // when we switch to this render target we want to set the viewport to
111 // only render to content area (as opposed to the whole allocation) and 102 // only render to content area (as opposed to the whole allocation) and
112 // we want the rendering to be at top left (GL has origin in bottom left) 103 // we want the rendering to be at top left (GL has origin in bottom left)
113 GrGLIRect fViewport; 104 GrGLIRect fViewport;
114 105
115 // onGpuMemorySize() needs to know the VRAM footprint of the FBO(s). However , abandon and 106 // onGpuMemorySize() needs to know the VRAM footprint of the FBO(s). However , abandon and
116 // release zero out the IDs and the cache needs to know the size even after those actions. 107 // release zero out the IDs and the cache needs to know the size even after those actions.
117 size_t fGpuMemorySize; 108 size_t fGpuMemorySize;
118 109
119 typedef GrRenderTarget INHERITED; 110 typedef GrRenderTarget INHERITED;
120 }; 111 };
121 112
122 #endif 113 #endif
OLDNEW
« no previous file with comments | « src/gpu/gl/GrGLPathRange.cpp ('k') | src/gpu/gl/GrGLRenderTarget.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698