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 "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/logging.h" | 9 #include "base/logging.h" |
10 #include "base/message_loop.h" | 10 #include "base/message_loop.h" |
(...skipping 441 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
452 if (bound_instance_ == new_instance) | 452 if (bound_instance_ == new_instance) |
453 return true; // Rebinding the same device, nothing to do. | 453 return true; // Rebinding the same device, nothing to do. |
454 if (bound_instance_ && new_instance) | 454 if (bound_instance_ && new_instance) |
455 return false; // Can't change a bound device. | 455 return false; // Can't change a bound device. |
456 | 456 |
457 if (!new_instance) { | 457 if (!new_instance) { |
458 // When the device is detached, we'll not get any more paint callbacks so | 458 // When the device is detached, we'll not get any more paint callbacks so |
459 // we need to clear the list, but we still want to issue any pending | 459 // we need to clear the list, but we still want to issue any pending |
460 // callbacks to the plugin. | 460 // callbacks to the plugin. |
461 if (!unpainted_flush_callback_.is_null()) { | 461 if (!unpainted_flush_callback_.is_null()) { |
462 ScheduleOffscreenCallback(unpainted_flush_callback_); | 462 FlushCallbackData callback; |
463 std::swap(callback, unpainted_flush_callback_); | |
463 unpainted_flush_callback_.Clear(); | 464 unpainted_flush_callback_.Clear(); |
viettrungluu
2011/03/08 00:06:01
Is this Clear() really needed?
piman
2011/03/08 00:55:30
Done.
| |
465 ScheduleOffscreenCallback(callback); | |
464 } | 466 } |
465 if (!painted_flush_callback_.is_null()) { | 467 if (!painted_flush_callback_.is_null()) { |
466 ScheduleOffscreenCallback(painted_flush_callback_); | 468 FlushCallbackData callback; |
469 std::swap(callback, painted_flush_callback_); | |
467 painted_flush_callback_.Clear(); | 470 painted_flush_callback_.Clear(); |
viettrungluu
2011/03/08 00:06:01
"
piman
2011/03/08 00:55:30
Done.
| |
471 ScheduleOffscreenCallback(callback); | |
468 } | 472 } |
469 } else if (flushed_any_data_) { | 473 } else if (flushed_any_data_) { |
470 // Only schedule a paint if this backing store has had any data flushed to | 474 // Only schedule a paint if this backing store has had any data flushed to |
471 // it. This is an optimization. A "normal" plugin will first allocated a | 475 // it. This is an optimization. A "normal" plugin will first allocated a |
472 // backing store, bind it, and then execute their normal painting and | 476 // backing store, bind it, and then execute their normal painting and |
473 // update loop. If binding a device always invalidated, it would mean we | 477 // update loop. If binding a device always invalidated, it would mean we |
474 // would get one paint for the bind, and one for the first time the plugin | 478 // would get one paint for the bind, and one for the first time the plugin |
475 // actually painted something. By not bothering to schedule an invalidate | 479 // actually painted something. By not bothering to schedule an invalidate |
476 // when an empty device is initially bound, we can save an extra paint for | 480 // when an empty device is initially bound, we can save an extra paint for |
477 // many plugins during the critical page initialization phase. | 481 // many plugins during the critical page initialization phase. |
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
672 | 676 |
673 bool PPB_Graphics2D_Impl::HasPendingFlush() const { | 677 bool PPB_Graphics2D_Impl::HasPendingFlush() const { |
674 return !unpainted_flush_callback_.is_null() || | 678 return !unpainted_flush_callback_.is_null() || |
675 !painted_flush_callback_.is_null() || | 679 !painted_flush_callback_.is_null() || |
676 offscreen_flush_pending_; | 680 offscreen_flush_pending_; |
677 } | 681 } |
678 | 682 |
679 } // namespace ppapi | 683 } // namespace ppapi |
680 } // namespace webkit | 684 } // namespace webkit |
681 | 685 |
OLD | NEW |