| 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/npapi/webplugin_delegate_impl.h" | 5 #include "webkit/plugins/npapi/webplugin_delegate_impl.h" |
| 6 | 6 |
| 7 #import <Cocoa/Cocoa.h> | 7 #import <Cocoa/Cocoa.h> |
| 8 #import <QuartzCore/QuartzCore.h> | 8 #import <QuartzCore/QuartzCore.h> |
| 9 #include <unistd.h> | 9 #include <unistd.h> |
| 10 | 10 |
| (...skipping 437 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 448 const gfx::Rect& damage_rect) { | 448 const gfx::Rect& damage_rect) { |
| 449 // If we get a paint event before we are completely set up (e.g., a nested | 449 // If we get a paint event before we are completely set up (e.g., a nested |
| 450 // call while the plugin is still in NPP_SetWindow), bail. | 450 // call while the plugin is still in NPP_SetWindow), bail. |
| 451 if (!have_called_set_window_ || (use_buffer_context_ && !buffer_context_)) | 451 if (!have_called_set_window_ || (use_buffer_context_ && !buffer_context_)) |
| 452 return; | 452 return; |
| 453 DCHECK(!use_buffer_context_ || buffer_context_ == context); | 453 DCHECK(!use_buffer_context_ || buffer_context_ == context); |
| 454 | 454 |
| 455 base::StatsRate plugin_paint("Plugin.Paint"); | 455 base::StatsRate plugin_paint("Plugin.Paint"); |
| 456 base::StatsScope<base::StatsRate> scope(plugin_paint); | 456 base::StatsScope<base::StatsRate> scope(plugin_paint); |
| 457 | 457 |
| 458 gfx::Rect paint_rect; | 458 gfx::Rect paint_rect = damage_rect; |
| 459 if (use_buffer_context_) { | 459 if (use_buffer_context_) { |
| 460 // Plugin invalidates trigger asynchronous paints with the original | 460 // Plugin invalidates trigger asynchronous paints with the original |
| 461 // invalidation rect; the plugin may be resized before the paint is handled, | 461 // invalidation rect; the plugin may be resized before the paint is handled, |
| 462 // so we need to ensure that the damage rect is still sane. | 462 // so we need to ensure that the damage rect is still sane. |
| 463 paint_rect = damage_rect.Intersect( | 463 paint_rect.Intersect( |
| 464 gfx::Rect(0, 0, window_rect_.width(), window_rect_.height())); | 464 gfx::Rect(0, 0, window_rect_.width(), window_rect_.height())); |
| 465 } else { | 465 } else { |
| 466 // Use the actual window region when drawing directly to the window context. | 466 // Use the actual window region when drawing directly to the window context. |
| 467 paint_rect = damage_rect.Intersect(window_rect_); | 467 paint_rect.Intersect(window_rect_); |
| 468 } | 468 } |
| 469 | 469 |
| 470 ScopedActiveDelegate active_delegate(this); | 470 ScopedActiveDelegate active_delegate(this); |
| 471 | 471 |
| 472 CGContextSaveGState(context); | 472 CGContextSaveGState(context); |
| 473 | 473 |
| 474 if (!use_buffer_context_) { | 474 if (!use_buffer_context_) { |
| 475 // Reposition the context origin so that plugins will draw at the correct | 475 // Reposition the context origin so that plugins will draw at the correct |
| 476 // location in the window. | 476 // location in the window. |
| 477 CGContextClipToRect(context, paint_rect.ToCGRect()); | 477 CGContextClipToRect(context, paint_rect.ToCGRect()); |
| (...skipping 285 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 763 DCHECK(!composited_); | 763 DCHECK(!composited_); |
| 764 windowed_handle_ = handle; | 764 windowed_handle_ = handle; |
| 765 surface_->SetWindowHandle(handle); | 765 surface_->SetWindowHandle(handle); |
| 766 UpdateAcceleratedSurface(); | 766 UpdateAcceleratedSurface(); |
| 767 // Kick off the drawing timer, if necessary. | 767 // Kick off the drawing timer, if necessary. |
| 768 PluginVisibilityChanged(); | 768 PluginVisibilityChanged(); |
| 769 } | 769 } |
| 770 | 770 |
| 771 } // namespace npapi | 771 } // namespace npapi |
| 772 } // namespace webkit | 772 } // namespace webkit |
| OLD | NEW |