blob: e104e85b3ffba5fa87a256721e02c7200f6863d1 [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
12#include "GrGLTexture.h"
13#include "GrGLRenderTarget.h"
14
Greg Daniel6ecc9112017-06-16 16:17:03 +000015class GrGLGpu;
16
bsalomon37dd3312014-11-03 08:47:23 -080017#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
23class GrGLTextureRenderTarget : public GrGLTexture, public GrGLRenderTarget {
24public:
25 // We're virtually derived from GrSurface (via both GrGLTexture and GrGLRenderTarget) so its
26 // constructor must be explicitly called.
bsalomon861e1032014-12-16 07:33:49 -080027 GrGLTextureRenderTarget(GrGLGpu* gpu,
kkinnunen2e6055b2016-04-22 01:48:29 -070028 SkBudgeted budgeted,
bsalomon37dd3312014-11-03 08:47:23 -080029 const GrSurfaceDesc& desc,
30 const GrGLTexture::IDDesc& texIDDesc,
Robert Phillipsd6214d42016-11-07 08:23:48 -050031 const GrGLRenderTarget::IDDesc& rtIDDesc,
Greg Daniel6ecc9112017-06-16 16:17:03 +000032 bool wasMipMapDataProvided);
bsalomon37dd3312014-11-03 08:47:23 -080033
kkinnunen2e6055b2016-04-22 01:48:29 -070034 bool canAttemptStencilAttachment() const override;
35
ericrk0a5fa482015-09-15 14:16:10 -070036 void dumpMemoryStatistics(SkTraceMemoryDump* traceMemoryDump) const override;
37
bungeman6bd52842016-10-27 09:30:08 -070038 static sk_sp<GrGLTextureRenderTarget> MakeWrapped(GrGLGpu* gpu, const GrSurfaceDesc& desc,
39 const GrGLTexture::IDDesc& texIDDesc,
40 const GrGLRenderTarget::IDDesc& rtIDDesc);
bsalomon37dd3312014-11-03 08:47:23 -080041protected:
mtklein36352bf2015-03-25 18:17:31 -070042 void onAbandon() override {
bsalomon37dd3312014-11-03 08:47:23 -080043 GrGLRenderTarget::onAbandon();
44 GrGLTexture::onAbandon();
45 }
46
mtklein36352bf2015-03-25 18:17:31 -070047 void onRelease() override {
bsalomon37dd3312014-11-03 08:47:23 -080048 GrGLRenderTarget::onRelease();
49 GrGLTexture::onRelease();
50 }
bsalomon69ed47f2014-11-12 11:13:39 -080051
52private:
kkinnunen2e6055b2016-04-22 01:48:29 -070053 // Constructor for instances wrapping backend objects.
54 GrGLTextureRenderTarget(GrGLGpu* gpu,
55 const GrSurfaceDesc& desc,
56 const GrGLTexture::IDDesc& texIDDesc,
Robert Phillipsd6214d42016-11-07 08:23:48 -050057 const GrGLRenderTarget::IDDesc& rtIDDesc,
Greg Daniel6ecc9112017-06-16 16:17:03 +000058 bool wasMipMapDataProvided);
kkinnunen2e6055b2016-04-22 01:48:29 -070059
Robert Phillips646e4292017-06-13 12:44:56 -040060 size_t onGpuMemorySize() const override;
bsalomon37dd3312014-11-03 08:47:23 -080061};
62
63#ifdef SK_BUILD_FOR_WIN
64#pragma warning(pop)
65#endif
66
67#endif