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 "SkCanvas.h" | 8 #include "SkCanvas.h" |
9 #include "SkData.h" | 9 #include "SkData.h" |
10 #include "SkDevice.h" | 10 #include "SkDevice.h" |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
73 | 73 |
74 static void test_encode(skiatest::Reporter* reporter, GrContext* ctx) { | 74 static void test_encode(skiatest::Reporter* reporter, GrContext* ctx) { |
75 const SkIRect ir = SkIRect::MakeXYWH(5, 5, 10, 10); | 75 const SkIRect ir = SkIRect::MakeXYWH(5, 5, 10, 10); |
76 SkAutoTUnref<SkImage> orig(make_image(ctx, 20, 20, ir)); | 76 SkAutoTUnref<SkImage> orig(make_image(ctx, 20, 20, ir)); |
77 SkAutoTUnref<SkData> origEncoded(orig->encode()); | 77 SkAutoTUnref<SkData> origEncoded(orig->encode()); |
78 REPORTER_ASSERT(reporter, origEncoded); | 78 REPORTER_ASSERT(reporter, origEncoded); |
79 REPORTER_ASSERT(reporter, origEncoded->size() > 0); | 79 REPORTER_ASSERT(reporter, origEncoded->size() > 0); |
80 | 80 |
81 SkAutoTUnref<SkImage> decoded(SkImage::NewFromEncoded(origEncoded)); | 81 SkAutoTUnref<SkImage> decoded(SkImage::NewFromEncoded(origEncoded)); |
82 REPORTER_ASSERT(reporter, decoded); | 82 REPORTER_ASSERT(reporter, decoded); |
83 assert_equal(reporter, orig, NULL, decoded); | 83 assert_equal(reporter, orig, nullptr, decoded); |
84 | 84 |
85 // Now see if we can instantiate an image from a subset of the surface/origE
ncoded | 85 // Now see if we can instantiate an image from a subset of the surface/origE
ncoded |
86 | 86 |
87 decoded.reset(SkImage::NewFromEncoded(origEncoded, &ir)); | 87 decoded.reset(SkImage::NewFromEncoded(origEncoded, &ir)); |
88 REPORTER_ASSERT(reporter, decoded); | 88 REPORTER_ASSERT(reporter, decoded); |
89 assert_equal(reporter, orig, &ir, decoded); | 89 assert_equal(reporter, orig, &ir, decoded); |
90 } | 90 } |
91 | 91 |
92 DEF_TEST(Image_Encode_Cpu, reporter) { | 92 DEF_TEST(Image_Encode_Cpu, reporter) { |
93 test_encode(reporter, NULL); | 93 test_encode(reporter, nullptr); |
94 } | 94 } |
95 | 95 |
96 #if SK_SUPPORT_GPU | 96 #if SK_SUPPORT_GPU |
97 DEF_GPUTEST(Image_Encode_Gpu, reporter, factory) { | 97 DEF_GPUTEST(Image_Encode_Gpu, reporter, factory) { |
98 GrContext* ctx = factory->get(GrContextFactory::kNative_GLContextType); | 98 GrContext* ctx = factory->get(GrContextFactory::kNative_GLContextType); |
99 if (!ctx) { | 99 if (!ctx) { |
100 REPORTER_ASSERT(reporter, false); | 100 REPORTER_ASSERT(reporter, false); |
101 return; | 101 return; |
102 } | 102 } |
103 test_encode(reporter, ctx); | 103 test_encode(reporter, ctx); |
(...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
308 } | 308 } |
309 } | 309 } |
310 | 310 |
311 image.reset(nullptr); | 311 image.reset(nullptr); |
312 { | 312 { |
313 SkBitmap cachedBitmap; | 313 SkBitmap cachedBitmap; |
314 REPORTER_ASSERT(reporter, !SkBitmapCache::Find(uniqueID, &cachedBitmap))
; | 314 REPORTER_ASSERT(reporter, !SkBitmapCache::Find(uniqueID, &cachedBitmap))
; |
315 } | 315 } |
316 } | 316 } |
317 #endif | 317 #endif |
OLD | NEW |