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 #include "Test.h" | 8 #include "Test.h" |
9 #if SK_SUPPORT_GPU | 9 #if SK_SUPPORT_GPU |
10 #include "GrCaps.h" | 10 #include "GrCaps.h" |
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
154 } | 154 } |
155 } | 155 } |
156 | 156 |
157 GrSurfaceDesc desc; | 157 GrSurfaceDesc desc; |
158 desc.fFlags = kRenderTarget_GrSurfaceFlag; | 158 desc.fFlags = kRenderTarget_GrSurfaceFlag; |
159 desc.fWidth = kW; | 159 desc.fWidth = kW; |
160 desc.fHeight = kH; | 160 desc.fHeight = kH; |
161 desc.fConfig = kSRGBA_8888_GrPixelConfig; | 161 desc.fConfig = kSRGBA_8888_GrPixelConfig; |
162 if (context->caps()->isConfigRenderable(desc.fConfig, false) && | 162 if (context->caps()->isConfigRenderable(desc.fConfig, false) && |
163 context->caps()->isConfigTexturable(desc.fConfig)) { | 163 context->caps()->isConfigTexturable(desc.fConfig)) { |
164 SkAutoTUnref<GrTexture> tex(context->textureProvider()->createTexture( | 164 SkAutoTUnref<GrTexture> tex(context->textureProvider()->createTexture(de
sc, false)); |
165 desc, SkBudgeted::kNo)); | |
166 if (!tex) { | 165 if (!tex) { |
167 ERRORF(reporter, "Could not create SRGBA texture."); | 166 ERRORF(reporter, "Could not create SRGBA texture."); |
168 return; | 167 return; |
169 } | 168 } |
170 | 169 |
171 float error = context->caps()->shaderCaps()->floatPrecisionVaries() ? 1.
2f : 0.5f; | 170 float error = context->caps()->shaderCaps()->floatPrecisionVaries() ? 1.
2f : 0.5f; |
172 | 171 |
173 // Write srgba data and read as srgba and then as rgba | 172 // Write srgba data and read as srgba and then as rgba |
174 if (tex->writePixels(0, 0, kW, kH, kSRGBA_8888_GrPixelConfig, origData))
{ | 173 if (tex->writePixels(0, 0, kW, kH, kSRGBA_8888_GrPixelConfig, origData))
{ |
175 // For the all-srgba case, we allow a small error only for devices t
hat have | 174 // For the all-srgba case, we allow a small error only for devices t
hat have |
(...skipping 18 matching lines...) Expand all Loading... |
194 check_linear_to_srgb_conversion, error, | 193 check_linear_to_srgb_conversion, error, |
195 "write rgba/read srgba with srgba texture"); | 194 "write rgba/read srgba with srgba texture"); |
196 read_and_check_pixels(reporter, tex, origData, kRGBA_8888_GrPixelCon
fig, | 195 read_and_check_pixels(reporter, tex, origData, kRGBA_8888_GrPixelCon
fig, |
197 check_linear_to_srgb_to_linear_conversion, err
or, | 196 check_linear_to_srgb_to_linear_conversion, err
or, |
198 "write/read rgba with srgba texture"); | 197 "write/read rgba with srgba texture"); |
199 } else { | 198 } else { |
200 ERRORF(reporter, "Could not write rgba data to srgba texture."); | 199 ERRORF(reporter, "Could not write rgba data to srgba texture."); |
201 } | 200 } |
202 | 201 |
203 desc.fConfig = kRGBA_8888_GrPixelConfig; | 202 desc.fConfig = kRGBA_8888_GrPixelConfig; |
204 tex.reset(context->textureProvider()->createTexture(desc, SkBudgeted::kN
o)); | 203 tex.reset(context->textureProvider()->createTexture(desc, false)); |
205 if (!tex) { | 204 if (!tex) { |
206 ERRORF(reporter, "Could not create RGBA texture."); | 205 ERRORF(reporter, "Could not create RGBA texture."); |
207 return; | 206 return; |
208 } | 207 } |
209 | 208 |
210 // Write srgba data to a rgba texture and read back as srgba and rgba | 209 // Write srgba data to a rgba texture and read back as srgba and rgba |
211 if (tex->writePixels(0, 0, kW, kH, kSRGBA_8888_GrPixelConfig, origData))
{ | 210 if (tex->writePixels(0, 0, kW, kH, kSRGBA_8888_GrPixelConfig, origData))
{ |
212 read_and_check_pixels(reporter, tex, origData, kSRGBA_8888_GrPixelCo
nfig, | 211 read_and_check_pixels(reporter, tex, origData, kSRGBA_8888_GrPixelCo
nfig, |
213 check_srgb_to_linear_to_srgb_conversion, error
, | 212 check_srgb_to_linear_to_srgb_conversion, error
, |
214 "write/read srgba to rgba texture"); | 213 "write/read srgba to rgba texture"); |
215 read_and_check_pixels(reporter, tex, origData, kRGBA_8888_GrPixelCon
fig, | 214 read_and_check_pixels(reporter, tex, origData, kRGBA_8888_GrPixelCon
fig, |
216 check_srgb_to_linear_conversion, error, | 215 check_srgb_to_linear_conversion, error, |
217 "write srgba/read rgba to rgba texture"); | 216 "write srgba/read rgba to rgba texture"); |
218 } else { | 217 } else { |
219 ERRORF(reporter, "Could not write srgba data to rgba texture."); | 218 ERRORF(reporter, "Could not write srgba data to rgba texture."); |
220 } | 219 } |
221 | 220 |
222 // Write rgba data to a rgba texture and read back as srgba | 221 // Write rgba data to a rgba texture and read back as srgba |
223 if (tex->writePixels(0, 0, kW, kH, kRGBA_8888_GrPixelConfig, origData))
{ | 222 if (tex->writePixels(0, 0, kW, kH, kRGBA_8888_GrPixelConfig, origData))
{ |
224 read_and_check_pixels(reporter, tex, origData, kSRGBA_8888_GrPixelCo
nfig, | 223 read_and_check_pixels(reporter, tex, origData, kSRGBA_8888_GrPixelCo
nfig, |
225 check_linear_to_srgb_conversion, 1.2f, | 224 check_linear_to_srgb_conversion, 1.2f, |
226 "write rgba/read srgba to rgba texture"); | 225 "write rgba/read srgba to rgba texture"); |
227 } else { | 226 } else { |
228 ERRORF(reporter, "Could not write rgba data to rgba texture."); | 227 ERRORF(reporter, "Could not write rgba data to rgba texture."); |
229 } | 228 } |
230 } | 229 } |
231 } | 230 } |
232 #endif | 231 #endif |
OLD | NEW |