blob: 0749f6b62cb88b800618bdd483441c2f87545e41 [file] [log] [blame]
Greg Daniel164a9f02016-02-22 09:56:40 -05001/*
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 Daniel164a9f02016-02-22 09:56:40 -050011#include "GrTexture.h"
12#include "GrVkImage.h"
13
14class GrVkGpu;
15class GrVkImageView;
egdanielb2df0c22016-05-13 11:30:37 -070016struct GrVkImageInfo;
Greg Daniel164a9f02016-02-22 09:56:40 -050017
18class GrVkTexture : public GrTexture, public virtual GrVkImage {
19public:
Greg Daniel834f1202017-10-09 15:06:20 -040020 static sk_sp<GrVkTexture> CreateNewTexture(GrVkGpu*,
21 SkBudgeted budgeted,
22 const GrSurfaceDesc&,
23 const GrVkImage::ImageDesc&,
Greg Daniel0fc4d2d2017-10-12 11:23:36 -040024 GrMipMapsStatus);
halcanary9d524f22016-03-29 09:03:52 -070025
bungeman6bd52842016-10-27 09:30:08 -070026 static sk_sp<GrVkTexture> MakeWrappedTexture(GrVkGpu*, const GrSurfaceDesc&,
27 GrWrapOwnership, const GrVkImageInfo*);
Greg Daniel164a9f02016-02-22 09:56:40 -050028
29 ~GrVkTexture() override;
30
31 GrBackendObject getTextureHandle() const override;
32
33 void textureParamsModified() override {}
34
brianosmanf05ab1b2016-05-12 11:01:10 -070035 const GrVkImageView* textureView(bool allowSRGB);
Greg Daniel164a9f02016-02-22 09:56:40 -050036
egdaniel50ead532016-07-13 14:23:26 -070037 bool reallocForMipmap(GrVkGpu* gpu, uint32_t mipLevels);
jvanverth62340062016-04-26 08:01:44 -070038
Greg Danielcef213c2017-04-21 11:52:27 -040039 // 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 Daniel164a9f02016-02-22 09:56:40 -050046protected:
egdanielb2df0c22016-05-13 11:30:37 -070047 GrVkTexture(GrVkGpu*, const GrSurfaceDesc&, const GrVkImageInfo&, const GrVkImageView*,
Greg Daniel0fc4d2d2017-10-12 11:23:36 -040048 GrMipMapsStatus, GrBackendObjectOwnership);
Greg Daniel164a9f02016-02-22 09:56:40 -050049
halcanary9d524f22016-03-29 09:03:52 -070050 GrVkGpu* getVkGpu() const;
Greg Daniel164a9f02016-02-22 09:56:40 -050051
52 void onAbandon() override;
53 void onRelease() override;
54
Eric Karl914a36b2017-10-12 12:44:50 -070055 bool onStealBackendTexture(GrBackendTexture*, SkImage::BackendTextureReleaseProc*) override {
56 return false;
57 }
58
Greg Daniel164a9f02016-02-22 09:56:40 -050059private:
kkinnunen2e6055b2016-04-22 01:48:29 -070060 enum Wrapped { kWrapped };
61 GrVkTexture(GrVkGpu*, SkBudgeted, const GrSurfaceDesc&,
Greg Daniel834f1202017-10-09 15:06:20 -040062 const GrVkImageInfo&, const GrVkImageView* imageView,
Greg Daniel0fc4d2d2017-10-12 11:23:36 -040063 GrMipMapsStatus);
kkinnunen2e6055b2016-04-22 01:48:29 -070064 GrVkTexture(GrVkGpu*, Wrapped, const GrSurfaceDesc&,
Greg Daniel0fc4d2d2017-10-12 11:23:36 -040065 const GrVkImageInfo&, const GrVkImageView* imageView, GrMipMapsStatus,
66 GrBackendObjectOwnership);
kkinnunen2e6055b2016-04-22 01:48:29 -070067
jvanverth900bd4a2016-04-29 13:53:12 -070068 const GrVkImageView* fTextureView;
brianosmanf05ab1b2016-05-12 11:01:10 -070069 const GrVkImageView* fLinearTextureView;
Greg Daniel164a9f02016-02-22 09:56:40 -050070
71 typedef GrTexture INHERITED;
72};
73
74#endif