28 {
29 if (context->IsSubtreeDirty()) {
30 for (auto& layer : layers_) {
31 layer->Diff(context, nullptr);
32 }
33 return;
34 }
36
37 const auto& prev_layers = old_layer->layers_;
38
39
40 int new_children_top = 0;
41 int old_children_top = 0;
42
43
44 int new_children_bottom = layers_.size() - 1;
45 int old_children_bottom = prev_layers.size() - 1;
46
47 while ((old_children_top <= old_children_bottom) &&
48 (new_children_top <= new_children_bottom)) {
50 context, prev_layers[old_children_top].
get())) {
51 break;
52 }
53 ++new_children_top;
54 ++old_children_top;
55 }
56
57 while ((old_children_top <= old_children_bottom) &&
58 (new_children_top <= new_children_bottom)) {
60 context, prev_layers[old_children_bottom].
get())) {
61 break;
62 }
63 --new_children_bottom;
64 --old_children_bottom;
65 }
66
67
68 for (int i = old_children_top; i <= old_children_bottom; ++i) {
69 auto layer = prev_layers[i];
70 context->AddDamage(context->GetOldLayerPaintRegion(layer.get()));
71 }
72
73 for (int i = 0; i < static_cast<int>(layers_.size()); ++i) {
74 if (i < new_children_top || i > new_children_bottom) {
75 int i_prev =
76 i < new_children_top ? i : prev_layers.size() - (layers_.size() - i);
77 auto layer = layers_[i];
78 auto prev_layer = prev_layers[i_prev];
79 auto paint_region = context->GetOldLayerPaintRegion(prev_layer.get());
80 if (layer == prev_layer && !paint_region.has_readback() &&
81 !paint_region.has_texture()) {
82
83
84
85
86
87
88 context->AddExistingPaintRegion(paint_region);
89
90
91
92
93 layer->PreservePaintRegion(context);
94 } else {
95 layer->Diff(context, prev_layer.get());
96 }
97 } else {
98 DiffContext::AutoSubtreeRestore subtree(context);
99 context->MarkSubtreeDirty();
100 auto layer = layers_[i];
101 layer->Diff(context, nullptr);
102 }
103 }
104}
virtual bool IsReplacing(DiffContext *context, const Layer *old_layer) const
#define FML_DCHECK(condition)
const myers::Point & get(const myers::Segment &)