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

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

Issue 695813003: Add class GrGLTextureRenderTarget for GL texture/rendertarget objects (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: forgot to save file 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 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 GrGpuGL; 16 class GrGpuGL;
17 class GrGLTexture;
18 class GrGLTexID;
19 17
20 class GrGLRenderTarget : public GrRenderTarget { 18 class GrGLRenderTarget : public GrRenderTarget {
21
22 public: 19 public:
23 // set fTexFBOID to this value to indicate that it is multisampled but 20 // set fTexFBOID to this value to indicate that it is multisampled but
24 // Gr doesn't know how to resolve it. 21 // Gr doesn't know how to resolve it.
25 enum { kUnresolvableFBOID = 0 }; 22 enum { kUnresolvableFBOID = 0 };
26 23
27 struct IDDesc { 24 struct IDDesc {
28 GrGLuint fRTFBOID; 25 GrGLuint fRTFBOID;
29 GrGLuint fTexFBOID; 26 GrGLuint fTexFBOID;
30 GrGLuint fMSColorRenderbufferID; 27 GrGLuint fMSColorRenderbufferID;
31 bool fIsWrapped; 28 bool fIsWrapped;
32 }; 29 };
33 30
34 // creates a GrGLRenderTarget associated with a texture 31 GrGLRenderTarget(GrGpuGL*, const GrSurfaceDesc&, const IDDesc&);
35 GrGLRenderTarget(GrGpuGL*, const IDDesc&, const GrGLIRect& viewport,
36 GrGLTexID*, GrGLTexture*);
37
38 // creates an independent GrGLRenderTarget
39 GrGLRenderTarget(GrGpuGL*, const GrSurfaceDesc&, const IDDesc&, const GrGLIR ect& viewport);
40 32
41 virtual ~GrGLRenderTarget() { this->release(); } 33 virtual ~GrGLRenderTarget() { this->release(); }
42 34
43 void setViewport(const GrGLIRect& rect) { fViewport = rect; } 35 void setViewport(const GrGLIRect& rect) { fViewport = rect; }
44 const GrGLIRect& getViewport() const { return fViewport; } 36 const GrGLIRect& getViewport() const { return fViewport; }
45 37
46 // The following two functions return the same ID when a 38 // The following two functions return the same ID when a
47 // texture/render target is multisampled, and different IDs when 39 // texture/render target is multisampled, and different IDs when
48 // it is. 40 // it is.
49 // FBO ID used to render into 41 // FBO ID used to render into
50 GrGLuint renderFBOID() const { return fRTFBOID; } 42 GrGLuint renderFBOID() const { return fRTFBOID; }
51 // FBO ID that has texture ID attached. 43 // FBO ID that has texture ID attached.
52 GrGLuint textureFBOID() const { return fTexFBOID; } 44 GrGLuint textureFBOID() const { return fTexFBOID; }
53 45
54 // override of GrRenderTarget 46 // override of GrRenderTarget
55 virtual GrBackendObject getRenderTargetHandle() const { 47 virtual GrBackendObject getRenderTargetHandle() const { return this->renderF BOID(); }
56 return this->renderFBOID(); 48 virtual GrBackendObject getRenderTargetResolvedHandle() const { return this- >textureFBOID(); }
57 }
58 virtual GrBackendObject getRenderTargetResolvedHandle() const {
59 return this->textureFBOID();
60 }
61 virtual ResolveType getResolveType() const { 49 virtual ResolveType getResolveType() const {
62
63 if (!this->isMultisampled() || 50 if (!this->isMultisampled() ||
64 fRTFBOID == fTexFBOID) { 51 fRTFBOID == fTexFBOID) {
65 // catches FBO 0 and non MSAA case 52 // catches FBO 0 and non MSAA case
66 return kAutoResolves_ResolveType; 53 return kAutoResolves_ResolveType;
67 } else if (kUnresolvableFBOID == fTexFBOID) { 54 } else if (kUnresolvableFBOID == fTexFBOID) {
68 return kCantResolve_ResolveType; 55 return kCantResolve_ResolveType;
69 } else { 56 } else {
70 return kCanResolve_ResolveType; 57 return kCanResolve_ResolveType;
71 } 58 }
72 } 59 }
73 60
61 virtual size_t gpuMemorySize() const SK_OVERRIDE;
62
74 protected: 63 protected:
75 // override of GrResource 64 // The public constructor registers this object with the cache. However, onl y the most derived
65 // class should register with the cache. This constructor does not do the re gistration and
66 // rather moves that burden onto the derived class.
67 enum Derived { kDerived };
68 GrGLRenderTarget(GrGpuGL*, const GrSurfaceDesc&, const IDDesc&, Derived);
69
70 void init(const GrSurfaceDesc&, const IDDesc&);
71
76 virtual void onAbandon() SK_OVERRIDE; 72 virtual void onAbandon() SK_OVERRIDE;
77 virtual void onRelease() SK_OVERRIDE; 73 virtual void onRelease() SK_OVERRIDE;
78 74
79 private: 75 private:
80 GrGLuint fRTFBOID; 76 GrGLuint fRTFBOID;
81 GrGLuint fTexFBOID; 77 GrGLuint fTexFBOID;
82
83 GrGLuint fMSColorRenderbufferID; 78 GrGLuint fMSColorRenderbufferID;
84 79
85 // when we switch to this render target we want to set the viewport to 80 // when we switch to this render target we want to set the viewport to
86 // only render to to content area (as opposed to the whole allocation) and 81 // only render to content area (as opposed to the whole allocation) and
87 // we want the rendering to be at top left (GL has origin in bottom left) 82 // we want the rendering to be at top left (GL has origin in bottom left)
88 GrGLIRect fViewport; 83 GrGLIRect fViewport;
89 84
90 // non-NULL if this RT was created by Gr with an associated GrGLTexture. 85 // gpuMemorySize() needs to know what how many color values are owned per pi xel. However,
91 SkAutoTUnref<GrGLTexID> fTexIDObj; 86 // abandon and release zero out the IDs and the cache needs to know the size even after those
92 87 // actions.
93 void init(const GrSurfaceDesc&, const IDDesc&, const GrGLIRect& viewport, Gr GLTexID*); 88 uint8_t fColorValuesPerPixel;
94 89
95 typedef GrRenderTarget INHERITED; 90 typedef GrRenderTarget INHERITED;
96 }; 91 };
97 92
98 #endif 93 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698