blob: d74239ec14db7112df90aa243c450df00f650d14 [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
Greg Daniel56af45b2017-06-15 21:51:46 +000012#include "GrGLGpu.h"
bsalomon37dd3312014-11-03 08:47:23 -080013#include "GrGLTexture.h"
14#include "GrGLRenderTarget.h"
15
bsalomon37dd3312014-11-03 08:47:23 -080016#ifdef SK_BUILD_FOR_WIN
17// Windows gives bogus warnings about inheriting asTexture/asRenderTarget via dominance.
18#pragma warning(push)
19#pragma warning(disable: 4250)
20#endif
21
22class GrGLTextureRenderTarget : public GrGLTexture, public GrGLRenderTarget {
23public:
24 // We're virtually derived from GrSurface (via both GrGLTexture and GrGLRenderTarget) so its
25 // constructor must be explicitly called.
bsalomon861e1032014-12-16 07:33:49 -080026 GrGLTextureRenderTarget(GrGLGpu* gpu,
kkinnunen2e6055b2016-04-22 01:48:29 -070027 SkBudgeted budgeted,
bsalomon37dd3312014-11-03 08:47:23 -080028 const GrSurfaceDesc& desc,
29 const GrGLTexture::IDDesc& texIDDesc,
Robert Phillipsd6214d42016-11-07 08:23:48 -050030 const GrGLRenderTarget::IDDesc& rtIDDesc,
Greg Daniel56af45b2017-06-15 21:51:46 +000031 bool wasMipMapDataProvided)
32 : GrSurface(gpu, desc)
33 , GrGLTexture(gpu, desc, texIDDesc, wasMipMapDataProvided)
34 , GrGLRenderTarget(gpu, desc, rtIDDesc) {
35 this->registerWithCache(budgeted);
36 }
bsalomon37dd3312014-11-03 08:47:23 -080037
kkinnunen2e6055b2016-04-22 01:48:29 -070038 bool canAttemptStencilAttachment() const override;
39
ericrk0a5fa482015-09-15 14:16:10 -070040 void dumpMemoryStatistics(SkTraceMemoryDump* traceMemoryDump) const override;
41
bungeman6bd52842016-10-27 09:30:08 -070042 static sk_sp<GrGLTextureRenderTarget> MakeWrapped(GrGLGpu* gpu, const GrSurfaceDesc& desc,
43 const GrGLTexture::IDDesc& texIDDesc,
44 const GrGLRenderTarget::IDDesc& rtIDDesc);
bsalomon37dd3312014-11-03 08:47:23 -080045protected:
mtklein36352bf2015-03-25 18:17:31 -070046 void onAbandon() override {
bsalomon37dd3312014-11-03 08:47:23 -080047 GrGLRenderTarget::onAbandon();
48 GrGLTexture::onAbandon();
49 }
50
mtklein36352bf2015-03-25 18:17:31 -070051 void onRelease() override {
bsalomon37dd3312014-11-03 08:47:23 -080052 GrGLRenderTarget::onRelease();
53 GrGLTexture::onRelease();
54 }
bsalomon69ed47f2014-11-12 11:13:39 -080055
56private:
kkinnunen2e6055b2016-04-22 01:48:29 -070057 // Constructor for instances wrapping backend objects.
58 GrGLTextureRenderTarget(GrGLGpu* gpu,
59 const GrSurfaceDesc& desc,
60 const GrGLTexture::IDDesc& texIDDesc,
Robert Phillipsd6214d42016-11-07 08:23:48 -050061 const GrGLRenderTarget::IDDesc& rtIDDesc,
Greg Daniel56af45b2017-06-15 21:51:46 +000062 bool wasMipMapDataProvided)
63 : GrSurface(gpu, desc)
64 , GrGLTexture(gpu, desc, texIDDesc, wasMipMapDataProvided)
65 , GrGLRenderTarget(gpu, desc, rtIDDesc) {
66 this->registerWithCacheWrapped();
67 }
kkinnunen2e6055b2016-04-22 01:48:29 -070068
Robert Phillips646e4292017-06-13 12:44:56 -040069 size_t onGpuMemorySize() const override;
bsalomon37dd3312014-11-03 08:47:23 -080070};
71
72#ifdef SK_BUILD_FOR_WIN
73#pragma warning(pop)
74#endif
75
76#endif