1cb93a386Sopenharmony_ci/*
2cb93a386Sopenharmony_ci * Copyright 2015 Google Inc.
3cb93a386Sopenharmony_ci *
4cb93a386Sopenharmony_ci * Use of this source code is governed by a BSD-style license that can be
5cb93a386Sopenharmony_ci * found in the LICENSE file.
6cb93a386Sopenharmony_ci */
7cb93a386Sopenharmony_ci
8cb93a386Sopenharmony_ci
9cb93a386Sopenharmony_ci#ifndef GrVkTextureRenderTarget_DEFINED
10cb93a386Sopenharmony_ci#define GrVkTextureRenderTarget_DEFINED
11cb93a386Sopenharmony_ci
12cb93a386Sopenharmony_ci#include "include/gpu/vk/GrVkTypes.h"
13cb93a386Sopenharmony_ci#include "src/gpu/vk/GrVkRenderTarget.h"
14cb93a386Sopenharmony_ci#include "src/gpu/vk/GrVkTexture.h"
15cb93a386Sopenharmony_ci
16cb93a386Sopenharmony_ciclass GrVkGpu;
17cb93a386Sopenharmony_ci
18cb93a386Sopenharmony_ci#ifdef SK_BUILD_FOR_WIN
19cb93a386Sopenharmony_ci// Windows gives bogus warnings about inheriting asTexture/asRenderTarget via dominance.
20cb93a386Sopenharmony_ci#pragma warning(push)
21cb93a386Sopenharmony_ci#pragma warning(disable: 4250)
22cb93a386Sopenharmony_ci#endif
23cb93a386Sopenharmony_ci
24cb93a386Sopenharmony_ciclass GrVkImageView;
25cb93a386Sopenharmony_cistruct GrVkImageInfo;
26cb93a386Sopenharmony_ci
27cb93a386Sopenharmony_ciclass GrVkTextureRenderTarget: public GrVkTexture, public GrVkRenderTarget {
28cb93a386Sopenharmony_cipublic:
29cb93a386Sopenharmony_ci    static sk_sp<GrVkTextureRenderTarget> MakeNewTextureRenderTarget(
30cb93a386Sopenharmony_ci            GrVkGpu* gpu,
31cb93a386Sopenharmony_ci            SkBudgeted budgeted,
32cb93a386Sopenharmony_ci            SkISize dimensions,
33cb93a386Sopenharmony_ci            VkFormat format,
34cb93a386Sopenharmony_ci            uint32_t mipLevels,
35cb93a386Sopenharmony_ci            int sampleCnt,
36cb93a386Sopenharmony_ci            GrMipmapStatus mipmapStatus,
37cb93a386Sopenharmony_ci            GrProtected isProtected);
38cb93a386Sopenharmony_ci
39cb93a386Sopenharmony_ci    static sk_sp<GrVkTextureRenderTarget> MakeWrappedTextureRenderTarget(
40cb93a386Sopenharmony_ci            GrVkGpu*,
41cb93a386Sopenharmony_ci            SkISize dimensions,
42cb93a386Sopenharmony_ci            int sampleCnt,
43cb93a386Sopenharmony_ci            GrWrapOwnership,
44cb93a386Sopenharmony_ci            GrWrapCacheable,
45cb93a386Sopenharmony_ci            const GrVkImageInfo&,
46cb93a386Sopenharmony_ci            sk_sp<GrBackendSurfaceMutableStateImpl>);
47cb93a386Sopenharmony_ci
48cb93a386Sopenharmony_ci    GrBackendFormat backendFormat() const override { return GrVkTexture::backendFormat(); }
49cb93a386Sopenharmony_ci
50cb93a386Sopenharmony_ci    void dumpMemoryStatistics(SkTraceMemoryDump* traceMemoryDump) const override;
51cb93a386Sopenharmony_ci
52cb93a386Sopenharmony_ciprotected:
53cb93a386Sopenharmony_ci    void onAbandon() override {
54cb93a386Sopenharmony_ci        // In order to correctly handle calling texture idle procs, GrVkTexture must go first.
55cb93a386Sopenharmony_ci        GrVkTexture::onAbandon();
56cb93a386Sopenharmony_ci        GrVkRenderTarget::onAbandon();
57cb93a386Sopenharmony_ci    }
58cb93a386Sopenharmony_ci
59cb93a386Sopenharmony_ci    void onRelease() override {
60cb93a386Sopenharmony_ci        // In order to correctly handle calling texture idle procs, GrVkTexture must go first.
61cb93a386Sopenharmony_ci        GrVkTexture::onRelease();
62cb93a386Sopenharmony_ci        GrVkRenderTarget::onRelease();
63cb93a386Sopenharmony_ci    }
64cb93a386Sopenharmony_ci
65cb93a386Sopenharmony_ciprivate:
66cb93a386Sopenharmony_ci    GrVkTextureRenderTarget(GrVkGpu* gpu,
67cb93a386Sopenharmony_ci                            SkBudgeted budgeted,
68cb93a386Sopenharmony_ci                            SkISize dimensions,
69cb93a386Sopenharmony_ci                            sk_sp<GrVkImage> texture,
70cb93a386Sopenharmony_ci                            sk_sp<GrVkImage> colorAttachment,
71cb93a386Sopenharmony_ci                            sk_sp<GrVkImage> resolveAttachment,
72cb93a386Sopenharmony_ci                            GrMipmapStatus);
73cb93a386Sopenharmony_ci
74cb93a386Sopenharmony_ci    GrVkTextureRenderTarget(GrVkGpu* gpu,
75cb93a386Sopenharmony_ci                            SkISize dimensions,
76cb93a386Sopenharmony_ci                            sk_sp<GrVkImage> texture,
77cb93a386Sopenharmony_ci                            sk_sp<GrVkImage> colorAttachment,
78cb93a386Sopenharmony_ci                            sk_sp<GrVkImage> resolveAttachment,
79cb93a386Sopenharmony_ci                            GrMipmapStatus,
80cb93a386Sopenharmony_ci                            GrWrapCacheable);
81cb93a386Sopenharmony_ci
82cb93a386Sopenharmony_ci    size_t onGpuMemorySize() const override;
83cb93a386Sopenharmony_ci
84cb93a386Sopenharmony_ci    // In Vulkan we call the release proc after we are finished with the underlying
85cb93a386Sopenharmony_ci    // GrVkImage::Resource object (which occurs after the GPU has finished all work on it).
86cb93a386Sopenharmony_ci    void onSetRelease(sk_sp<GrRefCntedCallback> releaseHelper) override {
87cb93a386Sopenharmony_ci        // Forward the release proc on to GrVkImage
88cb93a386Sopenharmony_ci        GrVkTexture::onSetRelease(std::move(releaseHelper));
89cb93a386Sopenharmony_ci    }
90cb93a386Sopenharmony_ci};
91cb93a386Sopenharmony_ci
92cb93a386Sopenharmony_ci#ifdef SK_BUILD_FOR_WIN
93cb93a386Sopenharmony_ci#pragma warning(pop)
94cb93a386Sopenharmony_ci#endif
95cb93a386Sopenharmony_ci
96cb93a386Sopenharmony_ci#endif
97