| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "content/renderer/webplugin_delegate_proxy.h" | 5 #include "content/renderer/webplugin_delegate_proxy.h" |
| 6 | 6 |
| 7 #if defined(TOOLKIT_GTK) | 7 #if defined(TOOLKIT_GTK) |
| 8 #include <gtk/gtk.h> | 8 #include <gtk/gtk.h> |
| 9 #elif defined(USE_X11) | 9 #elif defined(USE_X11) |
| 10 #include <cairo/cairo.h> | 10 #include <cairo/cairo.h> |
| (...skipping 671 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 682 | 682 |
| 683 transport_stores_[0].canvas.reset(); | 683 transport_stores_[0].canvas.reset(); |
| 684 transport_stores_[1].canvas.reset(); | 684 transport_stores_[1].canvas.reset(); |
| 685 background_store_.canvas.reset(); | 685 background_store_.canvas.reset(); |
| 686 transport_store_painted_ = gfx::Rect(); | 686 transport_store_painted_ = gfx::Rect(); |
| 687 front_buffer_diff_ = gfx::Rect(); | 687 front_buffer_diff_ = gfx::Rect(); |
| 688 } | 688 } |
| 689 | 689 |
| 690 static size_t BitmapSizeForPluginRect(const gfx::Rect& plugin_rect) { | 690 static size_t BitmapSizeForPluginRect(const gfx::Rect& plugin_rect) { |
| 691 const size_t stride = | 691 const size_t stride = |
| 692 skia::PlatformCanvas::StrideForWidth(plugin_rect.width()); | 692 skia::PlatformCanvasStrideForWidth(plugin_rect.width()); |
| 693 return stride * plugin_rect.height(); | 693 return stride * plugin_rect.height(); |
| 694 } | 694 } |
| 695 | 695 |
| 696 #if !defined(OS_WIN) | 696 #if !defined(OS_WIN) |
| 697 bool WebPluginDelegateProxy::CreateLocalBitmap( | 697 bool WebPluginDelegateProxy::CreateLocalBitmap( |
| 698 std::vector<uint8>* memory, | 698 std::vector<uint8>* memory, |
| 699 scoped_ptr<skia::PlatformCanvas>* canvas) { | 699 scoped_ptr<skia::PlatformCanvas>* canvas) { |
| 700 const size_t size = BitmapSizeForPluginRect(plugin_rect_); | 700 const size_t size = BitmapSizeForPluginRect(plugin_rect_); |
| 701 memory->resize(size); | 701 memory->resize(size); |
| 702 if (memory->size() != size) | 702 if (memory->size() != size) |
| 703 return false; | 703 return false; |
| 704 canvas->reset(new skia::PlatformCanvas( | 704 canvas->reset(skia::CreatePlatformCanvas( |
| 705 plugin_rect_.width(), plugin_rect_.height(), true, &((*memory)[0]))); | 705 plugin_rect_.width(), plugin_rect_.height(), true, &((*memory)[0]), |
| 706 skia::CRASH_ON_FAILURE)); |
| 706 return true; | 707 return true; |
| 707 } | 708 } |
| 708 #endif | 709 #endif |
| 709 | 710 |
| 710 bool WebPluginDelegateProxy::CreateSharedBitmap( | 711 bool WebPluginDelegateProxy::CreateSharedBitmap( |
| 711 scoped_ptr<TransportDIB>* memory, | 712 scoped_ptr<TransportDIB>* memory, |
| 712 scoped_ptr<skia::PlatformCanvas>* canvas) { | 713 scoped_ptr<skia::PlatformCanvas>* canvas) { |
| 713 const size_t size = BitmapSizeForPluginRect(plugin_rect_); | 714 const size_t size = BitmapSizeForPluginRect(plugin_rect_); |
| 714 #if defined(OS_POSIX) && !defined(OS_MACOSX) | 715 #if defined(OS_POSIX) && !defined(OS_MACOSX) |
| 715 memory->reset(TransportDIB::Create(size, 0)); | 716 memory->reset(TransportDIB::Create(size, 0)); |
| (...skipping 559 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1275 webkit::PaintSadPlugin(native_context, plugin_rect_, *sad_plugin_); | 1276 webkit::PaintSadPlugin(native_context, plugin_rect_, *sad_plugin_); |
| 1276 } | 1277 } |
| 1277 | 1278 |
| 1278 void WebPluginDelegateProxy::CopyFromBackBufferToFrontBuffer( | 1279 void WebPluginDelegateProxy::CopyFromBackBufferToFrontBuffer( |
| 1279 const gfx::Rect& rect) { | 1280 const gfx::Rect& rect) { |
| 1280 #if defined(OS_MACOSX) | 1281 #if defined(OS_MACOSX) |
| 1281 // Blitting the bits directly is much faster than going through CG, and since | 1282 // Blitting the bits directly is much faster than going through CG, and since |
| 1282 // the goal is just to move the raw pixels between two bitmaps with the same | 1283 // the goal is just to move the raw pixels between two bitmaps with the same |
| 1283 // pixel format (no compositing, color correction, etc.), it's safe. | 1284 // pixel format (no compositing, color correction, etc.), it's safe. |
| 1284 const size_t stride = | 1285 const size_t stride = |
| 1285 skia::PlatformCanvas::StrideForWidth(plugin_rect_.width()); | 1286 skia::PlatformCanvasStrideForWidth(plugin_rect_.width()); |
| 1286 const size_t chunk_size = 4 * rect.width(); | 1287 const size_t chunk_size = 4 * rect.width(); |
| 1287 DCHECK(back_buffer_dib() != NULL); | 1288 DCHECK(back_buffer_dib() != NULL); |
| 1288 uint8* source_data = static_cast<uint8*>(back_buffer_dib()->memory()) + | 1289 uint8* source_data = static_cast<uint8*>(back_buffer_dib()->memory()) + |
| 1289 rect.y() * stride + 4 * rect.x(); | 1290 rect.y() * stride + 4 * rect.x(); |
| 1290 DCHECK(front_buffer_dib() != NULL); | 1291 DCHECK(front_buffer_dib() != NULL); |
| 1291 uint8* target_data = static_cast<uint8*>(front_buffer_dib()->memory()) + | 1292 uint8* target_data = static_cast<uint8*>(front_buffer_dib()->memory()) + |
| 1292 rect.y() * stride + 4 * rect.x(); | 1293 rect.y() * stride + 4 * rect.x(); |
| 1293 for (int row = 0; row < rect.height(); ++row) { | 1294 for (int row = 0; row < rect.height(); ++row) { |
| 1294 memcpy(target_data, source_data, chunk_size); | 1295 memcpy(target_data, source_data, chunk_size); |
| 1295 source_data += stride; | 1296 source_data += stride; |
| (...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1542 | 1543 |
| 1543 void WebPluginDelegateProxy::OnURLRedirectResponse(bool allow, | 1544 void WebPluginDelegateProxy::OnURLRedirectResponse(bool allow, |
| 1544 int resource_id) { | 1545 int resource_id) { |
| 1545 if (!plugin_) | 1546 if (!plugin_) |
| 1546 return; | 1547 return; |
| 1547 | 1548 |
| 1548 plugin_->URLRedirectResponse(allow, resource_id); | 1549 plugin_->URLRedirectResponse(allow, resource_id); |
| 1549 } | 1550 } |
| 1550 | 1551 |
| 1551 } // namespace content | 1552 } // namespace content |
| OLD | NEW |