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

Side by Side Diff: tests/ImageTest.cpp

Issue 1780933003: Use std::unique_ptr. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: once more, all together Created 4 years, 9 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/ClearTest.cpp ('k') | tests/PictureTest.cpp » ('j') | 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 "DMGpuSupport.h" 10 #include "DMGpuSupport.h"
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after
157 const SkIRect ir = SkIRect::MakeXYWH(5, 5, 10, 10); 157 const SkIRect ir = SkIRect::MakeXYWH(5, 5, 10, 10);
158 SkAutoTUnref<SkData> origEncoded(image->encode()); 158 SkAutoTUnref<SkData> origEncoded(image->encode());
159 REPORTER_ASSERT(reporter, origEncoded); 159 REPORTER_ASSERT(reporter, origEncoded);
160 REPORTER_ASSERT(reporter, origEncoded->size() > 0); 160 REPORTER_ASSERT(reporter, origEncoded->size() > 0);
161 161
162 SkAutoTUnref<SkImage> decoded(SkImage::NewFromEncoded(origEncoded)); 162 SkAutoTUnref<SkImage> decoded(SkImage::NewFromEncoded(origEncoded));
163 REPORTER_ASSERT(reporter, decoded); 163 REPORTER_ASSERT(reporter, decoded);
164 assert_equal(reporter, image, nullptr, decoded); 164 assert_equal(reporter, image, nullptr, decoded);
165 165
166 // Now see if we can instantiate an image from a subset of the surface/origE ncoded 166 // Now see if we can instantiate an image from a subset of the surface/origE ncoded
167 167
168 decoded.reset(SkImage::NewFromEncoded(origEncoded, &ir)); 168 decoded.reset(SkImage::NewFromEncoded(origEncoded, &ir));
169 REPORTER_ASSERT(reporter, decoded); 169 REPORTER_ASSERT(reporter, decoded);
170 assert_equal(reporter, image, &ir, decoded); 170 assert_equal(reporter, image, &ir, decoded);
171 } 171 }
172 172
173 DEF_TEST(ImageEncode, reporter) { 173 DEF_TEST(ImageEncode, reporter) {
174 SkAutoTUnref<SkImage> image(create_image()); 174 SkAutoTUnref<SkImage> image(create_image());
175 test_encode(reporter, image); 175 test_encode(reporter, image);
176 } 176 }
177 177
(...skipping 693 matching lines...) Expand 10 before | Expand all | Expand 10 after
871 void* misaligned = reinterpret_cast<void*>(reinterpret_cast<intptr_t >(buffer) + 3); 871 void* misaligned = reinterpret_cast<void*>(reinterpret_cast<intptr_t >(buffer) + 3);
872 if (image->getDeferredTextureImageData(*proxy, &params, 1, misaligne d)) { 872 if (image->getDeferredTextureImageData(*proxy, &params, 1, misaligne d)) {
873 ERRORF(reporter, "Should fail when buffer is misaligned."); 873 ERRORF(reporter, "Should fail when buffer is misaligned.");
874 } 874 }
875 if (!image->getDeferredTextureImageData(*proxy, &params, 1, buffer)) { 875 if (!image->getDeferredTextureImageData(*proxy, &params, 1, buffer)) {
876 ERRORF(reporter, "deferred image size succeeded but creation fai led."); 876 ERRORF(reporter, "deferred image size succeeded but creation fai led.");
877 } else { 877 } else {
878 for (auto budgeted : { SkBudgeted::kNo, SkBudgeted::kYes }) { 878 for (auto budgeted : { SkBudgeted::kNo, SkBudgeted::kYes }) {
879 SkAutoTUnref<SkImage> newImage( 879 SkAutoTUnref<SkImage> newImage(
880 SkImage::NewFromDeferredTextureImageData(context, buffer , budgeted)); 880 SkImage::NewFromDeferredTextureImageData(context, buffer , budgeted));
881 REPORTER_ASSERT(reporter, SkToBool(newImage)); 881 REPORTER_ASSERT(reporter, newImage != nullptr);
882 if (newImage) { 882 if (newImage) {
883 check_images_same(reporter, image, newImage); 883 check_images_same(reporter, image, newImage);
884 } 884 }
885 // The other context should not be able to create images fro m texture data 885 // The other context should not be able to create images fro m texture data
886 // created by the original context. 886 // created by the original context.
887 SkAutoTUnref<SkImage> newImage2(SkImage::NewFromDeferredText ureImageData( 887 SkAutoTUnref<SkImage> newImage2(SkImage::NewFromDeferredText ureImageData(
888 otherContextInfo.fGrContext, buffer, budgeted)); 888 otherContextInfo.fGrContext, buffer, budgeted));
889 REPORTER_ASSERT(reporter, !newImage2); 889 REPORTER_ASSERT(reporter, !newImage2);
890 glContext->makeCurrent(); 890 glContext->makeCurrent();
891 } 891 }
892 } 892 }
893 sk_free(buffer); 893 sk_free(buffer);
894 } 894 }
895 } 895 }
896 } 896 }
897 #endif 897 #endif
OLDNEW
« no previous file with comments | « tests/ClearTest.cpp ('k') | tests/PictureTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698