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 | |
Greg Daniel | 56af45b | 2017-06-15 21:51:46 +0000 | [diff] [blame] | 12 | #include "GrGLGpu.h" |
bsalomon | 37dd331 | 2014-11-03 08:47:23 -0800 | [diff] [blame] | 13 | #include "GrGLTexture.h" |
| 14 | #include "GrGLRenderTarget.h" |
| 15 | |
bsalomon | 37dd331 | 2014-11-03 08:47:23 -0800 | [diff] [blame] | 16 | #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 | |
| 22 | class GrGLTextureRenderTarget : public GrGLTexture, public GrGLRenderTarget { |
| 23 | public: |
| 24 | // We're virtually derived from GrSurface (via both GrGLTexture and GrGLRenderTarget) so its |
| 25 | // constructor must be explicitly called. |
bsalomon | 861e103 | 2014-12-16 07:33:49 -0800 | [diff] [blame] | 26 | GrGLTextureRenderTarget(GrGLGpu* gpu, |
kkinnunen | 2e6055b | 2016-04-22 01:48:29 -0700 | [diff] [blame] | 27 | SkBudgeted budgeted, |
bsalomon | 37dd331 | 2014-11-03 08:47:23 -0800 | [diff] [blame] | 28 | const GrSurfaceDesc& desc, |
| 29 | const GrGLTexture::IDDesc& texIDDesc, |
Robert Phillips | d6214d4 | 2016-11-07 08:23:48 -0500 | [diff] [blame] | 30 | const GrGLRenderTarget::IDDesc& rtIDDesc, |
Greg Daniel | 56af45b | 2017-06-15 21:51:46 +0000 | [diff] [blame] | 31 | bool wasMipMapDataProvided) |
| 32 | : GrSurface(gpu, desc) |
| 33 | , GrGLTexture(gpu, desc, texIDDesc, wasMipMapDataProvided) |
| 34 | , GrGLRenderTarget(gpu, desc, rtIDDesc) { |
| 35 | this->registerWithCache(budgeted); |
| 36 | } |
bsalomon | 37dd331 | 2014-11-03 08:47:23 -0800 | [diff] [blame] | 37 | |
kkinnunen | 2e6055b | 2016-04-22 01:48:29 -0700 | [diff] [blame] | 38 | bool canAttemptStencilAttachment() const override; |
| 39 | |
ericrk | 0a5fa48 | 2015-09-15 14:16:10 -0700 | [diff] [blame] | 40 | void dumpMemoryStatistics(SkTraceMemoryDump* traceMemoryDump) const override; |
| 41 | |
bungeman | 6bd5284 | 2016-10-27 09:30:08 -0700 | [diff] [blame] | 42 | static sk_sp<GrGLTextureRenderTarget> MakeWrapped(GrGLGpu* gpu, const GrSurfaceDesc& desc, |
| 43 | const GrGLTexture::IDDesc& texIDDesc, |
| 44 | const GrGLRenderTarget::IDDesc& rtIDDesc); |
bsalomon | 37dd331 | 2014-11-03 08:47:23 -0800 | [diff] [blame] | 45 | protected: |
mtklein | 36352bf | 2015-03-25 18:17:31 -0700 | [diff] [blame] | 46 | void onAbandon() override { |
bsalomon | 37dd331 | 2014-11-03 08:47:23 -0800 | [diff] [blame] | 47 | GrGLRenderTarget::onAbandon(); |
| 48 | GrGLTexture::onAbandon(); |
| 49 | } |
| 50 | |
mtklein | 36352bf | 2015-03-25 18:17:31 -0700 | [diff] [blame] | 51 | void onRelease() override { |
bsalomon | 37dd331 | 2014-11-03 08:47:23 -0800 | [diff] [blame] | 52 | GrGLRenderTarget::onRelease(); |
| 53 | GrGLTexture::onRelease(); |
| 54 | } |
bsalomon | 69ed47f | 2014-11-12 11:13:39 -0800 | [diff] [blame] | 55 | |
| 56 | private: |
kkinnunen | 2e6055b | 2016-04-22 01:48:29 -0700 | [diff] [blame] | 57 | // Constructor for instances wrapping backend objects. |
| 58 | GrGLTextureRenderTarget(GrGLGpu* gpu, |
| 59 | const GrSurfaceDesc& desc, |
| 60 | const GrGLTexture::IDDesc& texIDDesc, |
Robert Phillips | d6214d4 | 2016-11-07 08:23:48 -0500 | [diff] [blame] | 61 | const GrGLRenderTarget::IDDesc& rtIDDesc, |
Greg Daniel | 56af45b | 2017-06-15 21:51:46 +0000 | [diff] [blame] | 62 | bool wasMipMapDataProvided) |
| 63 | : GrSurface(gpu, desc) |
| 64 | , GrGLTexture(gpu, desc, texIDDesc, wasMipMapDataProvided) |
| 65 | , GrGLRenderTarget(gpu, desc, rtIDDesc) { |
| 66 | this->registerWithCacheWrapped(); |
| 67 | } |
kkinnunen | 2e6055b | 2016-04-22 01:48:29 -0700 | [diff] [blame] | 68 | |
Robert Phillips | 646e429 | 2017-06-13 12:44:56 -0400 | [diff] [blame] | 69 | size_t onGpuMemorySize() const override; |
bsalomon | 37dd331 | 2014-11-03 08:47:23 -0800 | [diff] [blame] | 70 | }; |
| 71 | |
| 72 | #ifdef SK_BUILD_FOR_WIN |
| 73 | #pragma warning(pop) |
| 74 | #endif |
| 75 | |
| 76 | #endif |