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

Side by Side Diff: tests/ImageTest.cpp

Issue 2147493004: Add a function to convert a texture backed SkImage to raster. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: cleanup Created 4 years, 5 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 | « src/image/SkImage_Gpu.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
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 <functional> 8 #include <functional>
9 #include <initializer_list> 9 #include <initializer_list>
10 #include <vector> 10 #include <vector>
(...skipping 457 matching lines...) Expand 10 before | Expand all | Expand 10 after
468 } 468 }
469 if (image->width() != texImage->width() || image->height() != texImage-> height()) { 469 if (image->width() != texImage->width() || image->height() != texImage-> height()) {
470 ERRORF(reporter, "newTextureImage changed the image size."); 470 ERRORF(reporter, "newTextureImage changed the image size.");
471 } 471 }
472 if (image->isOpaque() != texImage->isOpaque()) { 472 if (image->isOpaque() != texImage->isOpaque()) {
473 ERRORF(reporter, "newTextureImage changed image opaqueness."); 473 ERRORF(reporter, "newTextureImage changed image opaqueness.");
474 } 474 }
475 } 475 }
476 } 476 }
477 477
478 DEF_GPUTEST_FOR_RENDERING_CONTEXTS(SkImage_makeNonTextureImage, reporter, contex tInfo) {
479 GrContext* context = contextInfo.grContext();
480
481 std::function<sk_sp<SkImage>()> imageFactories[] = {
482 create_image,
483 create_codec_image,
484 create_data_image,
485 create_picture_image,
486 [context] { return create_gpu_image(context); },
487 };
488 for (auto factory : imageFactories) {
489 sk_sp<SkImage> image = factory();
490 if (!image->isTextureBacked()) {
491 REPORTER_ASSERT(reporter, image->makeNonTextureImage().get() == imag e.get());
492 if (!(image = image->makeTextureImage(context))) {
493 continue;
494 }
495 }
496 auto rasterImage = image->makeNonTextureImage();
497 if (!rasterImage) {
498 ERRORF(reporter, "makeNonTextureImage failed for texture-backed imag e.");
499 }
500 REPORTER_ASSERT(reporter, !rasterImage->isTextureBacked());
501 assert_equal(reporter, image.get(), nullptr, rasterImage.get());
502 }
503 }
504
478 DEF_GPUTEST_FOR_GL_RENDERING_CONTEXTS(SkImage_drawAbandonedGpuImage, reporter, c ontextInfo) { 505 DEF_GPUTEST_FOR_GL_RENDERING_CONTEXTS(SkImage_drawAbandonedGpuImage, reporter, c ontextInfo) {
479 auto context = contextInfo.grContext(); 506 auto context = contextInfo.grContext();
480 auto image = create_gpu_image(context); 507 auto image = create_gpu_image(context);
481 auto info = SkImageInfo::MakeN32(20, 20, kOpaque_SkAlphaType); 508 auto info = SkImageInfo::MakeN32(20, 20, kOpaque_SkAlphaType);
482 auto surface(SkSurface::MakeRenderTarget(context, SkBudgeted::kNo, info)); 509 auto surface(SkSurface::MakeRenderTarget(context, SkBudgeted::kNo, info));
483 as_IB(image)->peekTexture()->abandon(); 510 as_IB(image)->peekTexture()->abandon();
484 surface->getCanvas()->drawImage(image, 0, 0); 511 surface->getCanvas()->drawImage(image, 0, 0);
485 } 512 }
486 513
487 #endif 514 #endif
(...skipping 448 matching lines...) Expand 10 before | Expand all | Expand 10 after
936 otherContextInfo.grContext(), buffer, budgeted)); 963 otherContextInfo.grContext(), buffer, budgeted));
937 REPORTER_ASSERT(reporter, !newImage2); 964 REPORTER_ASSERT(reporter, !newImage2);
938 testContext->makeCurrent(); 965 testContext->makeCurrent();
939 } 966 }
940 } 967 }
941 sk_free(buffer); 968 sk_free(buffer);
942 } 969 }
943 } 970 }
944 } 971 }
945 #endif 972 #endif
OLDNEW
« no previous file with comments | « src/image/SkImage_Gpu.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698