5#define FML_USED_ON_EMBEDDER
9#include "flutter/shell/platform/android/external_view_embedder/external_view_embedder.h"
11#include "flutter/flow/embedded_views.h"
12#include "flutter/flow/surface.h"
13#include "flutter/fml/raster_thread_merger.h"
14#include "flutter/fml/thread.h"
15#include "flutter/shell/platform/android/jni/jni_mock.h"
16#include "flutter/shell/platform/android/surface/android_surface.h"
17#include "flutter/shell/platform/android/surface/android_surface_mock.h"
19#include "gmock/gmock.h"
20#include "gtest/gtest.h"
27using ::testing::ByMove;
28using ::testing::Return;
35 std::function<std::unique_ptr<AndroidSurface>(
void)>;
37 surface_producer_ = surface_producer;
43 return surface_producer_();
75 if (!rasterizer_thread) {
76 return fml::MakeRefCounted<fml::RasterThreadMerger>(platform_queue_id,
79 auto rasterizer_queue_id =
80 rasterizer_thread->GetTaskRunner()->GetTaskQueueId();
81 return fml::MakeRefCounted<fml::RasterThreadMerger>(platform_queue_id,
93 return fml::MakeRefCounted<fml::RasterThreadMerger>(platform_queue_id,
102 loop.GetTaskRunner(),
103 loop.GetTaskRunner(),
104 loop.GetTaskRunner(),
111 auto embedder = std::make_unique<AndroidExternalViewEmbedder>(
114 ASSERT_EQ(
nullptr, embedder->CompositeEmbeddedView(0));
115 embedder->PrerollCompositeEmbeddedView(
116 0, std::make_unique<EmbeddedViewParams>());
117 ASSERT_NE(
nullptr, embedder->CompositeEmbeddedView(0));
119 ASSERT_EQ(
nullptr, embedder->CompositeEmbeddedView(1));
120 embedder->PrerollCompositeEmbeddedView(
121 1, std::make_unique<EmbeddedViewParams>());
122 ASSERT_NE(
nullptr, embedder->CompositeEmbeddedView(1));
127 auto embedder = std::make_unique<AndroidExternalViewEmbedder>(
130 embedder->PrerollCompositeEmbeddedView(
131 0, std::make_unique<EmbeddedViewParams>());
132 embedder->CancelFrame();
134 ASSERT_EQ(embedder->CompositeEmbeddedView(0),
nullptr);
138 auto jni_mock = std::make_shared<JNIMock>();
140 auto embedder = std::make_unique<AndroidExternalViewEmbedder>(
144 auto raster_thread_merger =
146 ASSERT_FALSE(raster_thread_merger->IsMerged());
148 EXPECT_CALL(*jni_mock, FlutterViewBeginFrame());
149 embedder->BeginFrame(
nullptr, raster_thread_merger);
153 embedder->PrerollCompositeEmbeddedView(
154 0, std::make_unique<EmbeddedViewParams>());
156 auto postpreroll_result = embedder->PostPrerollAction(raster_thread_merger);
159 EXPECT_CALL(*jni_mock, FlutterViewEndFrame());
160 embedder->EndFrame(
true, raster_thread_merger);
162 ASSERT_TRUE(raster_thread_merger->IsMerged());
164 int pending_frames = 0;
165 while (raster_thread_merger->IsMerged()) {
166 raster_thread_merger->DecrementLease();
169 ASSERT_EQ(10, pending_frames);
173 auto jni_mock = std::make_shared<JNIMock>();
175 auto embedder = std::make_unique<AndroidExternalViewEmbedder>(
179 auto raster_thread_merger =
181 ASSERT_FALSE(raster_thread_merger->IsMerged());
186 EXPECT_CALL(*jni_mock, FlutterViewEndFrame());
187 embedder->EndFrame(
true, raster_thread_merger);
189 ASSERT_FALSE(raster_thread_merger->IsMerged());
193 auto jni_mock = std::make_shared<JNIMock>();
196 auto embedder = std::make_unique<AndroidExternalViewEmbedder>(
199 auto raster_thread_merger =
202 EXPECT_CALL(*jni_mock, FlutterViewBeginFrame());
203 embedder->BeginFrame(
nullptr, raster_thread_merger);
216 embedder->PrerollCompositeEmbeddedView(view_id, std::move(view_params));
217 ASSERT_EQ(
SkRect::MakeXYWH(15, 30, 45, 60), embedder->GetViewRect(view_id));
221 auto jni_mock = std::make_shared<JNIMock>();
224 auto embedder = std::make_unique<AndroidExternalViewEmbedder>(
227 auto raster_thread_merger =
230 EXPECT_CALL(*jni_mock, FlutterViewBeginFrame());
231 embedder->BeginFrame(
nullptr, raster_thread_merger);
241 auto view_params_1 = std::make_unique<EmbeddedViewParams>(
244 embedder->PrerollCompositeEmbeddedView(view_id, std::move(view_params_1));
252 auto view_params_2 = std::make_unique<EmbeddedViewParams>(
255 embedder->PrerollCompositeEmbeddedView(view_id, std::move(view_params_2));
257 ASSERT_EQ(
SkRect::MakeXYWH(75, 90, 105, 120), embedder->GetViewRect(view_id));
261 auto jni_mock = std::make_shared<JNIMock>();
262 auto android_context =
265 auto window = fml::MakeRefCounted<AndroidNativeWindow>(
nullptr);
269 auto surface_factory = std::make_shared<TestAndroidSurfaceFactory>(
270 [gr_context,
window, frame_size, framebuffer_info]() {
271 auto surface_frame_1 = std::make_unique<SurfaceFrame>(
277 auto surface_frame_2 = std::make_unique<SurfaceFrame>(
284 auto surface_mock = std::make_unique<SurfaceMock>();
285 EXPECT_CALL(*surface_mock, AcquireFrame(frame_size))
287 .WillOnce(Return(ByMove(std::move(surface_frame_1))))
288 .WillOnce(Return(ByMove(std::move(surface_frame_2))));
290 auto android_surface_mock = std::make_unique<AndroidSurfaceMock>();
291 EXPECT_CALL(*android_surface_mock, IsValid()).WillOnce(Return(
true));
293 EXPECT_CALL(*android_surface_mock, CreateGPUSurface(gr_context.get()))
294 .WillOnce(Return(ByMove(std::move(surface_mock))));
296 EXPECT_CALL(*android_surface_mock, SetNativeWindow(
window));
298 return android_surface_mock;
300 auto embedder = std::make_unique<AndroidExternalViewEmbedder>(
307 auto did_submit_frame =
false;
308 auto surface_frame = std::make_unique<SurfaceFrame>(
312 if (canvas !=
nullptr) {
313 did_submit_frame =
true;
319 embedder->SubmitFlutterView(
kImplicitViewId, gr_context.get(),
nullptr,
320 std::move(surface_frame));
324 auto postpreroll_result = embedder->PostPrerollAction(raster_thread_merger);
327 EXPECT_CALL(*jni_mock, FlutterViewEndFrame());
328 embedder->EndFrame(
false, raster_thread_merger);
333 EXPECT_CALL(*jni_mock, FlutterViewBeginFrame());
334 embedder->BeginFrame(
nullptr, raster_thread_merger);
335 embedder->PrepareFlutterView(frame_size, 1.5);
348 auto view_params_1 = std::make_unique<EmbeddedViewParams>(
351 embedder->PrerollCompositeEmbeddedView(0, std::move(view_params_1));
353 auto canvas_1 = embedder->CompositeEmbeddedView(0);
366 EXPECT_CALL(*jni_mock, FlutterViewCreateOverlaySurface())
368 ByMove(std::make_unique<PlatformViewAndroidJNI::OverlayMetadata>(
371 EXPECT_CALL(*jni_mock, FlutterViewOnDisplayPlatformView(
372 0, 150, 150, 300, 300, 300, 300, stack1));
374 EXPECT_CALL(*jni_mock,
375 FlutterViewDisplayOverlaySurface(0, 150, 150, 100, 100));
377 auto did_submit_frame =
false;
378 auto surface_frame = std::make_unique<SurfaceFrame>(
382 if (canvas !=
nullptr) {
383 did_submit_frame =
true;
389 embedder->SubmitFlutterView(
kImplicitViewId, gr_context.get(),
nullptr,
390 std::move(surface_frame));
392 EXPECT_FALSE(did_submit_frame);
394 auto postpreroll_result = embedder->PostPrerollAction(raster_thread_merger);
397 EXPECT_CALL(*jni_mock, FlutterViewEndFrame());
398 embedder->EndFrame(
false, raster_thread_merger);
403 EXPECT_CALL(*jni_mock, FlutterViewBeginFrame());
404 embedder->BeginFrame(
nullptr, raster_thread_merger);
405 embedder->PrepareFlutterView(frame_size, 1.5);
418 auto view_params_1 = std::make_unique<EmbeddedViewParams>(
421 embedder->PrerollCompositeEmbeddedView(0, std::move(view_params_1));
423 auto canvas_1 = embedder->CompositeEmbeddedView(0);
437 EXPECT_CALL(*jni_mock, FlutterViewCreateOverlaySurface()).Times(0);
439 EXPECT_CALL(*jni_mock, FlutterViewOnDisplayPlatformView(
440 0, 150, 150, 300, 300, 300, 300, stack1));
442 EXPECT_CALL(*jni_mock,
443 FlutterViewDisplayOverlaySurface(0, 150, 150, 100, 100));
445 auto did_submit_frame =
false;
446 auto surface_frame = std::make_unique<SurfaceFrame>(
450 if (canvas !=
nullptr) {
451 did_submit_frame =
true;
456 embedder->SubmitFlutterView(
kImplicitViewId, gr_context.get(),
nullptr,
457 std::move(surface_frame));
461 auto postpreroll_result = embedder->PostPrerollAction(raster_thread_merger);
464 EXPECT_CALL(*jni_mock, FlutterViewEndFrame());
465 embedder->EndFrame(
false, raster_thread_merger);
473 auto jni_mock = std::make_shared<JNIMock>();
474 auto android_context =
477 auto window = fml::MakeRefCounted<AndroidNativeWindow>(
nullptr);
481 auto surface_factory = std::make_shared<TestAndroidSurfaceFactory>(
482 [gr_context,
window, frame_size, framebuffer_info]() {
483 auto surface_frame_1 = std::make_unique<SurfaceFrame>(
490 auto surface_mock = std::make_unique<SurfaceMock>();
491 EXPECT_CALL(*surface_mock, AcquireFrame(frame_size))
493 .WillOnce(Return(ByMove(std::move(surface_frame_1))));
495 auto android_surface_mock = std::make_unique<AndroidSurfaceMock>();
496 EXPECT_CALL(*android_surface_mock, IsValid()).WillOnce(Return(
true));
498 EXPECT_CALL(*android_surface_mock, CreateGPUSurface(gr_context.get()))
499 .WillOnce(Return(ByMove(std::move(surface_mock))));
501 EXPECT_CALL(*android_surface_mock, SetNativeWindow(
window));
502 return android_surface_mock;
504 auto embedder = std::make_unique<AndroidExternalViewEmbedder>(
509 EXPECT_CALL(*jni_mock, FlutterViewBeginFrame());
510 embedder->BeginFrame(
nullptr, raster_thread_merger);
511 embedder->PrepareFlutterView(frame_size, 1.5);
517 embedder->PrerollCompositeEmbeddedView(
521 EXPECT_CALL(*jni_mock, FlutterViewOnDisplayPlatformView(
522 0, 100, 100, 100, 100, 150, 150, stack));
529 embedder->PrerollCompositeEmbeddedView(
533 EXPECT_CALL(*jni_mock, FlutterViewOnDisplayPlatformView(
534 1, 300, 100, 100, 100, 150, 150, stack));
544 embedder->CompositeEmbeddedView(1)->DrawRect(
547 EXPECT_CALL(*jni_mock, FlutterViewCreateOverlaySurface())
548 .WillRepeatedly([&]() {
549 return std::make_unique<PlatformViewAndroidJNI::OverlayMetadata>(
554 EXPECT_CALL(*jni_mock,
555 FlutterViewDisplayOverlaySurface(1, 150, 100, 200, 100))
558 auto surface_frame = std::make_unique<SurfaceFrame>(
565 embedder->SubmitFlutterView(
kImplicitViewId, gr_context.get(),
nullptr,
566 std::move(surface_frame));
568 EXPECT_CALL(*jni_mock, FlutterViewEndFrame());
569 embedder->EndFrame(
false, raster_thread_merger);
573 auto jni_mock = std::make_shared<JNIMock>();
574 auto android_context =
577 auto window = fml::MakeRefCounted<AndroidNativeWindow>(
nullptr);
581 auto surface_factory = std::make_shared<TestAndroidSurfaceFactory>(
582 [gr_context,
window, frame_size, framebuffer_info]() {
583 auto surface_frame_1 = std::make_unique<SurfaceFrame>(
590 auto surface_mock = std::make_unique<SurfaceMock>();
591 EXPECT_CALL(*surface_mock, AcquireFrame(frame_size))
593 .WillOnce(Return(ByMove(std::move(surface_frame_1))));
595 auto android_surface_mock = std::make_unique<AndroidSurfaceMock>();
596 EXPECT_CALL(*android_surface_mock, IsValid()).WillOnce(Return(
true));
598 EXPECT_CALL(*android_surface_mock, CreateGPUSurface(gr_context.get()))
599 .WillOnce(Return(ByMove(std::move(surface_mock))));
601 EXPECT_CALL(*android_surface_mock, SetNativeWindow(
window));
602 return android_surface_mock;
604 auto embedder = std::make_unique<AndroidExternalViewEmbedder>(
609 EXPECT_CALL(*jni_mock, FlutterViewBeginFrame());
610 embedder->BeginFrame(
nullptr, raster_thread_merger);
611 embedder->PrepareFlutterView(frame_size, 1.5);
619 embedder->PrerollCompositeEmbeddedView(
622 EXPECT_CALL(*jni_mock, FlutterViewOnDisplayPlatformView(0, 0, 0, 200, 200,
631 embedder->CompositeEmbeddedView(0)->DrawRect(
640 embedder->PrerollCompositeEmbeddedView(
643 EXPECT_CALL(*jni_mock, FlutterViewOnDisplayPlatformView(1, 0, 0, 100, 100,
648 embedder->CompositeEmbeddedView(1)->DrawRect(
SkRect::MakeXYWH(25, 25, 80, 50),
651 embedder->CompositeEmbeddedView(1)->DrawRect(
654 EXPECT_CALL(*jni_mock, FlutterViewCreateOverlaySurface())
655 .WillRepeatedly([&]() {
656 return std::make_unique<PlatformViewAndroidJNI::OverlayMetadata>(
660 EXPECT_CALL(*jni_mock, FlutterViewDisplayOverlaySurface(1, 25, 25, 80, 150))
663 auto surface_frame = std::make_unique<SurfaceFrame>(
670 embedder->SubmitFlutterView(
kImplicitViewId, gr_context.get(),
nullptr,
671 std::move(surface_frame));
673 EXPECT_CALL(*jni_mock, FlutterViewEndFrame());
674 embedder->EndFrame(
false, raster_thread_merger);
678 auto jni_mock = std::make_shared<JNIMock>();
679 auto android_context =
682 auto window = fml::MakeRefCounted<AndroidNativeWindow>(
nullptr);
686 auto surface_factory = std::make_shared<TestAndroidSurfaceFactory>(
687 [gr_context,
window, frame_size, framebuffer_info]() {
688 auto surface_frame_1 = std::make_unique<SurfaceFrame>(
695 auto surface_mock = std::make_unique<SurfaceMock>();
696 EXPECT_CALL(*surface_mock, AcquireFrame(frame_size))
698 .WillOnce(Return(ByMove(std::move(surface_frame_1))));
700 auto android_surface_mock = std::make_unique<AndroidSurfaceMock>();
701 EXPECT_CALL(*android_surface_mock, IsValid()).WillOnce(Return(
true));
703 EXPECT_CALL(*android_surface_mock, CreateGPUSurface(gr_context.get()))
704 .WillOnce(Return(ByMove(std::move(surface_mock))));
706 EXPECT_CALL(*android_surface_mock, SetNativeWindow(
window));
707 return android_surface_mock;
709 auto embedder = std::make_unique<AndroidExternalViewEmbedder>(
714 EXPECT_CALL(*jni_mock, FlutterViewBeginFrame());
715 embedder->BeginFrame(
nullptr, raster_thread_merger);
716 embedder->PrepareFlutterView(frame_size, 1.5);
724 embedder->PrerollCompositeEmbeddedView(
727 EXPECT_CALL(*jni_mock, FlutterViewOnDisplayPlatformView(0, 0, 0, 200, 200,
731 EXPECT_CALL(*jni_mock, FlutterViewCreateOverlaySurface()).Times(0);
733 auto surface_frame = std::make_unique<SurfaceFrame>(
740 embedder->SubmitFlutterView(
kImplicitViewId, gr_context.get(),
nullptr,
741 std::move(surface_frame));
743 EXPECT_CALL(*jni_mock, FlutterViewEndFrame());
744 embedder->EndFrame(
false, raster_thread_merger);
748 auto jni_mock = std::make_shared<JNIMock>();
751 auto embedder = std::make_unique<AndroidExternalViewEmbedder>(
759 EXPECT_CALL(*jni_mock, FlutterViewBeginFrame()).Times(0);
760 embedder->BeginFrame(
nullptr, raster_thread_merger);
763 EXPECT_CALL(*jni_mock, FlutterViewEndFrame()).Times(0);
764 embedder->EndFrame(
false, raster_thread_merger);
768 auto jni_mock = std::make_shared<JNIMock>();
770 auto android_context =
772 auto window = fml::MakeRefCounted<AndroidNativeWindow>(
nullptr);
776 auto surface_factory = std::make_shared<TestAndroidSurfaceFactory>(
777 [gr_context,
window, frame_size, framebuffer_info]() {
778 auto surface_frame_1 = std::make_unique<SurfaceFrame>(
785 auto surface_mock = std::make_unique<SurfaceMock>();
786 EXPECT_CALL(*surface_mock, AcquireFrame(frame_size))
787 .WillOnce(Return(ByMove(std::move(surface_frame_1))));
789 auto android_surface_mock = std::make_unique<AndroidSurfaceMock>();
790 EXPECT_CALL(*android_surface_mock, IsValid()).WillOnce(Return(
true));
792 EXPECT_CALL(*android_surface_mock, CreateGPUSurface(gr_context.get()))
793 .WillOnce(Return(ByMove(std::move(surface_mock))));
795 EXPECT_CALL(*android_surface_mock, SetNativeWindow(
window));
797 return android_surface_mock;
800 auto embedder = std::make_unique<AndroidExternalViewEmbedder>(
803 auto raster_thread_merger =
808 EXPECT_CALL(*jni_mock, FlutterViewBeginFrame());
809 embedder->BeginFrame(
nullptr, raster_thread_merger);
810 embedder->PrepareFlutterView(frame_size, 1.5);
816 auto view_params_1 = std::make_unique<EmbeddedViewParams>(
819 embedder->PrerollCompositeEmbeddedView(0, std::move(view_params_1));
822 embedder->CompositeEmbeddedView(0)->DrawRect(
826 EXPECT_CALL(*jni_mock, FlutterViewCreateOverlaySurface())
828 ByMove(std::make_unique<PlatformViewAndroidJNI::OverlayMetadata>(
831 EXPECT_CALL(*jni_mock, FlutterViewOnDisplayPlatformView(0, 0, 0, 200, 200,
833 EXPECT_CALL(*jni_mock,
834 FlutterViewDisplayOverlaySurface(0, 50, 50, 150, 150));
837 auto surface_frame = std::make_unique<SurfaceFrame>(
843 embedder->SubmitFlutterView(
kImplicitViewId, gr_context.get(),
nullptr,
844 std::move(surface_frame));
846 EXPECT_CALL(*jni_mock, FlutterViewEndFrame());
847 embedder->EndFrame(
false, raster_thread_merger);
850 EXPECT_CALL(*jni_mock, FlutterViewDestroyOverlaySurfaces());
851 EXPECT_CALL(*jni_mock, FlutterViewBeginFrame());
853 embedder->BeginFrame(
nullptr, raster_thread_merger);
858 auto jni_mock = std::make_shared<JNIMock>();
859 auto android_context =
862 auto window = fml::MakeRefCounted<AndroidNativeWindow>(
nullptr);
866 auto surface_factory = std::make_shared<TestAndroidSurfaceFactory>(
867 [gr_context,
window, frame_size, framebuffer_info]() {
868 auto surface_frame_1 = std::make_unique<SurfaceFrame>(
875 auto surface_mock = std::make_unique<SurfaceMock>();
876 EXPECT_CALL(*surface_mock, AcquireFrame(frame_size))
877 .WillOnce(Return(ByMove(std::move(surface_frame_1))));
879 auto android_surface_mock = std::make_unique<AndroidSurfaceMock>();
880 EXPECT_CALL(*android_surface_mock, IsValid()).WillOnce(Return(
true));
882 EXPECT_CALL(*android_surface_mock, CreateGPUSurface(gr_context.get()))
883 .WillOnce(Return(ByMove(std::move(surface_mock))));
885 EXPECT_CALL(*android_surface_mock, SetNativeWindow(
window));
887 return android_surface_mock;
890 auto embedder = std::make_unique<AndroidExternalViewEmbedder>(
896 auto raster_thread_merger =
898 EXPECT_CALL(*jni_mock, FlutterViewBeginFrame());
899 embedder->BeginFrame(
nullptr, raster_thread_merger);
900 embedder->PrepareFlutterView(frame_size, 1.5);
906 auto view_params_1 = std::make_unique<EmbeddedViewParams>(
909 embedder->PrerollCompositeEmbeddedView(0, std::move(view_params_1));
912 embedder->CompositeEmbeddedView(0)->DrawRect(
916 EXPECT_CALL(*jni_mock, FlutterViewCreateOverlaySurface())
918 ByMove(std::make_unique<PlatformViewAndroidJNI::OverlayMetadata>(
921 EXPECT_CALL(*jni_mock, FlutterViewOnDisplayPlatformView(0, 0, 0, 200, 200,
923 EXPECT_CALL(*jni_mock,
924 FlutterViewDisplayOverlaySurface(0, 50, 50, 150, 150));
926 auto surface_frame = std::make_unique<SurfaceFrame>(
932 embedder->SubmitFlutterView(
kImplicitViewId, gr_context.get(),
nullptr,
933 std::move(surface_frame));
935 EXPECT_CALL(*jni_mock, FlutterViewEndFrame());
936 embedder->EndFrame(
false, raster_thread_merger);
939 EXPECT_CALL(*jni_mock, FlutterViewDestroyOverlaySurfaces()).Times(1);
940 EXPECT_CALL(*jni_mock, FlutterViewBeginFrame()).Times(0);
943 embedder->BeginFrame(
nullptr,
949 auto jni_mock = std::make_shared<JNIMock>();
951 auto embedder = std::make_unique<AndroidExternalViewEmbedder>(
953 ASSERT_TRUE(embedder->SupportsDynamicThreadMerging());
957 auto jni_mock = std::make_shared<JNIMock>();
959 auto embedder = std::make_unique<AndroidExternalViewEmbedder>(
964 ASSERT_FALSE(raster_thread_merger->IsMerged());
967 raster_thread_merger->Disable();
969 EXPECT_CALL(*jni_mock, FlutterViewBeginFrame()).Times(0);
971 embedder->BeginFrame(
nullptr, raster_thread_merger);
974 embedder->PrerollCompositeEmbeddedView(
975 0, std::make_unique<EmbeddedViewParams>());
977 auto postpreroll_result = embedder->PostPrerollAction(raster_thread_merger);
980 EXPECT_CALL(*jni_mock, FlutterViewEndFrame()).Times(0);
981 embedder->EndFrame(
true, raster_thread_merger);
983 ASSERT_FALSE(raster_thread_merger->IsMerged());
987 auto jni_mock = std::make_shared<JNIMock>();
988 auto android_context =
990 auto window = fml::MakeRefCounted<AndroidNativeWindow>(
nullptr);
993 auto surface_factory = std::make_shared<TestAndroidSurfaceFactory>(
994 [gr_context,
window, frame_size]() {
996 auto surface_frame_1 = std::make_unique<SurfaceFrame>(
1003 auto surface_mock = std::make_unique<SurfaceMock>();
1004 EXPECT_CALL(*surface_mock, AcquireFrame(frame_size))
1005 .WillOnce(Return(ByMove(std::move(surface_frame_1))));
1007 auto android_surface_mock = std::make_unique<AndroidSurfaceMock>();
1008 EXPECT_CALL(*android_surface_mock, IsValid()).WillOnce(Return(
true));
1009 EXPECT_CALL(*android_surface_mock, CreateGPUSurface(gr_context.get()))
1010 .WillOnce(Return(ByMove(std::move(surface_mock))));
1012 return android_surface_mock;
1015 auto embedder = std::make_unique<AndroidExternalViewEmbedder>(
1018 auto raster_thread_merger =
1021 embedder->BeginFrame(
nullptr, raster_thread_merger);
1022 embedder->PrepareFlutterView(frame_size, 1.5);
1026 auto view_params = std::make_unique<EmbeddedViewParams>(
1029 embedder->PrerollCompositeEmbeddedView(0, std::move(view_params));
1032 embedder->CompositeEmbeddedView(0)->DrawRect(
1036 EXPECT_CALL(*jni_mock, FlutterViewCreateOverlaySurface())
1038 ByMove(std::make_unique<PlatformViewAndroidJNI::OverlayMetadata>(
1042 auto surface_frame = std::make_unique<SurfaceFrame>(
1046 embedder->SubmitFlutterView(
kImplicitViewId, gr_context.get(),
nullptr,
1047 std::move(surface_frame));
1049 embedder->EndFrame(
false, raster_thread_merger);
1051 EXPECT_CALL(*jni_mock, FlutterViewDestroyOverlaySurfaces());
1053 embedder->Teardown();
1057 auto jni_mock = std::make_shared<JNIMock>();
1058 auto android_context =
1060 auto embedder = std::make_unique<AndroidExternalViewEmbedder>(
1063 EXPECT_CALL(*jni_mock, FlutterViewDestroyOverlaySurfaces()).Times(0);
1064 embedder->Teardown();
static sk_sp< GrDirectContext > MakeMock(const GrMockOptions *, const GrContextOptions &)
static SkMatrix Scale(SkScalar sx, SkScalar sy)
static SkMatrix Translate(SkScalar dx, SkScalar dy)
SkMatrix & setConcat(const SkMatrix &a, const SkMatrix &b)
Holds state that is shared across Android surfaces.
Developer-facing API for rendering anything within the engine.
Abstract Base Class that represents where we will be rendering content.
virtual SkMatrix GetRootTransformation() const =0
virtual std::unique_ptr< SurfaceFrame > AcquireFrame(const SkISize &size)=0
virtual GrDirectContext * GetContext()=0
virtual std::unique_ptr< GLContextResult > MakeRenderContextCurrent()
MOCK_METHOD(GrDirectContext *, GetContext,(),(override))
MOCK_METHOD(bool, IsValid,(),(override))
MOCK_METHOD(std::unique_ptr< SurfaceFrame >, AcquireFrame,(const SkISize &size),(override))
MOCK_METHOD(SkMatrix, GetRootTransformation,(),(const, override))
MOCK_METHOD(std::unique_ptr< GLContextResult >, MakeRenderContextCurrent,(),(override))
TestAndroidSurfaceFactory(TestSurfaceProducer &&surface_producer)
std::unique_ptr< AndroidSurface > CreateSurface() override
~TestAndroidSurfaceFactory() override=default
std::function< std::unique_ptr< AndroidSurface >(void)> TestSurfaceProducer
static void EnsureInitializedForCurrentThread()
static FML_EMBEDDER_ONLY MessageLoop & GetCurrent()
static TaskQueueId GetCurrentTaskQueueId()
virtual TaskQueueId GetTaskQueueId()
fml::RefPtr< fml::TaskRunner > GetTaskRunner() const
unsigned useCenter Optional< SkMatrix > matrix
SK_API sk_sp< SkSurface > Null(int width, int height)
fml::RefPtr< fml::RasterThreadMerger > GetThreadMergerFromPlatformThread(fml::Thread *rasterizer_thread=nullptr)
TaskRunners GetTaskRunnersForFixture()
TEST(DisplayListComplexity, EmptyDisplayList)
fml::RefPtr< fml::RasterThreadMerger > GetThreadMergerFromRasterThread(fml::Thread *platform_thread)
constexpr int64_t kImplicitViewId
@ kFill
fills interior of shapes
it will be possible to load the file into Perfetto s trace viewer disable asset Prevents usage of any non test fonts unless they were explicitly Loaded via prefetched default font Indicates whether the embedding started a prefetch of the default font manager before creating the engine run In non interactive keep the shell running after the Dart script has completed enable serial On low power devices with low core running concurrent GC tasks on threads can cause them to contend with the UI thread which could potentially lead to jank This option turns off all concurrent GC activities domain network JSON encoded network policy per domain This overrides the DisallowInsecureConnections switch Embedder can specify whether to allow or disallow insecure connections at a domain level old gen heap size
static constexpr SkISize Make(int32_t w, int32_t h)
static constexpr SkRect MakeXYWH(float x, float y, float w, float h)
static constexpr SkSize Make(SkScalar w, SkScalar h)
static constexpr DlColor kCyan()
#define EXPECT_TRUE(handle)