Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(387)

Side by Side Diff: third_party/WebKit/Source/platform/image-decoders/jpeg/JPEGImageDecoderTest.cpp

Issue 2385993002: Rewrap comments to 80 columns in Source/platform/image-decoders/. (Closed)
Patch Set: Rewrite comment Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
80 unsigned* outputYHeight, 80 unsigned* outputYHeight,
81 unsigned* outputUVWidth, 81 unsigned* outputUVWidth,
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 d o YUV decoding. 90 // Setting a dummy ImagePlanes object signals to the decoder that we want to
91 // do YUV decoding.
91 std::unique_ptr<ImagePlanes> dummyImagePlanes = wrapUnique(new ImagePlanes()); 92 std::unique_ptr<ImagePlanes> dummyImagePlanes = wrapUnique(new ImagePlanes());
92 decoder->setImagePlanes(std::move(dummyImagePlanes)); 93 decoder->setImagePlanes(std::move(dummyImagePlanes));
93 94
94 bool sizeIsAvailable = decoder->isSizeAvailable(); 95 bool sizeIsAvailable = decoder->isSizeAvailable();
95 ASSERT_TRUE(sizeIsAvailable); 96 ASSERT_TRUE(sizeIsAvailable);
96 97
97 IntSize size = decoder->decodedSize(); 98 IntSize size = decoder->decodedSize();
98 IntSize ySize = decoder->decodedYUVSize(0); 99 IntSize ySize = decoder->decodedYUVSize(0);
99 IntSize uSize = decoder->decodedYUVSize(1); 100 IntSize uSize = decoder->decodedYUVSize(1);
100 IntSize vSize = decoder->decodedYUVSize(2); 101 IntSize vSize = decoder->decodedYUVSize(2);
(...skipping 29 matching lines...) Expand all
130 ASSERT_TRUE(decoder->decodeToYUV()); 131 ASSERT_TRUE(decoder->decodeToYUV());
131 } 132 }
132 133
133 // Tests failure on a too big image. 134 // Tests failure on a too big image.
134 TEST(JPEGImageDecoderTest, tooBig) { 135 TEST(JPEGImageDecoderTest, tooBig) {
135 std::unique_ptr<ImageDecoder> decoder = createDecoder(100); 136 std::unique_ptr<ImageDecoder> decoder = createDecoder(100);
136 EXPECT_FALSE(decoder->setSize(10000, 10000)); 137 EXPECT_FALSE(decoder->setSize(10000, 10000));
137 EXPECT_TRUE(decoder->failed()); 138 EXPECT_TRUE(decoder->failed());
138 } 139 }
139 140
140 // Tests that JPEG decoder can downsample image whose width and height are multi ple of 8, 141 // Tests that the JPEG decoder can downsample image whose width and height are
141 // to ensure we compute the correct decodedSize and pass correct parameters to l ibjpeg to 142 // multiples of 8, to ensure we compute the correct decodedSize and pass correct
142 // output image with the expected size. 143 // parameters to libjpeg to output the image with the expected size.
143 TEST(JPEGImageDecoderTest, downsampleImageSizeMultipleOf8) { 144 TEST(JPEGImageDecoderTest, downsampleImageSizeMultipleOf8) {
144 const char* jpegFile = 145 const char* jpegFile =
145 "/LayoutTests/fast/images/resources/lenna.jpg"; // 256x256 146 "/LayoutTests/fast/images/resources/lenna.jpg"; // 256x256
146 unsigned outputWidth, outputHeight; 147 unsigned outputWidth, outputHeight;
147 148
148 // 1/8 downsample. 149 // 1/8 downsample.
149 downsample(40 * 40 * 4, &outputWidth, &outputHeight, jpegFile); 150 downsample(40 * 40 * 4, &outputWidth, &outputHeight, jpegFile);
150 EXPECT_EQ(32u, outputWidth); 151 EXPECT_EQ(32u, outputWidth);
151 EXPECT_EQ(32u, outputHeight); 152 EXPECT_EQ(32u, outputHeight);
152 153
(...skipping 21 matching lines...) Expand all
174 downsample(200 * 200 * 4, &outputWidth, &outputHeight, jpegFile); 175 downsample(200 * 200 * 4, &outputWidth, &outputHeight, jpegFile);
175 EXPECT_EQ(192u, outputWidth); 176 EXPECT_EQ(192u, outputWidth);
176 EXPECT_EQ(192u, outputHeight); 177 EXPECT_EQ(192u, outputHeight);
177 178
178 // 7/8 downsample. 179 // 7/8 downsample.
179 downsample(230 * 230 * 4, &outputWidth, &outputHeight, jpegFile); 180 downsample(230 * 230 * 4, &outputWidth, &outputHeight, jpegFile);
180 EXPECT_EQ(224u, outputWidth); 181 EXPECT_EQ(224u, outputWidth);
181 EXPECT_EQ(224u, outputHeight); 182 EXPECT_EQ(224u, outputHeight);
182 } 183 }
183 184
184 // Tests that JPEG decoder can downsample image whose width and height are not m ultiple of 8. 185 // Tests that JPEG decoder can downsample image whose width and height are not
185 // Ensures that we round decodedSize and scale_num using the same algorithm as t hat of libjpeg. 186 // multiple of 8. Ensures that we round using the same algorithm as libjpeg.
186 TEST(JPEGImageDecoderTest, downsampleImageSizeNotMultipleOf8) { 187 TEST(JPEGImageDecoderTest, downsampleImageSizeNotMultipleOf8) {
187 const char* jpegFile = 188 const char* jpegFile =
188 "/LayoutTests/fast/images/resources/icc-v2-gbr.jpg"; // 275x207 189 "/LayoutTests/fast/images/resources/icc-v2-gbr.jpg"; // 275x207
189 unsigned outputWidth, outputHeight; 190 unsigned outputWidth, outputHeight;
190 191
191 // 1/8 downsample. 192 // 1/8 downsample.
192 downsample(40 * 40 * 4, &outputWidth, &outputHeight, jpegFile); 193 downsample(40 * 40 * 4, &outputWidth, &outputHeight, jpegFile);
193 EXPECT_EQ(35u, outputWidth); 194 EXPECT_EQ(35u, outputWidth);
194 EXPECT_EQ(26u, outputHeight); 195 EXPECT_EQ(26u, outputHeight);
195 196
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
292 // This test verifies that calling SharedBuffer::mergeSegmentsIntoBuffer() does 293 // This test verifies that calling SharedBuffer::mergeSegmentsIntoBuffer() does
293 // not break JPEG decoding at a critical point: in between a call to decode the 294 // not break JPEG decoding at a critical point: in between a call to decode the
294 // size (when JPEGImageDecoder stops while it may still have input data to 295 // size (when JPEGImageDecoder stops while it may still have input data to
295 // read) and a call to do a full decode. 296 // read) and a call to do a full decode.
296 TEST(JPEGImageDecoderTest, mergeBuffer) { 297 TEST(JPEGImageDecoderTest, mergeBuffer) {
297 const char* jpegFile = "/LayoutTests/fast/images/resources/lenna.jpg"; 298 const char* jpegFile = "/LayoutTests/fast/images/resources/lenna.jpg";
298 testMergeBuffer(&createDecoder, jpegFile); 299 testMergeBuffer(&createDecoder, jpegFile);
299 } 300 }
300 301
301 } // namespace blink 302 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698