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 "GrGpu.h"
12#include "GrTexture.h"
13#include "GrVkImage.h"
14
15class GrVkGpu;
16class GrVkImageView;
17
18class GrVkTexture : public GrTexture, public virtual GrVkImage {
19public:
20    static GrVkTexture* CreateNewTexture(GrVkGpu*, const GrSurfaceDesc&,
21                                         GrGpuResource::LifeCycle,
22                                         const GrVkImage::ImageDesc&);
23
24
25    static GrVkTexture* CreateWrappedTexture(GrVkGpu*, const GrSurfaceDesc&,
26                                             GrGpuResource::LifeCycle,
27                                             VkFormat, const GrVkImage::Resource*);
28
29    ~GrVkTexture() override;
30
31    GrBackendObject getTextureHandle() const override;
32
33    void textureParamsModified() override {}
34
35    const GrVkImageView* textureView() const { return fTextureView; }
36
37protected:
38    enum Derived { kDerived };
39
40    GrVkTexture(GrVkGpu*, const GrSurfaceDesc&, GrGpuResource::LifeCycle,
41                const GrVkImage::Resource*, const GrVkImageView* imageView);
42
43    GrVkTexture(GrVkGpu*, const GrSurfaceDesc&, GrGpuResource::LifeCycle,
44                const GrVkImage::Resource*, const GrVkImageView* imageView, Derived);
45
46    static GrVkTexture* Create(GrVkGpu*, const GrSurfaceDesc&,
47                               GrGpuResource::LifeCycle, VkFormat,
48                               const GrVkImage::Resource* texImpl);
49
50    GrVkGpu* getVkGpu() const;
51
52    void onAbandon() override;
53    void onRelease() override;
54
55private:
56    const GrVkImageView* fTextureView;
57
58    typedef GrTexture INHERITED;
59};
60
61#endif
62