blob: 12a8ea08d26d9ab64b568fcce030697c526fd956 [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 Daniel0fc4d2d2017-10-12 11:23:36 -040032 GrMipMapsStatus);
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,
Greg Daniel177e6952017-10-12 12:27:11 -040040 const GrGLRenderTarget::IDDesc& rtIDDesc,
Brian Salomonaa6ca0a2019-01-24 16:03:07 -050041 GrWrapCacheable cacheble, GrMipMapsStatus);
Greg Daniel4065d452018-11-16 15:43:41 -050042
43 GrBackendFormat backendFormat() const override {
44 // It doesn't matter if we take the texture or render target path, so just pick texture.
45 return GrGLTexture::backendFormat();
46 }
47
bsalomon37dd3312014-11-03 08:47:23 -080048protected:
mtklein36352bf2015-03-25 18:17:31 -070049 void onAbandon() override {
bsalomon37dd3312014-11-03 08:47:23 -080050 GrGLRenderTarget::onAbandon();
51 GrGLTexture::onAbandon();
52 }
53
mtklein36352bf2015-03-25 18:17:31 -070054 void onRelease() override {
bsalomon37dd3312014-11-03 08:47:23 -080055 GrGLRenderTarget::onRelease();
56 GrGLTexture::onRelease();
57 }
bsalomon69ed47f2014-11-12 11:13:39 -080058
59private:
kkinnunen2e6055b2016-04-22 01:48:29 -070060 // Constructor for instances wrapping backend objects.
61 GrGLTextureRenderTarget(GrGLGpu* gpu,
62 const GrSurfaceDesc& desc,
63 const GrGLTexture::IDDesc& texIDDesc,
Greg Daniel177e6952017-10-12 12:27:11 -040064 const GrGLRenderTarget::IDDesc& rtIDDesc,
Brian Salomonaa6ca0a2019-01-24 16:03:07 -050065 GrWrapCacheable,
Greg Daniel177e6952017-10-12 12:27:11 -040066 GrMipMapsStatus);
kkinnunen2e6055b2016-04-22 01:48:29 -070067
Robert Phillips646e4292017-06-13 12:44:56 -040068 size_t onGpuMemorySize() const override;
Greg Daniel2d35a1c2019-02-01 14:48:10 -050069
70 void onSetRelease(sk_sp<GrReleaseProcHelper> releaseHelper) override {}
bsalomon37dd3312014-11-03 08:47:23 -080071};
72
73#ifdef SK_BUILD_FOR_WIN
74#pragma warning(pop)
75#endif
76
77#endif