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

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 return true; 700 return true;
701 } 701 }
702 #endif 702 #endif
703 703
704 bool WebPluginDelegateProxy::CreateSharedBitmap( 704 bool WebPluginDelegateProxy::CreateSharedBitmap(
705 scoped_ptr<TransportDIB>* memory, 705 scoped_ptr<TransportDIB>* memory,
706 scoped_ptr<skia::PlatformCanvas>* canvas) { 706 scoped_ptr<skia::PlatformCanvas>* canvas) {
707 const size_t size = BitmapSizeForPluginRect(plugin_rect_); 707 const size_t size = BitmapSizeForPluginRect(plugin_rect_);
708 #if defined(OS_POSIX) && !defined(OS_MACOSX) 708 #if defined(OS_POSIX) && !defined(OS_MACOSX)
(...skipping 554 matching lines...) Expand 10 before | Expand all | Expand 10 after
1263 webkit::PaintSadPlugin(native_context, plugin_rect_, *sad_plugin_); 1263 webkit::PaintSadPlugin(native_context, plugin_rect_, *sad_plugin_);
1264 } 1264 }
1265 1265
1266 void WebPluginDelegateProxy::CopyFromBackBufferToFrontBuffer( 1266 void WebPluginDelegateProxy::CopyFromBackBufferToFrontBuffer(
1267 const gfx::Rect& rect) { 1267 const gfx::Rect& rect) {
1268 #if defined(OS_MACOSX) 1268 #if defined(OS_MACOSX)
1269 // Blitting the bits directly is much faster than going through CG, and since 1269 // 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 1270 // 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. 1271 // pixel format (no compositing, color correction, etc.), it's safe.
1272 const size_t stride = 1272 const size_t stride =
1273 skia::PlatformCanvas::StrideForWidth(plugin_rect_.width()); 1273 skia::PlatformCanvasStrideForWidth(plugin_rect_.width());
1274 const size_t chunk_size = 4 * rect.width(); 1274 const size_t chunk_size = 4 * rect.width();
1275 DCHECK(back_buffer_dib() != NULL); 1275 DCHECK(back_buffer_dib() != NULL);
1276 uint8* source_data = static_cast<uint8*>(back_buffer_dib()->memory()) + 1276 uint8* source_data = static_cast<uint8*>(back_buffer_dib()->memory()) +
1277 rect.y() * stride + 4 * rect.x(); 1277 rect.y() * stride + 4 * rect.x();
1278 DCHECK(front_buffer_dib() != NULL); 1278 DCHECK(front_buffer_dib() != NULL);
1279 uint8* target_data = static_cast<uint8*>(front_buffer_dib()->memory()) + 1279 uint8* target_data = static_cast<uint8*>(front_buffer_dib()->memory()) +
1280 rect.y() * stride + 4 * rect.x(); 1280 rect.y() * stride + 4 * rect.x();
1281 for (int row = 0; row < rect.height(); ++row) { 1281 for (int row = 0; row < rect.height(); ++row) {
1282 memcpy(target_data, source_data, chunk_size); 1282 memcpy(target_data, source_data, chunk_size);
1283 source_data += stride; 1283 source_data += stride;
(...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after
1530 1530
1531 void WebPluginDelegateProxy::OnURLRedirectResponse(bool allow, 1531 void WebPluginDelegateProxy::OnURLRedirectResponse(bool allow,
1532 int resource_id) { 1532 int resource_id) {
1533 if (!plugin_) 1533 if (!plugin_)
1534 return; 1534 return;
1535 1535
1536 plugin_->URLRedirectResponse(allow, resource_id); 1536 plugin_->URLRedirectResponse(allow, resource_id);
1537 } 1537 }
1538 1538
1539 } // namespace content 1539 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698