OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "webkit/plugins/ppapi/ppb_graphics_2d_impl.h" | 5 #include "webkit/plugins/ppapi/ppb_graphics_2d_impl.h" |
6 | 6 |
7 #include <iterator> | 7 #include <iterator> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/debug/trace_event.h" | 10 #include "base/debug/trace_event.h" |
(...skipping 326 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
337 case QueuedOperation::SCROLL: | 337 case QueuedOperation::SCROLL: |
338 ExecuteScroll(operation.scroll_clip_rect, | 338 ExecuteScroll(operation.scroll_clip_rect, |
339 operation.scroll_dx, operation.scroll_dy, | 339 operation.scroll_dx, operation.scroll_dy, |
340 &op_rect); | 340 &op_rect); |
341 break; | 341 break; |
342 case QueuedOperation::REPLACE: | 342 case QueuedOperation::REPLACE: |
343 ExecuteReplaceContents(operation.replace_image, &op_rect); | 343 ExecuteReplaceContents(operation.replace_image, &op_rect); |
344 break; | 344 break; |
345 } | 345 } |
346 | 346 |
347 // We need the rect to be in terms of the current clip rect of the plugin | 347 // For correctness with accelerated compositing, we must issue an invalidate |
348 // since that's what will actually be painted. If we issue an invalidate | 348 // on the full op_rect even if it is partially or completely off-screen. |
349 // for a clipped-out region, WebKit will do nothing and we won't get any | 349 // However, if we issue an invalidate for a clipped-out region, WebKit will |
350 // ViewWillInitiatePaint/ViewFlushedPaint calls, leaving our callback | 350 // do nothing and we won't get any ViewWillInitiatePaint/ViewFlushedPaint |
351 // stranded. | 351 // calls, leaving our callback stranded. So we still need to check whether |
352 gfx::Rect visible_changed_rect; | 352 // the repainted area is visible to determine how to deal with the callback. |
353 if (bound_instance_ && !op_rect.IsEmpty()) | 353 if (bound_instance_) { |
354 visible_changed_rect =PP_ToGfxRect(bound_instance_->view_data().clip_rect) . | |
355 Intersect(op_rect); | |
356 | 354 |
357 if (bound_instance_ && !visible_changed_rect.IsEmpty()) { | 355 // Set |nothing_visible| to false if the change overlaps the visible area. |
356 if (!op_rect.IsEmpty()) { | |
357 gfx::Rect visible_changed_rect = | |
358 PP_ToGfxRect(bound_instance_->view_data().clip_rect). | |
359 Intersect(op_rect); | |
360 | |
361 if (!visible_changed_rect.IsEmpty()) | |
362 nothing_visible = false; | |
363 } | |
364 | |
365 // Notify the plugin of the entire change (op_rect), even if it is | |
Wez
2012/04/26 21:13:29
Doesn't this block want to be inside the !op_rect.
shawnsingh
2012/04/26 22:35:50
Yes - thanks. That should also simplify the ugly
| |
366 // partially or completely off-screen. | |
358 if (operation.type == QueuedOperation::SCROLL) { | 367 if (operation.type == QueuedOperation::SCROLL) { |
359 bound_instance_->ScrollRect(operation.scroll_dx, operation.scroll_dy, | 368 bound_instance_->ScrollRect(operation.scroll_dx, operation.scroll_dy, |
360 visible_changed_rect); | 369 op_rect); |
361 } else { | 370 } else { |
362 bound_instance_->InvalidateRect(visible_changed_rect); | 371 bound_instance_->InvalidateRect(op_rect); |
363 } | 372 } |
364 nothing_visible = false; | |
365 } | 373 } |
366 } | 374 } |
367 queued_operations_.clear(); | 375 queued_operations_.clear(); |
368 | 376 |
369 if (nothing_visible) { | 377 if (nothing_visible) { |
370 // There's nothing visible to invalidate so just schedule the callback to | 378 // There's nothing visible to invalidate so just schedule the callback to |
371 // execute in the next round of the message loop. | 379 // execute in the next round of the message loop. |
372 ScheduleOffscreenCallback(FlushCallbackData( | 380 ScheduleOffscreenCallback(FlushCallbackData( |
373 scoped_refptr<TrackedCallback>(new TrackedCallback(this, callback)))); | 381 scoped_refptr<TrackedCallback>(new TrackedCallback(this, callback)))); |
374 } else { | 382 } else { |
(...skipping 305 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
680 } | 688 } |
681 | 689 |
682 bool PPB_Graphics2D_Impl::HasPendingFlush() const { | 690 bool PPB_Graphics2D_Impl::HasPendingFlush() const { |
683 return !unpainted_flush_callback_.is_null() || | 691 return !unpainted_flush_callback_.is_null() || |
684 !painted_flush_callback_.is_null() || | 692 !painted_flush_callback_.is_null() || |
685 offscreen_flush_pending_; | 693 offscreen_flush_pending_; |
686 } | 694 } |
687 | 695 |
688 } // namespace ppapi | 696 } // namespace ppapi |
689 } // namespace webkit | 697 } // namespace webkit |
OLD | NEW |