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->isOffscreen() == rtProxy->isOffscreen()); | |
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 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
134 bool renderable = ctxInfo.grContext()->caps()->isConfigRende rable( | 136 bool renderable = ctxInfo.grContext()->caps()->isConfigRende rable( |
135 config, numSampl es > 0); | 137 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; | |
csmartdalton
2016/08/09 06:52:58
Would this also work for vulkan?
| |
156 | |
157 GrGpu* gpu = ctxInfo.grContext()->getGpu(); | |
158 sk_sp<GrRenderTarget> defaultFBO( | |
159 gpu->wrapBackendRenderTarget(backendDesc, kBorrow_Gr WrapOwnership)); | |
160 SkASSERT(!defaultFBO->isOffscreen()); | |
161 | |
162 sk_sp<GrRenderTargetProxy> rtProxy( | |
163 GrRenderTargetProxy::Make(*ctxInfo.grContext()->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(rt->isOffscreen()); | |
150 | 177 |
151 sk_sp<GrRenderTargetProxy> rtProxy(GrRenderTargetProxy:: Make(rt)); | 178 sk_sp<GrRenderTargetProxy> rtProxy( |
179 GrRenderTargetProxy::Make(*ctxInfo.grContext()->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 |