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 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
75 void SetUp() override | 75 void SetUp() override |
76 { | 76 { |
77 ImageDecodingStore::instance().setCacheLimitInBytes(1024 * 1024); | 77 ImageDecodingStore::instance().setCacheLimitInBytes(1024 * 1024); |
78 DeferredImageDecoder::setEnabled(true); | 78 DeferredImageDecoder::setEnabled(true); |
79 m_data = SharedBuffer::create(whitePNG, sizeof(whitePNG)); | 79 m_data = SharedBuffer::create(whitePNG, sizeof(whitePNG)); |
80 m_frameCount = 1; | 80 m_frameCount = 1; |
81 OwnPtr<MockImageDecoder> decoder = MockImageDecoder::create(this); | 81 OwnPtr<MockImageDecoder> decoder = MockImageDecoder::create(this); |
82 m_actualDecoder = decoder.get(); | 82 m_actualDecoder = decoder.get(); |
83 m_actualDecoder->setSize(1, 1); | 83 m_actualDecoder->setSize(1, 1); |
84 m_lazyDecoder = DeferredImageDecoder::createForTesting(decoder.release()
); | 84 m_lazyDecoder = DeferredImageDecoder::createForTesting(decoder.release()
); |
85 m_surface.reset(SkSurface::NewRasterN32Premul(100, 100)); | 85 m_surface = SkSurface::MakeRasterN32Premul(100, 100); |
86 ASSERT_TRUE(m_surface.get()); | 86 ASSERT_TRUE(m_surface.get()); |
87 m_decodeRequestCount = 0; | 87 m_decodeRequestCount = 0; |
88 m_repetitionCount = cAnimationNone; | 88 m_repetitionCount = cAnimationNone; |
89 m_status = ImageFrame::FrameComplete; | 89 m_status = ImageFrame::FrameComplete; |
90 m_frameDuration = 0; | 90 m_frameDuration = 0; |
91 m_decodedSize = m_actualDecoder->size(); | 91 m_decodedSize = m_actualDecoder->size(); |
92 } | 92 } |
93 | 93 |
94 void TearDown() override | 94 void TearDown() override |
95 { | 95 { |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
133 | 133 |
134 protected: | 134 protected: |
135 void useMockImageDecoderFactory() | 135 void useMockImageDecoderFactory() |
136 { | 136 { |
137 m_lazyDecoder->frameGenerator()->setImageDecoderFactory(MockImageDecoder
Factory::create(this, m_decodedSize)); | 137 m_lazyDecoder->frameGenerator()->setImageDecoderFactory(MockImageDecoder
Factory::create(this, m_decodedSize)); |
138 } | 138 } |
139 | 139 |
140 // Don't own this but saves the pointer to query states. | 140 // Don't own this but saves the pointer to query states. |
141 MockImageDecoder* m_actualDecoder; | 141 MockImageDecoder* m_actualDecoder; |
142 OwnPtr<DeferredImageDecoder> m_lazyDecoder; | 142 OwnPtr<DeferredImageDecoder> m_lazyDecoder; |
143 SkAutoTUnref<SkSurface> m_surface; | 143 sk_sp<SkSurface> m_surface; |
144 int m_decodeRequestCount; | 144 int m_decodeRequestCount; |
145 RefPtr<SharedBuffer> m_data; | 145 RefPtr<SharedBuffer> m_data; |
146 size_t m_frameCount; | 146 size_t m_frameCount; |
147 int m_repetitionCount; | 147 int m_repetitionCount; |
148 ImageFrame::Status m_status; | 148 ImageFrame::Status m_status; |
149 float m_frameDuration; | 149 float m_frameDuration; |
150 IntSize m_decodedSize; | 150 IntSize m_decodedSize; |
151 }; | 151 }; |
152 | 152 |
153 TEST_F(DeferredImageDecoderTest, drawIntoSkPicture) | 153 TEST_F(DeferredImageDecoderTest, drawIntoSkPicture) |
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
361 // After decoding, the frame is known to be opaque. | 361 // After decoding, the frame is known to be opaque. |
362 frame = decoder->createFrameAtIndex(0); | 362 frame = decoder->createFrameAtIndex(0); |
363 ASSERT_TRUE(frame); | 363 ASSERT_TRUE(frame); |
364 EXPECT_TRUE(frame->isOpaque()); | 364 EXPECT_TRUE(frame->isOpaque()); |
365 | 365 |
366 // Re-generating the opaque-marked frame should not fail. | 366 // Re-generating the opaque-marked frame should not fail. |
367 EXPECT_TRUE(frame->readPixels(pixmap, 0, 0)); | 367 EXPECT_TRUE(frame->readPixels(pixmap, 0, 0)); |
368 } | 368 } |
369 | 369 |
370 } // namespace blink | 370 } // namespace blink |
OLD | NEW |