OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2016 Google Inc. | 2 * Copyright 2016 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 // This is a GPU-backend specific test. | 8 // This is a GPU-backend specific test. |
9 | 9 |
10 #include "Test.h" | 10 #include "Test.h" |
11 | 11 |
12 #if SK_SUPPORT_GPU | 12 #if SK_SUPPORT_GPU |
| 13 #include "GrGpu.h" |
13 #include "GrSurfaceProxy.h" | 14 #include "GrSurfaceProxy.h" |
14 #include "GrTextureProxy.h" | 15 #include "GrTextureProxy.h" |
15 #include "GrRenderTargetProxy.h" | 16 #include "GrRenderTargetProxy.h" |
16 | 17 |
17 static void check_surface(skiatest::Reporter* reporter, | 18 static void check_surface(skiatest::Reporter* reporter, |
18 GrSurfaceProxy* proxy, | 19 GrSurfaceProxy* proxy, |
19 GrSurfaceOrigin origin, | 20 GrSurfaceOrigin origin, |
20 int width, int height, | 21 int width, int height, |
21 GrPixelConfig config) { | 22 GrPixelConfig config) { |
22 REPORTER_ASSERT(reporter, proxy->origin() == origin); | 23 REPORTER_ASSERT(reporter, proxy->origin() == origin); |
(...skipping 20 matching lines...) Expand all Loading... |
43 REPORTER_ASSERT(reporter, rt->width() >= rtProxy->width()); | 44 REPORTER_ASSERT(reporter, rt->width() >= rtProxy->width()); |
44 REPORTER_ASSERT(reporter, rt->height() >= rtProxy->height()); | 45 REPORTER_ASSERT(reporter, rt->height() >= rtProxy->height()); |
45 } | 46 } |
46 REPORTER_ASSERT(reporter, rt->config() == rtProxy->config()); | 47 REPORTER_ASSERT(reporter, rt->config() == rtProxy->config()); |
47 | 48 |
48 REPORTER_ASSERT(reporter, rt->isUnifiedMultisampled() == rtProxy->isUnifiedM
ultisampled()); | 49 REPORTER_ASSERT(reporter, rt->isUnifiedMultisampled() == rtProxy->isUnifiedM
ultisampled()); |
49 REPORTER_ASSERT(reporter, rt->isStencilBufferMultisampled() == | 50 REPORTER_ASSERT(reporter, rt->isStencilBufferMultisampled() == |
50 rtProxy->isStencilBufferMultisampled()); | 51 rtProxy->isStencilBufferMultisampled()); |
51 REPORTER_ASSERT(reporter, rt->numColorSamples() == rtProxy->numColorSamples(
)); | 52 REPORTER_ASSERT(reporter, rt->numColorSamples() == rtProxy->numColorSamples(
)); |
52 REPORTER_ASSERT(reporter, rt->numStencilSamples() == rtProxy->numStencilSamp
les()); | 53 REPORTER_ASSERT(reporter, rt->numStencilSamples() == rtProxy->numStencilSamp
les()); |
53 REPORTER_ASSERT(reporter, rt->hasMixedSamples() == rtProxy->hasMixedSamples(
)); | 54 REPORTER_ASSERT(reporter, rt->isMixedSampled() == rtProxy->isMixedSampled())
; |
| 55 REPORTER_ASSERT(reporter, rt->renderTargetPriv().flags() == rtProxy->testing
Only_getFlags()); |
54 } | 56 } |
55 | 57 |
56 static void check_texture(skiatest::Reporter* reporter, | 58 static void check_texture(skiatest::Reporter* reporter, |
57 GrTextureProvider* provider, | 59 GrTextureProvider* provider, |
58 GrTextureProxy* texProxy, | 60 GrTextureProxy* texProxy, |
59 SkBackingFit fit) { | 61 SkBackingFit fit) { |
60 REPORTER_ASSERT(reporter, texProxy->asTextureProxy() == texProxy); | 62 REPORTER_ASSERT(reporter, texProxy->asTextureProxy() == texProxy); |
61 REPORTER_ASSERT(reporter, texProxy->asRenderTargetProxy() == nullptr); // fo
r now | 63 REPORTER_ASSERT(reporter, texProxy->asRenderTargetProxy() == nullptr); // fo
r now |
62 | 64 |
63 GrTexture* tex = texProxy->instantiate(provider); | 65 GrTexture* tex = texProxy->instantiate(provider); |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
117 } | 119 } |
118 } | 120 } |
119 } | 121 } |
120 } | 122 } |
121 } | 123 } |
122 } | 124 } |
123 } | 125 } |
124 | 126 |
125 DEF_GPUTEST_FOR_RENDERING_CONTEXTS(WrappedProxyTest, reporter, ctxInfo) { | 127 DEF_GPUTEST_FOR_RENDERING_CONTEXTS(WrappedProxyTest, reporter, ctxInfo) { |
126 GrTextureProvider* provider = ctxInfo.grContext()->textureProvider(); | 128 GrTextureProvider* provider = ctxInfo.grContext()->textureProvider(); |
| 129 const GrCaps& caps = *ctxInfo.grContext()->caps(); |
127 | 130 |
128 static const int kWidthHeight = 100; | 131 static const int kWidthHeight = 100; |
129 | 132 |
130 for (auto origin : { kBottomLeft_GrSurfaceOrigin, kTopLeft_GrSurfaceOrigin }
) { | 133 for (auto origin : { kBottomLeft_GrSurfaceOrigin, kTopLeft_GrSurfaceOrigin }
) { |
131 for (auto config : { kAlpha_8_GrPixelConfig, kRGBA_8888_GrPixelConfig })
{ | 134 for (auto config : { kAlpha_8_GrPixelConfig, kRGBA_8888_GrPixelConfig })
{ |
132 for (auto budgeted : { SkBudgeted::kYes, SkBudgeted::kNo }) { | 135 for (auto budgeted : { SkBudgeted::kYes, SkBudgeted::kNo }) { |
133 for (auto numSamples: { 0, 4}) { | 136 for (auto numSamples: { 0, 4}) { |
134 bool renderable = ctxInfo.grContext()->caps()->isConfigRende
rable( | 137 bool renderable = caps.isConfigRenderable(config, numSamples
> 0); |
135 config, numSampl
es > 0); | |
136 | 138 |
137 GrSurfaceDesc desc; | 139 GrSurfaceDesc desc; |
138 desc.fOrigin = origin; | 140 desc.fOrigin = origin; |
139 desc.fWidth = kWidthHeight; | 141 desc.fWidth = kWidthHeight; |
140 desc.fHeight = kWidthHeight; | 142 desc.fHeight = kWidthHeight; |
141 desc.fConfig = config; | 143 desc.fConfig = config; |
142 desc.fSampleCnt = numSamples; | 144 desc.fSampleCnt = numSamples; |
143 | 145 |
| 146 // External on-screen render target. |
| 147 if (renderable && kOpenGL_GrBackend == ctxInfo.backend()) { |
| 148 GrBackendRenderTargetDesc backendDesc; |
| 149 backendDesc.fWidth = kWidthHeight; |
| 150 backendDesc.fHeight = kWidthHeight; |
| 151 backendDesc.fConfig = config; |
| 152 backendDesc.fOrigin = origin; |
| 153 backendDesc.fSampleCnt = numSamples; |
| 154 backendDesc.fStencilBits = 8; |
| 155 backendDesc.fRenderTargetHandle = 0; |
| 156 |
| 157 GrGpu* gpu = ctxInfo.grContext()->getGpu(); |
| 158 sk_sp<GrRenderTarget> defaultFBO( |
| 159 gpu->wrapBackendRenderTarget(backendDesc, kBorrow_Gr
WrapOwnership)); |
| 160 SkASSERT(!defaultFBO->renderTargetPriv().supportsWindowR
ectangles()); |
| 161 |
| 162 sk_sp<GrRenderTargetProxy> rtProxy( |
| 163 GrRenderTargetProxy::Make(caps, defaultFBO)); |
| 164 check_surface(reporter, rtProxy.get(), origin, |
| 165 kWidthHeight, kWidthHeight, config); |
| 166 check_rendertarget(reporter, provider, rtProxy.get(), Sk
BackingFit::kExact); |
| 167 } |
| 168 |
144 sk_sp<GrTexture> tex; | 169 sk_sp<GrTexture> tex; |
145 | 170 |
| 171 // Internal offscreen render target. |
146 if (renderable) { | 172 if (renderable) { |
147 desc.fFlags = kRenderTarget_GrSurfaceFlag; | 173 desc.fFlags = kRenderTarget_GrSurfaceFlag; |
148 tex.reset(provider->createTexture(desc, budgeted)); | 174 tex.reset(provider->createTexture(desc, budgeted)); |
149 sk_sp<GrRenderTarget> rt(sk_ref_sp(tex->asRenderTarget()
)); | 175 sk_sp<GrRenderTarget> rt(sk_ref_sp(tex->asRenderTarget()
)); |
| 176 SkASSERT(caps.maxWindowRectangles() <= 0 || |
| 177 rt->renderTargetPriv().supportsWindowRectangles(
)); |
150 | 178 |
151 sk_sp<GrRenderTargetProxy> rtProxy(GrRenderTargetProxy::
Make(rt)); | 179 sk_sp<GrRenderTargetProxy> rtProxy(GrRenderTargetProxy::
Make(caps, rt)); |
152 check_surface(reporter, rtProxy.get(), origin, | 180 check_surface(reporter, rtProxy.get(), origin, |
153 kWidthHeight, kWidthHeight, config); | 181 kWidthHeight, kWidthHeight, config); |
154 check_rendertarget(reporter, provider, rtProxy.get(), Sk
BackingFit::kExact); | 182 check_rendertarget(reporter, provider, rtProxy.get(), Sk
BackingFit::kExact); |
155 } | 183 } |
156 | 184 |
157 if (!tex) { | 185 if (!tex) { |
158 SkASSERT(kNone_GrSurfaceFlags == desc.fFlags ); | 186 SkASSERT(kNone_GrSurfaceFlags == desc.fFlags ); |
159 desc.fSampleCnt = 0; | 187 desc.fSampleCnt = 0; |
160 tex.reset(provider->createTexture(desc, budgeted)); | 188 tex.reset(provider->createTexture(desc, budgeted)); |
161 } | 189 } |
162 | 190 |
163 sk_sp<GrTextureProxy> texProxy(GrTextureProxy::Make(tex)); | 191 sk_sp<GrTextureProxy> texProxy(GrTextureProxy::Make(tex)); |
164 check_surface(reporter, texProxy.get(), origin, | 192 check_surface(reporter, texProxy.get(), origin, |
165 kWidthHeight, kWidthHeight, config); | 193 kWidthHeight, kWidthHeight, config); |
166 check_texture(reporter, provider, texProxy.get(), SkBackingF
it::kExact); | 194 check_texture(reporter, provider, texProxy.get(), SkBackingF
it::kExact); |
167 } | 195 } |
168 } | 196 } |
169 } | 197 } |
170 } | 198 } |
171 } | 199 } |
172 | 200 |
173 #endif | 201 #endif |
OLD | NEW |