Flutter Engine
mock_layer.cc
Go to the documentation of this file.
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 
7 namespace flutter {
8 namespace testing {
9 
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 
21 void 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 
35 void MockLayer::Paint(PaintContext& context) const {
37 
38  context.leaf_nodes_canvas->drawPath(fake_paint_path_, fake_paint_);
39 }
40 
41 } // namespace testing
42 } // namespace flutter
DEF_SWITCHES_START snapshot asset path
Definition: switches.h:32
MockLayer(SkPath path, SkPaint paint=SkPaint(), bool fake_has_platform_view=false, bool fake_needs_system_composite=false, bool fake_reads_surface=false)
Definition: mock_layer.cc:10
#define FML_DCHECK(condition)
Definition: logging.h:86
void Preroll(PrerollContext *context, const SkMatrix &matrix) override
Definition: mock_layer.cc:21
void Paint(PaintContext &context) const override
Definition: mock_layer.cc:35
bool needs_painting() const
Definition: layer.h:174
SkCanvas * leaf_nodes_canvas
Definition: layer.h:116
void set_paint_bounds(const SkRect &paint_bounds)
Definition: layer.h:170
bool surface_needs_readback
Definition: layer.h:50
void set_needs_system_composite(bool value)
Definition: layer.h:162
MutatorsStack & mutators_stack
Definition: layer.h:47