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 <functional> | 8 #include <functional> |
9 #include <initializer_list> | 9 #include <initializer_list> |
10 #include "DMGpuSupport.h" | 10 #include "DMGpuSupport.h" |
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
156 const SkIRect ir = SkIRect::MakeXYWH(5, 5, 10, 10); | 156 const SkIRect ir = SkIRect::MakeXYWH(5, 5, 10, 10); |
157 SkAutoTUnref<SkData> origEncoded(image->encode()); | 157 SkAutoTUnref<SkData> origEncoded(image->encode()); |
158 REPORTER_ASSERT(reporter, origEncoded); | 158 REPORTER_ASSERT(reporter, origEncoded); |
159 REPORTER_ASSERT(reporter, origEncoded->size() > 0); | 159 REPORTER_ASSERT(reporter, origEncoded->size() > 0); |
160 | 160 |
161 SkAutoTUnref<SkImage> decoded(SkImage::NewFromEncoded(origEncoded)); | 161 SkAutoTUnref<SkImage> decoded(SkImage::NewFromEncoded(origEncoded)); |
162 REPORTER_ASSERT(reporter, decoded); | 162 REPORTER_ASSERT(reporter, decoded); |
163 assert_equal(reporter, image, nullptr, decoded); | 163 assert_equal(reporter, image, nullptr, decoded); |
164 | 164 |
165 // Now see if we can instantiate an image from a subset of the surface/origE
ncoded | 165 // Now see if we can instantiate an image from a subset of the surface/origE
ncoded |
166 | 166 |
167 decoded.reset(SkImage::NewFromEncoded(origEncoded, &ir)); | 167 decoded.reset(SkImage::NewFromEncoded(origEncoded, &ir)); |
168 REPORTER_ASSERT(reporter, decoded); | 168 REPORTER_ASSERT(reporter, decoded); |
169 assert_equal(reporter, image, &ir, decoded); | 169 assert_equal(reporter, image, &ir, decoded); |
170 } | 170 } |
171 | 171 |
172 DEF_TEST(ImageEncode, reporter) { | 172 DEF_TEST(ImageEncode, reporter) { |
173 SkAutoTUnref<SkImage> image(create_image()); | 173 SkAutoTUnref<SkImage> image(create_image()); |
174 test_encode(reporter, image); | 174 test_encode(reporter, image); |
175 } | 175 } |
176 | 176 |
(...skipping 693 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
870 void* misaligned = reinterpret_cast<void*>(reinterpret_cast<intptr_t
>(buffer) + 3); | 870 void* misaligned = reinterpret_cast<void*>(reinterpret_cast<intptr_t
>(buffer) + 3); |
871 if (image->getDeferredTextureImageData(*proxy, ¶ms, 1, misaligne
d)) { | 871 if (image->getDeferredTextureImageData(*proxy, ¶ms, 1, misaligne
d)) { |
872 ERRORF(reporter, "Should fail when buffer is misaligned."); | 872 ERRORF(reporter, "Should fail when buffer is misaligned."); |
873 } | 873 } |
874 if (!image->getDeferredTextureImageData(*proxy, ¶ms, 1, buffer))
{ | 874 if (!image->getDeferredTextureImageData(*proxy, ¶ms, 1, buffer))
{ |
875 ERRORF(reporter, "deferred image size succeeded but creation fai
led."); | 875 ERRORF(reporter, "deferred image size succeeded but creation fai
led."); |
876 } else { | 876 } else { |
877 for (auto budgeted : { SkBudgeted::kNo, SkBudgeted::kYes }) { | 877 for (auto budgeted : { SkBudgeted::kNo, SkBudgeted::kYes }) { |
878 SkAutoTUnref<SkImage> newImage( | 878 SkAutoTUnref<SkImage> newImage( |
879 SkImage::NewFromDeferredTextureImageData(context, buffer
, budgeted)); | 879 SkImage::NewFromDeferredTextureImageData(context, buffer
, budgeted)); |
880 REPORTER_ASSERT(reporter, newImage != nullptr); | 880 REPORTER_ASSERT(reporter, SkToBool(newImage)); |
881 if (newImage) { | 881 if (newImage) { |
882 check_images_same(reporter, image, newImage); | 882 check_images_same(reporter, image, newImage); |
883 } | 883 } |
884 // The other context should not be able to create images fro
m texture data | 884 // The other context should not be able to create images fro
m texture data |
885 // created by the original context. | 885 // created by the original context. |
886 SkAutoTUnref<SkImage> newImage2(SkImage::NewFromDeferredText
ureImageData( | 886 SkAutoTUnref<SkImage> newImage2(SkImage::NewFromDeferredText
ureImageData( |
887 otherContextInfo.fGrContext, buffer, budgeted)); | 887 otherContextInfo.fGrContext, buffer, budgeted)); |
888 REPORTER_ASSERT(reporter, !newImage2); | 888 REPORTER_ASSERT(reporter, !newImage2); |
889 glContext->makeCurrent(); | 889 glContext->makeCurrent(); |
890 } | 890 } |
891 } | 891 } |
892 sk_free(buffer); | 892 sk_free(buffer); |
893 } | 893 } |
894 } | 894 } |
895 } | 895 } |
896 #endif | 896 #endif |
OLD | NEW |