blob: e2dd14c8820c2b611e81c9bd97b6dc302b4d6cf8 [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
bsalomon861e1032014-12-16 07:33:49 -080015class GrGLGpu;
bsalomon37dd3312014-11-03 08:47:23 -080016
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
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,
bsalomon37dd3312014-11-03 08:47:23 -080028 const GrSurfaceDesc& desc,
29 const GrGLTexture::IDDesc& texIDDesc,
30 const GrGLRenderTarget::IDDesc& rtIDDesc)
bsalomon5236cf42015-01-14 10:42:08 -080031 : GrSurface(gpu, texIDDesc.fLifeCycle, desc)
bsalomon37dd3312014-11-03 08:47:23 -080032 , GrGLTexture(gpu, desc, texIDDesc, GrGLTexture::kDerived)
33 , GrGLRenderTarget(gpu, desc, rtIDDesc, GrGLRenderTarget::kDerived) {
bsalomon69ed47f2014-11-12 11:13:39 -080034 this->registerWithCache();
bsalomon37dd3312014-11-03 08:47:23 -080035 }
36
bsalomon37dd3312014-11-03 08:47:23 -080037protected:
mtklein72c9faa2015-01-09 10:06:39 -080038 void onAbandon() SK_OVERRIDE {
bsalomon37dd3312014-11-03 08:47:23 -080039 GrGLRenderTarget::onAbandon();
40 GrGLTexture::onAbandon();
41 }
42
mtklein72c9faa2015-01-09 10:06:39 -080043 void onRelease() SK_OVERRIDE {
bsalomon37dd3312014-11-03 08:47:23 -080044 GrGLRenderTarget::onRelease();
45 GrGLTexture::onRelease();
46 }
bsalomon69ed47f2014-11-12 11:13:39 -080047
48private:
49 // GrGLRenderTarget accounts for the texture's memory and any MSAA renderbuffer's memory.
mtklein72c9faa2015-01-09 10:06:39 -080050 size_t onGpuMemorySize() const SK_OVERRIDE {
bsalomon69ed47f2014-11-12 11:13:39 -080051 return GrGLRenderTarget::onGpuMemorySize();
52 }
53
bsalomon37dd3312014-11-03 08:47:23 -080054};
55
56#ifdef SK_BUILD_FOR_WIN
57#pragma warning(pop)
58#endif
59
60#endif