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) #18285
Merged
iskakaushik
merged 2 commits into
flutter:master
from
iskakaushik:reland-pipeline-removal
May 14, 2020
Merged
Changes from all commits
Commits
Show all changes
2 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,32 @@ | ||
| // 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 { | ||
|
|
||
| LayerTreeHolder::LayerTreeHolder() = default; | ||
|
|
||
| LayerTreeHolder::~LayerTreeHolder() = default; | ||
|
|
||
| std::unique_ptr<LayerTree> LayerTreeHolder::Pop() { | ||
| std::scoped_lock lock(layer_tree_mutex); | ||
| return std::move(layer_tree_); | ||
| } | ||
|
|
||
| void LayerTreeHolder::PushIfNewer( | ||
| 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,55 @@ | ||
| // 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 { | ||
|
|
||
| /** | ||
| * @brief Holds the next `flutter::LayerTree` that needs to be rasterized. The | ||
| * accesses to `LayerTreeHolder` are thread safe. This is important as this | ||
| * component is accessed from both the UI and the Raster threads. | ||
| * | ||
| * A typical flow of events through this component would be: | ||
| * 1. `flutter::Animator` pushed a layer tree to be rendered during each | ||
| * `Animator::Render` call. | ||
| * 2. `flutter::Rasterizer::Draw` consumes the pushed layer tree via `Pop`. | ||
| * | ||
| * It is important to note that if a layer tree held by this class is yet to be | ||
| * consumed, it can be overriden by a newer layer tree produced by the | ||
| * `Animator`. The newness of the layer tree is determined by the target time. | ||
| */ | ||
| class LayerTreeHolder { | ||
|
Member
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. Documentation for this class. The following would be good to answer in this docset:
Contributor
Author
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. Done |
||
| public: | ||
| LayerTreeHolder(); | ||
|
|
||
| ~LayerTreeHolder(); | ||
|
|
||
| /** | ||
| * @brief Checks if a layer tree is currently held. | ||
| * | ||
| * @return true is no layer tree is held. | ||
| * @return false if there is a layer tree waiting to be consumed. | ||
| */ | ||
| bool IsEmpty() const; | ||
|
|
||
| [[nodiscard]] std::unique_ptr<LayerTree> Pop(); | ||
|
|
||
| void PushIfNewer(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.PushIfNewer(std::move(layer_tree)); | ||
| ASSERT_FALSE(layer_tree_holder.IsEmpty()); | ||
| const auto stored = layer_tree_holder.Pop(); | ||
| ASSERT_EQ(stored->frame_size(), frame_size); | ||
| 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.PushIfNewer(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.PushIfNewer(std::move(layer_tree_2)); | ||
|
|
||
| const auto stored = layer_tree_holder.Pop(); | ||
| 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.PushIfNewer(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.PushIfNewer(std::move(layer_tree_2)); | ||
|
|
||
| const auto stored = layer_tree_holder.Pop(); | ||
| 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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Awesome.