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/ppapi_plugin_instance.h" | 5 #include "webkit/plugins/ppapi/ppapi_plugin_instance.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "base/metrics/histogram.h" | 8 #include "base/metrics/histogram.h" |
9 #include "base/scoped_ptr.h" | 9 #include "base/scoped_ptr.h" |
10 #include "base/utf_string_conversions.h" | 10 #include "base/utf_string_conversions.h" |
(...skipping 440 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
451 | 451 |
452 if (graphics_2d) { | 452 if (graphics_2d) { |
453 if (!graphics_2d->BindToInstance(this)) | 453 if (!graphics_2d->BindToInstance(this)) |
454 return false; // Can't bind to more than one instance. | 454 return false; // Can't bind to more than one instance. |
455 | 455 |
456 // See http://crbug.com/49403: this can be further optimized by keeping the | 456 // See http://crbug.com/49403: this can be further optimized by keeping the |
457 // old device around and painting from it. | 457 // old device around and painting from it. |
458 if (bound_graphics_2d()) { | 458 if (bound_graphics_2d()) { |
459 // Start the new image with the content of the old image until the plugin | 459 // Start the new image with the content of the old image until the plugin |
460 // repaints. | 460 // repaints. |
| 461 // Use ImageDataAutoMapper to ensure the image data is valid. |
| 462 ImageDataAutoMapper mapper(bound_graphics_2d()->image_data()); |
| 463 if (!mapper.is_valid()) |
| 464 return false; |
461 const SkBitmap* old_backing_bitmap = | 465 const SkBitmap* old_backing_bitmap = |
462 bound_graphics_2d()->image_data()->GetMappedBitmap(); | 466 bound_graphics_2d()->image_data()->GetMappedBitmap(); |
463 SkRect old_size = SkRect::MakeWH( | 467 SkRect old_size = SkRect::MakeWH( |
464 SkScalar(static_cast<float>(old_backing_bitmap->width())), | 468 SkScalar(static_cast<float>(old_backing_bitmap->width())), |
465 SkScalar(static_cast<float>(old_backing_bitmap->height()))); | 469 SkScalar(static_cast<float>(old_backing_bitmap->height()))); |
466 | 470 |
467 SkCanvas canvas(*graphics_2d->image_data()->GetMappedBitmap()); | 471 SkCanvas canvas(*graphics_2d->image_data()->GetMappedBitmap()); |
468 canvas.drawBitmap(*old_backing_bitmap, 0, 0); | 472 canvas.drawBitmap(*old_backing_bitmap, 0, 0); |
469 | 473 |
470 // Fill in any extra space with white. | 474 // Fill in any extra space with white. |
(...skipping 759 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1230 return found->second; | 1234 return found->second; |
1231 } | 1235 } |
1232 | 1236 |
1233 bool PluginInstance::IsFullPagePlugin() const { | 1237 bool PluginInstance::IsFullPagePlugin() const { |
1234 WebFrame* frame = container()->element().document().frame(); | 1238 WebFrame* frame = container()->element().document().frame(); |
1235 return frame->view()->mainFrame()->document().isPluginDocument(); | 1239 return frame->view()->mainFrame()->document().isPluginDocument(); |
1236 } | 1240 } |
1237 | 1241 |
1238 } // namespace ppapi | 1242 } // namespace ppapi |
1239 } // namespace webkit | 1243 } // namespace webkit |
OLD | NEW |