OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2013 Google Inc. | 2 * Copyright 2013 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 "SkCodec.h" | 8 #include "SkCodec.h" |
9 #include "Resources.h" | 9 #include "Resources.h" |
10 #include "SkStream.h" | 10 #include "SkStream.h" |
11 #include "SkTemplates.h" | 11 #include "SkTemplates.h" |
| 12 #include "SkYUVSizeInfo.h" |
12 #include "Test.h" | 13 #include "Test.h" |
13 | 14 |
14 static SkStreamAsset* resource(const char path[]) { | 15 static SkStreamAsset* resource(const char path[]) { |
15 SkString fullPath = GetResourcePath(path); | 16 SkString fullPath = GetResourcePath(path); |
16 return SkStream::NewFromFile(fullPath.c_str()); | 17 return SkStream::NewFromFile(fullPath.c_str()); |
17 } | 18 } |
18 | 19 |
19 static void codec_yuv(skiatest::Reporter* reporter, | 20 static void codec_yuv(skiatest::Reporter* reporter, |
20 const char path[], | 21 const char path[], |
21 SkISize expectedSizes[3]) { | 22 SkISize expectedSizes[3]) { |
22 SkAutoTDelete<SkStream> stream(resource(path)); | 23 SkAutoTDelete<SkStream> stream(resource(path)); |
23 if (!stream) { | 24 if (!stream) { |
24 SkDebugf("Missing resource '%s'\n", path); | 25 SkDebugf("Missing resource '%s'\n", path); |
25 return; | 26 return; |
26 } | 27 } |
27 SkAutoTDelete<SkCodec> codec(SkCodec::NewFromStream(stream.detach())); | 28 SkAutoTDelete<SkCodec> codec(SkCodec::NewFromStream(stream.detach())); |
28 REPORTER_ASSERT(reporter, codec); | 29 REPORTER_ASSERT(reporter, codec); |
29 if (!codec) { | 30 if (!codec) { |
30 return; | 31 return; |
31 } | 32 } |
32 | 33 |
33 // Test queryYUV8() | 34 // Test queryYUV8() |
34 SkCodec::YUVSizeInfo info; | 35 YUVSizeInfo info; |
35 bool success = codec->queryYUV8(nullptr, nullptr); | 36 bool success = codec->queryYUV8(nullptr, nullptr); |
36 REPORTER_ASSERT(reporter, !success); | 37 REPORTER_ASSERT(reporter, !success); |
37 success = codec->queryYUV8(&info, nullptr); | 38 success = codec->queryYUV8(&info, nullptr); |
38 REPORTER_ASSERT(reporter, (expectedSizes == nullptr) == !success); | 39 REPORTER_ASSERT(reporter, (expectedSizes == nullptr) == !success); |
39 if (!success) { | 40 if (!success) { |
40 return; | 41 return; |
41 } | 42 } |
42 REPORTER_ASSERT(reporter, | 43 REPORTER_ASSERT(reporter, |
43 0 == memcmp((const void*) &info, (const void*) expectedSizes, 3 * si
zeof(SkISize))); | 44 0 == memcmp((const void*) &info, (const void*) expectedSizes, 3 * si
zeof(SkISize))); |
44 REPORTER_ASSERT(reporter, info.fYWidthBytes == (uint32_t) SkAlign8(info.fYSi
ze.width())); | 45 REPORTER_ASSERT(reporter, info.fYWidthBytes == (uint32_t) SkAlign8(info.fYSi
ze.width())); |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
112 codec_yuv(r, "brickwork-texture.jpg", sizes); | 113 codec_yuv(r, "brickwork-texture.jpg", sizes); |
113 codec_yuv(r, "brickwork_normal-map.jpg", sizes); | 114 codec_yuv(r, "brickwork_normal-map.jpg", sizes); |
114 | 115 |
115 // A CMYK encoded image should fail. | 116 // A CMYK encoded image should fail. |
116 codec_yuv(r, "CMYK.jpg", nullptr); | 117 codec_yuv(r, "CMYK.jpg", nullptr); |
117 // A grayscale encoded image should fail. | 118 // A grayscale encoded image should fail. |
118 codec_yuv(r, "grayscale.jpg", nullptr); | 119 codec_yuv(r, "grayscale.jpg", nullptr); |
119 // A PNG should fail. | 120 // A PNG should fail. |
120 codec_yuv(r, "arrow.png", nullptr); | 121 codec_yuv(r, "arrow.png", nullptr); |
121 } | 122 } |
OLD | NEW |