Flutter Engine Uber Docs
Docs for the entire Flutter Engine repo.
 
Loading...
Searching...
No Matches
display_list_deferred_image_gpu_impeller_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#include "flutter/common/graphics/texture.h" // Include for TextureRegistry
13#include "gmock/gmock.h"
14#include "gtest/gtest.h"
17
18namespace flutter {
19namespace testing {
20
22 fml::Thread raster_thread("raster");
23 auto task_runner = raster_thread.GetTaskRunner();
24 const DlISize size = {100, 200};
26
27 std::unique_ptr<MockSnapshotDelegate> snapshot_delegate;
28 fml::TaskRunnerAffineWeakPtr<SnapshotDelegate> snapshot_delegate_weak_ptr;
29 PostTaskSync(task_runner, [&]() {
30 snapshot_delegate = std::make_unique<MockSnapshotDelegate>();
31 // Set up the mock to return the internal texture_registry_.
32 ON_CALL(*snapshot_delegate, GetTextureRegistry())
33 .WillByDefault(
34 ::testing::Return(snapshot_delegate->GetMockTextureRegistry()));
35 snapshot_delegate_weak_ptr = snapshot_delegate->GetWeakPtr();
36 });
37
39 builder.Build(), size, snapshot_delegate_weak_ptr, task_runner);
40 ASSERT_EQ(image->GetSize(), size);
41
42 PostTaskSync(task_runner, [&]() { snapshot_delegate.reset(); });
43}
44
45TEST(DlDeferredImageGPUImpeller, TrashesDisplayList) {
46 fml::Thread raster_thread("raster");
47 auto task_runner = raster_thread.GetTaskRunner();
48 const DlISize size = {100, 200};
50
51 std::unique_ptr<MockSnapshotDelegate> snapshot_delegate;
52 fml::TaskRunnerAffineWeakPtr<SnapshotDelegate> snapshot_delegate_weak_ptr;
53 PostTaskSync(task_runner, [&]() {
54 snapshot_delegate = std::make_unique<MockSnapshotDelegate>();
55 // Set up the mock to return the internal texture_registry_.
56 ON_CALL(*snapshot_delegate, GetTextureRegistry())
57 .WillByDefault(
58 ::testing::Return(snapshot_delegate->GetMockTextureRegistry()));
59
60 auto mock_image = sk_make_sp<MockDlImage>();
62 desc.size = {1, 1};
63 auto mock_texture = std::make_shared<impeller::testing::MockTexture>(desc);
64 EXPECT_CALL(*mock_image, impeller_texture)
65 .WillOnce(::testing::Return(mock_texture));
66 EXPECT_CALL(*snapshot_delegate,
67 MakeRasterSnapshotSync(::testing::_, ::testing::_))
68 .WillOnce(::testing::Return(mock_image));
69 snapshot_delegate_weak_ptr = snapshot_delegate->GetWeakPtr();
70 });
71
72 // Pause raster thread.
74 task_runner->PostTask([&latch]() { latch.Wait(); });
75
77 builder.Build(), size, snapshot_delegate_weak_ptr, task_runner);
78
79 EXPECT_FALSE(image->impeller_texture());
80
81 // Unpause raster thread.
82 latch.Signal();
83
84 PostTaskSync(task_runner, [&]() {
85 EXPECT_TRUE(image->impeller_texture());
86 snapshot_delegate.reset();
87 });
88}
89
90} // namespace testing
91} // namespace flutter
sk_sp< DisplayList > Build()
Definition dl_builder.cc:66
static sk_sp< DlDeferredImageGPUImpeller > Make(std::unique_ptr< LayerTree > layer_tree, fml::TaskRunnerAffineWeakPtr< SnapshotDelegate > snapshot_delegate, fml::RefPtr< fml::TaskRunner > raster_task_runner)
fml::RefPtr< fml::TaskRunner > GetTaskRunner() const
Definition thread.cc:164
FlutterVulkanImage * image
static MockImage mock_image
Definition mock_epoxy.cc:59
void PostTaskSync(const fml::RefPtr< fml::TaskRunner > &task_runner, const std::function< void()> &function)
TEST(NativeAssetsManagerTest, NoAvailableAssets)
it will be possible to load the file into Perfetto s trace viewer use test Running tests that layout and measure text will not yield consistent results across various platforms Enabling this option will make font resolution default to the Ahem test font on all 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
A lightweight object that describes the attributes of a texture that can then used an allocator to cr...