| 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/glue/plugins/pepper_plugin_instance.h" | 5 #include "webkit/glue/plugins/pepper_plugin_instance.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "base/histogram.h" | 8 #include "base/histogram.h" |
| 9 #if defined(OS_MACOSX) | 9 #if defined(OS_MACOSX) |
| 10 #include "base/mac_util.h" | 10 #include "base/mac_util.h" |
| (...skipping 296 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 307 } | 307 } |
| 308 return true; | 308 return true; |
| 309 } | 309 } |
| 310 | 310 |
| 311 scoped_refptr<DeviceContext2D> device_2d = | 311 scoped_refptr<DeviceContext2D> device_2d = |
| 312 Resource::GetAs<DeviceContext2D>(device_id); | 312 Resource::GetAs<DeviceContext2D>(device_id); |
| 313 | 313 |
| 314 if (device_2d) { | 314 if (device_2d) { |
| 315 if (!device_2d->BindToInstance(this)) | 315 if (!device_2d->BindToInstance(this)) |
| 316 return false; // Can't bind to more than one instance. | 316 return false; // Can't bind to more than one instance. |
| 317 |
| 318 if (device_context_2d_.get()) { |
| 319 // Start the new image with the content of the old image until the plugin |
| 320 // repaints. |
| 321 const SkBitmap* old_backing_bitmap = |
| 322 device_context_2d_->image_data()->GetMappedBitmap(); |
| 323 SkRect old_size = SkRect::MakeWH( |
| 324 SkScalar(static_cast<float>(old_backing_bitmap->width())), |
| 325 SkScalar(static_cast<float>(old_backing_bitmap->height()))); |
| 326 |
| 327 SkCanvas canvas(*device_2d->image_data()->GetMappedBitmap()); |
| 328 canvas.drawBitmap(*old_backing_bitmap, 0, 0); |
| 329 |
| 330 // Fill in any extra space with white. |
| 331 canvas.clipRect(old_size, SkRegion::kDifference_Op); |
| 332 canvas.drawARGB(255, 255, 255, 255); |
| 333 } |
| 334 |
| 317 device_context_2d_ = device_2d; | 335 device_context_2d_ = device_2d; |
| 318 // BindToInstance will have invalidated the plugin if necessary. | 336 // BindToInstance will have invalidated the plugin if necessary. |
| 319 } | 337 } |
| 320 | 338 |
| 321 return true; | 339 return true; |
| 322 } | 340 } |
| 323 | 341 |
| 324 bool PluginInstance::SetCursor(PP_CursorType type) { | 342 bool PluginInstance::SetCursor(PP_CursorType type) { |
| 325 cursor_.reset(new WebCursorInfo(static_cast<WebCursorInfo::Type>(type))); | 343 cursor_.reset(new WebCursorInfo(static_cast<WebCursorInfo::Type>(type))); |
| 326 return true; | 344 return true; |
| (...skipping 472 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 799 bounds.size.width = dest_rect.width(); | 817 bounds.size.width = dest_rect.width(); |
| 800 bounds.size.height = dest_rect.height(); | 818 bounds.size.height = dest_rect.height(); |
| 801 | 819 |
| 802 CGContextDrawImage(canvas, bounds, image); | 820 CGContextDrawImage(canvas, bounds, image); |
| 803 CGContextRestoreGState(canvas); | 821 CGContextRestoreGState(canvas); |
| 804 } | 822 } |
| 805 #endif // defined(OS_MACOSX) | 823 #endif // defined(OS_MACOSX) |
| 806 | 824 |
| 807 | 825 |
| 808 } // namespace pepper | 826 } // namespace pepper |
| OLD | NEW |