layer_tree.h 2.3 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

class LayerTree {
 public:
  LayerTree();
23

24 25
  ~LayerTree();

26 27
  void Raster(CompositorContext::ScopedFrame& frame,
              bool ignore_raster_cache = false);
28

29 30 31 32 33 34
  // 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);

35
  Layer* root_layer() const { return root_layer_.get(); }
36

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

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

43 44
  void set_frame_size(const SkISize& frame_size) { frame_size_ = frame_size; }

45
  uint32_t scene_version() const { return scene_version_; }
46

47 48 49 50
  void set_scene_version(uint32_t scene_version) {
    scene_version_ = scene_version;
  }

A
Adam Barth 已提交
51
  void set_construction_time(const ftl::TimeDelta& delta) {
52 53 54
    construction_time_ = delta;
  }

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

57 58 59 60
  // 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 已提交
61
    rasterizer_tracing_threshold_ = interval;
62 63 64
  }

  uint32_t rasterizer_tracing_threshold() const {
J
Jason Simmons 已提交
65
    return rasterizer_tracing_threshold_;
66 67
  }

68
 private:
69
  SkISize frame_size_;  // Physical pixels.
70
  uint32_t scene_version_;
71 72
  std::unique_ptr<Layer> root_layer_;

A
Adam Barth 已提交
73
  ftl::TimeDelta construction_time_;
J
Jason Simmons 已提交
74
  uint32_t rasterizer_tracing_threshold_;
75

A
Adam Barth 已提交
76
  FTL_DISALLOW_COPY_AND_ASSIGN(LayerTree);
77 78
};

A
Adam Barth 已提交
79
}  // namespace flow
80

81
#endif  // FLUTTER_FLOW_LAYERS_LAYER_TREE_H_