1// Copyright 2013 The Flutter Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5#include "flutter/flow/testing/mock_layer.h"
6
7namespace flutter {
8namespace testing {
9
10MockLayer::MockLayer(SkPath path,
11 SkPaint paint,
12 bool fake_has_platform_view,
13 bool fake_needs_system_composite,
14 bool fake_reads_surface)
15 : fake_paint_path_(path),
16 fake_paint_(paint),
17 fake_has_platform_view_(fake_has_platform_view),
18 fake_needs_system_composite_(fake_needs_system_composite),
19 fake_reads_surface_(fake_reads_surface) {}
20
21void MockLayer::Preroll(PrerollContext* context, const SkMatrix& matrix) {
22 parent_mutators_ = context->mutators_stack;
23 parent_matrix_ = matrix;
24 parent_cull_rect_ = context->cull_rect;
25 parent_has_platform_view_ = context->has_platform_view;
26
27 context->has_platform_view = fake_has_platform_view_;
28 set_paint_bounds(fake_paint_path_.getBounds());
29 set_needs_system_composite(fake_needs_system_composite_);
30 if (fake_reads_surface_) {
31 context->surface_needs_readback = true;
32 }
33}
34
35void MockLayer::Paint(PaintContext& context) const {
36 FML_DCHECK(needs_painting());
37
38 context.leaf_nodes_canvas->drawPath(fake_paint_path_, fake_paint_);
39}
40
41} // namespace testing
42} // namespace flutter
43