Chromium Code Reviews| 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 441 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 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 const SkBitmap* old_backing_bitmap = | 461 const SkBitmap* old_backing_bitmap = |
| 462 bound_graphics_2d()->image_data()->GetMappedBitmap(); | 462 bound_graphics_2d()->image_data()->GetMappedBitmap(); |
|
David Springer
2011/01/24 20:19:29
Is there any chance that these accessors could ret
| |
| 463 SkRect old_size = SkRect::MakeWH( | 463 if (old_backing_bitmap != NULL) { |
|
brettw
2011/01/24 21:00:07
Instead of checking to see if there's no mapped bi
| |
| 464 SkScalar(static_cast<float>(old_backing_bitmap->width())), | 464 SkRect old_size = SkRect::MakeWH( |
| 465 SkScalar(static_cast<float>(old_backing_bitmap->height()))); | 465 SkScalar(static_cast<float>(old_backing_bitmap->width())), |
| 466 SkScalar(static_cast<float>(old_backing_bitmap->height()))); | |
| 466 | 467 |
| 467 SkCanvas canvas(*graphics_2d->image_data()->GetMappedBitmap()); | 468 SkCanvas canvas(*graphics_2d->image_data()->GetMappedBitmap()); |
| 468 canvas.drawBitmap(*old_backing_bitmap, 0, 0); | 469 canvas.drawBitmap(*old_backing_bitmap, 0, 0); |
| 469 | 470 |
| 470 // Fill in any extra space with white. | 471 // Fill in any extra space with white. |
| 471 canvas.clipRect(old_size, SkRegion::kDifference_Op); | 472 canvas.clipRect(old_size, SkRegion::kDifference_Op); |
| 472 canvas.drawARGB(255, 255, 255, 255); | 473 canvas.drawARGB(255, 255, 255, 255); |
| 474 } | |
| 473 } | 475 } |
| 474 | 476 |
| 475 bound_graphics_ = graphics_2d; | 477 bound_graphics_ = graphics_2d; |
| 476 // BindToInstance will have invalidated the plugin if necessary. | 478 // BindToInstance will have invalidated the plugin if necessary. |
| 477 } else if (graphics_3d) { | 479 } else if (graphics_3d) { |
| 478 // Make sure graphics can only be bound to the instance it is | 480 // Make sure graphics can only be bound to the instance it is |
| 479 // associated with. | 481 // associated with. |
| 480 if (graphics_3d->instance() != this) | 482 if (graphics_3d->instance() != this) |
| 481 return false; | 483 return false; |
| 482 if (!graphics_3d->BindToInstance(true)) | 484 if (!graphics_3d->BindToInstance(true)) |
| (...skipping 747 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1230 return found->second; | 1232 return found->second; |
| 1231 } | 1233 } |
| 1232 | 1234 |
| 1233 bool PluginInstance::IsFullPagePlugin() const { | 1235 bool PluginInstance::IsFullPagePlugin() const { |
| 1234 WebFrame* frame = container()->element().document().frame(); | 1236 WebFrame* frame = container()->element().document().frame(); |
| 1235 return frame->view()->mainFrame()->document().isPluginDocument(); | 1237 return frame->view()->mainFrame()->document().isPluginDocument(); |
| 1236 } | 1238 } |
| 1237 | 1239 |
| 1238 } // namespace ppapi | 1240 } // namespace ppapi |
| 1239 } // namespace webkit | 1241 } // namespace webkit |
| OLD | NEW |