OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "core/svg/graphics/SVGImage.h" | 5 #include "core/svg/graphics/SVGImage.h" |
6 | 6 |
7 #include "core/svg/graphics/SVGImageChromeClient.h" | 7 #include "core/svg/graphics/SVGImageChromeClient.h" |
8 #include "platform/SharedBuffer.h" | 8 #include "platform/SharedBuffer.h" |
9 #include "platform/Timer.h" | 9 #include "platform/Timer.h" |
10 #include "platform/geometry/FloatRect.h" | 10 #include "platform/geometry/FloatRect.h" |
(...skipping 12 matching lines...) Expand all Loading... |
23 | 23 |
24 void load(const char* data, bool shouldPause) { | 24 void load(const char* data, bool shouldPause) { |
25 m_observer = new PauseControlImageObserver(shouldPause); | 25 m_observer = new PauseControlImageObserver(shouldPause); |
26 m_image = SVGImage::create(m_observer); | 26 m_image = SVGImage::create(m_observer); |
27 m_image->setData(SharedBuffer::create(data, strlen(data)), true); | 27 m_image->setData(SharedBuffer::create(data, strlen(data)), true); |
28 } | 28 } |
29 | 29 |
30 void pumpFrame() { | 30 void pumpFrame() { |
31 Image* image = m_image.get(); | 31 Image* image = m_image.get(); |
32 std::unique_ptr<SkCanvas> nullCanvas = SkMakeNullCanvas(); | 32 std::unique_ptr<SkCanvas> nullCanvas = SkMakeNullCanvas(); |
33 PaintCanvas canvas(nullCanvas.get()); | 33 PaintCanvasPassThrough canvas(nullCanvas.get()); |
34 PaintFlags flags; | 34 PaintFlags flags; |
35 FloatRect dummyRect(0, 0, 100, 100); | 35 FloatRect dummyRect(0, 0, 100, 100); |
36 image->draw(&canvas, flags, dummyRect, dummyRect, | 36 image->draw(&canvas, flags, dummyRect, dummyRect, |
37 DoNotRespectImageOrientation, | 37 DoNotRespectImageOrientation, |
38 Image::DoNotClampImageToSourceRect); | 38 Image::DoNotClampImageToSourceRect); |
39 } | 39 } |
40 | 40 |
41 private: | 41 private: |
42 class PauseControlImageObserver | 42 class PauseControlImageObserver |
43 : public GarbageCollectedFinalized<PauseControlImageObserver>, | 43 : public GarbageCollectedFinalized<PauseControlImageObserver>, |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
136 EXPECT_TRUE(chromeClient.isSuspended()); | 136 EXPECT_TRUE(chromeClient.isSuspended()); |
137 EXPECT_FALSE(timer->isActive()); | 137 EXPECT_FALSE(timer->isActive()); |
138 | 138 |
139 // Simulate a draw. This should resume the animation again. | 139 // Simulate a draw. This should resume the animation again. |
140 pumpFrame(); | 140 pumpFrame(); |
141 EXPECT_FALSE(chromeClient.isSuspended()); | 141 EXPECT_FALSE(chromeClient.isSuspended()); |
142 EXPECT_TRUE(timer->isActive()); | 142 EXPECT_TRUE(timer->isActive()); |
143 } | 143 } |
144 | 144 |
145 } // namespace blink | 145 } // namespace blink |
OLD | NEW |