blob: 02db8bc08634994fec3842dbd449cb9f75e64f8e [file] [log] [blame]
bsalomon37dd3312014-11-03 08:47:23 -08001/*
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
ericrk0a5fa482015-09-15 14:16:10 -070012#include "GrGLGpu.h"
bsalomon37dd3312014-11-03 08:47:23 -080013#include "GrGLTexture.h"
14#include "GrGLRenderTarget.h"
15
bsalomon861e1032014-12-16 07:33:49 -080016class GrGLGpu;
bsalomon37dd3312014-11-03 08:47:23 -080017
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
24class GrGLTextureRenderTarget : public GrGLTexture, public GrGLRenderTarget {
25public:
26 // We're virtually derived from GrSurface (via both GrGLTexture and GrGLRenderTarget) so its
27 // constructor must be explicitly called.
bsalomon861e1032014-12-16 07:33:49 -080028 GrGLTextureRenderTarget(GrGLGpu* gpu,
bsalomon37dd3312014-11-03 08:47:23 -080029 const GrSurfaceDesc& desc,
30 const GrGLTexture::IDDesc& texIDDesc,
31 const GrGLRenderTarget::IDDesc& rtIDDesc)
bsalomon5236cf42015-01-14 10:42:08 -080032 : GrSurface(gpu, texIDDesc.fLifeCycle, desc)
bsalomon37dd3312014-11-03 08:47:23 -080033 , GrGLTexture(gpu, desc, texIDDesc, GrGLTexture::kDerived)
34 , GrGLRenderTarget(gpu, desc, rtIDDesc, GrGLRenderTarget::kDerived) {
bsalomon69ed47f2014-11-12 11:13:39 -080035 this->registerWithCache();
bsalomon37dd3312014-11-03 08:47:23 -080036 }
37
ericrk0a5fa482015-09-15 14:16:10 -070038 void dumpMemoryStatistics(SkTraceMemoryDump* traceMemoryDump) const override;
39
bsalomon37dd3312014-11-03 08:47:23 -080040protected:
mtklein36352bf2015-03-25 18:17:31 -070041 void onAbandon() override {
bsalomon37dd3312014-11-03 08:47:23 -080042 GrGLRenderTarget::onAbandon();
43 GrGLTexture::onAbandon();
44 }
45
mtklein36352bf2015-03-25 18:17:31 -070046 void onRelease() override {
bsalomon37dd3312014-11-03 08:47:23 -080047 GrGLRenderTarget::onRelease();
48 GrGLTexture::onRelease();
49 }
bsalomon69ed47f2014-11-12 11:13:39 -080050
51private:
52 // GrGLRenderTarget accounts for the texture's memory and any MSAA renderbuffer's memory.
mtklein36352bf2015-03-25 18:17:31 -070053 size_t onGpuMemorySize() const override {
bsalomon69ed47f2014-11-12 11:13:39 -080054 return GrGLRenderTarget::onGpuMemorySize();
55 }
56
bsalomon37dd3312014-11-03 08:47:23 -080057};
58
59#ifdef SK_BUILD_FOR_WIN
60#pragma warning(pop)
61#endif
62
63#endif