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 "GrGLTexture.h"
     13 #include "GrGLRenderTarget.h"
     14 
     15 class GrGLGpu;
     16 
     17 #ifdef SK_BUILD_FOR_WIN
     18 // Windows gives bogus warnings about inheriting asTexture/asRenderTarget via dominance.
     19 #pragma warning(push)
     20 #pragma warning(disable: 4250)
     21 #endif
     22 
     23 class GrGLTextureRenderTarget : public GrGLTexture, public GrGLRenderTarget {
     24 public:
     25     // We're virtually derived from GrSurface (via both GrGLTexture and GrGLRenderTarget) so its
     26     // constructor must be explicitly called.
     27     GrGLTextureRenderTarget(GrGLGpu* gpu,
     28                             SkBudgeted budgeted,
     29                             const GrSurfaceDesc& desc,
     30                             const GrGLTexture::IDDesc& texIDDesc,
     31                             const GrGLRenderTarget::IDDesc& rtIDDesc,
     32                             GrMipMapsStatus);
     33 
     34     bool canAttemptStencilAttachment() const override;
     35 
     36     void dumpMemoryStatistics(SkTraceMemoryDump* traceMemoryDump) const override;
     37 
     38     static sk_sp<GrGLTextureRenderTarget> MakeWrapped(GrGLGpu* gpu, const GrSurfaceDesc& desc,
     39                                                       const GrGLTexture::IDDesc& texIDDesc,
     40                                                       const GrGLRenderTarget::IDDesc& rtIDDesc,
     41                                                       GrMipMapsStatus);
     42 protected:
     43     void onAbandon() override {
     44         GrGLRenderTarget::onAbandon();
     45         GrGLTexture::onAbandon();
     46     }
     47 
     48     void onRelease() override {
     49         GrGLRenderTarget::onRelease();
     50         GrGLTexture::onRelease();
     51     }
     52 
     53 private:
     54     // Constructor for instances wrapping backend objects.
     55     GrGLTextureRenderTarget(GrGLGpu* gpu,
     56                             const GrSurfaceDesc& desc,
     57                             const GrGLTexture::IDDesc& texIDDesc,
     58                             const GrGLRenderTarget::IDDesc& rtIDDesc,
     59                             GrMipMapsStatus);
     60 
     61     size_t onGpuMemorySize() const override;
     62 };
     63 
     64 #ifdef SK_BUILD_FOR_WIN
     65 #pragma warning(pop)
     66 #endif
     67 
     68 #endif
     69