OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "platform/graphics/CompositorMutatorClient.h" |
| 6 |
| 7 #include "cc/animation/mutable_properties.h" |
| 8 #include "platform/graphics/CompositorMutation.h" |
| 9 #include "platform/graphics/CompositorMutator.h" |
| 10 #include "platform/graphics/CompositorMutableProperties.h" |
| 11 #include "platform/graphics/CompositorMutableStateProvider.h" |
| 12 #include "platform/TraceEvent.h" |
| 13 |
| 14 namespace blink { |
| 15 |
| 16 static_assert( |
| 17 static_cast<cc::MutableProperty>(CompositorMutablePropertyNone) == cc::kMuta
blePropertyNone, |
| 18 "MutableProperty and CompositorMutableProperty enums must match"); |
| 19 |
| 20 static_assert( |
| 21 static_cast<cc::MutableProperty>(CompositorMutablePropertyOpacity) == cc::kM
utablePropertyOpacity, |
| 22 "MutableProperty and CompositorMutableProperty enums must match"); |
| 23 |
| 24 static_assert( |
| 25 static_cast<cc::MutableProperty>(CompositorMutablePropertyScrollLeft) == cc:
:kMutablePropertyScrollLeft, |
| 26 "MutableProperty and CompositorMutableProperty enums must match"); |
| 27 |
| 28 static_assert( |
| 29 static_cast<cc::MutableProperty>(CompositorMutablePropertyScrollTop) == cc::
kMutablePropertyScrollTop, |
| 30 "MutableProperty and CompositorMutableProperty enums must match"); |
| 31 |
| 32 static_assert( |
| 33 static_cast<cc::MutableProperty>(CompositorMutablePropertyTransform) == cc::
kMutablePropertyTransform, |
| 34 "MutableProperty and CompositorMutableProperty enums must match"); |
| 35 |
| 36 CompositorMutatorClient::CompositorMutatorClient(CompositorMutator* mutator) |
| 37 : m_client(nullptr) |
| 38 , m_mutator(mutator) |
| 39 { |
| 40 TRACE_EVENT0("compositor-worker", "CompositorMutatorClient::CompositorMutato
rClient"); |
| 41 } |
| 42 |
| 43 CompositorMutatorClient::~CompositorMutatorClient() |
| 44 { |
| 45 TRACE_EVENT0("compositor-worker", "CompositorMutatorClient::~CompositorMutat
orClient"); |
| 46 } |
| 47 |
| 48 bool CompositorMutatorClient::Mutate( |
| 49 base::TimeTicks now, |
| 50 cc::LayerTreeImpl* state) |
| 51 { |
| 52 TRACE_EVENT0("compositor-worker", "CompositorMutatorClient::GetMutations"); |
| 53 double time = (now - base::TimeTicks()).InSecondsF(); |
| 54 if (!m_mutations) |
| 55 m_mutations = adoptPtr(new CompositorMutations); |
| 56 CompositorMutableStateProvider compositor_state(state, m_mutations.get()); |
| 57 bool should_reinvoke = m_mutator->mutate(time, &compositor_state); |
| 58 // TODO(flackr): Detect if there actually were any mutations and set |
| 59 // needs commit? |
| 60 return should_reinvoke; |
| 61 } |
| 62 |
| 63 void CompositorMutatorClient::SetClient(cc::LayerTreeMutatorClient* client) |
| 64 { |
| 65 TRACE_EVENT0("compositor-worker", "CompositorMutatorClient::SetClient"); |
| 66 m_client = client; |
| 67 setNeedsMutate(); |
| 68 } |
| 69 |
| 70 scoped_ptr<cc::LayerTreeMutations> CompositorMutatorClient::TakeMutations() |
| 71 { |
| 72 return make_scoped_ptr<cc::LayerTreeMutations>(m_mutations.leakPtr()); |
| 73 } |
| 74 |
| 75 void CompositorMutatorClient::setNeedsMutate() |
| 76 { |
| 77 TRACE_EVENT0("compositor-worker", "CompositorMutatorClient::requestMutation"
); |
| 78 m_client->SetNeedsMutate(); |
| 79 } |
| 80 |
| 81 } // namespace blink |
OLD | NEW |