Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Commit d90de5d

Browse files
committed
Merge remote-tracking branch 'upstream/master' into trace_save_layer
2 parents 49760a8 + 3364409 commit d90de5d

File tree

143 files changed

+2123
-828
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

143 files changed

+2123
-828
lines changed

BUILD.gn

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,6 @@ config("config") {
2121
cflags = [ "/WX" ] # Treat warnings as errors.
2222
}
2323
}
24-
25-
defines = []
26-
27-
if (is_debug) {
28-
defines += [ "FLUTTER_ENABLE_DIFF_CONTEXT" ]
29-
}
3024
}
3125

3226
config("export_dynamic_symbols") {

DEPS

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ vars = {
2727
'skia_git': 'https://skia.googlesource.com',
2828
# OCMock is for testing only so there is no google clone
2929
'ocmock_git': 'https://github.com/erikdoe/ocmock.git',
30-
'skia_revision': '39eccabdc3e4bdc5f3088e3fa241eba0847ed9d0',
30+
'skia_revision': 'a05d3029ac650f2662e7aba925d464c279e8d685',
3131

3232
# WARNING: DO NOT EDIT canvaskit_cipd_instance MANUALLY
3333
# See `lib/web_ui/README.md` for how to roll CanvasKit to a new version.
@@ -99,7 +99,7 @@ allowed_hosts = [
9999
]
100100

101101
deps = {
102-
'src': 'https://github.com/flutter/buildroot.git' + '@' + '2610767168166f98e7e0656893fe1a550d5f6fab',
102+
'src': 'https://github.com/flutter/buildroot.git' + '@' + 'b0c315b5e6964fd85dd87b8d0195ddb5c3b60a34',
103103

104104
# Fuchsia compatibility
105105
#
@@ -570,7 +570,7 @@ deps = {
570570
'packages': [
571571
{
572572
'package': 'flutter/android/embedding_bundle',
573-
'version': 'last_updated:2021-10-28T23:34:47-0700'
573+
'version': 'last_updated:2021-11-03T10:29:50-0700'
574574
}
575575
],
576576
'condition': 'download_android_deps',
@@ -625,7 +625,7 @@ deps = {
625625
'packages': [
626626
{
627627
'package': 'fuchsia/third_party/clang/linux-amd64',
628-
'version': 'usfKkGnw00OEgzxLzcWeF1xLd9SsPtL9BxNhxTcawLkC'
628+
'version': '5N9a1nYj5C2ueEhnn6QH-yo00rVsRHll-w33R9UAH50C'
629629
}
630630
],
631631
'condition': 'host_os == "linux"',
@@ -651,7 +651,7 @@ deps = {
651651
'packages': [
652652
{
653653
'package': 'fuchsia/sdk/core/mac-amd64',
654-
'version': 'nblJjRFDAh-l2D4eNhZfTsUsSjrbplStpRa8eBsPKkQC'
654+
'version': 'nkHhPcy3qP2eerVT3O2h2jyIDk5ad5MxY_qQHfL3ERUC'
655655
}
656656
],
657657
'condition': 'host_os == "mac"',
@@ -661,7 +661,7 @@ deps = {
661661
'packages': [
662662
{
663663
'package': 'fuchsia/sdk/core/linux-amd64',
664-
'version': 'tBL8VjITEMr2lN4iUgYcOl_MnOZ7-K0bgCFlF0_XGTEC'
664+
'version': 'm90mMA37b7TMZqFL-v-jk2obHAjYn67shKTWmulUXSQC'
665665
}
666666
],
667667
'condition': 'host_os == "linux"',

build/dart/rules.gni

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import("//build/compiled_action.gni")
88
import("//build/module_args/dart.gni")
99
import("//flutter/common/config.gni")
1010
import("//third_party/dart/build/dart/dart_action.gni")
11+
import("//third_party/dart/sdk_args.gni")
1112

1213
frontend_server_files =
1314
exec_script("//third_party/dart/tools/list_dart_files.py",
@@ -267,6 +268,13 @@ template("application_snapshot") {
267268
assert(false, "Bad snapshot_kind: '$snapshot_kind'")
268269
}
269270

271+
# Ensure the compiled appliation (e.g. frontend-server, ...) will use this
272+
# Dart SDK hash when consuming/producing kernel.
273+
#
274+
# (Instead of ensuring every user of the "application_snapshot" passes it's
275+
# own)
276+
snapshot_vm_args += [ "-Dsdk_hash=$sdk_hash" ]
277+
270278
if (flutter_prebuilt_dart_sdk) {
271279
action(target_name) {
272280
forward_variables_from(invoker,

ci/licenses_golden/licenses_flutter

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -835,6 +835,7 @@ FILE: ../../../flutter/shell/platform/android/io/flutter/embedding/android/Rende
835835
FILE: ../../../flutter/shell/platform/android/io/flutter/embedding/android/SplashScreen.java
836836
FILE: ../../../flutter/shell/platform/android/io/flutter/embedding/android/SplashScreenProvider.java
837837
FILE: ../../../flutter/shell/platform/android/io/flutter/embedding/android/TransparencyMode.java
838+
FILE: ../../../flutter/shell/platform/android/io/flutter/embedding/android/WindowInfoRepositoryCallbackAdapterWrapper.java
838839
FILE: ../../../flutter/shell/platform/android/io/flutter/embedding/engine/FlutterEngine.java
839840
FILE: ../../../flutter/shell/platform/android/io/flutter/embedding/engine/FlutterEngineCache.java
840841
FILE: ../../../flutter/shell/platform/android/io/flutter/embedding/engine/FlutterEngineConnectionRegistry.java

ci/licenses_golden/licenses_fuchsia

Lines changed: 180 additions & 141 deletions
Large diffs are not rendered by default.

ci/licenses_golden/licenses_skia

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
Signature: 786622216247c45ab35bd4e632e459dc
1+
Signature: 1a0bc799c84c3cad01c08469e8d29ed0
22

33
UNUSED LICENSES:
44

@@ -863,9 +863,6 @@ FILE: ../../../third_party/skia/infra/bots/recipe_modules/build/examples/full.ex
863863
FILE: ../../../third_party/skia/infra/bots/recipe_modules/build/examples/full.expected/Build-Debian10-Clang-x86_64-Debug-SwiftShader_TSAN.json
864864
FILE: ../../../third_party/skia/infra/bots/recipe_modules/build/examples/full.expected/Build-Debian10-Clang-x86_64-Debug-TSAN.json
865865
FILE: ../../../third_party/skia/infra/bots/recipe_modules/build/examples/full.expected/Build-Debian10-Clang-x86_64-Debug-Tidy.json
866-
FILE: ../../../third_party/skia/infra/bots/recipe_modules/build/examples/full.expected/Build-Debian10-Clang-x86_64-Debug-V1andV2.json
867-
FILE: ../../../third_party/skia/infra/bots/recipe_modules/build/examples/full.expected/Build-Debian10-Clang-x86_64-Debug-V1only.json
868-
FILE: ../../../third_party/skia/infra/bots/recipe_modules/build/examples/full.expected/Build-Debian10-Clang-x86_64-Debug-V2only.json
869866
FILE: ../../../third_party/skia/infra/bots/recipe_modules/build/examples/full.expected/Build-Debian10-Clang-x86_64-Debug-Wuffs.json
870867
FILE: ../../../third_party/skia/infra/bots/recipe_modules/build/examples/full.expected/Build-Debian10-Clang-x86_64-Release-ANGLE.json
871868
FILE: ../../../third_party/skia/infra/bots/recipe_modules/build/examples/full.expected/Build-Debian10-Clang-x86_64-Release-ASAN.json
@@ -4038,7 +4035,6 @@ FILE: ../../../third_party/skia/fuzz/FuzzSkParagraph.cpp
40384035
FILE: ../../../third_party/skia/gm/3d.cpp
40394036
FILE: ../../../third_party/skia/gm/bc1_transparency.cpp
40404037
FILE: ../../../third_party/skia/gm/bicubic.cpp
4041-
FILE: ../../../third_party/skia/gm/colrv1.cpp
40424038
FILE: ../../../third_party/skia/gm/compressed_textures.cpp
40434039
FILE: ../../../third_party/skia/gm/crbug_1073670.cpp
40444040
FILE: ../../../third_party/skia/gm/crbug_1086705.cpp
@@ -5401,6 +5397,7 @@ FILE: ../../../third_party/skia/experimental/graphite/src/mtl/MtlUtils.mm
54015397
FILE: ../../../third_party/skia/fuzz/FuzzDDLThreading.cpp
54025398
FILE: ../../../third_party/skia/gm/aarecteffect.cpp
54035399
FILE: ../../../third_party/skia/gm/colorspace.cpp
5400+
FILE: ../../../third_party/skia/gm/colrv1.cpp
54045401
FILE: ../../../third_party/skia/gm/drawglyphs.cpp
54055402
FILE: ../../../third_party/skia/gm/largeclippedpath.cpp
54065403
FILE: ../../../third_party/skia/gm/skbug_12212.cpp
@@ -5431,6 +5428,7 @@ FILE: ../../../third_party/skia/modules/androidkit/src/Utils.cpp
54315428
FILE: ../../../third_party/skia/modules/androidkit/src/Utils.h
54325429
FILE: ../../../third_party/skia/modules/skottie/src/effects/DirectionalBlur.cpp
54335430
FILE: ../../../third_party/skia/modules/skottie/src/effects/FractalNoiseEffect.cpp
5431+
FILE: ../../../third_party/skia/modules/skottie/src/effects/SkSLEffect.cpp
54345432
FILE: ../../../third_party/skia/modules/skottie/src/effects/SphereEffect.cpp
54355433
FILE: ../../../third_party/skia/modules/skottie/src/effects/ThresholdEffect.cpp
54365434
FILE: ../../../third_party/skia/modules/skunicode/src/SkUnicode_icu.h

flow/compositor_context.cc

Lines changed: 49 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,45 @@
44

55
#include "flutter/flow/compositor_context.h"
66

7+
#include <optional>
78
#include "flutter/flow/layers/layer_tree.h"
89
#include "third_party/skia/include/core/SkCanvas.h"
910

1011
namespace flutter {
1112

13+
std::optional<SkRect> FrameDamage::ComputeClipRect(
14+
flutter::LayerTree& layer_tree) {
15+
if (layer_tree.root_layer()) {
16+
PaintRegionMap empty_paint_region_map;
17+
DiffContext context(layer_tree.frame_size(),
18+
layer_tree.device_pixel_ratio(),
19+
layer_tree.paint_region_map(),
20+
prev_layer_tree_ ? prev_layer_tree_->paint_region_map()
21+
: empty_paint_region_map);
22+
context.PushCullRect(SkRect::MakeIWH(layer_tree.frame_size().width(),
23+
layer_tree.frame_size().height()));
24+
{
25+
DiffContext::AutoSubtreeRestore subtree(&context);
26+
const Layer* prev_root_layer = nullptr;
27+
if (!prev_layer_tree_ ||
28+
prev_layer_tree_->frame_size() != layer_tree.frame_size()) {
29+
// If there is no previous layer tree assume the entire frame must be
30+
// repainted.
31+
context.MarkSubtreeDirty(SkRect::MakeIWH(
32+
layer_tree.frame_size().width(), layer_tree.frame_size().height()));
33+
} else {
34+
prev_root_layer = prev_layer_tree_->root_layer();
35+
}
36+
layer_tree.root_layer()->Diff(&context, prev_root_layer);
37+
}
38+
39+
damage_ = context.ComputeDamage(additional_damage_);
40+
return SkRect::Make(damage_->buffer_damage);
41+
} else {
42+
return std::nullopt;
43+
}
44+
}
45+
1246
CompositorContext::CompositorContext(fml::Milliseconds frame_budget)
1347
: raster_time_(frame_budget), ui_time_(frame_budget) {}
1448

@@ -68,9 +102,15 @@ CompositorContext::ScopedFrame::~ScopedFrame() {
68102

69103
RasterStatus CompositorContext::ScopedFrame::Raster(
70104
flutter::LayerTree& layer_tree,
71-
bool ignore_raster_cache) {
105+
bool ignore_raster_cache,
106+
FrameDamage* frame_damage) {
72107
TRACE_EVENT0("flutter", "CompositorContext::ScopedFrame::Raster");
73-
bool root_needs_readback = layer_tree.Preroll(*this, ignore_raster_cache);
108+
109+
std::optional<SkRect> clip_rect =
110+
frame_damage ? frame_damage->ComputeClipRect(layer_tree) : std::nullopt;
111+
112+
bool root_needs_readback = layer_tree.Preroll(
113+
*this, ignore_raster_cache, clip_rect ? *clip_rect : kGiantRect);
74114
bool needs_save_layer = root_needs_readback && !surface_supports_readback();
75115
PostPrerollResult post_preroll_result = PostPrerollResult::kSuccess;
76116
if (view_embedder_ && raster_thread_merger_) {
@@ -84,9 +124,16 @@ RasterStatus CompositorContext::ScopedFrame::Raster(
84124
if (post_preroll_result == PostPrerollResult::kSkipAndRetryFrame) {
85125
return RasterStatus::kSkipAndRetry;
86126
}
127+
128+
SkAutoCanvasRestore restore(canvas(), clip_rect.has_value());
129+
87130
// Clearing canvas after preroll reduces one render target switch when preroll
88131
// paints some raster cache.
89132
if (canvas()) {
133+
if (clip_rect) {
134+
canvas()->clipRect(*clip_rect);
135+
}
136+
90137
if (needs_save_layer) {
91138
TRACE_EVENT0("flutter", "Canvas::saveLayer");
92139
SkRect bounds = SkRect::Make(layer_tree.frame_size());

flow/compositor_context.h

Lines changed: 40 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
#include <string>
1010

1111
#include "flutter/common/graphics/texture.h"
12+
#include "flutter/flow/diff_context.h"
1213
#include "flutter/flow/embedded_views.h"
1314
#include "flutter/flow/instrumentation.h"
1415
#include "flutter/flow/raster_cache.h"
@@ -54,6 +55,43 @@ enum class RasterStatus {
5455
kYielded,
5556
};
5657

58+
class FrameDamage {
59+
public:
60+
// Sets previous layer tree for calculating frame damage. If not set, entire
61+
// frame will be repainted.
62+
void SetPreviousLayerTree(const LayerTree* prev_layer_tree) {
63+
prev_layer_tree_ = prev_layer_tree;
64+
}
65+
66+
// Adds additional damage (accumulated for double / triple buffering).
67+
// This is area that will be repainted alongside any changed part.
68+
void AddAdditonalDamage(const SkIRect& damage) {
69+
additional_damage_.join(damage);
70+
}
71+
72+
// Calculates clip rect for current rasterization. This is diff of layer tree
73+
// and previous layer tree + any additional provideddamage.
74+
// If previous layer tree is not specified, clip rect will be nulloptional,
75+
// but the paint region of layer_tree will be calculated so that it can be
76+
// used for diffing of subsequent frames.
77+
std::optional<SkRect> ComputeClipRect(flutter::LayerTree& layer_tree);
78+
79+
// See Damage::frame_damage.
80+
std::optional<SkIRect> GetFrameDamage() const {
81+
return damage_ ? std::make_optional(damage_->frame_damage) : std::nullopt;
82+
}
83+
84+
// See Damage::buffer_damage.
85+
std::optional<SkIRect> GetBufferDamage() {
86+
return damage_ ? std::make_optional(damage_->buffer_damage) : std::nullopt;
87+
}
88+
89+
private:
90+
SkIRect additional_damage_ = SkIRect::MakeEmpty();
91+
std::optional<Damage> damage_;
92+
const LayerTree* prev_layer_tree_ = nullptr;
93+
};
94+
5795
class CompositorContext {
5896
public:
5997
class ScopedFrame {
@@ -84,7 +122,8 @@ class CompositorContext {
84122
GrDirectContext* gr_context() const { return gr_context_; }
85123

86124
virtual RasterStatus Raster(LayerTree& layer_tree,
87-
bool ignore_raster_cache);
125+
bool ignore_raster_cache,
126+
FrameDamage* frame_damage);
88127

89128
private:
90129
CompositorContext& context_;

flow/diff_context.cc

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@
77

88
namespace flutter {
99

10-
#ifdef FLUTTER_ENABLE_DIFF_CONTEXT
11-
1210
DiffContext::DiffContext(SkISize frame_size,
1311
double frame_device_pixel_ratio,
1412
PaintRegionMap& this_frame_paint_region_map,
@@ -23,6 +21,7 @@ void DiffContext::BeginSubtree() {
2321
state_stack_.push_back(state_);
2422
state_.rect_index_ = rects_->size();
2523
state_.has_filter_bounds_adjustment = false;
24+
state_.has_texture = false;
2625
if (state_.transform_override) {
2726
state_.transform = *state_.transform_override;
2827
state_.transform_override = std::nullopt;
@@ -42,7 +41,8 @@ DiffContext::State::State()
4241
: dirty(false),
4342
cull_rect(kGiantRect),
4443
rect_index_(0),
45-
has_filter_bounds_adjustment(false) {}
44+
has_filter_bounds_adjustment(false),
45+
has_texture(false) {}
4646

4747
void DiffContext::PushTransform(const SkMatrix& transform) {
4848
state_.transform.preConcat(transform);
@@ -118,6 +118,12 @@ void DiffContext::MarkSubtreeDirty(const PaintRegion& previous_paint_region) {
118118
state_.dirty = true;
119119
}
120120

121+
void DiffContext::MarkSubtreeDirty(const SkRect& previous_paint_region) {
122+
FML_DCHECK(!IsSubtreeDirty());
123+
AddDamage(previous_paint_region);
124+
state_.dirty = true;
125+
}
126+
121127
void DiffContext::AddLayerBounds(const SkRect& rect) {
122128
// During painting we cull based on non-overriden transform and then
123129
// override the transform right before paint. Do the same thing here to get
@@ -136,6 +142,16 @@ void DiffContext::AddLayerBounds(const SkRect& rect) {
136142
}
137143
}
138144

145+
void DiffContext::MarkSubtreeHasTextureLayer() {
146+
// Set the has_texture flag on current state and all parent states. That
147+
// way we'll know that we can't skip diff for retained layers because
148+
// they contain a TextureLayer.
149+
for (auto& state : state_stack_) {
150+
state.has_texture = true;
151+
}
152+
state_.has_texture = true;
153+
}
154+
139155
void DiffContext::AddExistingPaintRegion(const PaintRegion& region) {
140156
// Adding paint region for retained layer implies that current subtree is not
141157
// dirty, so we know, for example, that the inherited transforms must match
@@ -158,7 +174,8 @@ PaintRegion DiffContext::CurrentSubtreeRegion() const {
158174
bool has_readback = std::any_of(
159175
readbacks_.begin(), readbacks_.end(),
160176
[&](const Readback& r) { return r.position >= state_.rect_index_; });
161-
return PaintRegion(rects_, state_.rect_index_, rects_->size(), has_readback);
177+
return PaintRegion(rects_, state_.rect_index_, rects_->size(), has_readback,
178+
state_.has_texture);
162179
}
163180

164181
void DiffContext::AddDamage(const PaintRegion& damage) {
@@ -200,6 +217,4 @@ void DiffContext::Statistics::LogStatistics() {
200217
#endif // !FLUTTER_RELEASE
201218
}
202219

203-
#endif // FLUTTER_ENABLE_DIFF_CONTEXT
204-
205220
} // namespace flutter

flow/diff_context.h

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,6 @@
1717

1818
namespace flutter {
1919

20-
#ifdef FLUTTER_ENABLE_DIFF_CONTEXT
21-
2220
class Layer;
2321

2422
// Represents area that needs to be updated in front buffer (frame_damage) and
@@ -102,9 +100,14 @@ class DiffContext {
102100
// added to damage.
103101
void MarkSubtreeDirty(
104102
const PaintRegion& previous_paint_region = PaintRegion());
103+
void MarkSubtreeDirty(const SkRect& previous_paint_region);
105104

106105
bool IsSubtreeDirty() const { return state_.dirty; }
107106

107+
// Marks that current subtree contains a TextureLayer. This is needed to
108+
// ensure that we'll Diff the TextureLayer even if inside retained layer.
109+
void MarkSubtreeHasTextureLayer();
110+
108111
// Add layer bounds to current paint region; rect is in "local" (layer)
109112
// coordinates.
110113
void AddLayerBounds(const SkRect& rect);
@@ -204,6 +207,9 @@ class DiffContext {
204207
// Whether this subtree has filter bounds adjustment function. If so,
205208
// it will need to be removed from stack when subtree is closed.
206209
bool has_filter_bounds_adjustment;
210+
211+
// Whether there is a texture layer in this subtree.
212+
bool has_texture;
207213
};
208214

209215
std::shared_ptr<std::vector<SkRect>> rects_;
@@ -237,8 +243,6 @@ class DiffContext {
237243
Statistics statistics_;
238244
};
239245

240-
#endif // FLUTTER_ENABLE_DIFF_CONTEXT
241-
242246
} // namespace flutter
243247

244248
#endif // FLUTTER_FLOW_DIFF_CONTEXT_H_

0 commit comments

Comments
 (0)