Home | History | Annotate | Download | only in gl
      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 
     16 class GrGLGpu;
     17 
     18 #ifdef SK_BUILD_FOR_WIN
     19 // Windows gives bogus warnings about inheriting asTexture/asRenderTarget via dominance.
     20 #pragma warning(push)
     21 #pragma warning(disable: 4250)
     22 #endif
     23 
     24 class GrGLTextureRenderTarget : public GrGLTexture, public GrGLRenderTarget {
     25 public:
     26     // We're virtually derived from GrSurface (via both GrGLTexture and GrGLRenderTarget) so its
     27     // constructor must be explicitly called.
     28     GrGLTextureRenderTarget(GrGLGpu* gpu,
     29                             const GrSurfaceDesc& desc,
     30                             const GrGLTexture::IDDesc& texIDDesc,
     31                             const GrGLRenderTarget::IDDesc& rtIDDesc)
     32         : GrSurface(gpu, texIDDesc.fLifeCycle, desc)
     33         , GrGLTexture(gpu, desc, texIDDesc, GrGLTexture::kDerived)
     34         , GrGLRenderTarget(gpu, desc, rtIDDesc, GrGLRenderTarget::kDerived) {
     35         this->registerWithCache();
     36     }
     37 
     38     void dumpMemoryStatistics(SkTraceMemoryDump* traceMemoryDump) const override;
     39 
     40 protected:
     41     void onAbandon() override {
     42         GrGLRenderTarget::onAbandon();
     43         GrGLTexture::onAbandon();
     44     }
     45 
     46     void onRelease() override {
     47         GrGLRenderTarget::onRelease();
     48         GrGLTexture::onRelease();
     49     }
     50 
     51 private:
     52     // GrGLRenderTarget accounts for the texture's memory and any MSAA renderbuffer's memory.
     53     size_t onGpuMemorySize() const override {
     54         return GrGLRenderTarget::onGpuMemorySize();
     55     }
     56 
     57 };
     58 
     59 #ifdef SK_BUILD_FOR_WIN
     60 #pragma warning(pop)
     61 #endif
     62 
     63 #endif
     64