Flutter Engine
 
Loading...
Searching...
No Matches
surface_frame_unittests.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#define FML_USED_ON_EMBEDDER
6
9
10namespace flutter {
11
12TEST(FlowTest, SurfaceFrameDoesNotSubmitInDtor) {
13 SurfaceFrame::FramebufferInfo framebuffer_info;
14 auto callback = [](const SurfaceFrame&) {
15 EXPECT_FALSE(true);
16 return true;
17 };
18 auto encode_callback = [](const SurfaceFrame&, DlCanvas*) {
19 EXPECT_FALSE(true);
20 return true;
21 };
22
23 auto surface_frame = std::make_unique<SurfaceFrame>(
24 /*surface=*/nullptr,
25 /*framebuffer_info=*/framebuffer_info,
26 /*encode_callback=*/encode_callback,
27 /*submit_callback=*/callback,
28 /*frame_size=*/DlISize(800, 600));
29 surface_frame.reset();
30}
31
32TEST(FlowTest, SurfaceFrameDoesNotHaveEmptyCanvas) {
33 SurfaceFrame::FramebufferInfo framebuffer_info;
34 auto callback = [](const SurfaceFrame&, DlCanvas*) { return true; };
35 auto submit_callback = [](const SurfaceFrame&) { return true; };
36 SurfaceFrame frame(
37 /*surface=*/nullptr,
38 /*framebuffer_info=*/framebuffer_info,
39 /*encode_callback=*/callback,
40 /*submit_callback=*/submit_callback,
41 /*frame_size=*/DlISize(800, 600),
42 /*context_result=*/nullptr,
43 /*display_list_fallback=*/true);
44
45 EXPECT_FALSE(frame.Canvas()->GetLocalClipCoverage().IsEmpty());
46 EXPECT_FALSE(frame.Canvas()->QuickReject(DlRect::MakeLTRB(10, 10, 50, 50)));
47}
48
49TEST(FlowTest, SurfaceFrameDoesNotPrepareRtree) {
50 SurfaceFrame::FramebufferInfo framebuffer_info;
51 auto callback = [](const SurfaceFrame&, DlCanvas*) { return true; };
52 auto submit_callback = [](const SurfaceFrame&) { return true; };
53 auto surface_frame = std::make_unique<SurfaceFrame>(
54 /*surface=*/nullptr,
55 /*framebuffer_info=*/framebuffer_info,
56 /*encode_callback=*/callback,
57 /*submit_callback=*/submit_callback,
58 /*frame_size=*/DlISize(800, 600),
59 /*context_result=*/nullptr,
60 /*display_list_fallback=*/true);
61 surface_frame->Canvas()->DrawRect(DlRect::MakeWH(100, 100), DlPaint());
62 EXPECT_FALSE(surface_frame->BuildDisplayList()->has_rtree());
63}
64
65} // namespace flutter
Developer-facing API for rendering anything within the engine.
Definition dl_canvas.h:32
virtual DlRect GetLocalClipCoverage() const =0
virtual bool QuickReject(const DlRect &bounds) const =0
FlutterDesktopBinaryReply callback
TEST(FrameTimingsRecorderTest, RecordVsync)
impeller::ISize32 DlISize
static constexpr TRect MakeWH(Type width, Type height)
Definition rect.h:140
constexpr bool IsEmpty() const
Returns true if either of the width or height are 0, negative, or NaN.
Definition rect.h:297
static constexpr TRect MakeLTRB(Type left, Type top, Type right, Type bottom)
Definition rect.h:129