Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(418)

Side by Side Diff: content/renderer/webplugin_delegate_proxy.cc

Issue 11138024: Simplify platform_canvas.h by recognizing that PlatformCanvas does not actually extend (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « content/renderer/webplugin_delegate_proxy.h ('k') | content/shell/webkit_test_runner.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 611 matching lines...) Expand 10 before | Expand all | Expand 10 after
622 transport_stores_[1].dib.reset(); 622 transport_stores_[1].dib.reset();
623 623
624 transport_stores_[0].canvas.reset(); 624 transport_stores_[0].canvas.reset();
625 transport_stores_[1].canvas.reset(); 625 transport_stores_[1].canvas.reset();
626 transport_store_painted_ = gfx::Rect(); 626 transport_store_painted_ = gfx::Rect();
627 front_buffer_diff_ = gfx::Rect(); 627 front_buffer_diff_ = gfx::Rect();
628 } 628 }
629 629
630 static size_t BitmapSizeForPluginRect(const gfx::Rect& plugin_rect) { 630 static size_t BitmapSizeForPluginRect(const gfx::Rect& plugin_rect) {
631 const size_t stride = 631 const size_t stride =
632 skia::PlatformCanvas::StrideForWidth(plugin_rect.width()); 632 skia::PlatformCanvasStrideForWidth(plugin_rect.width());
633 return stride * plugin_rect.height(); 633 return stride * plugin_rect.height();
634 } 634 }
635 635
636 #if !defined(OS_WIN) 636 #if !defined(OS_WIN)
637 bool WebPluginDelegateProxy::CreateLocalBitmap( 637 bool WebPluginDelegateProxy::CreateLocalBitmap(
638 std::vector<uint8>* memory, 638 std::vector<uint8>* memory,
639 scoped_ptr<skia::PlatformCanvas>* canvas) { 639 scoped_ptr<skia::PlatformCanvas>* canvas) {
640 const size_t size = BitmapSizeForPluginRect(plugin_rect_); 640 const size_t size = BitmapSizeForPluginRect(plugin_rect_);
641 memory->resize(size); 641 memory->resize(size);
642 if (memory->size() != size) 642 if (memory->size() != size)
643 return false; 643 return false;
644 canvas->reset(new skia::PlatformCanvas( 644 canvas->reset(skia::CreatePlatformCanvas(
645 plugin_rect_.width(), plugin_rect_.height(), true, &((*memory)[0]))); 645 plugin_rect_.width(), plugin_rect_.height(), true, &((*memory)[0]),
646 skia::CRASH_ON_FAILURE));
646 return true; 647 return true;
647 } 648 }
648 #endif 649 #endif
649 650
650 bool WebPluginDelegateProxy::CreateSharedBitmap( 651 bool WebPluginDelegateProxy::CreateSharedBitmap(
651 scoped_ptr<TransportDIB>* memory, 652 scoped_ptr<TransportDIB>* memory,
652 scoped_ptr<skia::PlatformCanvas>* canvas) { 653 scoped_ptr<skia::PlatformCanvas>* canvas) {
653 const size_t size = BitmapSizeForPluginRect(plugin_rect_); 654 const size_t size = BitmapSizeForPluginRect(plugin_rect_);
654 #if defined(OS_POSIX) && !defined(OS_MACOSX) 655 #if defined(OS_POSIX) && !defined(OS_MACOSX)
655 memory->reset(TransportDIB::Create(size, 0)); 656 memory->reset(TransportDIB::Create(size, 0));
(...skipping 376 matching lines...) Expand 10 before | Expand all | Expand 10 after
1032 webkit::PaintSadPlugin(native_context, plugin_rect_, *sad_plugin_); 1033 webkit::PaintSadPlugin(native_context, plugin_rect_, *sad_plugin_);
1033 } 1034 }
1034 1035
1035 void WebPluginDelegateProxy::CopyFromBackBufferToFrontBuffer( 1036 void WebPluginDelegateProxy::CopyFromBackBufferToFrontBuffer(
1036 const gfx::Rect& rect) { 1037 const gfx::Rect& rect) {
1037 #if defined(OS_MACOSX) 1038 #if defined(OS_MACOSX)
1038 // Blitting the bits directly is much faster than going through CG, and since 1039 // Blitting the bits directly is much faster than going through CG, and since
1039 // the goal is just to move the raw pixels between two bitmaps with the same 1040 // the goal is just to move the raw pixels between two bitmaps with the same
1040 // pixel format (no compositing, color correction, etc.), it's safe. 1041 // pixel format (no compositing, color correction, etc.), it's safe.
1041 const size_t stride = 1042 const size_t stride =
1042 skia::PlatformCanvas::StrideForWidth(plugin_rect_.width()); 1043 skia::PlatformCanvasStrideForWidth(plugin_rect_.width());
1043 const size_t chunk_size = 4 * rect.width(); 1044 const size_t chunk_size = 4 * rect.width();
1044 DCHECK(back_buffer_dib() != NULL); 1045 DCHECK(back_buffer_dib() != NULL);
1045 uint8* source_data = static_cast<uint8*>(back_buffer_dib()->memory()) + 1046 uint8* source_data = static_cast<uint8*>(back_buffer_dib()->memory()) +
1046 rect.y() * stride + 4 * rect.x(); 1047 rect.y() * stride + 4 * rect.x();
1047 DCHECK(front_buffer_dib() != NULL); 1048 DCHECK(front_buffer_dib() != NULL);
1048 uint8* target_data = static_cast<uint8*>(front_buffer_dib()->memory()) + 1049 uint8* target_data = static_cast<uint8*>(front_buffer_dib()->memory()) +
1049 rect.y() * stride + 4 * rect.x(); 1050 rect.y() * stride + 4 * rect.x();
1050 for (int row = 0; row < rect.height(); ++row) { 1051 for (int row = 0; row < rect.height(); ++row) {
1051 memcpy(target_data, source_data, chunk_size); 1052 memcpy(target_data, source_data, chunk_size);
1052 source_data += stride; 1053 source_data += stride;
(...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after
1299 1300
1300 void WebPluginDelegateProxy::OnURLRedirectResponse(bool allow, 1301 void WebPluginDelegateProxy::OnURLRedirectResponse(bool allow,
1301 int resource_id) { 1302 int resource_id) {
1302 if (!plugin_) 1303 if (!plugin_)
1303 return; 1304 return;
1304 1305
1305 plugin_->URLRedirectResponse(allow, resource_id); 1306 plugin_->URLRedirectResponse(allow, resource_id);
1306 } 1307 }
1307 1308
1308 } // namespace content 1309 } // namespace content
OLDNEW
« no previous file with comments | « content/renderer/webplugin_delegate_proxy.h ('k') | content/shell/webkit_test_runner.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698