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" |
| 13 | |
| 14 | class GrVkGpu; |
| 15 | class GrVkImageView; |
egdaniel | b2df0c2 | 2016-05-13 11:30:37 -0700 | [diff] [blame] | 16 | struct GrVkImageInfo; |
Greg Daniel | 164a9f0 | 2016-02-22 09:56:40 -0500 | [diff] [blame] | 17 | |
| 18 | class GrVkTexture : public GrTexture, public virtual GrVkImage { |
| 19 | public: |
Greg Daniel | 834f120 | 2017-10-09 15:06:20 -0400 | [diff] [blame] | 20 | static sk_sp<GrVkTexture> CreateNewTexture(GrVkGpu*, |
| 21 | SkBudgeted budgeted, |
| 22 | const GrSurfaceDesc&, |
| 23 | const GrVkImage::ImageDesc&, |
Greg Daniel | 0fc4d2d | 2017-10-12 11:23:36 -0400 | [diff] [blame] | 24 | GrMipMapsStatus); |
halcanary | 9d524f2 | 2016-03-29 09:03:52 -0700 | [diff] [blame] | 25 | |
bungeman | 6bd5284 | 2016-10-27 09:30:08 -0700 | [diff] [blame] | 26 | static sk_sp<GrVkTexture> MakeWrappedTexture(GrVkGpu*, const GrSurfaceDesc&, |
| 27 | GrWrapOwnership, const GrVkImageInfo*); |
Greg Daniel | 164a9f0 | 2016-02-22 09:56:40 -0500 | [diff] [blame] | 28 | |
| 29 | ~GrVkTexture() override; |
| 30 | |
| 31 | GrBackendObject getTextureHandle() const override; |
| 32 | |
| 33 | void textureParamsModified() override {} |
| 34 | |
brianosman | f05ab1b | 2016-05-12 11:01:10 -0700 | [diff] [blame] | 35 | const GrVkImageView* textureView(bool allowSRGB); |
Greg Daniel | 164a9f0 | 2016-02-22 09:56:40 -0500 | [diff] [blame] | 36 | |
egdaniel | 50ead53 | 2016-07-13 14:23:26 -0700 | [diff] [blame] | 37 | bool reallocForMipmap(GrVkGpu* gpu, uint32_t mipLevels); |
jvanverth | 6234006 | 2016-04-26 08:01:44 -0700 | [diff] [blame] | 38 | |
Greg Daniel | cef213c | 2017-04-21 11:52:27 -0400 | [diff] [blame] | 39 | // In Vulkan we call the release proc after we are finished with the underlying |
| 40 | // GrVkImage::Resource object (which occurs after the GPU has finsihed all work on it). |
| 41 | void setRelease(GrTexture::ReleaseProc proc, GrTexture::ReleaseCtx ctx) override { |
| 42 | // Forward the release proc on to GrVkImage |
| 43 | this->setResourceRelease(proc, ctx); |
| 44 | } |
| 45 | |
Greg Daniel | 164a9f0 | 2016-02-22 09:56:40 -0500 | [diff] [blame] | 46 | protected: |
egdaniel | b2df0c2 | 2016-05-13 11:30:37 -0700 | [diff] [blame] | 47 | GrVkTexture(GrVkGpu*, const GrSurfaceDesc&, const GrVkImageInfo&, const GrVkImageView*, |
Greg Daniel | 0fc4d2d | 2017-10-12 11:23:36 -0400 | [diff] [blame] | 48 | GrMipMapsStatus, GrBackendObjectOwnership); |
Greg Daniel | 164a9f0 | 2016-02-22 09:56:40 -0500 | [diff] [blame] | 49 | |
halcanary | 9d524f2 | 2016-03-29 09:03:52 -0700 | [diff] [blame] | 50 | GrVkGpu* getVkGpu() const; |
Greg Daniel | 164a9f0 | 2016-02-22 09:56:40 -0500 | [diff] [blame] | 51 | |
| 52 | void onAbandon() override; |
| 53 | void onRelease() override; |
| 54 | |
Eric Karl | 914a36b | 2017-10-12 12:44:50 -0700 | [diff] [blame] | 55 | bool onStealBackendTexture(GrBackendTexture*, SkImage::BackendTextureReleaseProc*) override { |
| 56 | return false; |
| 57 | } |
| 58 | |
Greg Daniel | 164a9f0 | 2016-02-22 09:56:40 -0500 | [diff] [blame] | 59 | private: |
kkinnunen | 2e6055b | 2016-04-22 01:48:29 -0700 | [diff] [blame] | 60 | enum Wrapped { kWrapped }; |
| 61 | GrVkTexture(GrVkGpu*, SkBudgeted, const GrSurfaceDesc&, |
Greg Daniel | 834f120 | 2017-10-09 15:06:20 -0400 | [diff] [blame] | 62 | const GrVkImageInfo&, const GrVkImageView* imageView, |
Greg Daniel | 0fc4d2d | 2017-10-12 11:23:36 -0400 | [diff] [blame] | 63 | GrMipMapsStatus); |
kkinnunen | 2e6055b | 2016-04-22 01:48:29 -0700 | [diff] [blame] | 64 | GrVkTexture(GrVkGpu*, Wrapped, const GrSurfaceDesc&, |
Greg Daniel | 0fc4d2d | 2017-10-12 11:23:36 -0400 | [diff] [blame] | 65 | const GrVkImageInfo&, const GrVkImageView* imageView, GrMipMapsStatus, |
| 66 | GrBackendObjectOwnership); |
kkinnunen | 2e6055b | 2016-04-22 01:48:29 -0700 | [diff] [blame] | 67 | |
jvanverth | 900bd4a | 2016-04-29 13:53:12 -0700 | [diff] [blame] | 68 | const GrVkImageView* fTextureView; |
brianosman | f05ab1b | 2016-05-12 11:01:10 -0700 | [diff] [blame] | 69 | const GrVkImageView* fLinearTextureView; |
Greg Daniel | 164a9f0 | 2016-02-22 09:56:40 -0500 | [diff] [blame] | 70 | |
| 71 | typedef GrTexture INHERITED; |
| 72 | }; |
| 73 | |
| 74 | #endif |