Greg Daniel | 164a9f0 | 2016-02-22 09:56:40 -0500 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2015 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 | #ifndef GrVkTexture_DEFINED |
| 9 | #define GrVkTexture_DEFINED |
| 10 | |
Greg Daniel | 164a9f0 | 2016-02-22 09:56:40 -0500 | [diff] [blame] | 11 | #include "GrTexture.h" |
| 12 | #include "GrVkImage.h" |
Greg Daniel | 487132b | 2018-12-20 14:09:36 -0500 | [diff] [blame] | 13 | #include "vk/GrVkTypes.h" |
Greg Daniel | 164a9f0 | 2016-02-22 09:56:40 -0500 | [diff] [blame] | 14 | |
| 15 | class GrVkGpu; |
| 16 | class GrVkImageView; |
egdaniel | b2df0c2 | 2016-05-13 11:30:37 -0700 | [diff] [blame] | 17 | struct GrVkImageInfo; |
Greg Daniel | 164a9f0 | 2016-02-22 09:56:40 -0500 | [diff] [blame] | 18 | |
| 19 | class GrVkTexture : public GrTexture, public virtual GrVkImage { |
| 20 | public: |
Greg Daniel | 475eb70 | 2018-09-28 14:16:50 -0400 | [diff] [blame] | 21 | static sk_sp<GrVkTexture> MakeNewTexture(GrVkGpu*, |
| 22 | SkBudgeted budgeted, |
| 23 | const GrSurfaceDesc&, |
| 24 | const GrVkImage::ImageDesc&, |
| 25 | GrMipMapsStatus); |
halcanary | 9d524f2 | 2016-03-29 09:03:52 -0700 | [diff] [blame] | 26 | |
Brian Salomon | c67c31c | 2018-12-06 10:00:03 -0500 | [diff] [blame] | 27 | static sk_sp<GrVkTexture> MakeWrappedTexture(GrVkGpu*, const GrSurfaceDesc&, GrWrapOwnership, |
Brian Salomon | fa2ebea | 2019-01-24 15:58:58 -0500 | [diff] [blame] | 28 | GrWrapCacheable, GrIOType, const GrVkImageInfo&, |
| 29 | sk_sp<GrVkImageLayout>); |
Greg Daniel | 164a9f0 | 2016-02-22 09:56:40 -0500 | [diff] [blame] | 30 | |
| 31 | ~GrVkTexture() override; |
| 32 | |
Robert Phillips | b67821d | 2017-12-13 15:00:45 -0500 | [diff] [blame] | 33 | GrBackendTexture getBackendTexture() const override; |
Greg Daniel | 164a9f0 | 2016-02-22 09:56:40 -0500 | [diff] [blame] | 34 | |
Greg Daniel | 4065d45 | 2018-11-16 15:43:41 -0500 | [diff] [blame] | 35 | GrBackendFormat backendFormat() const override { return this->getBackendFormat(); } |
| 36 | |
Greg Daniel | 164a9f0 | 2016-02-22 09:56:40 -0500 | [diff] [blame] | 37 | void textureParamsModified() override {} |
| 38 | |
Brian Osman | 2b23c4b | 2018-06-01 12:25:08 -0400 | [diff] [blame] | 39 | const GrVkImageView* textureView(); |
Greg Daniel | 164a9f0 | 2016-02-22 09:56:40 -0500 | [diff] [blame] | 40 | |
Greg Daniel | cef213c | 2017-04-21 11:52:27 -0400 | [diff] [blame] | 41 | // In Vulkan we call the release proc after we are finished with the underlying |
| 42 | // GrVkImage::Resource object (which occurs after the GPU has finsihed all work on it). |
Greg Daniel | 6a0176b | 2018-01-30 09:28:44 -0500 | [diff] [blame] | 43 | void setRelease(sk_sp<GrReleaseProcHelper> releaseHelper) override { |
Greg Daniel | cef213c | 2017-04-21 11:52:27 -0400 | [diff] [blame] | 44 | // Forward the release proc on to GrVkImage |
Greg Daniel | 6a0176b | 2018-01-30 09:28:44 -0500 | [diff] [blame] | 45 | this->setResourceRelease(std::move(releaseHelper)); |
Greg Daniel | cef213c | 2017-04-21 11:52:27 -0400 | [diff] [blame] | 46 | } |
| 47 | |
Brian Salomon | 614c1a8 | 2018-12-19 15:42:06 -0500 | [diff] [blame] | 48 | void setIdleProc(IdleProc, void* context) override; |
Brian Salomon | 1bf0ed8 | 2019-01-16 13:51:35 -0500 | [diff] [blame] | 49 | void* idleContext() const override { return fIdleProcContext; } |
Brian Salomon | 614c1a8 | 2018-12-19 15:42:06 -0500 | [diff] [blame] | 50 | |
Greg Daniel | 164a9f0 | 2016-02-22 09:56:40 -0500 | [diff] [blame] | 51 | protected: |
Greg Daniel | 52e16d9 | 2018-04-10 09:34:07 -0400 | [diff] [blame] | 52 | GrVkTexture(GrVkGpu*, const GrSurfaceDesc&, const GrVkImageInfo&, sk_sp<GrVkImageLayout>, |
| 53 | const GrVkImageView*, GrMipMapsStatus, GrBackendObjectOwnership); |
Greg Daniel | 164a9f0 | 2016-02-22 09:56:40 -0500 | [diff] [blame] | 54 | |
halcanary | 9d524f2 | 2016-03-29 09:03:52 -0700 | [diff] [blame] | 55 | GrVkGpu* getVkGpu() const; |
Greg Daniel | 164a9f0 | 2016-02-22 09:56:40 -0500 | [diff] [blame] | 56 | |
| 57 | void onAbandon() override; |
| 58 | void onRelease() override; |
| 59 | |
Eric Karl | 914a36b | 2017-10-12 12:44:50 -0700 | [diff] [blame] | 60 | bool onStealBackendTexture(GrBackendTexture*, SkImage::BackendTextureReleaseProc*) override { |
| 61 | return false; |
| 62 | } |
| 63 | |
Greg Daniel | 164a9f0 | 2016-02-22 09:56:40 -0500 | [diff] [blame] | 64 | private: |
Greg Daniel | 52e16d9 | 2018-04-10 09:34:07 -0400 | [diff] [blame] | 65 | GrVkTexture(GrVkGpu*, SkBudgeted, const GrSurfaceDesc&, const GrVkImageInfo&, |
| 66 | sk_sp<GrVkImageLayout> layout, const GrVkImageView* imageView, |
Greg Daniel | 0fc4d2d | 2017-10-12 11:23:36 -0400 | [diff] [blame] | 67 | GrMipMapsStatus); |
Brian Salomon | fa2ebea | 2019-01-24 15:58:58 -0500 | [diff] [blame] | 68 | GrVkTexture(GrVkGpu*, const GrSurfaceDesc&, const GrVkImageInfo&, sk_sp<GrVkImageLayout>, |
| 69 | const GrVkImageView*, GrMipMapsStatus, GrBackendObjectOwnership, GrWrapCacheable, |
| 70 | GrIOType); |
kkinnunen | 2e6055b | 2016-04-22 01:48:29 -0700 | [diff] [blame] | 71 | |
Brian Salomon | 9bc76d9 | 2019-01-24 12:18:33 -0500 | [diff] [blame^] | 72 | void removedLastRefOrPendingIO() override; |
Brian Salomon | 614c1a8 | 2018-12-19 15:42:06 -0500 | [diff] [blame] | 73 | |
| 74 | const GrVkImageView* fTextureView; |
| 75 | GrTexture::IdleProc* fIdleProc = nullptr; |
| 76 | void* fIdleProcContext = nullptr; |
Greg Daniel | 164a9f0 | 2016-02-22 09:56:40 -0500 | [diff] [blame] | 77 | |
| 78 | typedef GrTexture INHERITED; |
| 79 | }; |
| 80 | |
| 81 | #endif |