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 855 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
866 : -transform.ty; | 866 : -transform.ty; |
867 gfx::Rect full_content_rect(context_offset_x, context_offset_y, | 867 gfx::Rect full_content_rect(context_offset_x, context_offset_y, |
868 CGBitmapContextGetWidth(context), | 868 CGBitmapContextGetWidth(context), |
869 CGBitmapContextGetHeight(context)); | 869 CGBitmapContextGetHeight(context)); |
870 #else | 870 #else |
871 cairo_surface_t* page_surface = cairo_get_target(context); | 871 cairo_surface_t* page_surface = cairo_get_target(context); |
872 DCHECK_EQ(cairo_surface_get_type(page_surface), CAIRO_SURFACE_TYPE_IMAGE); | 872 DCHECK_EQ(cairo_surface_get_type(page_surface), CAIRO_SURFACE_TYPE_IMAGE); |
873 DCHECK_EQ(cairo_image_surface_get_format(page_surface), CAIRO_FORMAT_ARGB32); | 873 DCHECK_EQ(cairo_image_surface_get_format(page_surface), CAIRO_FORMAT_ARGB32); |
874 | 874 |
875 // Transform context coordinates into surface coordinates. | 875 // Transform context coordinates into surface coordinates. |
876 double page_x_double = rect.x(); | 876 double page_x_double = 0; |
877 double page_y_double = rect.y(); | 877 double page_y_double = 0; |
878 cairo_user_to_device(context, &page_x_double, &page_y_double); | 878 cairo_device_to_user(context, &page_x_double, &page_y_double); |
879 gfx::Rect full_content_rect(0, 0, | 879 gfx::Rect full_content_rect(static_cast<int>(page_x_double), |
| 880 static_cast<int>(page_y_double), |
880 cairo_image_surface_get_width(page_surface), | 881 cairo_image_surface_get_width(page_surface), |
881 cairo_image_surface_get_height(page_surface)); | 882 cairo_image_surface_get_height(page_surface)); |
882 #endif | 883 #endif |
883 // According to comments in the Windows code, the damage rect that we're given | 884 // According to comments in the Windows code, the damage rect that we're given |
884 // may project outside the image, so intersect their rects. | 885 // may project outside the image, so intersect their rects. |
885 gfx::Rect content_rect = rect.Intersect(full_content_rect); | 886 gfx::Rect content_rect = rect.Intersect(full_content_rect); |
886 | 887 |
887 #if defined(OS_MACOSX) | 888 #if defined(OS_MACOSX) |
888 const unsigned char* page_bytes = static_cast<const unsigned char*>( | 889 const unsigned char* page_bytes = static_cast<const unsigned char*>( |
889 CGBitmapContextGetData(context)); | 890 CGBitmapContextGetData(context)); |
(...skipping 12 matching lines...) Expand all Loading... |
902 int full_bg_width = CGBitmapContextGetWidth(bg_context); | 903 int full_bg_width = CGBitmapContextGetWidth(bg_context); |
903 int full_bg_height = CGBitmapContextGetHeight(bg_context); | 904 int full_bg_height = CGBitmapContextGetHeight(bg_context); |
904 int bg_stride = CGBitmapContextGetBytesPerRow(bg_context); | 905 int bg_stride = CGBitmapContextGetBytesPerRow(bg_context); |
905 int bg_last_row = CGBitmapContextGetHeight(bg_context) - 1; | 906 int bg_last_row = CGBitmapContextGetHeight(bg_context) - 1; |
906 | 907 |
907 int bytes_per_pixel = CGBitmapContextGetBitsPerPixel(context) / 8; | 908 int bytes_per_pixel = CGBitmapContextGetBitsPerPixel(context) / 8; |
908 #else | 909 #else |
909 cairo_surface_flush(page_surface); | 910 cairo_surface_flush(page_surface); |
910 const unsigned char* page_bytes = cairo_image_surface_get_data(page_surface); | 911 const unsigned char* page_bytes = cairo_image_surface_get_data(page_surface); |
911 int page_stride = cairo_image_surface_get_stride(page_surface); | 912 int page_stride = cairo_image_surface_get_stride(page_surface); |
912 int page_start_x = static_cast<int>(page_x_double); | 913 int page_start_x = content_rect.x() - static_cast<int>(page_x_double); |
913 int page_start_y = static_cast<int>(page_y_double); | 914 int page_start_y = content_rect.y() - static_cast<int>(page_y_double); |
914 | 915 |
915 skia::ScopedPlatformPaint scoped_platform_paint( | 916 skia::ScopedPlatformPaint scoped_platform_paint( |
916 background_store_.canvas.get()); | 917 background_store_.canvas.get()); |
917 cairo_surface_t* bg_surface =cairo_get_target( | 918 cairo_surface_t* bg_surface =cairo_get_target( |
918 scoped_platform_paint.GetPlatformSurface()); | 919 scoped_platform_paint.GetPlatformSurface()); |
919 DCHECK_EQ(cairo_surface_get_type(bg_surface), CAIRO_SURFACE_TYPE_IMAGE); | 920 DCHECK_EQ(cairo_surface_get_type(bg_surface), CAIRO_SURFACE_TYPE_IMAGE); |
920 DCHECK_EQ(cairo_image_surface_get_format(bg_surface), CAIRO_FORMAT_ARGB32); | 921 DCHECK_EQ(cairo_image_surface_get_format(bg_surface), CAIRO_FORMAT_ARGB32); |
921 cairo_surface_flush(bg_surface); | 922 cairo_surface_flush(bg_surface); |
922 const unsigned char* bg_bytes = cairo_image_surface_get_data(bg_surface); | 923 const unsigned char* bg_bytes = cairo_image_surface_get_data(bg_surface); |
923 int full_bg_width = cairo_image_surface_get_width(bg_surface); | 924 int full_bg_width = cairo_image_surface_get_width(bg_surface); |
(...skipping 586 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1510 } | 1511 } |
1511 #endif | 1512 #endif |
1512 | 1513 |
1513 void WebPluginDelegateProxy::OnURLRedirectResponse(bool allow, | 1514 void WebPluginDelegateProxy::OnURLRedirectResponse(bool allow, |
1514 int resource_id) { | 1515 int resource_id) { |
1515 if (!plugin_) | 1516 if (!plugin_) |
1516 return; | 1517 return; |
1517 | 1518 |
1518 plugin_->URLRedirectResponse(allow, resource_id); | 1519 plugin_->URLRedirectResponse(allow, resource_id); |
1519 } | 1520 } |
OLD | NEW |