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