layer_tree.h 2.2 KB
Newer Older
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_FLOW_LAYERS_LAYER_TREE_H_
#define FLUTTER_FLOW_LAYERS_LAYER_TREE_H_
7

8
#include <stdint.h>
A
Adam Barth 已提交
9

10 11
#include <memory>

12 13
#include "flutter/flow/compositor_context.h"
#include "flutter/flow/layers/layer.h"
A
Adam Barth 已提交
14 15
#include "lib/ftl/macros.h"
#include "lib/ftl/time/time_delta.h"
16 17
#include "third_party/skia/include/core/SkSize.h"

A
Adam Barth 已提交
18
namespace flow {
19 20 21 22 23 24

class LayerTree {
 public:
  LayerTree();
  ~LayerTree();

25 26
  void Raster(CompositorContext::ScopedFrame& frame);

27 28 29 30 31 32
  // TODO(abarth): Integrate scene updates with the rasterization pass so that
  // we can draw on top of child scenes (and so that we can apply clips and
  // blending operations to child scene).
  void UpdateScene(mojo::gfx::composition::SceneUpdate* update,
                   mojo::gfx::composition::Node* container);

33
  Layer* root_layer() const { return root_layer_.get(); }
34

35 36 37 38 39
  void set_root_layer(std::unique_ptr<Layer> root_layer) {
    root_layer_ = std::move(root_layer);
  }

  const SkISize& frame_size() const { return frame_size_; }
40

41 42
  void set_frame_size(const SkISize& frame_size) { frame_size_ = frame_size; }

43 44 45 46 47
  uint32_t scene_version() const { return scene_version_; }
  void set_scene_version(uint32_t scene_version) {
    scene_version_ = scene_version;
  }

A
Adam Barth 已提交
48
  void set_construction_time(const ftl::TimeDelta& delta) {
49 50 51
    construction_time_ = delta;
  }

A
Adam Barth 已提交
52
  const ftl::TimeDelta& construction_time() const { return construction_time_; }
53

54 55 56 57
  // The number of frame intervals missed after which the compositor must
  // trace the rasterized picture to a trace file. Specify 0 to disable all
  // tracing
  void set_rasterizer_tracing_threshold(uint32_t interval) {
J
Jason Simmons 已提交
58
    rasterizer_tracing_threshold_ = interval;
59 60 61
  }

  uint32_t rasterizer_tracing_threshold() const {
J
Jason Simmons 已提交
62
    return rasterizer_tracing_threshold_;
63 64
  }

65
 private:
66
  SkISize frame_size_;  // Physical pixels.
67
  uint32_t scene_version_;
68 69
  std::unique_ptr<Layer> root_layer_;

A
Adam Barth 已提交
70
  ftl::TimeDelta construction_time_;
J
Jason Simmons 已提交
71
  uint32_t rasterizer_tracing_threshold_;
72

A
Adam Barth 已提交
73
  FTL_DISALLOW_COPY_AND_ASSIGN(LayerTree);
74 75
};

A
Adam Barth 已提交
76
}  // namespace flow
77

78
#endif  // FLUTTER_FLOW_LAYERS_LAYER_TREE_H_