OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
9 #include "base/message_loop.h" | 9 #include "base/message_loop.h" |
10 #include "base/metrics/histogram.h" | 10 #include "base/metrics/histogram.h" |
(...skipping 1367 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1378 | 1378 |
1379 if (graphics_2d) { | 1379 if (graphics_2d) { |
1380 // Refuse to bind if we're transitioning to fullscreen. | 1380 // Refuse to bind if we're transitioning to fullscreen. |
1381 if (fullscreen_container_ && !fullscreen_) | 1381 if (fullscreen_container_ && !fullscreen_) |
1382 return PP_FALSE; | 1382 return PP_FALSE; |
1383 if (graphics_2d->instance() != this) | 1383 if (graphics_2d->instance() != this) |
1384 return PP_FALSE; // Can't bind other instance's contexts. | 1384 return PP_FALSE; // Can't bind other instance's contexts. |
1385 if (!graphics_2d->BindToInstance(this)) | 1385 if (!graphics_2d->BindToInstance(this)) |
1386 return PP_FALSE; // Can't bind to more than one instance. | 1386 return PP_FALSE; // Can't bind to more than one instance. |
1387 | 1387 |
1388 // See http://crbug.com/49403: this can be further optimized by keeping the | |
1389 // old device around and painting from it. | |
1390 if (bound_graphics_2d()) { | |
1391 // Start the new image with the content of the old image until the plugin | |
1392 // repaints. | |
1393 // Use ImageDataAutoMapper to ensure the image data is valid. | |
1394 ImageDataAutoMapper mapper(bound_graphics_2d()->image_data()); | |
1395 if (!mapper.is_valid()) | |
1396 return PP_FALSE; | |
1397 const SkBitmap* old_backing_bitmap = | |
1398 bound_graphics_2d()->image_data()->GetMappedBitmap(); | |
1399 SkRect old_size = SkRect::MakeWH( | |
1400 SkScalar(static_cast<float>(old_backing_bitmap->width())), | |
1401 SkScalar(static_cast<float>(old_backing_bitmap->height()))); | |
1402 | |
1403 SkCanvas canvas(*graphics_2d->image_data()->GetMappedBitmap()); | |
1404 canvas.drawBitmap(*old_backing_bitmap, 0, 0); | |
1405 | |
1406 // Fill in any extra space with white. | |
1407 canvas.clipRect(old_size, SkRegion::kDifference_Op); | |
1408 canvas.drawARGB(255, 255, 255, 255); | |
1409 } | |
1410 | |
1411 bound_graphics_ = graphics_2d; | 1388 bound_graphics_ = graphics_2d; |
1412 setBackingTextureId(0); | 1389 setBackingTextureId(0); |
1413 // BindToInstance will have invalidated the plugin if necessary. | 1390 // BindToInstance will have invalidated the plugin if necessary. |
1414 } else if (graphics_3d) { | 1391 } else if (graphics_3d) { |
1415 // Refuse to bind if we're transitioning to fullscreen. | 1392 // Refuse to bind if we're transitioning to fullscreen. |
1416 if (fullscreen_container_ && !fullscreen_) | 1393 if (fullscreen_container_ && !fullscreen_) |
1417 return PP_FALSE; | 1394 return PP_FALSE; |
1418 // Make sure graphics can only be bound to the instance it is | 1395 // Make sure graphics can only be bound to the instance it is |
1419 // associated with. | 1396 // associated with. |
1420 if (graphics_3d->instance() != this) | 1397 if (graphics_3d->instance() != this) |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1504 } | 1481 } |
1505 | 1482 |
1506 PP_Bool PluginInstance::GetScreenSize(PP_Instance instance, PP_Size* size) { | 1483 PP_Bool PluginInstance::GetScreenSize(PP_Instance instance, PP_Size* size) { |
1507 gfx::Size screen_size = delegate()->GetScreenSize(); | 1484 gfx::Size screen_size = delegate()->GetScreenSize(); |
1508 *size = PP_MakeSize(screen_size.width(), screen_size.height()); | 1485 *size = PP_MakeSize(screen_size.width(), screen_size.height()); |
1509 return PP_TRUE; | 1486 return PP_TRUE; |
1510 } | 1487 } |
1511 | 1488 |
1512 } // namespace ppapi | 1489 } // namespace ppapi |
1513 } // namespace webkit | 1490 } // namespace webkit |
OLD | NEW |