bsalomon | 37dd331 | 2014-11-03 08:47:23 -0800 | [diff] [blame] | 1 | /* |
| 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 | |
bsalomon | 861e103 | 2014-12-16 07:33:49 -0800 | [diff] [blame] | 15 | class GrGLGpu; |
bsalomon | 37dd331 | 2014-11-03 08:47:23 -0800 | [diff] [blame] | 16 | |
| 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 | |
| 23 | class GrGLTextureRenderTarget : public GrGLTexture, public GrGLRenderTarget { |
| 24 | public: |
| 25 | // We're virtually derived from GrSurface (via both GrGLTexture and GrGLRenderTarget) so its |
| 26 | // constructor must be explicitly called. |
bsalomon | 861e103 | 2014-12-16 07:33:49 -0800 | [diff] [blame] | 27 | GrGLTextureRenderTarget(GrGLGpu* gpu, |
bsalomon | 37dd331 | 2014-11-03 08:47:23 -0800 | [diff] [blame] | 28 | const GrSurfaceDesc& desc, |
| 29 | const GrGLTexture::IDDesc& texIDDesc, |
| 30 | const GrGLRenderTarget::IDDesc& rtIDDesc) |
bsalomon | 5236cf4 | 2015-01-14 10:42:08 -0800 | [diff] [blame] | 31 | : GrSurface(gpu, texIDDesc.fLifeCycle, desc) |
bsalomon | 37dd331 | 2014-11-03 08:47:23 -0800 | [diff] [blame] | 32 | , GrGLTexture(gpu, desc, texIDDesc, GrGLTexture::kDerived) |
| 33 | , GrGLRenderTarget(gpu, desc, rtIDDesc, GrGLRenderTarget::kDerived) { |
bsalomon | 69ed47f | 2014-11-12 11:13:39 -0800 | [diff] [blame] | 34 | this->registerWithCache(); |
bsalomon | 37dd331 | 2014-11-03 08:47:23 -0800 | [diff] [blame] | 35 | } |
| 36 | |
bsalomon | 37dd331 | 2014-11-03 08:47:23 -0800 | [diff] [blame] | 37 | protected: |
mtklein | 36352bf | 2015-03-25 18:17:31 -0700 | [diff] [blame] | 38 | void onAbandon() override { |
bsalomon | 37dd331 | 2014-11-03 08:47:23 -0800 | [diff] [blame] | 39 | GrGLRenderTarget::onAbandon(); |
| 40 | GrGLTexture::onAbandon(); |
| 41 | } |
| 42 | |
mtklein | 36352bf | 2015-03-25 18:17:31 -0700 | [diff] [blame] | 43 | void onRelease() override { |
bsalomon | 37dd331 | 2014-11-03 08:47:23 -0800 | [diff] [blame] | 44 | GrGLRenderTarget::onRelease(); |
| 45 | GrGLTexture::onRelease(); |
| 46 | } |
bsalomon | 69ed47f | 2014-11-12 11:13:39 -0800 | [diff] [blame] | 47 | |
| 48 | private: |
| 49 | // GrGLRenderTarget accounts for the texture's memory and any MSAA renderbuffer's memory. |
mtklein | 36352bf | 2015-03-25 18:17:31 -0700 | [diff] [blame] | 50 | size_t onGpuMemorySize() const override { |
bsalomon | 69ed47f | 2014-11-12 11:13:39 -0800 | [diff] [blame] | 51 | return GrGLRenderTarget::onGpuMemorySize(); |
| 52 | } |
| 53 | |
bsalomon | 37dd331 | 2014-11-03 08:47:23 -0800 | [diff] [blame] | 54 | }; |
| 55 | |
| 56 | #ifdef SK_BUILD_FOR_WIN |
| 57 | #pragma warning(pop) |
| 58 | #endif |
| 59 | |
| 60 | #endif |