| 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 unpainted_flush_callback_.Clear(); | 463 std::swap(callback, unpainted_flush_callback_); |
| 464 ScheduleOffscreenCallback(callback); |
| 464 } | 465 } |
| 465 if (!painted_flush_callback_.is_null()) { | 466 if (!painted_flush_callback_.is_null()) { |
| 466 ScheduleOffscreenCallback(painted_flush_callback_); | 467 FlushCallbackData callback; |
| 467 painted_flush_callback_.Clear(); | 468 std::swap(callback, painted_flush_callback_); |
| 469 ScheduleOffscreenCallback(callback); |
| 468 } | 470 } |
| 469 } else if (flushed_any_data_) { | 471 } else if (flushed_any_data_) { |
| 470 // Only schedule a paint if this backing store has had any data flushed to | 472 // 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 | 473 // it. This is an optimization. A "normal" plugin will first allocated a |
| 472 // backing store, bind it, and then execute their normal painting and | 474 // backing store, bind it, and then execute their normal painting and |
| 473 // update loop. If binding a device always invalidated, it would mean we | 475 // 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 | 476 // 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 | 477 // 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 | 478 // when an empty device is initially bound, we can save an extra paint for |
| 477 // many plugins during the critical page initialization phase. | 479 // many plugins during the critical page initialization phase. |
| (...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 672 | 674 |
| 673 bool PPB_Graphics2D_Impl::HasPendingFlush() const { | 675 bool PPB_Graphics2D_Impl::HasPendingFlush() const { |
| 674 return !unpainted_flush_callback_.is_null() || | 676 return !unpainted_flush_callback_.is_null() || |
| 675 !painted_flush_callback_.is_null() || | 677 !painted_flush_callback_.is_null() || |
| 676 offscreen_flush_pending_; | 678 offscreen_flush_pending_; |
| 677 } | 679 } |
| 678 | 680 |
| 679 } // namespace ppapi | 681 } // namespace ppapi |
| 680 } // namespace webkit | 682 } // namespace webkit |
| 681 | 683 |
| OLD | NEW |