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