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 "content/renderer/webplugin_delegate_proxy.h" | 5 #include "content/renderer/webplugin_delegate_proxy.h" |
6 | 6 |
7 #if defined(TOOLKIT_USES_GTK) | 7 #if defined(TOOLKIT_USES_GTK) |
8 #include <gtk/gtk.h> | 8 #include <gtk/gtk.h> |
9 #endif | 9 #endif |
10 | 10 |
(...skipping 710 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
721 if (!uses_shared_bitmaps_) | 721 if (!uses_shared_bitmaps_) |
722 return; | 722 return; |
723 | 723 |
724 // We got a paint before the plugin's coordinates, so there's no buffer to | 724 // We got a paint before the plugin's coordinates, so there's no buffer to |
725 // copy from. | 725 // copy from. |
726 if (!backing_store_canvas_.get()) | 726 if (!backing_store_canvas_.get()) |
727 return; | 727 return; |
728 | 728 |
729 // We're using the native OS APIs from here on out. | 729 // We're using the native OS APIs from here on out. |
730 #if WEBKIT_USING_SKIA | 730 #if WEBKIT_USING_SKIA |
731 gfx::NativeDrawingContext context = skia::BeginPlatformPaint(canvas); | 731 skia::ScopedPlatformPaint scoped_platform_paint(canvas); |
| 732 gfx::NativeDrawingContext context = |
| 733 scoped_platform_paint.GetPlatformSurface(); |
732 #elif WEBKIT_USING_CG | 734 #elif WEBKIT_USING_CG |
733 gfx::NativeDrawingContext context = canvas; | 735 gfx::NativeDrawingContext context = canvas; |
734 #endif | 736 #endif |
735 | 737 |
736 gfx::Rect offset_rect = rect; | 738 gfx::Rect offset_rect = rect; |
737 offset_rect.Offset(-plugin_rect_.x(), -plugin_rect_.y()); | 739 offset_rect.Offset(-plugin_rect_.x(), -plugin_rect_.y()); |
738 gfx::Rect canvas_rect = offset_rect; | 740 gfx::Rect canvas_rect = offset_rect; |
739 #if defined(OS_MACOSX) | 741 #if defined(OS_MACOSX) |
740 // The canvases are flipped relative to the context, so flip the rect too. | 742 // The canvases are flipped relative to the context, so flip the rect too. |
741 FlipRectVerticallyWithHeight(&canvas_rect, plugin_rect_.height()); | 743 FlipRectVerticallyWithHeight(&canvas_rect, plugin_rect_.height()); |
(...skipping 15 matching lines...) Expand all Loading... |
757 BlitCanvasToContext(context, rect, backing_store_canvas_.get(), | 759 BlitCanvasToContext(context, rect, backing_store_canvas_.get(), |
758 canvas_rect.origin()); | 760 canvas_rect.origin()); |
759 | 761 |
760 if (invalidate_pending_) { | 762 if (invalidate_pending_) { |
761 // Only send the PaintAck message if this paint is in response to an | 763 // Only send the PaintAck message if this paint is in response to an |
762 // invalidate from the plugin, since this message acts as an access token | 764 // invalidate from the plugin, since this message acts as an access token |
763 // to ensure only one process is using the transport dib at a time. | 765 // to ensure only one process is using the transport dib at a time. |
764 invalidate_pending_ = false; | 766 invalidate_pending_ = false; |
765 Send(new PluginMsg_DidPaint(instance_id_)); | 767 Send(new PluginMsg_DidPaint(instance_id_)); |
766 } | 768 } |
767 | |
768 #if WEBKIT_USING_SKIA | |
769 skia::EndPlatformPaint(canvas); | |
770 #endif | |
771 } | 769 } |
772 | 770 |
773 bool WebPluginDelegateProxy::BackgroundChanged( | 771 bool WebPluginDelegateProxy::BackgroundChanged( |
774 gfx::NativeDrawingContext context, | 772 gfx::NativeDrawingContext context, |
775 const gfx::Rect& rect) { | 773 const gfx::Rect& rect) { |
776 #if defined(OS_WIN) | 774 #if defined(OS_WIN) |
777 HBITMAP hbitmap = static_cast<HBITMAP>(GetCurrentObject(context, OBJ_BITMAP)); | 775 HBITMAP hbitmap = static_cast<HBITMAP>(GetCurrentObject(context, OBJ_BITMAP)); |
778 if (hbitmap == NULL) { | 776 if (hbitmap == NULL) { |
779 NOTREACHED(); | 777 NOTREACHED(); |
780 return true; | 778 return true; |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
843 // may project outside the image, so intersect their rects. | 841 // may project outside the image, so intersect their rects. |
844 gfx::Rect content_rect = rect.Intersect(full_content_rect); | 842 gfx::Rect content_rect = rect.Intersect(full_content_rect); |
845 | 843 |
846 #if defined(OS_MACOSX) | 844 #if defined(OS_MACOSX) |
847 const unsigned char* page_bytes = static_cast<const unsigned char*>( | 845 const unsigned char* page_bytes = static_cast<const unsigned char*>( |
848 CGBitmapContextGetData(context)); | 846 CGBitmapContextGetData(context)); |
849 int page_stride = CGBitmapContextGetBytesPerRow(context); | 847 int page_stride = CGBitmapContextGetBytesPerRow(context); |
850 int page_start_x = content_rect.x() - context_offset_x; | 848 int page_start_x = content_rect.x() - context_offset_x; |
851 int page_start_y = content_rect.y() - context_offset_y; | 849 int page_start_y = content_rect.y() - context_offset_y; |
852 | 850 |
853 CGContextRef bg_context = | 851 skia::ScopedPlatformPaint scoped_platform_paint( |
854 background_store_canvas_->getTopPlatformDevice().GetBitmapContext(); | 852 background_store_canvas_.get()); |
| 853 CGContextRef bg_context = scoped_platform_paint.GetPlatformSurface(); |
| 854 |
855 DCHECK_EQ(CGBitmapContextGetBitsPerPixel(context), | 855 DCHECK_EQ(CGBitmapContextGetBitsPerPixel(context), |
856 CGBitmapContextGetBitsPerPixel(bg_context)); | 856 CGBitmapContextGetBitsPerPixel(bg_context)); |
857 const unsigned char* bg_bytes = static_cast<const unsigned char*>( | 857 const unsigned char* bg_bytes = static_cast<const unsigned char*>( |
858 CGBitmapContextGetData(bg_context)); | 858 CGBitmapContextGetData(bg_context)); |
859 int full_bg_width = CGBitmapContextGetWidth(bg_context); | 859 int full_bg_width = CGBitmapContextGetWidth(bg_context); |
860 int full_bg_height = CGBitmapContextGetHeight(bg_context); | 860 int full_bg_height = CGBitmapContextGetHeight(bg_context); |
861 int bg_stride = CGBitmapContextGetBytesPerRow(bg_context); | 861 int bg_stride = CGBitmapContextGetBytesPerRow(bg_context); |
862 int bg_last_row = CGBitmapContextGetHeight(bg_context) - 1; | 862 int bg_last_row = CGBitmapContextGetHeight(bg_context) - 1; |
863 | 863 |
864 int bytes_per_pixel = CGBitmapContextGetBitsPerPixel(context) / 8; | 864 int bytes_per_pixel = CGBitmapContextGetBitsPerPixel(context) / 8; |
865 #else | 865 #else |
866 cairo_surface_flush(page_surface); | 866 cairo_surface_flush(page_surface); |
867 const unsigned char* page_bytes = cairo_image_surface_get_data(page_surface); | 867 const unsigned char* page_bytes = cairo_image_surface_get_data(page_surface); |
868 int page_stride = cairo_image_surface_get_stride(page_surface); | 868 int page_stride = cairo_image_surface_get_stride(page_surface); |
869 int page_start_x = static_cast<int>(page_x_double); | 869 int page_start_x = static_cast<int>(page_x_double); |
870 int page_start_y = static_cast<int>(page_y_double); | 870 int page_start_y = static_cast<int>(page_y_double); |
871 | 871 |
872 skia::PlatformDevice& device = | 872 skia::ScopedPlatformPaint scoped_platform_paint( |
873 background_store_canvas_->getTopPlatformDevice(); | 873 background_store_canvas_.get()); |
874 cairo_surface_t* bg_surface = cairo_get_target(device.BeginPlatformPaint()); | 874 cairo_surface_t* bg_surface =cairo_get_target( |
| 875 scoped_platform_paint.GetPlatformSurface()); |
875 DCHECK_EQ(cairo_surface_get_type(bg_surface), CAIRO_SURFACE_TYPE_IMAGE); | 876 DCHECK_EQ(cairo_surface_get_type(bg_surface), CAIRO_SURFACE_TYPE_IMAGE); |
876 DCHECK_EQ(cairo_image_surface_get_format(bg_surface), CAIRO_FORMAT_ARGB32); | 877 DCHECK_EQ(cairo_image_surface_get_format(bg_surface), CAIRO_FORMAT_ARGB32); |
877 cairo_surface_flush(bg_surface); | 878 cairo_surface_flush(bg_surface); |
878 const unsigned char* bg_bytes = cairo_image_surface_get_data(bg_surface); | 879 const unsigned char* bg_bytes = cairo_image_surface_get_data(bg_surface); |
879 int full_bg_width = cairo_image_surface_get_width(bg_surface); | 880 int full_bg_width = cairo_image_surface_get_width(bg_surface); |
880 int full_bg_height = cairo_image_surface_get_height(bg_surface); | 881 int full_bg_height = cairo_image_surface_get_height(bg_surface); |
881 int bg_stride = cairo_image_surface_get_stride(bg_surface); | 882 int bg_stride = cairo_image_surface_get_stride(bg_surface); |
882 | 883 |
883 int bytes_per_pixel = 4; // ARGB32 = 4 bytes per pixel. | 884 int bytes_per_pixel = 4; // ARGB32 = 4 bytes per pixel. |
884 #endif | 885 #endif |
(...skipping 479 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1364 } | 1365 } |
1365 #endif | 1366 #endif |
1366 | 1367 |
1367 void WebPluginDelegateProxy::OnURLRedirectResponse(bool allow, | 1368 void WebPluginDelegateProxy::OnURLRedirectResponse(bool allow, |
1368 int resource_id) { | 1369 int resource_id) { |
1369 if (!plugin_) | 1370 if (!plugin_) |
1370 return; | 1371 return; |
1371 | 1372 |
1372 plugin_->URLRedirectResponse(allow, resource_id); | 1373 plugin_->URLRedirectResponse(allow, resource_id); |
1373 } | 1374 } |
OLD | NEW |