• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 
11 #include "GrTexture.h"
12 #include "GrVkImage.h"
13 
14 class GrVkGpu;
15 class GrVkImageView;
16 struct GrVkImageInfo;
17 
18 class GrVkTexture : public GrTexture, public virtual GrVkImage {
19 public:
20     static sk_sp<GrVkTexture> CreateNewTexture(GrVkGpu*, SkBudgeted budgeted, const GrSurfaceDesc&,
21                                                const GrVkImage::ImageDesc&);
22 
23     static sk_sp<GrVkTexture> MakeWrappedTexture(GrVkGpu*, const GrSurfaceDesc&,
24                                                  GrWrapOwnership, const GrVkImageInfo*);
25 
26     ~GrVkTexture() override;
27 
28     GrBackendObject getTextureHandle() const override;
29 
textureParamsModified()30     void textureParamsModified() override {}
31 
32     const GrVkImageView* textureView(bool allowSRGB);
33 
34     bool reallocForMipmap(GrVkGpu* gpu, uint32_t mipLevels);
35 
36     // In Vulkan we call the release proc after we are finished with the underlying
37     // GrVkImage::Resource object (which occurs after the GPU has finsihed all work on it).
setRelease(GrTexture::ReleaseProc proc,GrTexture::ReleaseCtx ctx)38     void setRelease(GrTexture::ReleaseProc proc, GrTexture::ReleaseCtx ctx) override {
39         // Forward the release proc on to GrVkImage
40         this->setResourceRelease(proc, ctx);
41     }
42 
43 protected:
44     GrVkTexture(GrVkGpu*, const GrSurfaceDesc&, const GrVkImageInfo&, const GrVkImageView*,
45                 GrVkImage::Wrapped wrapped);
46 
47     GrVkGpu* getVkGpu() const;
48 
49     void onAbandon() override;
50     void onRelease() override;
51 
52 private:
53     enum Wrapped { kWrapped };
54     GrVkTexture(GrVkGpu*, SkBudgeted, const GrSurfaceDesc&,
55                 const GrVkImageInfo&, const GrVkImageView* imageView);
56     GrVkTexture(GrVkGpu*, Wrapped, const GrSurfaceDesc&,
57                 const GrVkImageInfo&, const GrVkImageView* imageView, GrVkImage::Wrapped wrapped);
58 
59     const GrVkImageView*     fTextureView;
60     const GrVkImageView*     fLinearTextureView;
61 
62     typedef GrTexture INHERITED;
63 };
64 
65 #endif
66