@@ -67,8 +67,33 @@ SkRect DiffContext::ApplyFilterBoundsAdjustment(SkRect rect) const {
6767 return rect;
6868}
6969
70- Damage DiffContext::ComputeDamage (
71- const SkIRect& accumulated_buffer_damage) const {
70+ void DiffContext::AlignRect (SkIRect& rect,
71+ int horizontal_alignment,
72+ int vertical_alignment) const {
73+ auto top = rect.top ();
74+ auto left = rect.left ();
75+ auto right = rect.right ();
76+ auto bottom = rect.bottom ();
77+ if (top % vertical_alignment != 0 ) {
78+ top -= top % vertical_alignment;
79+ }
80+ if (left % horizontal_alignment != 0 ) {
81+ left -= left % horizontal_alignment;
82+ }
83+ if (right % horizontal_alignment != 0 ) {
84+ right += horizontal_alignment - right % horizontal_alignment;
85+ }
86+ if (bottom % horizontal_alignment != 0 ) {
87+ bottom += horizontal_alignment - bottom % horizontal_alignment;
88+ }
89+ right = std::min (right, frame_size_.width ());
90+ bottom = std::min (bottom, frame_size_.height ());
91+ rect = SkIRect::MakeLTRB (left, top, right, bottom);
92+ }
93+
94+ Damage DiffContext::ComputeDamage (const SkIRect& accumulated_buffer_damage,
95+ int horizontal_clip_alignment,
96+ int vertical_clip_alignment) const {
7297 SkRect buffer_damage = SkRect::Make (accumulated_buffer_damage);
7398 buffer_damage.join (damage_);
7499 SkRect frame_damage (damage_);
@@ -90,6 +115,13 @@ Damage DiffContext::ComputeDamage(
90115 SkIRect frame_clip = SkIRect::MakeSize (frame_size_);
91116 res.buffer_damage .intersect (frame_clip);
92117 res.frame_damage .intersect (frame_clip);
118+
119+ if (horizontal_clip_alignment > 1 || vertical_clip_alignment > 1 ) {
120+ AlignRect (res.buffer_damage , horizontal_clip_alignment,
121+ vertical_clip_alignment);
122+ AlignRect (res.frame_damage , horizontal_clip_alignment,
123+ vertical_clip_alignment);
124+ }
93125 return res;
94126}
95127
0 commit comments