mirror of
https://github.com/flutter/flutter.git
synced 2026-02-20 02:29:02 +08:00
Currently helps primarily on iOS when no BackdropFilter is present by lowering energy usage
53 lines
1.8 KiB
C++
53 lines
1.8 KiB
C++
// Copyright 2013 The Flutter Authors. All rights reserved.
|
|
// Use of this source code is governed by a BSD-style license that can be
|
|
// found in the LICENSE file.
|
|
|
|
#ifndef FLOW_TESTING_MOCK_LAYER_H_
|
|
#define FLOW_TESTING_MOCK_LAYER_H_
|
|
|
|
#include "flutter/flow/layers/layer.h"
|
|
|
|
namespace flutter {
|
|
namespace testing {
|
|
|
|
// Mock implementation of the |Layer| interface that does nothing but paint
|
|
// the specified |path| into the canvas. It records the |PrerollContext| and
|
|
// |PaintContext| data passed in by its parent |Layer|, so the test can later
|
|
// verify the data against expected values.
|
|
class MockLayer : public Layer {
|
|
public:
|
|
MockLayer(SkPath path,
|
|
SkPaint paint = SkPaint(),
|
|
bool fake_has_platform_view = false,
|
|
bool fake_needs_system_composite = false,
|
|
bool fake_reads_surface = false);
|
|
|
|
void Preroll(PrerollContext* context, const SkMatrix& matrix) override;
|
|
void Paint(PaintContext& context) const override;
|
|
|
|
const MutatorsStack& parent_mutators() { return parent_mutators_; }
|
|
const SkMatrix& parent_matrix() { return parent_matrix_; }
|
|
const SkRect& parent_cull_rect() { return parent_cull_rect_; }
|
|
float parent_elevation() { return parent_elevation_; }
|
|
bool parent_has_platform_view() { return parent_has_platform_view_; }
|
|
|
|
private:
|
|
MutatorsStack parent_mutators_;
|
|
SkMatrix parent_matrix_;
|
|
SkRect parent_cull_rect_ = SkRect::MakeEmpty();
|
|
SkPath fake_paint_path_;
|
|
SkPaint fake_paint_;
|
|
float parent_elevation_ = 0;
|
|
bool parent_has_platform_view_ = false;
|
|
bool fake_has_platform_view_ = false;
|
|
bool fake_needs_system_composite_ = false;
|
|
bool fake_reads_surface_ = false;
|
|
|
|
FML_DISALLOW_COPY_AND_ASSIGN(MockLayer);
|
|
};
|
|
|
|
} // namespace testing
|
|
} // namespace flutter
|
|
|
|
#endif // FLOW_TESTING_MOCK_LAYER_H_
|