 Chromium Code Reviews
 Chromium Code Reviews Issue 695813003:
  Add class GrGLTextureRenderTarget for GL texture/rendertarget objects  (Closed) 
  Base URL: https://skia.googlesource.com/skia.git@master
    
  
    Issue 695813003:
  Add class GrGLTextureRenderTarget for GL texture/rendertarget objects  (Closed) 
  Base URL: https://skia.googlesource.com/skia.git@master| 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 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 | 
| 
robertphillips
2014/11/03 13:58:54
SK_OVERRIDE ?
 
bsalomon
2014/11/03 15:20:14
Done.
 | |
| 61 virtual size_t gpuMemorySize() const; | |
| 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* gpu, const GrSurfaceDesc&, const IDDesc&, Derived) ; | |
| 69 | |
| 76 virtual void onAbandon() SK_OVERRIDE; | 70 virtual void onAbandon() SK_OVERRIDE; | 
| 77 virtual void onRelease() SK_OVERRIDE; | 71 virtual void onRelease() SK_OVERRIDE; | 
| 78 | 72 | 
| 79 private: | 73 private: | 
| 80 GrGLuint fRTFBOID; | 74 GrGLuint fRTFBOID; | 
| 81 GrGLuint fTexFBOID; | 75 GrGLuint fTexFBOID; | 
| 82 | |
| 83 GrGLuint fMSColorRenderbufferID; | 76 GrGLuint fMSColorRenderbufferID; | 
| 84 | 77 | 
| 85 // when we switch to this render target we want to set the viewport to | 78 // 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 | 79 // 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) | 80 // we want the rendering to be at top left (GL has origin in bottom left) | 
| 88 GrGLIRect fViewport; | 81 GrGLIRect fViewport; | 
| 89 | 82 | 
| 90 // non-NULL if this RT was created by Gr with an associated GrGLTexture. | 83 // gpuMemorySize() needs to know what how many color values are owned per pi xel. However, | 
| 91 SkAutoTUnref<GrGLTexID> fTexIDObj; | 84 // abandon and release zero out the IDs and the cache needs to know the size even after those | 
| 92 | 85 // actions. | 
| 93 void init(const GrSurfaceDesc&, const IDDesc&, const GrGLIRect& viewport, Gr GLTexID*); | 86 uint8_t fColorValuesPerPixel; | 
| 94 | 87 | 
| 95 typedef GrRenderTarget INHERITED; | 88 typedef GrRenderTarget INHERITED; | 
| 96 }; | 89 }; | 
| 97 | 90 | 
| 98 #endif | 91 #endif | 
| OLD | NEW |