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
9#ifndef GrVkTextureRenderTarget_DEFINED
10#define GrVkTextureRenderTarget_DEFINED
11
12#include "GrVkTexture.h"
13#include "GrVkRenderTarget.h"
14
15class GrVkGpu;
16
17#ifdef SK_BUILD_FOR_WIN
18// Windows gives bogus warnings about inheriting asTexture/asRenderTarget via dominance.
19#pragma warning(push)
20#pragma warning(disable: 4250)
21#endif
22
23class GrVkImageView;
24struct GrVkImageInfo;
25
26class GrVkTextureRenderTarget: public GrVkTexture, public GrVkRenderTarget {
27public:
28    static sk_sp<GrVkTextureRenderTarget> CreateNewTextureRenderTarget(GrVkGpu*, SkBudgeted,
29                                                                       const GrSurfaceDesc&,
30                                                                       const GrVkImage::ImageDesc&,
31                                                                       GrMipMapsStatus);
32
33    static sk_sp<GrVkTextureRenderTarget> MakeWrappedTextureRenderTarget(GrVkGpu*,
34                                                                         const GrSurfaceDesc&,
35                                                                         GrWrapOwnership,
36                                                                         const GrVkImageInfo*);
37
38    bool updateForMipmap(GrVkGpu* gpu, const GrVkImageInfo& newInfo);
39
40protected:
41    void onAbandon() override {
42        GrVkRenderTarget::onAbandon();
43        GrVkTexture::onAbandon();
44    }
45
46    void onRelease() override {
47        GrVkRenderTarget::onRelease();
48        GrVkTexture::onRelease();
49    }
50
51private:
52    GrVkTextureRenderTarget(GrVkGpu* gpu,
53                            SkBudgeted budgeted,
54                            const GrSurfaceDesc& desc,
55                            const GrVkImageInfo& info,
56                            const GrVkImageView* texView,
57                            const GrVkImageInfo& msaaInfo,
58                            const GrVkImageView* colorAttachmentView,
59                            const GrVkImageView* resolveAttachmentView,
60                            GrMipMapsStatus,
61                            GrBackendObjectOwnership);
62
63    GrVkTextureRenderTarget(GrVkGpu* gpu,
64                            SkBudgeted budgeted,
65                            const GrSurfaceDesc& desc,
66                            const GrVkImageInfo& info,
67                            const GrVkImageView* texView,
68                            const GrVkImageView* colorAttachmentView,
69                            GrMipMapsStatus,
70                            GrBackendObjectOwnership);
71
72    GrVkTextureRenderTarget(GrVkGpu* gpu,
73                            const GrSurfaceDesc& desc,
74                            const GrVkImageInfo& info,
75                            const GrVkImageView* texView,
76                            const GrVkImageInfo& msaaInfo,
77                            const GrVkImageView* colorAttachmentView,
78                            const GrVkImageView* resolveAttachmentView,
79                            GrMipMapsStatus,
80                            GrBackendObjectOwnership);
81
82    GrVkTextureRenderTarget(GrVkGpu* gpu,
83                            const GrSurfaceDesc& desc,
84                            const GrVkImageInfo& info,
85                            const GrVkImageView* texView,
86                            const GrVkImageView* colorAttachmentView,
87                            GrMipMapsStatus,
88                            GrBackendObjectOwnership);
89
90    static sk_sp<GrVkTextureRenderTarget> Make(GrVkGpu*,
91                                               const GrSurfaceDesc&,
92                                               const GrVkImageInfo&,
93                                               GrMipMapsStatus,
94                                               SkBudgeted budgeted,
95                                               GrBackendObjectOwnership,
96                                               bool isWrapped);
97
98    // GrGLRenderTarget accounts for the texture's memory and any MSAA renderbuffer's memory.
99    size_t onGpuMemorySize() const override;
100};
101
102#endif
103