| 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 "SkYUVSizeInfo.h" |
| 13 #include "Test.h" | 13 #include "Test.h" |
| 14 | 14 |
| 15 static SkStreamAsset* resource(const char path[]) { |
| 16 SkString fullPath = GetResourcePath(path); |
| 17 return SkStream::NewFromFile(fullPath.c_str()); |
| 18 } |
| 19 |
| 15 static void codec_yuv(skiatest::Reporter* reporter, | 20 static void codec_yuv(skiatest::Reporter* reporter, |
| 16 const char path[], | 21 const char path[], |
| 17 SkISize expectedSizes[3]) { | 22 SkISize expectedSizes[3]) { |
| 18 SkAutoTDelete<SkStream> stream(GetResourceAsStream(path)); | 23 SkAutoTDelete<SkStream> stream(resource(path)); |
| 19 if (!stream) { | 24 if (!stream) { |
| 25 INFOF(reporter, "Missing resource '%s'\n", path); |
| 20 return; | 26 return; |
| 21 } | 27 } |
| 22 SkAutoTDelete<SkCodec> codec(SkCodec::NewFromStream(stream.release())); | 28 SkAutoTDelete<SkCodec> codec(SkCodec::NewFromStream(stream.release())); |
| 23 REPORTER_ASSERT(reporter, codec); | 29 REPORTER_ASSERT(reporter, codec); |
| 24 if (!codec) { | 30 if (!codec) { |
| 25 return; | 31 return; |
| 26 } | 32 } |
| 27 | 33 |
| 28 // Test queryYUV8() | 34 // Test queryYUV8() |
| 29 SkYUVSizeInfo info; | 35 SkYUVSizeInfo info; |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 116 codec_yuv(r, "brickwork-texture.jpg", sizes); | 122 codec_yuv(r, "brickwork-texture.jpg", sizes); |
| 117 codec_yuv(r, "brickwork_normal-map.jpg", sizes); | 123 codec_yuv(r, "brickwork_normal-map.jpg", sizes); |
| 118 | 124 |
| 119 // A CMYK encoded image should fail. | 125 // A CMYK encoded image should fail. |
| 120 codec_yuv(r, "CMYK.jpg", nullptr); | 126 codec_yuv(r, "CMYK.jpg", nullptr); |
| 121 // A grayscale encoded image should fail. | 127 // A grayscale encoded image should fail. |
| 122 codec_yuv(r, "grayscale.jpg", nullptr); | 128 codec_yuv(r, "grayscale.jpg", nullptr); |
| 123 // A PNG should fail. | 129 // A PNG should fail. |
| 124 codec_yuv(r, "arrow.png", nullptr); | 130 codec_yuv(r, "arrow.png", nullptr); |
| 125 } | 131 } |
| OLD | NEW |