| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2013 Google Inc. All rights reserved. | 2 * Copyright (C) 2013 Google Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
| 6 * met: | 6 * met: |
| 7 * | 7 * |
| 8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 82 unsigned* outputUVHeight, | 82 unsigned* outputUVHeight, |
| 83 const char* imageFilePath) { | 83 const char* imageFilePath) { |
| 84 RefPtr<SharedBuffer> data = readFile(imageFilePath); | 84 RefPtr<SharedBuffer> data = readFile(imageFilePath); |
| 85 ASSERT_TRUE(data); | 85 ASSERT_TRUE(data); |
| 86 | 86 |
| 87 std::unique_ptr<ImageDecoder> decoder = createDecoder(maxDecodedBytes); | 87 std::unique_ptr<ImageDecoder> decoder = createDecoder(maxDecodedBytes); |
| 88 decoder->setData(data.get(), true); | 88 decoder->setData(data.get(), true); |
| 89 | 89 |
| 90 // Setting a dummy ImagePlanes object signals to the decoder that we want to | 90 // Setting a dummy ImagePlanes object signals to the decoder that we want to |
| 91 // do YUV decoding. | 91 // do YUV decoding. |
| 92 std::unique_ptr<ImagePlanes> dummyImagePlanes = wrapUnique(new ImagePlanes()); | 92 std::unique_ptr<ImagePlanes> dummyImagePlanes = makeUnique<ImagePlanes>(); |
| 93 decoder->setImagePlanes(std::move(dummyImagePlanes)); | 93 decoder->setImagePlanes(std::move(dummyImagePlanes)); |
| 94 | 94 |
| 95 bool sizeIsAvailable = decoder->isSizeAvailable(); | 95 bool sizeIsAvailable = decoder->isSizeAvailable(); |
| 96 ASSERT_TRUE(sizeIsAvailable); | 96 ASSERT_TRUE(sizeIsAvailable); |
| 97 | 97 |
| 98 IntSize size = decoder->decodedSize(); | 98 IntSize size = decoder->decodedSize(); |
| 99 IntSize ySize = decoder->decodedYUVSize(0); | 99 IntSize ySize = decoder->decodedYUVSize(0); |
| 100 IntSize uSize = decoder->decodedYUVSize(1); | 100 IntSize uSize = decoder->decodedYUVSize(1); |
| 101 IntSize vSize = decoder->decodedYUVSize(2); | 101 IntSize vSize = decoder->decodedYUVSize(2); |
| 102 | 102 |
| (...skipping 15 matching lines...) Expand all Loading... |
| 118 RefPtr<ArrayBuffer> buffer(ArrayBuffer::create( | 118 RefPtr<ArrayBuffer> buffer(ArrayBuffer::create( |
| 119 rowBytes[0] * ySize.height() + rowBytes[1] * uSize.height() + | 119 rowBytes[0] * ySize.height() + rowBytes[1] * uSize.height() + |
| 120 rowBytes[2] * vSize.height(), | 120 rowBytes[2] * vSize.height(), |
| 121 1)); | 121 1)); |
| 122 void* planes[3]; | 122 void* planes[3]; |
| 123 planes[0] = buffer->data(); | 123 planes[0] = buffer->data(); |
| 124 planes[1] = ((char*)planes[0]) + rowBytes[0] * ySize.height(); | 124 planes[1] = ((char*)planes[0]) + rowBytes[0] * ySize.height(); |
| 125 planes[2] = ((char*)planes[1]) + rowBytes[1] * uSize.height(); | 125 planes[2] = ((char*)planes[1]) + rowBytes[1] * uSize.height(); |
| 126 | 126 |
| 127 std::unique_ptr<ImagePlanes> imagePlanes = | 127 std::unique_ptr<ImagePlanes> imagePlanes = |
| 128 wrapUnique(new ImagePlanes(planes, rowBytes)); | 128 makeUnique<ImagePlanes>(planes, rowBytes); |
| 129 decoder->setImagePlanes(std::move(imagePlanes)); | 129 decoder->setImagePlanes(std::move(imagePlanes)); |
| 130 | 130 |
| 131 ASSERT_TRUE(decoder->decodeToYUV()); | 131 ASSERT_TRUE(decoder->decodeToYUV()); |
| 132 } | 132 } |
| 133 | 133 |
| 134 // Tests failure on a too big image. | 134 // Tests failure on a too big image. |
| 135 TEST(JPEGImageDecoderTest, tooBig) { | 135 TEST(JPEGImageDecoderTest, tooBig) { |
| 136 std::unique_ptr<ImageDecoder> decoder = createDecoder(100); | 136 std::unique_ptr<ImageDecoder> decoder = createDecoder(100); |
| 137 EXPECT_FALSE(decoder->setSize(10000, 10000)); | 137 EXPECT_FALSE(decoder->setSize(10000, 10000)); |
| 138 EXPECT_TRUE(decoder->failed()); | 138 EXPECT_TRUE(decoder->failed()); |
| (...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 256 EXPECT_EQ(77u, outputUVHeight); | 256 EXPECT_EQ(77u, outputUVHeight); |
| 257 | 257 |
| 258 // Make sure we revert to RGBA decoding when we're about to downscale, | 258 // Make sure we revert to RGBA decoding when we're about to downscale, |
| 259 // which can occur on memory-constrained android devices. | 259 // which can occur on memory-constrained android devices. |
| 260 RefPtr<SharedBuffer> data = readFile(jpegFile); | 260 RefPtr<SharedBuffer> data = readFile(jpegFile); |
| 261 ASSERT_TRUE(data); | 261 ASSERT_TRUE(data); |
| 262 | 262 |
| 263 std::unique_ptr<ImageDecoder> decoder = createDecoder(230 * 230 * 4); | 263 std::unique_ptr<ImageDecoder> decoder = createDecoder(230 * 230 * 4); |
| 264 decoder->setData(data.get(), true); | 264 decoder->setData(data.get(), true); |
| 265 | 265 |
| 266 std::unique_ptr<ImagePlanes> imagePlanes = wrapUnique(new ImagePlanes()); | 266 std::unique_ptr<ImagePlanes> imagePlanes = makeUnique<ImagePlanes>(); |
| 267 decoder->setImagePlanes(std::move(imagePlanes)); | 267 decoder->setImagePlanes(std::move(imagePlanes)); |
| 268 ASSERT_TRUE(decoder->isSizeAvailable()); | 268 ASSERT_TRUE(decoder->isSizeAvailable()); |
| 269 ASSERT_FALSE(decoder->canDecodeToYUV()); | 269 ASSERT_FALSE(decoder->canDecodeToYUV()); |
| 270 } | 270 } |
| 271 | 271 |
| 272 TEST(JPEGImageDecoderTest, | 272 TEST(JPEGImageDecoderTest, |
| 273 byteByByteBaselineJPEGWithColorProfileAndRestartMarkers) { | 273 byteByByteBaselineJPEGWithColorProfileAndRestartMarkers) { |
| 274 testByteByByteDecode(&createDecoder, | 274 testByteByByteDecode(&createDecoder, |
| 275 "/LayoutTests/fast/images/resources/" | 275 "/LayoutTests/fast/images/resources/" |
| 276 "small-square-with-colorspin-profile.jpg", | 276 "small-square-with-colorspin-profile.jpg", |
| (...skipping 30 matching lines...) Expand all Loading... |
| 307 ASSERT_TRUE(testData.get()); | 307 ASSERT_TRUE(testData.get()); |
| 308 | 308 |
| 309 std::unique_ptr<ImageDecoder> testDecoder = createDecoder(); | 309 std::unique_ptr<ImageDecoder> testDecoder = createDecoder(); |
| 310 testDecoder->setData(testData.get(), true); | 310 testDecoder->setData(testData.get(), true); |
| 311 EXPECT_EQ(1u, testDecoder->frameCount()); | 311 EXPECT_EQ(1u, testDecoder->frameCount()); |
| 312 ASSERT_TRUE(testDecoder->frameBufferAtIndex(0)); | 312 ASSERT_TRUE(testDecoder->frameBufferAtIndex(0)); |
| 313 EXPECT_TRUE(testDecoder->failed()); | 313 EXPECT_TRUE(testDecoder->failed()); |
| 314 } | 314 } |
| 315 | 315 |
| 316 } // namespace blink | 316 } // namespace blink |
| OLD | NEW |