This repository was archived by the owner on Feb 25, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 6k
Remove pipeline in favor of layer tree holder #17688
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,28 @@ | ||
| // 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. | ||
|
|
||
| #include "flutter/shell/common/layer_tree_holder.h" | ||
|
|
||
| namespace flutter { | ||
|
|
||
| std::unique_ptr<LayerTree> LayerTreeHolder::Get() { | ||
| std::scoped_lock lock(layer_tree_mutex); | ||
| return std::move(layer_tree_); | ||
| } | ||
|
|
||
| void LayerTreeHolder::ReplaceIfNewer( | ||
| std::unique_ptr<LayerTree> proposed_layer_tree) { | ||
| std::scoped_lock lock(layer_tree_mutex); | ||
| if (!layer_tree_ || | ||
| layer_tree_->target_time() < proposed_layer_tree->target_time()) { | ||
| layer_tree_ = std::move(proposed_layer_tree); | ||
| } | ||
| } | ||
|
|
||
| bool LayerTreeHolder::IsEmpty() const { | ||
| std::scoped_lock lock(layer_tree_mutex); | ||
| return !layer_tree_; | ||
| } | ||
|
|
||
| }; // namespace flutter |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,35 @@ | ||
| // 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 FLUTTER_SHELL_COMMON_LAYER_TREE_HOLDER_H_ | ||
| #define FLUTTER_SHELL_COMMON_LAYER_TREE_HOLDER_H_ | ||
|
|
||
| #include <memory> | ||
|
|
||
| #include "flow/layers/layer_tree.h" | ||
|
|
||
| namespace flutter { | ||
|
|
||
| class LayerTreeHolder { | ||
| public: | ||
| LayerTreeHolder() = default; | ||
|
|
||
| ~LayerTreeHolder() = default; | ||
|
|
||
| bool IsEmpty() const; | ||
|
|
||
| std::unique_ptr<LayerTree> Get(); | ||
|
|
||
| void ReplaceIfNewer(std::unique_ptr<LayerTree> proposed_layer_tree); | ||
|
|
||
| private: | ||
| mutable std::mutex layer_tree_mutex; | ||
| std::unique_ptr<LayerTree> layer_tree_; | ||
|
|
||
| FML_DISALLOW_COPY_AND_ASSIGN(LayerTreeHolder); | ||
| }; | ||
|
|
||
| }; // namespace flutter | ||
|
|
||
| #endif // FLUTTER_SHELL_COMMON_LAYER_TREE_HOLDER_H_ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,76 @@ | ||
| // 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. | ||
|
|
||
| #define FML_USED_ON_EMBEDDER | ||
|
|
||
| #include <functional> | ||
| #include <future> | ||
| #include <memory> | ||
|
|
||
| #include "flutter/shell/common/layer_tree_holder.h" | ||
| #include "gtest/gtest.h" | ||
|
|
||
| namespace flutter { | ||
| namespace testing { | ||
|
|
||
| TEST(LayerTreeHolder, EmptyOnInit) { | ||
| const LayerTreeHolder layer_tree_holder; | ||
| ASSERT_TRUE(layer_tree_holder.IsEmpty()); | ||
| } | ||
|
|
||
| TEST(LayerTreeHolder, PutOneAndGet) { | ||
| LayerTreeHolder layer_tree_holder; | ||
| const auto frame_size = SkISize::Make(64, 64); | ||
| auto layer_tree = std::make_unique<LayerTree>(frame_size, 100.0f, 1.0f); | ||
| layer_tree_holder.ReplaceIfNewer(std::move(layer_tree)); | ||
| ASSERT_FALSE(layer_tree_holder.IsEmpty()); | ||
| const auto stored = layer_tree_holder.Get(); | ||
| ASSERT_EQ(stored->frame_size(), frame_size); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. also |
||
| ASSERT_TRUE(layer_tree_holder.IsEmpty()); | ||
| } | ||
|
|
||
| TEST(LayerTreeHolder, PutMultiGetsLatest) { | ||
| const auto build_begin = fml::TimePoint::Now(); | ||
| const auto target_time_1 = build_begin + fml::TimeDelta::FromSeconds(2); | ||
| const auto target_time_2 = build_begin + fml::TimeDelta::FromSeconds(5); | ||
|
|
||
| LayerTreeHolder layer_tree_holder; | ||
| const auto frame_size_1 = SkISize::Make(64, 64); | ||
| auto layer_tree_1 = std::make_unique<LayerTree>(frame_size_1, 100.0f, 1.0f); | ||
| layer_tree_1->RecordBuildTime(build_begin, target_time_1); | ||
| layer_tree_holder.ReplaceIfNewer(std::move(layer_tree_1)); | ||
|
|
||
| const auto frame_size_2 = SkISize::Make(128, 128); | ||
| auto layer_tree_2 = std::make_unique<LayerTree>(frame_size_2, 100.0f, 1.0f); | ||
| layer_tree_2->RecordBuildTime(build_begin, target_time_2); | ||
| layer_tree_holder.ReplaceIfNewer(std::move(layer_tree_2)); | ||
|
|
||
| const auto stored = layer_tree_holder.Get(); | ||
| ASSERT_EQ(stored->frame_size(), frame_size_2); | ||
| ASSERT_TRUE(layer_tree_holder.IsEmpty()); | ||
| } | ||
|
|
||
| TEST(LayerTreeHolder, RetainsOlderIfNewerFrameHasEarlierTargetTime) { | ||
| const auto build_begin = fml::TimePoint::Now(); | ||
| const auto target_time_1 = build_begin + fml::TimeDelta::FromSeconds(5); | ||
| const auto target_time_2 = build_begin + fml::TimeDelta::FromSeconds(2); | ||
|
|
||
| LayerTreeHolder layer_tree_holder; | ||
| const auto frame_size_1 = SkISize::Make(64, 64); | ||
| auto layer_tree_1 = std::make_unique<LayerTree>(frame_size_1, 100.0f, 1.0f); | ||
| layer_tree_1->RecordBuildTime(build_begin, target_time_1); | ||
| layer_tree_holder.ReplaceIfNewer(std::move(layer_tree_1)); | ||
|
|
||
| const auto frame_size_2 = SkISize::Make(128, 128); | ||
| auto layer_tree_2 = std::make_unique<LayerTree>(frame_size_2, 100.0f, 1.0f); | ||
| layer_tree_2->RecordBuildTime(build_begin, target_time_2); | ||
| layer_tree_holder.ReplaceIfNewer(std::move(layer_tree_2)); | ||
|
|
||
| const auto stored = layer_tree_holder.Get(); | ||
| ASSERT_EQ(stored->frame_size(), frame_size_1); | ||
| ASSERT_TRUE(layer_tree_holder.IsEmpty()); | ||
| } | ||
|
|
||
| } // namespace testing | ||
| } // namespace flutter | ||
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.