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 | |
Brian Salomon | 614c1a8 | 2018-12-19 15:42:06 -0500 | [diff] [blame] | 41 | void setIdleProc(IdleProc, void* context) override; |
Brian Salomon | 1bf0ed8 | 2019-01-16 13:51:35 -0500 | [diff] [blame] | 42 | void* idleContext() const override { return fIdleProcContext; } |
Brian Salomon | 614c1a8 | 2018-12-19 15:42:06 -0500 | [diff] [blame] | 43 | |
Greg Daniel | 164a9f0 | 2016-02-22 09:56:40 -0500 | [diff] [blame] | 44 | protected: |
Greg Daniel | 52e16d9 | 2018-04-10 09:34:07 -0400 | [diff] [blame] | 45 | GrVkTexture(GrVkGpu*, const GrSurfaceDesc&, const GrVkImageInfo&, sk_sp<GrVkImageLayout>, |
| 46 | const GrVkImageView*, GrMipMapsStatus, GrBackendObjectOwnership); |
Greg Daniel | 164a9f0 | 2016-02-22 09:56:40 -0500 | [diff] [blame] | 47 | |
halcanary | 9d524f2 | 2016-03-29 09:03:52 -0700 | [diff] [blame] | 48 | GrVkGpu* getVkGpu() const; |
Greg Daniel | 164a9f0 | 2016-02-22 09:56:40 -0500 | [diff] [blame] | 49 | |
| 50 | void onAbandon() override; |
| 51 | void onRelease() override; |
| 52 | |
Eric Karl | 914a36b | 2017-10-12 12:44:50 -0700 | [diff] [blame] | 53 | bool onStealBackendTexture(GrBackendTexture*, SkImage::BackendTextureReleaseProc*) override { |
| 54 | return false; |
| 55 | } |
| 56 | |
Greg Daniel | 164a9f0 | 2016-02-22 09:56:40 -0500 | [diff] [blame] | 57 | private: |
Greg Daniel | 52e16d9 | 2018-04-10 09:34:07 -0400 | [diff] [blame] | 58 | GrVkTexture(GrVkGpu*, SkBudgeted, const GrSurfaceDesc&, const GrVkImageInfo&, |
| 59 | sk_sp<GrVkImageLayout> layout, const GrVkImageView* imageView, |
Greg Daniel | 0fc4d2d | 2017-10-12 11:23:36 -0400 | [diff] [blame] | 60 | GrMipMapsStatus); |
Brian Salomon | fa2ebea | 2019-01-24 15:58:58 -0500 | [diff] [blame] | 61 | GrVkTexture(GrVkGpu*, const GrSurfaceDesc&, const GrVkImageInfo&, sk_sp<GrVkImageLayout>, |
| 62 | const GrVkImageView*, GrMipMapsStatus, GrBackendObjectOwnership, GrWrapCacheable, |
| 63 | GrIOType); |
kkinnunen | 2e6055b | 2016-04-22 01:48:29 -0700 | [diff] [blame] | 64 | |
Greg Daniel | 2d35a1c | 2019-02-01 14:48:10 -0500 | [diff] [blame] | 65 | // In Vulkan we call the release proc after we are finished with the underlying |
| 66 | // GrVkImage::Resource object (which occurs after the GPU has finished all work on it). |
| 67 | void onSetRelease(sk_sp<GrReleaseProcHelper> releaseHelper) override { |
| 68 | // Forward the release proc on to GrVkImage |
| 69 | this->setResourceRelease(std::move(releaseHelper)); |
| 70 | } |
| 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 |