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

Side by Side Diff: tests/ProxyTest.cpp

Issue 1937553002: Add Gr*Proxy classes (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Fix memory bugs Created 4 years, 7 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/PrimitiveProcessorTest.cpp ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 /*
2 * Copyright 2016 Google Inc.
3 *
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
6 */
7
8 // This is a GPU-backend specific test.
9
10 #include "Test.h"
11
12 #if SK_SUPPORT_GPU
13 #include "GrSurfaceProxy.h"
14 #include "GrTextureProxy.h"
15 #include "GrRenderTargetProxy.h"
16
17 static void check_surface(skiatest::Reporter* reporter,
18 GrSurfaceProxy* proxy,
19 GrSurfaceOrigin origin,
20 int width, int height,
21 GrPixelConfig config) {
22 REPORTER_ASSERT(reporter, proxy->origin() == origin);
23 REPORTER_ASSERT(reporter, proxy->width() == width);
24 REPORTER_ASSERT(reporter, proxy->height() == height);
25 REPORTER_ASSERT(reporter, proxy->config() == config);
26 }
27
28 static void check_rendertarget(skiatest::Reporter* reporter,
29 GrTextureProvider* provider,
30 GrRenderTargetProxy* rtProxy,
31 SkBackingFit fit) {
32 REPORTER_ASSERT(reporter, rtProxy->asTextureProxy() == nullptr); // for now
33 REPORTER_ASSERT(reporter, rtProxy->asRenderTargetProxy() == rtProxy);
34
35 GrRenderTarget* rt = rtProxy->instantiate(provider);
36 REPORTER_ASSERT(reporter, rt);
37
38 REPORTER_ASSERT(reporter, rt->origin() == rtProxy->origin());
39 if (SkBackingFit::kExact == fit) {
40 REPORTER_ASSERT(reporter, rt->width() == rtProxy->width());
41 REPORTER_ASSERT(reporter, rt->height() == rtProxy->height());
42 } else {
43 REPORTER_ASSERT(reporter, rt->width() >= rtProxy->width());
44 REPORTER_ASSERT(reporter, rt->height() >= rtProxy->height());
45 }
46 REPORTER_ASSERT(reporter, rt->config() == rtProxy->config());
47
48 REPORTER_ASSERT(reporter, rt->isUnifiedMultisampled() == rtProxy->isUnifiedM ultisampled());
49 REPORTER_ASSERT(reporter, rt->isStencilBufferMultisampled() ==
50 rtProxy->isStencilBufferMultisampled());
51 REPORTER_ASSERT(reporter, rt->numColorSamples() == rtProxy->numColorSamples( ));
52 REPORTER_ASSERT(reporter, rt->numStencilSamples() == rtProxy->numStencilSamp les());
53 REPORTER_ASSERT(reporter, rt->hasMixedSamples() == rtProxy->hasMixedSamples( ));
54 }
55
56 static void check_texture(skiatest::Reporter* reporter,
57 GrTextureProvider* provider,
58 GrTextureProxy* texProxy,
59 SkBackingFit fit) {
60 REPORTER_ASSERT(reporter, texProxy->asTextureProxy() == texProxy);
61 REPORTER_ASSERT(reporter, texProxy->asRenderTargetProxy() == nullptr); // fo r now
62
63 GrTexture* tex = texProxy->instantiate(provider);
64 REPORTER_ASSERT(reporter, tex);
65
66 REPORTER_ASSERT(reporter, tex->origin() == texProxy->origin());
67 if (SkBackingFit::kExact == fit) {
68 REPORTER_ASSERT(reporter, tex->width() == texProxy->width());
69 REPORTER_ASSERT(reporter, tex->height() == texProxy->height());
70 } else {
71 REPORTER_ASSERT(reporter, tex->width() >= texProxy->width());
72 REPORTER_ASSERT(reporter, tex->height() >= texProxy->height());
73 }
74 REPORTER_ASSERT(reporter, tex->config() == texProxy->config());
75 }
76
77
78 DEF_GPUTEST_FOR_GL_RENDERING_CONTEXTS(AllocedProxyTest, reporter, ctxInfo) {
79 GrTextureProvider* provider = ctxInfo.fGrContext->textureProvider();
80
81 for (auto origin : { kBottomLeft_GrSurfaceOrigin, kTopLeft_GrSurfaceOrigin } ) {
82 for (auto widthHeight : { 100, 128 }) {
83 for (auto config : { kAlpha_8_GrPixelConfig, kRGBA_8888_GrPixelConfi g }) {
84 for (auto fit : { SkBackingFit::kExact, SkBackingFit::kApprox }) {
85 for (auto budgeted : { SkBudgeted::kYes, SkBudgeted::kNo }) {
86 for (auto numSamples : { 0, 4}) {
87 bool renderable = ctxInfo.fGrContext->caps()->isConf igRenderable(
88 config, nu mSamples > 0);
89
90 GrSurfaceDesc desc;
91 desc.fOrigin = origin;
92 desc.fWidth = widthHeight;
93 desc.fHeight = widthHeight;
94 desc.fConfig = config;
95 desc.fSampleCnt = numSamples;
96
97 if (renderable) {
98 sk_sp<GrRenderTargetProxy> rtProxy(GrRenderTarge tProxy::Make(
99 *ctxInfo.fGr Context->caps(),
100 desc,
101 fit,
102 budgeted));
103 check_surface(reporter, rtProxy.get(), origin,
104 widthHeight, widthHeight, config);
105 check_rendertarget(reporter, provider, rtProxy.g et(), fit);
106 }
107
108 desc.fSampleCnt = 0;
109
110 sk_sp<GrTextureProxy> texProxy(GrTextureProxy::Make( desc,
111 fit,
112 budgeted));
113 check_surface(reporter, texProxy.get(), origin,
114 widthHeight, widthHeight, config);
115 check_texture(reporter, provider, texProxy.get(), fi t);
116 }
117 }
118 }
119 }
120 }
121 }
122 }
123
124 DEF_GPUTEST_FOR_GL_RENDERING_CONTEXTS(WrappedProxyTest, reporter, ctxInfo) {
125 GrTextureProvider* provider = ctxInfo.fGrContext->textureProvider();
126
127 static const int kWidthHeight = 100;
128
129 for (auto origin : { kBottomLeft_GrSurfaceOrigin, kTopLeft_GrSurfaceOrigin } ) {
130 for (auto config : { kAlpha_8_GrPixelConfig, kRGBA_8888_GrPixelConfig }) {
131 for (auto budgeted : { SkBudgeted::kYes, SkBudgeted::kNo }) {
132 for (auto numSamples: { 0, 4}) {
133 bool renderable = ctxInfo.fGrContext->caps()->isConfigRender able(
134 config, numSampl es > 0);
135
136 GrSurfaceDesc desc;
137 desc.fOrigin = origin;
138 desc.fWidth = kWidthHeight;
139 desc.fHeight = kWidthHeight;
140 desc.fConfig = config;
141 desc.fSampleCnt = numSamples;
142
143 sk_sp<GrTexture> tex;
144
145 if (renderable) {
146 desc.fFlags = kRenderTarget_GrSurfaceFlag;
147 tex.reset(provider->createTexture(desc, budgeted));
148 sk_sp<GrRenderTarget> rt(sk_ref_sp(tex->asRenderTarget() ));
149
150 sk_sp<GrRenderTargetProxy> rtProxy(GrRenderTargetProxy:: Make(rt));
151 check_surface(reporter, rtProxy.get(), origin,
152 kWidthHeight, kWidthHeight, config);
153 check_rendertarget(reporter, provider, rtProxy.get(), Sk BackingFit::kExact);
154 }
155
156 if (!tex) {
157 SkASSERT(kNone_GrSurfaceFlags == desc.fFlags );
158 desc.fSampleCnt = 0;
159 tex.reset(provider->createTexture(desc, budgeted));
160 }
161
162 sk_sp<GrTextureProxy> texProxy(GrTextureProxy::Make(tex));
163 check_surface(reporter, texProxy.get(), origin,
164 kWidthHeight, kWidthHeight, config);
165 check_texture(reporter, provider, texProxy.get(), SkBackingF it::kExact);
166 }
167 }
168 }
169 }
170 }
171
172 #endif
OLDNEW
« no previous file with comments | « tests/PrimitiveProcessorTest.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698