| 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_manager.h" | 5 #include "pdf/paint_manager.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "ppapi/c/pp_errors.h" | 10 #include "ppapi/c/pp_errors.h" |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 90 has_pending_resize_ = true; | 90 has_pending_resize_ = true; |
| 91 pending_size_ = new_size; | 91 pending_size_ = new_size; |
| 92 pending_device_scale_ = device_scale; | 92 pending_device_scale_ = device_scale; |
| 93 | 93 |
| 94 view_size_changed_waiting_for_paint_ = true; | 94 view_size_changed_waiting_for_paint_ = true; |
| 95 | 95 |
| 96 Invalidate(); | 96 Invalidate(); |
| 97 } | 97 } |
| 98 | 98 |
| 99 void PaintManager::Invalidate() { | 99 void PaintManager::Invalidate() { |
| 100 // You must call SetSize before using. | 100 if (graphics_.is_null() && !has_pending_resize_) |
| 101 DCHECK(!graphics_.is_null() || has_pending_resize_); | 101 return; |
| 102 | 102 |
| 103 EnsureCallbackPending(); | 103 EnsureCallbackPending(); |
| 104 aggregator_.InvalidateRect(pp::Rect(GetEffectiveSize())); | 104 aggregator_.InvalidateRect(pp::Rect(GetEffectiveSize())); |
| 105 } | 105 } |
| 106 | 106 |
| 107 void PaintManager::InvalidateRect(const pp::Rect& rect) { | 107 void PaintManager::InvalidateRect(const pp::Rect& rect) { |
| 108 DCHECK(!in_paint_); | 108 DCHECK(!in_paint_); |
| 109 | 109 |
| 110 // You must call SetSize before using. | 110 if (graphics_.is_null() && !has_pending_resize_) |
| 111 DCHECK(!graphics_.is_null() || has_pending_resize_); | 111 return; |
| 112 | 112 |
| 113 // Clip the rect to the device area. | 113 // Clip the rect to the device area. |
| 114 pp::Rect clipped_rect = rect.Intersect(pp::Rect(GetEffectiveSize())); | 114 pp::Rect clipped_rect = rect.Intersect(pp::Rect(GetEffectiveSize())); |
| 115 if (clipped_rect.IsEmpty()) | 115 if (clipped_rect.IsEmpty()) |
| 116 return; // Nothing to do. | 116 return; // Nothing to do. |
| 117 | 117 |
| 118 EnsureCallbackPending(); | 118 EnsureCallbackPending(); |
| 119 aggregator_.InvalidateRect(clipped_rect); | 119 aggregator_.InvalidateRect(clipped_rect); |
| 120 } | 120 } |
| 121 | 121 |
| 122 void PaintManager::ScrollRect(const pp::Rect& clip_rect, | 122 void PaintManager::ScrollRect(const pp::Rect& clip_rect, |
| 123 const pp::Point& amount) { | 123 const pp::Point& amount) { |
| 124 DCHECK(!in_paint_); | 124 DCHECK(!in_paint_); |
| 125 | 125 |
| 126 // You must call SetSize before using. | 126 if (graphics_.is_null() && !has_pending_resize_) |
| 127 DCHECK(!graphics_.is_null() || has_pending_resize_); | 127 return; |
| 128 | 128 |
| 129 EnsureCallbackPending(); | 129 EnsureCallbackPending(); |
| 130 | 130 |
| 131 aggregator_.ScrollRect(clip_rect, amount); | 131 aggregator_.ScrollRect(clip_rect, amount); |
| 132 } | 132 } |
| 133 | 133 |
| 134 pp::Size PaintManager::GetEffectiveSize() const { | 134 pp::Size PaintManager::GetEffectiveSize() const { |
| 135 return has_pending_resize_ ? pending_size_ : plugin_size_; | 135 return has_pending_resize_ ? pending_size_ : plugin_size_; |
| 136 } | 136 } |
| 137 | 137 |
| (...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 293 DCHECK(manual_callback_pending_); | 293 DCHECK(manual_callback_pending_); |
| 294 manual_callback_pending_ = false; | 294 manual_callback_pending_ = false; |
| 295 | 295 |
| 296 // Just because we have a manual callback doesn't mean there are actually any | 296 // Just because we have a manual callback doesn't mean there are actually any |
| 297 // invalid regions. Even though we only schedule this callback when something | 297 // invalid regions. Even though we only schedule this callback when something |
| 298 // is pending, a Flush callback could have come in before this callback was | 298 // is pending, a Flush callback could have come in before this callback was |
| 299 // executed and that could have cleared the queue. | 299 // executed and that could have cleared the queue. |
| 300 if (aggregator_.HasPendingUpdate()) | 300 if (aggregator_.HasPendingUpdate()) |
| 301 DoPaint(); | 301 DoPaint(); |
| 302 } | 302 } |
| OLD | NEW |