aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/gpu/vk/GrVkTextureRenderTarget.h
blob: 0a0ba4d5ce60d2eb26e6c77613050890a64afdcc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
/*
 * Copyright 2015 Google Inc.
 *
 * Use of this source code is governed by a BSD-style license that can be
 * found in the LICENSE file.
 */


#ifndef GrVkTextureRenderTarget_DEFINED
#define GrVkTextureRenderTarget_DEFINED

#include "GrVkTexture.h"
#include "GrVkRenderTarget.h"

class GrVkGpu;

#ifdef SK_BUILD_FOR_WIN
// Windows gives bogus warnings about inheriting asTexture/asRenderTarget via dominance.
#pragma warning(push)
#pragma warning(disable: 4250)
#endif

class GrVkImageView;
struct GrVkImageInfo;

class GrVkTextureRenderTarget: public GrVkTexture, public GrVkRenderTarget {
public:
    static sk_sp<GrVkTextureRenderTarget> CreateNewTextureRenderTarget(GrVkGpu*, SkBudgeted,
                                                                       const GrSurfaceDesc&,
                                                                       const GrVkImage::ImageDesc&,
                                                                       GrMipMapsStatus);

    static sk_sp<GrVkTextureRenderTarget> MakeWrappedTextureRenderTarget(GrVkGpu*,
                                                                         const GrSurfaceDesc&,
                                                                         GrWrapOwnership,
                                                                         const GrVkImageInfo&,
                                                                         sk_sp<GrVkImageLayout>);

    bool updateForMipmap(GrVkGpu* gpu, const GrVkImageInfo& newInfo);

protected:
    void onAbandon() override {
        GrVkRenderTarget::onAbandon();
        GrVkTexture::onAbandon();
    }

    void onRelease() override {
        GrVkRenderTarget::onRelease();
        GrVkTexture::onRelease();
    }

private:
    GrVkTextureRenderTarget(GrVkGpu* gpu,
                            SkBudgeted budgeted,
                            const GrSurfaceDesc& desc,
                            const GrVkImageInfo& info,
                            sk_sp<GrVkImageLayout> layout,
                            const GrVkImageView* texView,
                            const GrVkImageInfo& msaaInfo,
                            sk_sp<GrVkImageLayout> msaaLayout,
                            const GrVkImageView* colorAttachmentView,
                            const GrVkImageView* resolveAttachmentView,
                            GrMipMapsStatus,
                            GrBackendObjectOwnership);

    GrVkTextureRenderTarget(GrVkGpu* gpu,
                            SkBudgeted budgeted,
                            const GrSurfaceDesc& desc,
                            const GrVkImageInfo& info,
                            sk_sp<GrVkImageLayout> layout,
                            const GrVkImageView* texView,
                            const GrVkImageView* colorAttachmentView,
                            GrMipMapsStatus,
                            GrBackendObjectOwnership);

    GrVkTextureRenderTarget(GrVkGpu* gpu,
                            const GrSurfaceDesc& desc,
                            const GrVkImageInfo& info,
                            sk_sp<GrVkImageLayout> layout,
                            const GrVkImageView* texView,
                            const GrVkImageInfo& msaaInfo,
                            sk_sp<GrVkImageLayout> msaaLayout,
                            const GrVkImageView* colorAttachmentView,
                            const GrVkImageView* resolveAttachmentView,
                            GrMipMapsStatus,
                            GrBackendObjectOwnership);

    GrVkTextureRenderTarget(GrVkGpu* gpu,
                            const GrSurfaceDesc& desc,
                            const GrVkImageInfo& info,
                            sk_sp<GrVkImageLayout> layout,
                            const GrVkImageView* texView,
                            const GrVkImageView* colorAttachmentView,
                            GrMipMapsStatus,
                            GrBackendObjectOwnership);

    static sk_sp<GrVkTextureRenderTarget> Make(GrVkGpu*,
                                               const GrSurfaceDesc&,
                                               const GrVkImageInfo&,
                                               sk_sp<GrVkImageLayout>,
                                               GrMipMapsStatus,
                                               SkBudgeted budgeted,
                                               GrBackendObjectOwnership,
                                               bool isWrapped);

    // GrGLRenderTarget accounts for the texture's memory and any MSAA renderbuffer's memory.
    size_t onGpuMemorySize() const override;
};

#endif