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

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
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 665 matching lines...) Expand 10 before | Expand all | Expand 10 after
676 676
677 transport_stores_[0].canvas.reset(); 677 transport_stores_[0].canvas.reset();
678 transport_stores_[1].canvas.reset(); 678 transport_stores_[1].canvas.reset();
679 background_store_.canvas.reset(); 679 background_store_.canvas.reset();
680 transport_store_painted_ = gfx::Rect(); 680 transport_store_painted_ = gfx::Rect();
681 front_buffer_diff_ = gfx::Rect(); 681 front_buffer_diff_ = gfx::Rect();
682 } 682 }
683 683
684 static size_t BitmapSizeForPluginRect(const gfx::Rect& plugin_rect) { 684 static size_t BitmapSizeForPluginRect(const gfx::Rect& plugin_rect) {
685 const size_t stride = 685 const size_t stride =
686 skia::PlatformCanvas::StrideForWidth(plugin_rect.width()); 686 skia::PlatformCanvasStrideForWidth(plugin_rect.width());
687 return stride * plugin_rect.height(); 687 return stride * plugin_rect.height();
688 } 688 }
689 689
690 #if !defined(OS_WIN) 690 #if !defined(OS_WIN)
691 bool WebPluginDelegateProxy::CreateLocalBitmap( 691 bool WebPluginDelegateProxy::CreateLocalBitmap(
692 std::vector<uint8>* memory, 692 std::vector<uint8>* memory,
693 scoped_ptr<skia::PlatformCanvas>* canvas) { 693 scoped_ptr<skia::PlatformCanvas>* canvas) {
694 const size_t size = BitmapSizeForPluginRect(plugin_rect_); 694 const size_t size = BitmapSizeForPluginRect(plugin_rect_);
695 memory->resize(size); 695 memory->resize(size);
696 if (memory->size() != size) 696 if (memory->size() != size)
697 return false; 697 return false;
698 canvas->reset(new skia::PlatformCanvas( 698 canvas->reset(skia::CreatePlatformCanvas(
699 plugin_rect_.width(), plugin_rect_.height(), true, &((*memory)[0]))); 699 plugin_rect_.width(), plugin_rect_.height(), true, &((*memory)[0]),
700 skia::CRASH_ON_FAILURE));
700 return true; 701 return true;
701 } 702 }
702 #endif 703 #endif
703 704
704 bool WebPluginDelegateProxy::CreateSharedBitmap( 705 bool WebPluginDelegateProxy::CreateSharedBitmap(
705 scoped_ptr<TransportDIB>* memory, 706 scoped_ptr<TransportDIB>* memory,
706 scoped_ptr<skia::PlatformCanvas>* canvas) { 707 scoped_ptr<skia::PlatformCanvas>* canvas) {
707 const size_t size = BitmapSizeForPluginRect(plugin_rect_); 708 const size_t size = BitmapSizeForPluginRect(plugin_rect_);
708 #if defined(OS_POSIX) && !defined(OS_MACOSX) 709 #if defined(OS_POSIX) && !defined(OS_MACOSX)
709 memory->reset(TransportDIB::Create(size, 0)); 710 memory->reset(TransportDIB::Create(size, 0));
(...skipping 553 matching lines...) Expand 10 before | Expand all | Expand 10 after
1263 webkit::PaintSadPlugin(native_context, plugin_rect_, *sad_plugin_); 1264 webkit::PaintSadPlugin(native_context, plugin_rect_, *sad_plugin_);
1264 } 1265 }
1265 1266
1266 void WebPluginDelegateProxy::CopyFromBackBufferToFrontBuffer( 1267 void WebPluginDelegateProxy::CopyFromBackBufferToFrontBuffer(
1267 const gfx::Rect& rect) { 1268 const gfx::Rect& rect) {
1268 #if defined(OS_MACOSX) 1269 #if defined(OS_MACOSX)
1269 // Blitting the bits directly is much faster than going through CG, and since 1270 // Blitting the bits directly is much faster than going through CG, and since
1270 // the goal is just to move the raw pixels between two bitmaps with the same 1271 // the goal is just to move the raw pixels between two bitmaps with the same
1271 // pixel format (no compositing, color correction, etc.), it's safe. 1272 // pixel format (no compositing, color correction, etc.), it's safe.
1272 const size_t stride = 1273 const size_t stride =
1273 skia::PlatformCanvas::StrideForWidth(plugin_rect_.width()); 1274 skia::PlatformCanvasStrideForWidth(plugin_rect_.width());
1274 const size_t chunk_size = 4 * rect.width(); 1275 const size_t chunk_size = 4 * rect.width();
1275 DCHECK(back_buffer_dib() != NULL); 1276 DCHECK(back_buffer_dib() != NULL);
1276 uint8* source_data = static_cast<uint8*>(back_buffer_dib()->memory()) + 1277 uint8* source_data = static_cast<uint8*>(back_buffer_dib()->memory()) +
1277 rect.y() * stride + 4 * rect.x(); 1278 rect.y() * stride + 4 * rect.x();
1278 DCHECK(front_buffer_dib() != NULL); 1279 DCHECK(front_buffer_dib() != NULL);
1279 uint8* target_data = static_cast<uint8*>(front_buffer_dib()->memory()) + 1280 uint8* target_data = static_cast<uint8*>(front_buffer_dib()->memory()) +
1280 rect.y() * stride + 4 * rect.x(); 1281 rect.y() * stride + 4 * rect.x();
1281 for (int row = 0; row < rect.height(); ++row) { 1282 for (int row = 0; row < rect.height(); ++row) {
1282 memcpy(target_data, source_data, chunk_size); 1283 memcpy(target_data, source_data, chunk_size);
1283 source_data += stride; 1284 source_data += stride;
(...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after
1530 1531
1531 void WebPluginDelegateProxy::OnURLRedirectResponse(bool allow, 1532 void WebPluginDelegateProxy::OnURLRedirectResponse(bool allow,
1532 int resource_id) { 1533 int resource_id) {
1533 if (!plugin_) 1534 if (!plugin_)
1534 return; 1535 return;
1535 1536
1536 plugin_->URLRedirectResponse(allow, resource_id); 1537 plugin_->URLRedirectResponse(allow, resource_id);
1537 } 1538 }
1538 1539
1539 } // namespace content 1540 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698