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 "platform/graphics/CompositorMutableStateProvider.h" | 5 #include "platform/graphics/CompositorMutableStateProvider.h" |
6 | 6 |
7 #include "cc/layers/layer_impl.h" | 7 #include "cc/layers/layer_impl.h" |
8 #include "cc/trees/layer_tree_impl.h" | 8 #include "cc/trees/layer_tree_impl.h" |
| 9 #include "platform/graphics/CompositorElementId.h" |
| 10 #include "platform/graphics/CompositorMutableProperties.h" |
9 #include "platform/graphics/CompositorMutableState.h" | 11 #include "platform/graphics/CompositorMutableState.h" |
10 #include "platform/graphics/CompositorMutation.h" | 12 #include "platform/graphics/CompositorMutation.h" |
11 #include "wtf/PtrUtil.h" | 13 #include "wtf/PtrUtil.h" |
12 #include <memory> | 14 #include <memory> |
13 | 15 |
14 namespace blink { | 16 namespace blink { |
15 | 17 |
16 CompositorMutableStateProvider::CompositorMutableStateProvider(cc::LayerTreeImpl
* treeImpl, CompositorMutations* mutations) | 18 CompositorMutableStateProvider::CompositorMutableStateProvider(cc::LayerTreeImpl
* treeImpl, CompositorMutations* mutations) |
17 : m_tree(treeImpl) | 19 : m_tree(treeImpl) |
18 , m_mutations(mutations) | 20 , m_mutations(mutations) |
19 { | 21 { |
20 } | 22 } |
21 | 23 |
22 CompositorMutableStateProvider::~CompositorMutableStateProvider() {} | 24 CompositorMutableStateProvider::~CompositorMutableStateProvider() {} |
23 | 25 |
24 std::unique_ptr<CompositorMutableState> | 26 std::unique_ptr<CompositorMutableState> |
25 CompositorMutableStateProvider::getMutableStateFor(uint64_t elementId) | 27 CompositorMutableStateProvider::getMutableStateFor(uint64_t elementId) |
26 { | 28 { |
27 cc::LayerTreeImpl::ElementLayers layers = m_tree->GetMutableLayers(elementId
); | 29 cc::LayerImpl* mainLayer = m_tree->LayerByElementId(createCompositorElementI
d(elementId, CompositorSubElementId::Primary)); |
| 30 cc::LayerImpl* scrollLayer = m_tree->LayerByElementId(createCompositorElemen
tId(elementId, CompositorSubElementId::Scroll)); |
28 | 31 |
29 if (!layers.main && !layers.scroll) | 32 if (!mainLayer && !scrollLayer) |
30 return nullptr; | 33 return nullptr; |
31 | 34 |
32 // Ensure that we have an entry in the map for |elementId| but do as few | 35 // Ensure that we have an entry in the map for |elementId| but do as few |
33 // allocations and queries as possible. This will update the map only if we | 36 // allocations and queries as possible. This will update the map only if we |
34 // have not added a value for |elementId|. | 37 // have not added a value for |elementId|. |
35 auto result = m_mutations->map.add(elementId, nullptr); | 38 auto result = m_mutations->map.add(elementId, nullptr); |
36 | 39 |
37 // Only if this is a new entry do we want to allocate a new mutation. | 40 // Only if this is a new entry do we want to allocate a new mutation. |
38 if (result.isNewEntry) | 41 if (result.isNewEntry) |
39 result.storedValue->value = wrapUnique(new CompositorMutation); | 42 result.storedValue->value = wrapUnique(new CompositorMutation); |
40 | 43 |
41 return wrapUnique(new CompositorMutableState(result.storedValue->value.get()
, layers.main, layers.scroll)); | 44 return wrapUnique(new CompositorMutableState(result.storedValue->value.get()
, mainLayer, scrollLayer)); |
42 } | 45 } |
43 | 46 |
44 } // namespace blink | 47 } // namespace blink |
OLD | NEW |