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 #include "SkAutoPixmapStorage.h" | 8 #include "SkAutoPixmapStorage.h" |
9 #include "SkBitmap.h" | 9 #include "SkBitmap.h" |
10 #include "SkCanvas.h" | 10 #include "SkCanvas.h" |
(...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
236 } | 236 } |
237 | 237 |
238 { | 238 { |
239 // gpu | 239 // gpu |
240 GrSurfaceDesc desc; | 240 GrSurfaceDesc desc; |
241 desc.fConfig = kSkia8888_GrPixelConfig; | 241 desc.fConfig = kSkia8888_GrPixelConfig; |
242 desc.fFlags = kNone_GrSurfaceFlags; | 242 desc.fFlags = kNone_GrSurfaceFlags; |
243 desc.fWidth = kFullSize; | 243 desc.fWidth = kFullSize; |
244 desc.fHeight = kFullSize; | 244 desc.fHeight = kFullSize; |
245 | 245 |
246 SkAutoTUnref<GrTexture> texture(context->textureProvider()->createTextur
e(desc, | 246 sk_sp<GrTexture> texture(context->textureProvider()->createTexture(desc, |
247
SkBudgeted::kNo, | 247 SkBud
geted::kNo, |
248
bm.getPixels(), | 248 bm.ge
tPixels(), |
249
0)); | 249 0)); |
250 if (!texture) { | 250 if (!texture) { |
251 return; | 251 return; |
252 } | 252 } |
253 | 253 |
254 sk_sp<SkSpecialImage> gpuImage(SkSpecialImage::MakeFromGpu( | 254 sk_sp<SkSpecialImage> gpuImage(SkSpecialImage::MakeFromGpu( |
255 SkIRect::MakeWH(
kFullSize, | 255 SkIRect::MakeWH(
kFullSize, |
256
kFullSize), | 256
kFullSize), |
257 kNeedNewImageUni
queID_SpecialImage, | 257 kNeedNewImageUni
queID_SpecialImage, |
258 texture)); | 258 std::move(textur
e))); |
259 | 259 |
260 { | 260 { |
261 sk_sp<SkSpecialImage> fromGPU(gpuImage->makeTextureImage(context)); | 261 sk_sp<SkSpecialImage> fromGPU(gpuImage->makeTextureImage(context)); |
262 test_texture_backed(reporter, gpuImage, fromGPU); | 262 test_texture_backed(reporter, gpuImage, fromGPU); |
263 } | 263 } |
264 | 264 |
265 { | 265 { |
266 sk_sp<SkSpecialImage> subGPUImage(gpuImage->makeSubset(subset)); | 266 sk_sp<SkSpecialImage> subGPUImage(gpuImage->makeSubset(subset)); |
267 | 267 |
268 sk_sp<SkSpecialImage> fromSubGPU(subGPUImage->makeTextureImage(conte
xt)); | 268 sk_sp<SkSpecialImage> fromSubGPU(subGPUImage->makeTextureImage(conte
xt)); |
269 test_texture_backed(reporter, subGPUImage, fromSubGPU); | 269 test_texture_backed(reporter, subGPUImage, fromSubGPU); |
270 } | 270 } |
271 } | 271 } |
272 } | 272 } |
273 | 273 |
274 DEF_GPUTEST_FOR_RENDERING_CONTEXTS(SpecialImage_Gpu, reporter, ctxInfo) { | 274 DEF_GPUTEST_FOR_RENDERING_CONTEXTS(SpecialImage_Gpu, reporter, ctxInfo) { |
275 GrContext* context = ctxInfo.fGrContext; | 275 GrContext* context = ctxInfo.fGrContext; |
276 SkBitmap bm = create_bm(); | 276 SkBitmap bm = create_bm(); |
277 | 277 |
278 GrSurfaceDesc desc; | 278 GrSurfaceDesc desc; |
279 desc.fConfig = kSkia8888_GrPixelConfig; | 279 desc.fConfig = kSkia8888_GrPixelConfig; |
280 desc.fFlags = kNone_GrSurfaceFlags; | 280 desc.fFlags = kNone_GrSurfaceFlags; |
281 desc.fWidth = kFullSize; | 281 desc.fWidth = kFullSize; |
282 desc.fHeight = kFullSize; | 282 desc.fHeight = kFullSize; |
283 | 283 |
284 SkAutoTUnref<GrTexture> texture(context->textureProvider()->createTexture(de
sc, | 284 sk_sp<GrTexture> texture(context->textureProvider()->createTexture(desc, |
285 Sk
Budgeted::kNo, | 285 SkBudgete
d::kNo, |
286 bm
.getPixels(), 0)); | 286 bm.getPix
els(), 0)); |
287 if (!texture) { | 287 if (!texture) { |
288 return; | 288 return; |
289 } | 289 } |
290 | 290 |
291 sk_sp<SkSpecialImage> fullSImg(SkSpecialImage::MakeFromGpu( | 291 sk_sp<SkSpecialImage> fullSImg(SkSpecialImage::MakeFromGpu( |
292 SkIRect::MakeWH(kFul
lSize, kFullSize), | 292 SkIRect::MakeWH(kFul
lSize, kFullSize), |
293 kNeedNewImageUniqueI
D_SpecialImage, | 293 kNeedNewImageUniqueI
D_SpecialImage, |
294 texture)); | 294 texture)); |
295 | 295 |
296 const SkIRect& subset = SkIRect::MakeXYWH(kPad, kPad, kSmallerSize, kSmaller
Size); | 296 const SkIRect& subset = SkIRect::MakeXYWH(kPad, kPad, kSmallerSize, kSmaller
Size); |
297 | 297 |
298 { | 298 { |
299 sk_sp<SkSpecialImage> subSImg1(SkSpecialImage::MakeFromGpu( | 299 sk_sp<SkSpecialImage> subSImg1(SkSpecialImage::MakeFromGpu( |
300 subset, | 300 subset, |
301 kNeedNewImageUniq
ueID_SpecialImage, | 301 kNeedNewImageUniq
ueID_SpecialImage, |
302 texture)); | 302 texture)); |
303 test_image(subSImg1, reporter, context, true, kPad, kFullSize); | 303 test_image(subSImg1, reporter, context, true, kPad, kFullSize); |
304 } | 304 } |
305 | 305 |
306 { | 306 { |
307 sk_sp<SkSpecialImage> subSImg2(fullSImg->makeSubset(subset)); | 307 sk_sp<SkSpecialImage> subSImg2(fullSImg->makeSubset(subset)); |
308 test_image(subSImg2, reporter, context, true, kPad, kFullSize); | 308 test_image(subSImg2, reporter, context, true, kPad, kFullSize); |
309 } | 309 } |
310 } | 310 } |
311 | 311 |
312 #endif | 312 #endif |
OLD | NEW |