| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "pdf/paint_aggregator.h" | 5 #include "pdf/paint_aggregator.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <algorithm> | 10 #include <algorithm> |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 98 // Convert the internal paint update to the external one, which includes a | 98 // Convert the internal paint update to the external one, which includes a |
| 99 // bit more precomputed info for the caller. | 99 // bit more precomputed info for the caller. |
| 100 PaintUpdate ret; | 100 PaintUpdate ret; |
| 101 ret.scroll_delta = update_.scroll_delta; | 101 ret.scroll_delta = update_.scroll_delta; |
| 102 ret.scroll_rect = update_.scroll_rect; | 102 ret.scroll_rect = update_.scroll_rect; |
| 103 ret.has_scroll = ret.scroll_delta.x() != 0 || ret.scroll_delta.y() != 0; | 103 ret.has_scroll = ret.scroll_delta.x() != 0 || ret.scroll_delta.y() != 0; |
| 104 | 104 |
| 105 // Include the scroll damage (if any) in the paint rects. | 105 // Include the scroll damage (if any) in the paint rects. |
| 106 // Code invalidates damaged rect here, it pick it up from the list of paint | 106 // Code invalidates damaged rect here, it pick it up from the list of paint |
| 107 // rects in the next block. | 107 // rects in the next block. |
| 108 if (ret.has_scroll && !update_.synthesized_scroll_damage_rect_) { | 108 if (ret.has_scroll && !update_.synthesized_scroll_damage_rect_) { |
| 109 update_.synthesized_scroll_damage_rect_ = true; | 109 update_.synthesized_scroll_damage_rect_ = true; |
| 110 pp::Rect scroll_damage = update_.GetScrollDamage(); | 110 pp::Rect scroll_damage = update_.GetScrollDamage(); |
| 111 InvalidateRectInternal(scroll_damage, false); | 111 InvalidateRectInternal(scroll_damage, false); |
| 112 } | 112 } |
| 113 | 113 |
| 114 ret.paint_rects.reserve(update_.paint_rects.size() + 1); | 114 ret.paint_rects.reserve(update_.paint_rects.size() + 1); |
| 115 for (size_t i = 0; i < update_.paint_rects.size(); i++) | 115 ret.paint_rects.insert(ret.paint_rects.end(), update_.paint_rects.begin(), |
| 116 ret.paint_rects.push_back(update_.paint_rects[i]); | 116 update_.paint_rects.end()); |
| 117 | 117 |
| 118 return ret; | 118 return ret; |
| 119 } | 119 } |
| 120 | 120 |
| 121 void PaintAggregator::SetIntermediateResults( | 121 void PaintAggregator::SetIntermediateResults( |
| 122 const std::vector<ReadyRect>& ready, | 122 const std::vector<ReadyRect>& ready, |
| 123 const std::vector<pp::Rect>& pending) { | 123 const std::vector<pp::Rect>& pending) { |
| 124 update_.ready_rects.insert( | 124 update_.ready_rects.insert( |
| 125 update_.ready_rects.end(), ready.begin(), ready.end()); | 125 update_.ready_rects.end(), ready.begin(), ready.end()); |
| 126 update_.paint_rects = pending; | 126 update_.paint_rects = pending; |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 210 | 210 |
| 211 update_.paint_rects[i] = ScrollPaintRect(intersection, amount); | 211 update_.paint_rects[i] = ScrollPaintRect(intersection, amount); |
| 212 | 212 |
| 213 // The rect may have been scrolled out of view. | 213 // The rect may have been scrolled out of view. |
| 214 if (update_.paint_rects[i].IsEmpty()) { | 214 if (update_.paint_rects[i].IsEmpty()) { |
| 215 update_.paint_rects.erase(update_.paint_rects.begin() + i); | 215 update_.paint_rects.erase(update_.paint_rects.begin() + i); |
| 216 i--; | 216 i--; |
| 217 } | 217 } |
| 218 } | 218 } |
| 219 | 219 |
| 220 for (size_t i = 0; i < leftover_rects.size(); ++i) | 220 for (const auto& leftover_rect : leftover_rects) |
| 221 InvalidateRectInternal(leftover_rects[i], false); | 221 InvalidateRectInternal(leftover_rect, false); |
| 222 | 222 |
| 223 for (size_t i = 0; i < update_.ready_rects.size(); ++i) { | 223 for (auto& update_rect : update_.ready_rects) { |
| 224 if (update_.scroll_rect.Contains(update_.ready_rects[i].rect)) { | 224 if (update_.scroll_rect.Contains(update_rect.rect)) |
| 225 update_.ready_rects[i].rect = | 225 update_rect.rect = ScrollPaintRect(update_rect.rect, amount); |
| 226 ScrollPaintRect(update_.ready_rects[i].rect, amount); | |
| 227 } | |
| 228 } | 226 } |
| 229 | 227 |
| 230 if (update_.synthesized_scroll_damage_rect_) { | 228 if (update_.synthesized_scroll_damage_rect_) { |
| 231 pp::Rect damage = update_.GetScrollDamage(); | 229 pp::Rect damage = update_.GetScrollDamage(); |
| 232 InvalidateRect(damage); | 230 InvalidateRect(damage); |
| 233 } | 231 } |
| 234 } | 232 } |
| 235 | 233 |
| 236 pp::Rect PaintAggregator::ScrollPaintRect(const pp::Rect& paint_rect, | 234 pp::Rect PaintAggregator::ScrollPaintRect(const pp::Rect& paint_rect, |
| 237 const pp::Point& amount) const { | 235 const pp::Point& amount) const { |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 284 } | 282 } |
| 285 | 283 |
| 286 // If the new paint overlaps with a scroll, then also invalidate the rect in | 284 // If the new paint overlaps with a scroll, then also invalidate the rect in |
| 287 // its new position. | 285 // its new position. |
| 288 if (check_scroll && | 286 if (check_scroll && |
| 289 !update_.scroll_rect.IsEmpty() && | 287 !update_.scroll_rect.IsEmpty() && |
| 290 update_.scroll_rect.Intersects(rect)) { | 288 update_.scroll_rect.Intersects(rect)) { |
| 291 InvalidateRectInternal(ScrollPaintRect(rect, update_.scroll_delta), false); | 289 InvalidateRectInternal(ScrollPaintRect(rect, update_.scroll_delta), false); |
| 292 } | 290 } |
| 293 } | 291 } |
| OLD | NEW |