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