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 GrVkTextureInfo; |
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*, const
GrSurfaceDesc&, | 27 static GrVkTextureRenderTarget* CreateNewTextureRenderTarget(GrVkGpu*, SkBud
geted, |
28 GrGpuResource::
LifeCycle, | 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 GrGpuResour
ce::LifeCycle, | 33 GrWrapOwner
ship, |
34 VkFormat, | 34 VkFormat, |
35 const GrVkT
extureInfo*); | 35 const GrVkT
extureInfo*); |
36 | 36 |
37 protected: | 37 protected: |
38 void onAbandon() override { | 38 void onAbandon() override { |
39 GrVkRenderTarget::onAbandon(); | 39 GrVkRenderTarget::onAbandon(); |
40 GrVkTexture::onAbandon(); | 40 GrVkTexture::onAbandon(); |
41 } | 41 } |
42 | 42 |
43 void onRelease() override { | 43 void onRelease() override { |
44 GrVkRenderTarget::onRelease(); | 44 GrVkRenderTarget::onRelease(); |
45 GrVkTexture::onRelease(); | 45 GrVkTexture::onRelease(); |
46 } | 46 } |
47 | 47 |
48 private: | 48 private: |
49 GrVkTextureRenderTarget(GrVkGpu* gpu, | 49 GrVkTextureRenderTarget(GrVkGpu* gpu, |
| 50 SkBudgeted budgeted, |
50 const GrSurfaceDesc& desc, | 51 const GrSurfaceDesc& desc, |
51 GrGpuResource::LifeCycle lifeCycle, | |
52 const GrVkImage::Resource* imageResource, | 52 const GrVkImage::Resource* imageResource, |
53 const GrVkImageView* texView, | 53 const GrVkImageView* texView, |
54 const GrVkImage::Resource* msaaResource, | 54 const GrVkImage::Resource* msaaResource, |
55 const GrVkImageView* colorAttachmentView, | 55 const GrVkImageView* colorAttachmentView, |
56 const GrVkImageView* resolveAttachmentView) | 56 const GrVkImageView* resolveAttachmentView) |
57 : GrSurface(gpu, lifeCycle, desc) | 57 : GrSurface(gpu, desc) |
58 , GrVkImage(imageResource) | 58 , GrVkImage(imageResource) |
59 , GrVkTexture(gpu, desc, lifeCycle, imageResource, texView, GrVkTexture:
:kDerived) | 59 , GrVkTexture(gpu, desc, imageResource, texView) |
60 , GrVkRenderTarget(gpu, desc, lifeCycle, imageResource, msaaResource, co
lorAttachmentView, | 60 , GrVkRenderTarget(gpu, desc, imageResource, msaaResource, colorAttachme
ntView, |
61 resolveAttachmentView, GrVkRenderTarget::kDerived) { | 61 resolveAttachmentView) { |
62 this->registerWithCache(); | 62 this->registerWithCache(budgeted); |
63 } | 63 } |
64 | 64 |
65 GrVkTextureRenderTarget(GrVkGpu* gpu, | 65 GrVkTextureRenderTarget(GrVkGpu* gpu, |
| 66 SkBudgeted budgeted, |
66 const GrSurfaceDesc& desc, | 67 const GrSurfaceDesc& desc, |
67 GrGpuResource::LifeCycle lifeCycle, | |
68 const GrVkImage::Resource* imageResource, | 68 const GrVkImage::Resource* imageResource, |
69 const GrVkImageView* texView, | 69 const GrVkImageView* texView, |
70 const GrVkImageView* colorAttachmentView) | 70 const GrVkImageView* colorAttachmentView) |
71 : GrSurface(gpu, lifeCycle, desc) | 71 : GrSurface(gpu, desc) |
72 , GrVkImage(imageResource) | 72 , GrVkImage(imageResource) |
73 , GrVkTexture(gpu, desc, lifeCycle, imageResource, texView, GrVkTexture:
:kDerived) | 73 , GrVkTexture(gpu, desc, imageResource, texView) |
74 , GrVkRenderTarget(gpu, desc, lifeCycle, imageResource, colorAttachmentV
iew, | 74 , GrVkRenderTarget(gpu, desc, imageResource, colorAttachmentView) { |
75 GrVkRenderTarget::kDerived) { | 75 this->registerWithCache(budgeted); |
76 this->registerWithCache(); | 76 } |
| 77 enum Wrapped { kWrapped }; |
| 78 GrVkTextureRenderTarget(GrVkGpu* gpu, |
| 79 Wrapped, |
| 80 const GrSurfaceDesc& desc, |
| 81 const GrVkImage::Resource* imageResource, |
| 82 const GrVkImageView* texView, |
| 83 const GrVkImage::Resource* msaaResource, |
| 84 const GrVkImageView* colorAttachmentView, |
| 85 const GrVkImageView* resolveAttachmentView) |
| 86 : GrSurface(gpu, desc) |
| 87 , GrVkImage(imageResource) |
| 88 , GrVkTexture(gpu, desc, imageResource, texView) |
| 89 , GrVkRenderTarget(gpu, desc, imageResource, msaaResource, colorAttachme
ntView, |
| 90 resolveAttachmentView) { |
| 91 this->registerWithCacheWrapped(); |
77 } | 92 } |
78 | 93 |
79 static GrVkTextureRenderTarget* Create(GrVkGpu*, const GrSurfaceDesc&, | 94 GrVkTextureRenderTarget(GrVkGpu* gpu, |
80 GrGpuResource::LifeCycle, | 95 Wrapped, |
81 VkFormat format, | 96 const GrSurfaceDesc& desc, |
| 97 const GrVkImage::Resource* imageResource, |
| 98 const GrVkImageView* texView, |
| 99 const GrVkImageView* colorAttachmentView) |
| 100 : GrSurface(gpu, desc) |
| 101 , GrVkImage(imageResource) |
| 102 , GrVkTexture(gpu, desc, imageResource, texView) |
| 103 , GrVkRenderTarget(gpu, desc, imageResource, colorAttachmentView) { |
| 104 this->registerWithCacheWrapped(); |
| 105 } |
| 106 |
| 107 template <typename ResourceType> |
| 108 static GrVkTextureRenderTarget* Create(GrVkGpu*, |
| 109 ResourceType, |
| 110 const GrSurfaceDesc&, |
| 111 VkFormat, |
82 const GrVkImage::Resource* imageResou
rce); | 112 const GrVkImage::Resource* imageResou
rce); |
83 | 113 |
84 // GrGLRenderTarget accounts for the texture's memory and any MSAA renderbuf
fer's memory. | 114 // GrGLRenderTarget accounts for the texture's memory and any MSAA renderbuf
fer's memory. |
85 size_t onGpuMemorySize() const override { | 115 size_t onGpuMemorySize() const override { |
86 return GrVkRenderTarget::onGpuMemorySize(); | 116 return GrVkRenderTarget::onGpuMemorySize(); |
87 } | 117 } |
88 }; | 118 }; |
89 | 119 |
90 #endif | 120 #endif |
OLD | NEW |