container_layer.cc 1.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.

A
Adam Barth 已提交
5
#include "flow/layers/container_layer.h"
6

A
Adam Barth 已提交
7
namespace flow {
8 9 10 11 12 13 14 15 16 17 18 19

ContainerLayer::ContainerLayer() {
}

ContainerLayer::~ContainerLayer() {
}

void ContainerLayer::Add(std::unique_ptr<Layer> layer) {
  layer->set_parent(this);
  layers_.push_back(std::move(layer));
}

20 21
void ContainerLayer::Preroll(PrerollContext* context, const SkMatrix& matrix) {
  PrerollChildren(context, matrix);
22
  set_paint_bounds(context->child_paint_bounds);
A
Adam Barth 已提交
23 24
}

25
void ContainerLayer::PrerollChildren(PrerollContext* context,
A
Adam Barth 已提交
26
                                     const SkMatrix& matrix) {
27 28 29 30 31 32 33
  SkRect child_paint_bounds;
  for (auto& layer : layers_) {
    PrerollContext child_context = *context;
    layer->Preroll(&child_context, matrix);
    child_paint_bounds.join(child_context.child_paint_bounds);
  }
  context->child_paint_bounds = child_paint_bounds;
A
Adam Barth 已提交
34 35
}

36
void ContainerLayer::PaintChildren(PaintContext& context) const {
37
  for (auto& layer : layers_)
38
    layer->Paint(context);
39 40
}

41 42 43 44 45 46
void ContainerLayer::UpdateScene(mojo::gfx::composition::SceneUpdate* update,
                                 mojo::gfx::composition::Node* container) {
  for (auto& layer : layers_)
    layer->UpdateScene(update, container);
}

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