OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2015 Google Inc. | 2 * Copyright 2015 Google Inc. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
6 */ | 6 */ |
7 | 7 |
8 | 8 |
9 #ifndef GrVkTextureRenderTarget_DEFINED | 9 #ifndef GrVkTextureRenderTarget_DEFINED |
10 #define GrVkTextureRenderTarget_DEFINED | 10 #define GrVkTextureRenderTarget_DEFINED |
11 | 11 |
12 #include "GrVkTexture.h" | 12 #include "GrVkTexture.h" |
13 #include "GrVkRenderTarget.h" | 13 #include "GrVkRenderTarget.h" |
14 #include "GrVkGpu.h" | 14 #include "GrVkGpu.h" |
15 | 15 |
16 #ifdef SK_BUILD_FOR_WIN | 16 #ifdef SK_BUILD_FOR_WIN |
17 // Windows gives bogus warnings about inheriting asTexture/asRenderTarget via do
minance. | 17 // Windows gives bogus warnings about inheriting asTexture/asRenderTarget via do
minance. |
18 #pragma warning(push) | 18 #pragma warning(push) |
19 #pragma warning(disable: 4250) | 19 #pragma warning(disable: 4250) |
20 #endif | 20 #endif |
21 | 21 |
22 class GrVkImageView; | 22 class GrVkImageView; |
23 struct GrVkTextureInfo; | 23 struct GrVkImageInfo; |
24 | 24 |
25 class GrVkTextureRenderTarget: public GrVkTexture, public GrVkRenderTarget { | 25 class GrVkTextureRenderTarget: public GrVkTexture, public GrVkRenderTarget { |
26 public: | 26 public: |
27 static GrVkTextureRenderTarget* CreateNewTextureRenderTarget(GrVkGpu*, SkBud
geted, | 27 static GrVkTextureRenderTarget* CreateNewTextureRenderTarget(GrVkGpu*, SkBud
geted, |
28 const GrSurface
Desc&, | 28 const GrSurface
Desc&, |
29 const GrVkImage
::ImageDesc&); | 29 const GrVkImage
::ImageDesc&); |
30 | 30 |
31 static GrVkTextureRenderTarget* CreateWrappedTextureRenderTarget(GrVkGpu*, | 31 static GrVkTextureRenderTarget* CreateWrappedTextureRenderTarget(GrVkGpu*, |
32 const GrSur
faceDesc&, | 32 const GrSur
faceDesc&, |
33 GrWrapOwner
ship, | 33 GrWrapOwner
ship, |
34 VkFormat, | 34 const GrVkI
mageInfo*); |
35 const GrVkT
extureInfo*); | |
36 | 35 |
37 protected: | 36 protected: |
38 void onAbandon() override { | 37 void onAbandon() override { |
39 GrVkRenderTarget::onAbandon(); | 38 GrVkRenderTarget::onAbandon(); |
40 GrVkTexture::onAbandon(); | 39 GrVkTexture::onAbandon(); |
41 } | 40 } |
42 | 41 |
43 void onRelease() override { | 42 void onRelease() override { |
44 GrVkRenderTarget::onRelease(); | 43 GrVkRenderTarget::onRelease(); |
45 GrVkTexture::onRelease(); | 44 GrVkTexture::onRelease(); |
46 } | 45 } |
47 | 46 |
48 private: | 47 private: |
49 GrVkTextureRenderTarget(GrVkGpu* gpu, | 48 GrVkTextureRenderTarget(GrVkGpu* gpu, |
50 SkBudgeted budgeted, | 49 SkBudgeted budgeted, |
51 const GrSurfaceDesc& desc, | 50 const GrSurfaceDesc& desc, |
52 const GrVkImage::Resource* imageResource, | 51 const GrVkImageInfo& info, |
53 const GrVkImageView* texView, | 52 const GrVkImageView* texView, |
54 const GrVkImage::Resource* msaaResource, | 53 const GrVkImageInfo& msaaInfo, |
55 const GrVkImageView* colorAttachmentView, | 54 const GrVkImageView* colorAttachmentView, |
56 const GrVkImageView* resolveAttachmentView) | 55 const GrVkImageView* resolveAttachmentView) |
57 : GrSurface(gpu, desc) | 56 : GrSurface(gpu, desc) |
58 , GrVkImage(imageResource) | 57 , GrVkImage(info, GrVkImage::kNot_Wrapped) |
59 , GrVkTexture(gpu, desc, imageResource, texView) | 58 , GrVkTexture(gpu, desc, info, texView, GrVkImage::kNot_Wrapped) |
60 , GrVkRenderTarget(gpu, desc, imageResource, msaaResource, colorAttachme
ntView, | 59 , GrVkRenderTarget(gpu, desc, info, msaaInfo, colorAttachmentView, |
61 resolveAttachmentView) { | 60 resolveAttachmentView, GrVkImage::kNot_Wrapped) { |
62 this->registerWithCache(budgeted); | 61 this->registerWithCache(budgeted); |
63 } | 62 } |
64 | 63 |
65 GrVkTextureRenderTarget(GrVkGpu* gpu, | 64 GrVkTextureRenderTarget(GrVkGpu* gpu, |
66 SkBudgeted budgeted, | 65 SkBudgeted budgeted, |
67 const GrSurfaceDesc& desc, | 66 const GrSurfaceDesc& desc, |
68 const GrVkImage::Resource* imageResource, | 67 const GrVkImageInfo& info, |
69 const GrVkImageView* texView, | 68 const GrVkImageView* texView, |
70 const GrVkImageView* colorAttachmentView) | 69 const GrVkImageView* colorAttachmentView) |
71 : GrSurface(gpu, desc) | 70 : GrSurface(gpu, desc) |
72 , GrVkImage(imageResource) | 71 , GrVkImage(info, GrVkImage::kNot_Wrapped) |
73 , GrVkTexture(gpu, desc, imageResource, texView) | 72 , GrVkTexture(gpu, desc, info, texView, GrVkImage::kNot_Wrapped) |
74 , GrVkRenderTarget(gpu, desc, imageResource, colorAttachmentView) { | 73 , GrVkRenderTarget(gpu, desc, info, colorAttachmentView, GrVkImage::kNot
_Wrapped) { |
75 this->registerWithCache(budgeted); | 74 this->registerWithCache(budgeted); |
76 } | 75 } |
77 enum Wrapped { kWrapped }; | |
78 GrVkTextureRenderTarget(GrVkGpu* gpu, | 76 GrVkTextureRenderTarget(GrVkGpu* gpu, |
79 Wrapped, | |
80 const GrSurfaceDesc& desc, | 77 const GrSurfaceDesc& desc, |
81 const GrVkImage::Resource* imageResource, | 78 const GrVkImageInfo& info, |
82 const GrVkImageView* texView, | 79 const GrVkImageView* texView, |
83 const GrVkImage::Resource* msaaResource, | 80 const GrVkImageInfo& msaaInfo, |
84 const GrVkImageView* colorAttachmentView, | 81 const GrVkImageView* colorAttachmentView, |
85 const GrVkImageView* resolveAttachmentView) | 82 const GrVkImageView* resolveAttachmentView, |
| 83 GrVkImage::Wrapped wrapped) |
86 : GrSurface(gpu, desc) | 84 : GrSurface(gpu, desc) |
87 , GrVkImage(imageResource) | 85 , GrVkImage(info, wrapped) |
88 , GrVkTexture(gpu, desc, imageResource, texView) | 86 , GrVkTexture(gpu, desc, info, texView, wrapped) |
89 , GrVkRenderTarget(gpu, desc, imageResource, msaaResource, colorAttachme
ntView, | 87 , GrVkRenderTarget(gpu, desc, info, msaaInfo, colorAttachmentView, |
90 resolveAttachmentView) { | 88 resolveAttachmentView, wrapped) { |
91 this->registerWithCacheWrapped(); | 89 this->registerWithCacheWrapped(); |
92 } | 90 } |
93 | 91 |
94 GrVkTextureRenderTarget(GrVkGpu* gpu, | 92 GrVkTextureRenderTarget(GrVkGpu* gpu, |
95 Wrapped, | |
96 const GrSurfaceDesc& desc, | 93 const GrSurfaceDesc& desc, |
97 const GrVkImage::Resource* imageResource, | 94 const GrVkImageInfo& info, |
98 const GrVkImageView* texView, | 95 const GrVkImageView* texView, |
99 const GrVkImageView* colorAttachmentView) | 96 const GrVkImageView* colorAttachmentView, |
| 97 GrVkImage::Wrapped wrapped) |
100 : GrSurface(gpu, desc) | 98 : GrSurface(gpu, desc) |
101 , GrVkImage(imageResource) | 99 , GrVkImage(info, wrapped) |
102 , GrVkTexture(gpu, desc, imageResource, texView) | 100 , GrVkTexture(gpu, desc, info, texView, wrapped) |
103 , GrVkRenderTarget(gpu, desc, imageResource, colorAttachmentView) { | 101 , GrVkRenderTarget(gpu, desc, info, colorAttachmentView, wrapped) { |
104 this->registerWithCacheWrapped(); | 102 this->registerWithCacheWrapped(); |
105 } | 103 } |
106 | 104 |
107 template <typename ResourceType> | |
108 static GrVkTextureRenderTarget* Create(GrVkGpu*, | 105 static GrVkTextureRenderTarget* Create(GrVkGpu*, |
109 ResourceType, | |
110 const GrSurfaceDesc&, | 106 const GrSurfaceDesc&, |
111 VkFormat, | 107 const GrVkImageInfo&, |
112 const GrVkImage::Resource* imageResou
rce); | 108 SkBudgeted budgeted, |
| 109 GrVkImage::Wrapped wrapped); |
113 | 110 |
114 // GrGLRenderTarget accounts for the texture's memory and any MSAA renderbuf
fer's memory. | 111 // GrGLRenderTarget accounts for the texture's memory and any MSAA renderbuf
fer's memory. |
115 size_t onGpuMemorySize() const override { | 112 size_t onGpuMemorySize() const override { |
116 return GrVkRenderTarget::onGpuMemorySize(); | 113 return GrVkRenderTarget::onGpuMemorySize(); |
117 } | 114 } |
118 }; | 115 }; |
119 | 116 |
120 #endif | 117 #endif |
OLD | NEW |