animator.h 1.5 KB
Newer Older
A
Adam Barth 已提交
1 2 3 4
// Copyright 2015 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

5 6
#ifndef FLUTTER_SHELL_COMMON_ANIMATOR_H_
#define FLUTTER_SHELL_COMMON_ANIMATOR_H_
A
Adam Barth 已提交
7

8 9
#include "flutter/shell/common/engine.h"
#include "flutter/shell/common/rasterizer.h"
10
#include "flutter/shell/common/vsync_waiter.h"
11 12 13
#include "flutter/synchronization/pipeline.h"
#include "flutter/synchronization/semaphore.h"
#include "lib/ftl/memory/ref_ptr.h"
14
#include "lib/ftl/memory/weak_ptr.h"
A
Adam Barth 已提交
15
#include "lib/ftl/time/time_point.h"
A
Adam Barth 已提交
16 17 18 19 20

namespace shell {

class Animator {
 public:
21 22 23
  Animator(ftl::WeakPtr<Rasterizer> rasterizer,
           VsyncWaiter* waiter,
           Engine* engine);
24

A
Adam Barth 已提交
25 26 27
  ~Animator();

  void RequestFrame();
28

29 30
  void Render(std::unique_ptr<flow::LayerTree> layer_tree);

31
  void Start();
32

33
  void Stop();
34

A
Adam Barth 已提交
35
 private:
36 37
  using LayerTreePipeline = flutter::Pipeline<flow::LayerTree>;

38
  void BeginFrame(ftl::TimePoint frame_time);
A
Adam Barth 已提交
39

40
  void AwaitVSync();
41

42
  ftl::WeakPtr<Rasterizer> rasterizer_;
43
  VsyncWaiter* waiter_;
A
Adam Barth 已提交
44
  Engine* engine_;
45

46
  ftl::TimePoint last_begin_frame_time_;
47 48
  ftl::RefPtr<LayerTreePipeline> layer_tree_pipeline_;
  flutter::Semaphore pending_frame_semaphore_;
49
  LayerTreePipeline::ProducerContinuation producer_continuation_;
50
  bool paused_;
A
Adam Barth 已提交
51

52
  ftl::WeakPtrFactory<Animator> weak_factory_;
A
Adam Barth 已提交
53

54
  FTL_DISALLOW_COPY_AND_ASSIGN(Animator);
A
Adam Barth 已提交
55 56 57 58
};

}  // namespace shell

59
#endif  // FLUTTER_SHELL_COMMON_ANIMATOR_H_