OLD | NEW |
1 // Copyright 2011 The Chromium Authors. All rights reserved. | 1 // Copyright 2011 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 "cc/layer_tree_host_impl.h" | 5 #include "cc/layer_tree_host_impl.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
10 #include "base/debug/trace_event.h" | 10 #include "base/debug/trace_event.h" |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
64 return make_scoped_ptr(new LayerTreeHostImplTimeSourceAdapter(layerTreeH
ostImpl, timeSource)); | 64 return make_scoped_ptr(new LayerTreeHostImplTimeSourceAdapter(layerTreeH
ostImpl, timeSource)); |
65 } | 65 } |
66 virtual ~LayerTreeHostImplTimeSourceAdapter() | 66 virtual ~LayerTreeHostImplTimeSourceAdapter() |
67 { | 67 { |
68 m_timeSource->setClient(0); | 68 m_timeSource->setClient(0); |
69 m_timeSource->setActive(false); | 69 m_timeSource->setActive(false); |
70 } | 70 } |
71 | 71 |
72 virtual void onTimerTick() OVERRIDE | 72 virtual void onTimerTick() OVERRIDE |
73 { | 73 { |
| 74 // In single threaded mode we attempt to simulate changing the current |
| 75 // thread by maintaining a fake thread id. When we switch from one |
| 76 // thread to another, we construct DebugScopedSetXXXThread objects that |
| 77 // update the thread id. This lets DCHECKS that ensure we're on the |
| 78 // right thread to work correctly in single threaded mode. The problem |
| 79 // here is that the timer tasks are run via the message loop, and when |
| 80 // they run, we've had no chance to construct a DebugScopedSetXXXThread |
| 81 // object. The result is that we report that we're running on the main |
| 82 // thread. In multi-threaded mode, this timer is run on the compositor |
| 83 // thread, so to keep this consistent in single-threaded mode, we'll |
| 84 // construct a DebugScopedSetImplThread object. There is no need to do |
| 85 // this in multi-threaded mode since the real thread id's will be |
| 86 // correct. In fact, setting fake thread id's interferes with the real |
| 87 // thread id's and causes breakage. |
| 88 scoped_ptr<DebugScopedSetImplThread> setImplThread; |
| 89 if (!m_layerTreeHostImpl->proxy()->hasImplThread()) |
| 90 setImplThread.reset(new DebugScopedSetImplThread(m_layerTreeHostImpl
->proxy())); |
| 91 |
74 m_layerTreeHostImpl->animate(base::TimeTicks::Now(), base::Time::Now()); | 92 m_layerTreeHostImpl->animate(base::TimeTicks::Now(), base::Time::Now()); |
75 } | 93 } |
76 | 94 |
77 void setActive(bool active) | 95 void setActive(bool active) |
78 { | 96 { |
79 if (active != m_timeSource->active()) | 97 if (active != m_timeSource->active()) |
80 m_timeSource->setActive(active); | 98 m_timeSource->setActive(active); |
81 } | 99 } |
82 | 100 |
83 private: | 101 private: |
(...skipping 1547 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1631 } | 1649 } |
1632 | 1650 |
1633 skia::RefPtr<SkPicture> LayerTreeHostImpl::capturePicture() | 1651 skia::RefPtr<SkPicture> LayerTreeHostImpl::capturePicture() |
1634 { | 1652 { |
1635 LayerTreeImpl* tree = pendingTree() ? pendingTree() : activeTree(); | 1653 LayerTreeImpl* tree = pendingTree() ? pendingTree() : activeTree(); |
1636 LayerImpl* layer = getNonCompositedContentLayerRecursive(tree->RootLayer()); | 1654 LayerImpl* layer = getNonCompositedContentLayerRecursive(tree->RootLayer()); |
1637 return layer ? layer->getPicture() : skia::RefPtr<SkPicture>(); | 1655 return layer ? layer->getPicture() : skia::RefPtr<SkPicture>(); |
1638 } | 1656 } |
1639 | 1657 |
1640 } // namespace cc | 1658 } // namespace cc |
OLD | NEW |