OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright (C) 2009 Google Inc. All rights reserved. | 2 * Copyright (C) 2016 Google Inc. All rights reserved. |
scroggo_chromium
2016/10/04 14:50:16
I think you want a simpler copyright header:
// C
joostouwerling
2016/10/11 16:31:06
Acknowledged.
| |
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 |
11 * copyright notice, this list of conditions and the following disclaimer | 11 * copyright notice, this list of conditions and the following disclaimer |
12 * in the documentation and/or other materials provided with the | 12 * in the documentation and/or other materials provided with the |
13 * distribution. | 13 * distribution. |
14 * * Neither the name of Google Inc. nor the names of its | 14 * * Neither the name of Google Inc. nor the names of its |
15 * contributors may be used to endorse or promote products derived from | 15 * contributors may be used to endorse or promote products derived from |
16 * this software without specific prior written permission. | 16 * this software without specific prior written permission. |
17 * | 17 * |
18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | 18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
19 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | 19 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
20 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | 20 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
21 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | 21 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
22 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | 22 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | 23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
29 */ | 29 */ |
30 | 30 |
31 #include "platform/image-decoders/png/PNGImageDecoder.h" | |
32 | |
33 #include "platform/RuntimeEnabledFeatures.h" | |
34 #include "platform/SharedBuffer.h" | |
35 #include "platform/image-decoders/ImageDecoderTestHelpers.h" | |
31 #include "public/platform/WebData.h" | 36 #include "public/platform/WebData.h" |
32 | 37 #include "public/platform/WebSize.h" |
scroggo_chromium
2016/10/04 14:50:16
I don't think you need this (or WebData.h). Make s
joostouwerling
2016/10/11 16:31:06
Acknowledged.
| |
33 #include "platform/SharedBuffer.h" | 38 #include "testing/gtest/include/gtest/gtest.h" |
39 #include "wtf/PtrUtil.h" | |
40 #include "wtf/Vector.h" | |
41 #include "wtf/dtoa/utils.h" | |
42 #include <memory> | |
34 | 43 |
35 namespace blink { | 44 namespace blink { |
36 | 45 |
37 void WebData::reset() | 46 namespace { |
47 | |
48 std::unique_ptr<ImageDecoder> createDecoder(ImageDecoder::AlphaOption alphaOptio n) | |
38 { | 49 { |
39 m_private.reset(); | 50 return wrapUnique(new PNGImageDecoder(alphaOption, |
51 ImageDecoder::GammaAndColorProfileAppl ied, | |
52 ImageDecoder::noDecodedImageByteLimit) ); | |
40 } | 53 } |
41 | 54 |
42 void WebData::assign(const WebData& other) | 55 std::unique_ptr<ImageDecoder> createDecoder() |
43 { | 56 { |
44 m_private = other.m_private; | 57 return createDecoder(ImageDecoder::AlphaNotPremultiplied); |
45 } | 58 } |
46 | 59 |
47 void WebData::assign(const char* data, size_t size) | 60 void testFrameCount(const char* pngFile, size_t expectedFrameCount) |
48 { | 61 { |
49 m_private = SharedBuffer::create(data, size); | 62 auto decoder = createDecoder(); |
63 | |
64 auto data = readFile(pngFile); | |
65 ASSERT_TRUE(data.get()); | |
66 decoder->setData(data.get(), true); | |
67 | |
68 EXPECT_EQ(expectedFrameCount, decoder->frameCount()); | |
50 } | 69 } |
51 | 70 |
52 size_t WebData::size() const | 71 } // Anonymous namespace |
72 | |
73 TEST(AnimatedPNGTests, FrameCountTest) | |
53 { | 74 { |
54 if (m_private.isNull()) | 75 testFrameCount("/LayoutTests/fast/images/resources/png-animated-idat-part-of -animation.png", 20); |
55 return 0; | 76 testFrameCount("/LayoutTests/fast/images/resources/png-animated-idat-not-par t-of-animation.png", 1); |
56 return m_private->size(); | |
57 } | 77 } |
58 | 78 |
59 const char* WebData::data() const | 79 TEST(StaticPNGTests, FrameCountTest) |
60 { | 80 { |
61 if (m_private.isNull()) | 81 testFrameCount("/LayoutTests/fast/images/resources/png-simple.png", 1); |
62 return 0; | |
63 return m_private->data(); | |
64 } | 82 } |
65 | 83 |
66 WebData::WebData(PassRefPtr<SharedBuffer> buffer) | 84 }; // namespace blink |
67 : m_private(buffer) | |
68 { | |
69 } | |
70 | |
71 WebData& WebData::operator=(PassRefPtr<SharedBuffer> buffer) | |
72 { | |
73 m_private = buffer; | |
74 return *this; | |
75 } | |
76 | |
77 WebData::operator PassRefPtr<SharedBuffer>() const | |
78 { | |
79 return PassRefPtr<SharedBuffer>(m_private.get()); | |
80 } | |
81 | |
82 } // namespace blink | |
OLD | NEW |