| 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/metrics/histogram.h" | 8 #include "base/metrics/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 419 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 430 } | 430 } |
| 431 | 431 |
| 432 scoped_refptr<Graphics2D> graphics_2d = | 432 scoped_refptr<Graphics2D> graphics_2d = |
| 433 Resource::GetAs<Graphics2D>(graphics_id); | 433 Resource::GetAs<Graphics2D>(graphics_id); |
| 434 scoped_refptr<Graphics3D> graphics_3d = | 434 scoped_refptr<Graphics3D> graphics_3d = |
| 435 Resource::GetAs<Graphics3D>(graphics_id); | 435 Resource::GetAs<Graphics3D>(graphics_id); |
| 436 | 436 |
| 437 if (graphics_2d) { | 437 if (graphics_2d) { |
| 438 if (!graphics_2d->BindToInstance(this)) | 438 if (!graphics_2d->BindToInstance(this)) |
| 439 return false; // Can't bind to more than one instance. | 439 return false; // Can't bind to more than one instance. |
| 440 bound_graphics_ = graphics_2d; | |
| 441 | 440 |
| 442 // See http://crbug.com/49403: this can be further optimized by keeping the | 441 // See http://crbug.com/49403: this can be further optimized by keeping the |
| 443 // old device around and painting from it. | 442 // old device around and painting from it. |
| 444 if (bound_graphics_2d()) { | 443 if (bound_graphics_2d()) { |
| 445 // Start the new image with the content of the old image until the plugin | 444 // Start the new image with the content of the old image until the plugin |
| 446 // repaints. | 445 // repaints. |
| 447 const SkBitmap* old_backing_bitmap = | 446 const SkBitmap* old_backing_bitmap = |
| 448 bound_graphics_2d()->image_data()->GetMappedBitmap(); | 447 bound_graphics_2d()->image_data()->GetMappedBitmap(); |
| 449 SkRect old_size = SkRect::MakeWH( | 448 SkRect old_size = SkRect::MakeWH( |
| 450 SkScalar(static_cast<float>(old_backing_bitmap->width())), | 449 SkScalar(static_cast<float>(old_backing_bitmap->width())), |
| 451 SkScalar(static_cast<float>(old_backing_bitmap->height()))); | 450 SkScalar(static_cast<float>(old_backing_bitmap->height()))); |
| 452 | 451 |
| 453 SkCanvas canvas(*graphics_2d->image_data()->GetMappedBitmap()); | 452 SkCanvas canvas(*graphics_2d->image_data()->GetMappedBitmap()); |
| 454 canvas.drawBitmap(*old_backing_bitmap, 0, 0); | 453 canvas.drawBitmap(*old_backing_bitmap, 0, 0); |
| 455 | 454 |
| 456 // Fill in any extra space with white. | 455 // Fill in any extra space with white. |
| 457 canvas.clipRect(old_size, SkRegion::kDifference_Op); | 456 canvas.clipRect(old_size, SkRegion::kDifference_Op); |
| 458 canvas.drawARGB(255, 255, 255, 255); | 457 canvas.drawARGB(255, 255, 255, 255); |
| 459 } | 458 } |
| 460 | 459 |
| 461 // BindToInstance will have invalidated the plugin if necessary. | 460 // BindToInstance will have invalidated the plugin if necessary. |
| 461 bound_graphics_ = graphics_2d; |
| 462 } else if (graphics_3d) { | 462 } else if (graphics_3d) { |
| 463 if (!graphics_3d->BindToInstance(this)) | 463 if (!graphics_3d->BindToInstance(this)) |
| 464 return false; | 464 return false; |
| 465 | 465 |
| 466 bound_graphics_ = graphics_3d; | 466 bound_graphics_ = graphics_3d; |
| 467 bound_graphics_3d()->SetSwapBuffersCallback( | 467 bound_graphics_3d()->SetSwapBuffersCallback( |
| 468 NewCallback(this, &PluginInstance::CommitBackingTexture)); | 468 NewCallback(this, &PluginInstance::CommitBackingTexture)); |
| 469 } | 469 } |
| 470 | 470 |
| 471 return true; | 471 return true; |
| (...skipping 691 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1163 } | 1163 } |
| 1164 | 1164 |
| 1165 Graphics3D* PluginInstance::bound_graphics_3d() const { | 1165 Graphics3D* PluginInstance::bound_graphics_3d() const { |
| 1166 if (bound_graphics_.get() == NULL) | 1166 if (bound_graphics_.get() == NULL) |
| 1167 return NULL; | 1167 return NULL; |
| 1168 | 1168 |
| 1169 return bound_graphics_->Cast<Graphics3D>(); | 1169 return bound_graphics_->Cast<Graphics3D>(); |
| 1170 } | 1170 } |
| 1171 | 1171 |
| 1172 } // namespace pepper | 1172 } // namespace pepper |
| OLD | NEW |