OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2012 Google Inc. All rights reserved. | 2 * Copyright (C) 2012 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 | 5 * modification, are permitted provided that the following conditions |
6 * are met: | 6 * are met: |
7 * | 7 * |
8 * 1. Redistributions of source code must retain the above copyright | 8 * 1. 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 * 2. Redistributions in binary form must reproduce the above copyright | 10 * 2. Redistributions in binary form must reproduce the above copyright |
(...skipping 17 matching lines...) Expand all Loading... |
28 #include "platform/SharedBuffer.h" | 28 #include "platform/SharedBuffer.h" |
29 #include "platform/ThreadSafeFunctional.h" | 29 #include "platform/ThreadSafeFunctional.h" |
30 #include "platform/graphics/ImageDecodingStore.h" | 30 #include "platform/graphics/ImageDecodingStore.h" |
31 #include "platform/graphics/test/MockImageDecoder.h" | 31 #include "platform/graphics/test/MockImageDecoder.h" |
32 #include "platform/image-decoders/SegmentReader.h" | 32 #include "platform/image-decoders/SegmentReader.h" |
33 #include "public/platform/Platform.h" | 33 #include "public/platform/Platform.h" |
34 #include "public/platform/WebTaskRunner.h" | 34 #include "public/platform/WebTaskRunner.h" |
35 #include "public/platform/WebThread.h" | 35 #include "public/platform/WebThread.h" |
36 #include "public/platform/WebTraceLocation.h" | 36 #include "public/platform/WebTraceLocation.h" |
37 #include "testing/gtest/include/gtest/gtest.h" | 37 #include "testing/gtest/include/gtest/gtest.h" |
38 #include "wtf/PtrUtil.h" | |
39 #include <memory> | |
40 | 38 |
41 namespace blink { | 39 namespace blink { |
42 | 40 |
43 namespace { | 41 namespace { |
44 | 42 |
45 // Helper methods to generate standard sizes. | 43 // Helper methods to generate standard sizes. |
46 SkISize fullSize() { return SkISize::Make(100, 100); } | 44 SkISize fullSize() { return SkISize::Make(100, 100); } |
47 | 45 |
48 SkImageInfo imageInfo() | 46 SkImageInfo imageInfo() |
49 { | 47 { |
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
179 setFrameStatus(ImageFrame::FramePartial); | 177 setFrameStatus(ImageFrame::FramePartial); |
180 | 178 |
181 char buffer[100 * 100 * 4]; | 179 char buffer[100 * 100 * 4]; |
182 m_generator->decodeAndScale(m_segmentReader.get(), false, 0, imageInfo(), bu
ffer, 100 * 4); | 180 m_generator->decodeAndScale(m_segmentReader.get(), false, 0, imageInfo(), bu
ffer, 100 * 4); |
183 EXPECT_EQ(1, m_decodeRequestCount); | 181 EXPECT_EQ(1, m_decodeRequestCount); |
184 EXPECT_EQ(0, m_decodersDestroyed); | 182 EXPECT_EQ(0, m_decodersDestroyed); |
185 | 183 |
186 // LocalFrame can now be decoded completely. | 184 // LocalFrame can now be decoded completely. |
187 setFrameStatus(ImageFrame::FrameComplete); | 185 setFrameStatus(ImageFrame::FrameComplete); |
188 addNewData(); | 186 addNewData(); |
189 std::unique_ptr<WebThread> thread = wrapUnique(Platform::current()->createTh
read("DecodeThread")); | 187 OwnPtr<WebThread> thread = adoptPtr(Platform::current()->createThread("Decod
eThread")); |
190 thread->getWebTaskRunner()->postTask(BLINK_FROM_HERE, threadSafeBind(&decode
ThreadMain, m_generator, m_segmentReader)); | 188 thread->getWebTaskRunner()->postTask(BLINK_FROM_HERE, threadSafeBind(&decode
ThreadMain, m_generator, m_segmentReader)); |
191 thread.reset(); | 189 thread.reset(); |
192 EXPECT_EQ(2, m_decodeRequestCount); | 190 EXPECT_EQ(2, m_decodeRequestCount); |
193 EXPECT_EQ(1, m_decodersDestroyed); | 191 EXPECT_EQ(1, m_decodersDestroyed); |
194 | 192 |
195 // Decoder created again. | 193 // Decoder created again. |
196 m_generator->decodeAndScale(m_segmentReader.get(), false, 0, imageInfo(), bu
ffer, 100 * 4); | 194 m_generator->decodeAndScale(m_segmentReader.get(), false, 0, imageInfo(), bu
ffer, 100 * 4); |
197 EXPECT_EQ(3, m_decodeRequestCount); | 195 EXPECT_EQ(3, m_decodeRequestCount); |
198 | 196 |
199 addNewData(); | 197 addNewData(); |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
247 // Decoding the last frame of a multi-frame images should trigger clearing | 245 // Decoding the last frame of a multi-frame images should trigger clearing |
248 // all the frame data, but not destroying the decoder. See comments in | 246 // all the frame data, but not destroying the decoder. See comments in |
249 // ImageFrameGenerator::tryToResumeDecode(). | 247 // ImageFrameGenerator::tryToResumeDecode(). |
250 m_generator->decodeAndScale(m_segmentReader.get(), true, 2, imageInfo(), buf
fer, 100 * 4); | 248 m_generator->decodeAndScale(m_segmentReader.get(), true, 2, imageInfo(), buf
fer, 100 * 4); |
251 EXPECT_EQ(3, m_decodeRequestCount); | 249 EXPECT_EQ(3, m_decodeRequestCount); |
252 EXPECT_EQ(0, m_decodersDestroyed); | 250 EXPECT_EQ(0, m_decodersDestroyed); |
253 EXPECT_EQ(kNotFound, m_requestedClearExceptFrame); | 251 EXPECT_EQ(kNotFound, m_requestedClearExceptFrame); |
254 } | 252 } |
255 | 253 |
256 } // namespace blink | 254 } // namespace blink |
OLD | NEW |