transform_layer.cc 1.2 KB
Newer Older
M
Michael Goderbauer 已提交
1
// Copyright 2013 The Flutter Authors. All rights reserved.
2 3 4
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

5
#include "flutter/flow/layers/transform_layer.h"
6

A
Adam Barth 已提交
7
namespace flow {
8

9
TransformLayer::TransformLayer() = default;
10

11
TransformLayer::~TransformLayer() = default;
12

13
void TransformLayer::Preroll(PrerollContext* context, const SkMatrix& matrix) {
14 15 16 17 18 19 20 21
  SkMatrix child_matrix;
  child_matrix.setConcat(matrix, transform_);

  SkRect child_paint_bounds = SkRect::MakeEmpty();
  PrerollChildren(context, child_matrix, &child_paint_bounds);

  transform_.mapRect(&child_paint_bounds);
  set_paint_bounds(child_paint_bounds);
22 23 24 25
}

#if defined(OS_FUCHSIA)

26
void TransformLayer::UpdateScene(SceneUpdateContext& context) {
27
  FML_DCHECK(needs_system_composite());
28 29 30

  SceneUpdateContext::Transform transform(context, transform_);
  UpdateSceneChildren(context);
A
Adam Barth 已提交
31 32
}

33 34
#endif  // defined(OS_FUCHSIA)

35
void TransformLayer::Paint(PaintContext& context) const {
36
  TRACE_EVENT0("flutter", "TransformLayer::Paint");
37
  FML_DCHECK(needs_painting());
38

39 40
  SkAutoCanvasRestore save(context.internal_nodes_canvas, true);
  context.internal_nodes_canvas->concat(transform_);
41
  PaintChildren(context);
42 43
}

A
Adam Barth 已提交
44
}  // namespace flow