Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1206)

Side by Side Diff: tests/ProxyTest.cpp

Issue 2301523003: Have GrSurfaceProxys and GrGpuResources draw from the same pool of unique ids (Closed)
Patch Set: update to ToT Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « tests/ClearTest.cpp ('k') | tests/ResourceCacheTest.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "GrGpu.h"
14 #include "GrSurfaceProxy.h" 14 #include "GrSurfaceProxy.h"
15 #include "GrTextureProxy.h" 15 #include "GrTextureProxy.h"
16 #include "GrRenderTargetProxy.h" 16 #include "GrRenderTargetProxy.h"
17 17
18 // Check that the surface proxy's member vars are set as expected
18 static void check_surface(skiatest::Reporter* reporter, 19 static void check_surface(skiatest::Reporter* reporter,
19 GrSurfaceProxy* proxy, 20 GrSurfaceProxy* proxy,
20 GrSurfaceOrigin origin, 21 GrSurfaceOrigin origin,
21 int width, int height, 22 int width, int height,
22 GrPixelConfig config) { 23 GrPixelConfig config,
24 uint32_t uniqueID) {
23 REPORTER_ASSERT(reporter, proxy->origin() == origin); 25 REPORTER_ASSERT(reporter, proxy->origin() == origin);
24 REPORTER_ASSERT(reporter, proxy->width() == width); 26 REPORTER_ASSERT(reporter, proxy->width() == width);
25 REPORTER_ASSERT(reporter, proxy->height() == height); 27 REPORTER_ASSERT(reporter, proxy->height() == height);
26 REPORTER_ASSERT(reporter, proxy->config() == config); 28 REPORTER_ASSERT(reporter, proxy->config() == config);
29 if (SK_InvalidUniqueID != uniqueID) {
30 REPORTER_ASSERT(reporter, proxy->uniqueID() == uniqueID);
31 }
27 } 32 }
28 33
29 static void check_rendertarget(skiatest::Reporter* reporter, 34 static void check_rendertarget(skiatest::Reporter* reporter,
30 GrTextureProvider* provider, 35 GrTextureProvider* provider,
31 GrRenderTargetProxy* rtProxy, 36 GrRenderTargetProxy* rtProxy,
32 SkBackingFit fit) { 37 SkBackingFit fit) {
33 REPORTER_ASSERT(reporter, rtProxy->asTextureProxy() == nullptr); // for now 38 REPORTER_ASSERT(reporter, rtProxy->asTextureProxy() == nullptr); // for now
34 REPORTER_ASSERT(reporter, rtProxy->asRenderTargetProxy() == rtProxy); 39 REPORTER_ASSERT(reporter, rtProxy->asRenderTargetProxy() == rtProxy);
35 40
36 GrRenderTarget* rt = rtProxy->instantiate(provider); 41 GrRenderTarget* rt = rtProxy->instantiate(provider);
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
70 REPORTER_ASSERT(reporter, tex->width() == texProxy->width()); 75 REPORTER_ASSERT(reporter, tex->width() == texProxy->width());
71 REPORTER_ASSERT(reporter, tex->height() == texProxy->height()); 76 REPORTER_ASSERT(reporter, tex->height() == texProxy->height());
72 } else { 77 } else {
73 REPORTER_ASSERT(reporter, tex->width() >= texProxy->width()); 78 REPORTER_ASSERT(reporter, tex->width() >= texProxy->width());
74 REPORTER_ASSERT(reporter, tex->height() >= texProxy->height()); 79 REPORTER_ASSERT(reporter, tex->height() >= texProxy->height());
75 } 80 }
76 REPORTER_ASSERT(reporter, tex->config() == texProxy->config()); 81 REPORTER_ASSERT(reporter, tex->config() == texProxy->config());
77 } 82 }
78 83
79 84
80 DEF_GPUTEST_FOR_RENDERING_CONTEXTS(AllocedProxyTest, reporter, ctxInfo) { 85 DEF_GPUTEST_FOR_RENDERING_CONTEXTS(DeferredProxyTest, reporter, ctxInfo) {
81 GrTextureProvider* provider = ctxInfo.grContext()->textureProvider(); 86 GrTextureProvider* provider = ctxInfo.grContext()->textureProvider();
82 87
83 for (auto origin : { kBottomLeft_GrSurfaceOrigin, kTopLeft_GrSurfaceOrigin } ) { 88 for (auto origin : { kBottomLeft_GrSurfaceOrigin, kTopLeft_GrSurfaceOrigin } ) {
84 for (auto widthHeight : { 100, 128 }) { 89 for (auto widthHeight : { 100, 128 }) {
85 for (auto config : { kAlpha_8_GrPixelConfig, kRGBA_8888_GrPixelConfi g }) { 90 for (auto config : { kAlpha_8_GrPixelConfig, kRGBA_8888_GrPixelConfi g }) {
86 for (auto fit : { SkBackingFit::kExact, SkBackingFit::kApprox }) { 91 for (auto fit : { SkBackingFit::kExact, SkBackingFit::kApprox }) {
87 for (auto budgeted : { SkBudgeted::kYes, SkBudgeted::kNo }) { 92 for (auto budgeted : { SkBudgeted::kYes, SkBudgeted::kNo }) {
88 for (auto numSamples : { 0, 4}) { 93 for (auto numSamples : { 0, 4}) {
89 bool renderable = ctxInfo.grContext()->caps()->isCon figRenderable( 94 bool renderable = ctxInfo.grContext()->caps()->isCon figRenderable(
90 config, nu mSamples > 0) && 95 config, nu mSamples > 0) &&
91 numSamples <= ctxInfo.grContext()->caps()->max ColorSampleCount(); 96 numSamples <= ctxInfo.grContext()->caps()->max ColorSampleCount();
92 97
93 GrSurfaceDesc desc; 98 GrSurfaceDesc desc;
94 desc.fOrigin = origin; 99 desc.fOrigin = origin;
95 desc.fWidth = widthHeight; 100 desc.fWidth = widthHeight;
96 desc.fHeight = widthHeight; 101 desc.fHeight = widthHeight;
97 desc.fConfig = config; 102 desc.fConfig = config;
98 desc.fSampleCnt = numSamples; 103 desc.fSampleCnt = numSamples;
99 104
100 if (renderable) { 105 if (renderable) {
101 sk_sp<GrRenderTargetProxy> rtProxy(GrRenderTarge tProxy::Make( 106 sk_sp<GrRenderTargetProxy> rtProxy(GrRenderTarge tProxy::Make(
102 *ctxInfo.grC ontext()->caps(), 107 *ctxInfo.grC ontext()->caps(),
103 desc, 108 desc,
104 fit, 109 fit,
105 budgeted)); 110 budgeted));
106 check_surface(reporter, rtProxy.get(), origin, 111 check_surface(reporter, rtProxy.get(), origin,
107 widthHeight, widthHeight, config); 112 widthHeight, widthHeight, config, SK_InvalidUniqueID);
108 check_rendertarget(reporter, provider, rtProxy.g et(), fit); 113 check_rendertarget(reporter, provider, rtProxy.g et(), fit);
109 } 114 }
110 115
111 desc.fSampleCnt = 0; 116 desc.fSampleCnt = 0;
112 117
113 sk_sp<GrTextureProxy> texProxy(GrTextureProxy::Make( desc, 118 sk_sp<GrTextureProxy> texProxy(GrTextureProxy::Make( desc,
114 fit, 119 fit,
115 budgeted)); 120 budgeted));
116 check_surface(reporter, texProxy.get(), origin, 121 check_surface(reporter, texProxy.get(), origin,
117 widthHeight, widthHeight, config); 122 widthHeight, widthHeight, config, SK_I nvalidUniqueID);
118 check_texture(reporter, provider, texProxy.get(), fi t); 123 check_texture(reporter, provider, texProxy.get(), fi t);
119 } 124 }
120 } 125 }
121 } 126 }
122 } 127 }
123 } 128 }
124 } 129 }
125 } 130 }
126 131
127 DEF_GPUTEST_FOR_RENDERING_CONTEXTS(WrappedProxyTest, reporter, ctxInfo) { 132 DEF_GPUTEST_FOR_RENDERING_CONTEXTS(WrappedProxyTest, reporter, ctxInfo) {
(...skipping 27 matching lines...) Expand all
155 backendDesc.fRenderTargetHandle = 0; 160 backendDesc.fRenderTargetHandle = 0;
156 161
157 GrGpu* gpu = ctxInfo.grContext()->getGpu(); 162 GrGpu* gpu = ctxInfo.grContext()->getGpu();
158 sk_sp<GrRenderTarget> defaultFBO( 163 sk_sp<GrRenderTarget> defaultFBO(
159 gpu->wrapBackendRenderTarget(backendDesc, kBorrow_Gr WrapOwnership)); 164 gpu->wrapBackendRenderTarget(backendDesc, kBorrow_Gr WrapOwnership));
160 SkASSERT(!defaultFBO->renderTargetPriv().supportsWindowR ectangles()); 165 SkASSERT(!defaultFBO->renderTargetPriv().supportsWindowR ectangles());
161 166
162 sk_sp<GrRenderTargetProxy> rtProxy( 167 sk_sp<GrRenderTargetProxy> rtProxy(
163 GrRenderTargetProxy::Make(caps, defaultFBO)); 168 GrRenderTargetProxy::Make(caps, defaultFBO));
164 check_surface(reporter, rtProxy.get(), origin, 169 check_surface(reporter, rtProxy.get(), origin,
165 kWidthHeight, kWidthHeight, config); 170 kWidthHeight, kWidthHeight, config, defaul tFBO->uniqueID());
166 check_rendertarget(reporter, provider, rtProxy.get(), Sk BackingFit::kExact); 171 check_rendertarget(reporter, provider, rtProxy.get(), Sk BackingFit::kExact);
167 } 172 }
168 173
169 sk_sp<GrTexture> tex; 174 sk_sp<GrTexture> tex;
170 175
171 // Internal offscreen render target. 176 // Internal offscreen render target.
172 if (renderable) { 177 if (renderable) {
173 desc.fFlags = kRenderTarget_GrSurfaceFlag; 178 desc.fFlags = kRenderTarget_GrSurfaceFlag;
174 tex.reset(provider->createTexture(desc, budgeted)); 179 tex.reset(provider->createTexture(desc, budgeted));
175 sk_sp<GrRenderTarget> rt(sk_ref_sp(tex->asRenderTarget() )); 180 sk_sp<GrRenderTarget> rt(sk_ref_sp(tex->asRenderTarget() ));
176 SkASSERT(caps.maxWindowRectangles() <= 0 || 181 SkASSERT(caps.maxWindowRectangles() <= 0 ||
177 rt->renderTargetPriv().supportsWindowRectangles( )); 182 rt->renderTargetPriv().supportsWindowRectangles( ));
178 183
179 sk_sp<GrRenderTargetProxy> rtProxy(GrRenderTargetProxy:: Make(caps, rt)); 184 sk_sp<GrRenderTargetProxy> rtProxy(GrRenderTargetProxy:: Make(caps, rt));
180 check_surface(reporter, rtProxy.get(), origin, 185 check_surface(reporter, rtProxy.get(), origin,
181 kWidthHeight, kWidthHeight, config); 186 kWidthHeight, kWidthHeight, config, rt->un iqueID());
182 check_rendertarget(reporter, provider, rtProxy.get(), Sk BackingFit::kExact); 187 check_rendertarget(reporter, provider, rtProxy.get(), Sk BackingFit::kExact);
183 } 188 }
184 189
185 if (!tex) { 190 if (!tex) {
186 SkASSERT(kNone_GrSurfaceFlags == desc.fFlags ); 191 SkASSERT(kNone_GrSurfaceFlags == desc.fFlags );
187 desc.fSampleCnt = 0; 192 desc.fSampleCnt = 0;
188 tex.reset(provider->createTexture(desc, budgeted)); 193 tex.reset(provider->createTexture(desc, budgeted));
189 } 194 }
190 195
191 sk_sp<GrTextureProxy> texProxy(GrTextureProxy::Make(tex)); 196 sk_sp<GrTextureProxy> texProxy(GrTextureProxy::Make(tex));
192 check_surface(reporter, texProxy.get(), origin, 197 check_surface(reporter, texProxy.get(), origin,
193 kWidthHeight, kWidthHeight, config); 198 kWidthHeight, kWidthHeight, config, tex->uniqu eID());
194 check_texture(reporter, provider, texProxy.get(), SkBackingF it::kExact); 199 check_texture(reporter, provider, texProxy.get(), SkBackingF it::kExact);
195 } 200 }
196 } 201 }
197 } 202 }
198 } 203 }
199 } 204 }
200 205
201 #endif 206 #endif
OLDNEW
« no previous file with comments | « tests/ClearTest.cpp ('k') | tests/ResourceCacheTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698