1 /* 2 * Copyright 2014 Google Inc. 3 * 4 * Use of this source code is governed by a BSD-style license that can be 5 * found in the LICENSE file. 6 */ 7 8 9 #ifndef GrGLTextureRenderTarget_DEFINED 10 #define GrGLTextureRenderTarget_DEFINED 11 12 #include "GrGLGpu.h" 13 #include "GrGLTexture.h" 14 #include "GrGLRenderTarget.h" 15 #include "GrTexturePriv.h" 16 17 class GrGLGpu; 18 19 #ifdef SK_BUILD_FOR_WIN 20 // Windows gives bogus warnings about inheriting asTexture/asRenderTarget via dominance. 21 #pragma warning(push) 22 #pragma warning(disable: 4250) 23 #endif 24 25 class GrGLTextureRenderTarget : public GrGLTexture, public GrGLRenderTarget { 26 public: 27 // We're virtually derived from GrSurface (via both GrGLTexture and GrGLRenderTarget) so its 28 // constructor must be explicitly called. GrGLTextureRenderTarget(GrGLGpu * gpu,SkBudgeted budgeted,const GrSurfaceDesc & desc,const GrGLTexture::IDDesc & texIDDesc,const GrGLRenderTarget::IDDesc & rtIDDesc,bool wasMipMapDataProvided)29 GrGLTextureRenderTarget(GrGLGpu* gpu, 30 SkBudgeted budgeted, 31 const GrSurfaceDesc& desc, 32 const GrGLTexture::IDDesc& texIDDesc, 33 const GrGLRenderTarget::IDDesc& rtIDDesc, 34 bool wasMipMapDataProvided) 35 : GrSurface(gpu, desc) 36 , GrGLTexture(gpu, desc, texIDDesc, wasMipMapDataProvided) 37 , GrGLRenderTarget(gpu, desc, rtIDDesc) { 38 this->registerWithCache(budgeted); 39 } 40 41 bool canAttemptStencilAttachment() const override; 42 43 void dumpMemoryStatistics(SkTraceMemoryDump* traceMemoryDump) const override; 44 45 static sk_sp<GrGLTextureRenderTarget> MakeWrapped(GrGLGpu* gpu, const GrSurfaceDesc& desc, 46 const GrGLTexture::IDDesc& texIDDesc, 47 const GrGLRenderTarget::IDDesc& rtIDDesc); 48 protected: onAbandon()49 void onAbandon() override { 50 GrGLRenderTarget::onAbandon(); 51 GrGLTexture::onAbandon(); 52 } 53 onRelease()54 void onRelease() override { 55 GrGLRenderTarget::onRelease(); 56 GrGLTexture::onRelease(); 57 } 58 59 private: 60 // Constructor for instances wrapping backend objects. GrGLTextureRenderTarget(GrGLGpu * gpu,const GrSurfaceDesc & desc,const GrGLTexture::IDDesc & texIDDesc,const GrGLRenderTarget::IDDesc & rtIDDesc,bool wasMipMapDataProvided)61 GrGLTextureRenderTarget(GrGLGpu* gpu, 62 const GrSurfaceDesc& desc, 63 const GrGLTexture::IDDesc& texIDDesc, 64 const GrGLRenderTarget::IDDesc& rtIDDesc, 65 bool wasMipMapDataProvided) 66 : GrSurface(gpu, desc) 67 , GrGLTexture(gpu, desc, texIDDesc, wasMipMapDataProvided) 68 , GrGLRenderTarget(gpu, desc, rtIDDesc) { 69 this->registerWithCacheWrapped(); 70 } 71 onGpuMemorySize()72 size_t onGpuMemorySize() const override { 73 return GrSurface::ComputeSize(fDesc, 74 this->numSamplesOwnedPerPixel(), 75 this->texturePriv().hasMipMaps()); 76 } 77 78 }; 79 80 #ifdef SK_BUILD_FOR_WIN 81 #pragma warning(pop) 82 #endif 83 84 #endif 85