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 827 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
838 : -transform.ty; | 838 : -transform.ty; |
839 gfx::Rect full_content_rect(context_offset_x, context_offset_y, | 839 gfx::Rect full_content_rect(context_offset_x, context_offset_y, |
840 CGBitmapContextGetWidth(context), | 840 CGBitmapContextGetWidth(context), |
841 CGBitmapContextGetHeight(context)); | 841 CGBitmapContextGetHeight(context)); |
842 #else | 842 #else |
843 cairo_surface_t* page_surface = cairo_get_target(context); | 843 cairo_surface_t* page_surface = cairo_get_target(context); |
844 DCHECK_EQ(cairo_surface_get_type(page_surface), CAIRO_SURFACE_TYPE_IMAGE); | 844 DCHECK_EQ(cairo_surface_get_type(page_surface), CAIRO_SURFACE_TYPE_IMAGE); |
845 DCHECK_EQ(cairo_image_surface_get_format(page_surface), CAIRO_FORMAT_ARGB32); | 845 DCHECK_EQ(cairo_image_surface_get_format(page_surface), CAIRO_FORMAT_ARGB32); |
846 | 846 |
847 // Transform context coordinates into surface coordinates. | 847 // Transform context coordinates into surface coordinates. |
848 double page_x_double = rect.x(); | 848 double page_x_double = 0; |
849 double page_y_double = rect.y(); | 849 double page_y_double = 0; |
850 cairo_user_to_device(context, &page_x_double, &page_y_double); | 850 cairo_device_to_user(context, &page_x_double, &page_y_double); |
851 gfx::Rect full_content_rect(0, 0, | 851 gfx::Rect full_content_rect(static_cast<int>(page_x_double), |
| 852 static_cast<int>(page_y_double), |
852 cairo_image_surface_get_width(page_surface), | 853 cairo_image_surface_get_width(page_surface), |
853 cairo_image_surface_get_height(page_surface)); | 854 cairo_image_surface_get_height(page_surface)); |
854 #endif | 855 #endif |
855 // According to comments in the Windows code, the damage rect that we're given | 856 // According to comments in the Windows code, the damage rect that we're given |
856 // may project outside the image, so intersect their rects. | 857 // may project outside the image, so intersect their rects. |
857 gfx::Rect content_rect = rect.Intersect(full_content_rect); | 858 gfx::Rect content_rect = rect.Intersect(full_content_rect); |
858 | 859 |
859 #if defined(OS_MACOSX) | 860 #if defined(OS_MACOSX) |
860 const unsigned char* page_bytes = static_cast<const unsigned char*>( | 861 const unsigned char* page_bytes = static_cast<const unsigned char*>( |
861 CGBitmapContextGetData(context)); | 862 CGBitmapContextGetData(context)); |
(...skipping 12 matching lines...) Expand all Loading... |
874 int full_bg_width = CGBitmapContextGetWidth(bg_context); | 875 int full_bg_width = CGBitmapContextGetWidth(bg_context); |
875 int full_bg_height = CGBitmapContextGetHeight(bg_context); | 876 int full_bg_height = CGBitmapContextGetHeight(bg_context); |
876 int bg_stride = CGBitmapContextGetBytesPerRow(bg_context); | 877 int bg_stride = CGBitmapContextGetBytesPerRow(bg_context); |
877 int bg_last_row = CGBitmapContextGetHeight(bg_context) - 1; | 878 int bg_last_row = CGBitmapContextGetHeight(bg_context) - 1; |
878 | 879 |
879 int bytes_per_pixel = CGBitmapContextGetBitsPerPixel(context) / 8; | 880 int bytes_per_pixel = CGBitmapContextGetBitsPerPixel(context) / 8; |
880 #else | 881 #else |
881 cairo_surface_flush(page_surface); | 882 cairo_surface_flush(page_surface); |
882 const unsigned char* page_bytes = cairo_image_surface_get_data(page_surface); | 883 const unsigned char* page_bytes = cairo_image_surface_get_data(page_surface); |
883 int page_stride = cairo_image_surface_get_stride(page_surface); | 884 int page_stride = cairo_image_surface_get_stride(page_surface); |
884 int page_start_x = static_cast<int>(page_x_double); | 885 int page_start_x = content_rect.x() - static_cast<int>(page_x_double); |
885 int page_start_y = static_cast<int>(page_y_double); | 886 int page_start_y = content_rect.y() - static_cast<int>(page_y_double); |
886 | 887 |
887 skia::ScopedPlatformPaint scoped_platform_paint( | 888 skia::ScopedPlatformPaint scoped_platform_paint( |
888 background_store_.canvas.get()); | 889 background_store_.canvas.get()); |
889 cairo_surface_t* bg_surface =cairo_get_target( | 890 cairo_surface_t* bg_surface =cairo_get_target( |
890 scoped_platform_paint.GetPlatformSurface()); | 891 scoped_platform_paint.GetPlatformSurface()); |
891 DCHECK_EQ(cairo_surface_get_type(bg_surface), CAIRO_SURFACE_TYPE_IMAGE); | 892 DCHECK_EQ(cairo_surface_get_type(bg_surface), CAIRO_SURFACE_TYPE_IMAGE); |
892 DCHECK_EQ(cairo_image_surface_get_format(bg_surface), CAIRO_FORMAT_ARGB32); | 893 DCHECK_EQ(cairo_image_surface_get_format(bg_surface), CAIRO_FORMAT_ARGB32); |
893 cairo_surface_flush(bg_surface); | 894 cairo_surface_flush(bg_surface); |
894 const unsigned char* bg_bytes = cairo_image_surface_get_data(bg_surface); | 895 const unsigned char* bg_bytes = cairo_image_surface_get_data(bg_surface); |
895 int full_bg_width = cairo_image_surface_get_width(bg_surface); | 896 int full_bg_width = cairo_image_surface_get_width(bg_surface); |
(...skipping 584 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1480 } | 1481 } |
1481 #endif | 1482 #endif |
1482 | 1483 |
1483 void WebPluginDelegateProxy::OnURLRedirectResponse(bool allow, | 1484 void WebPluginDelegateProxy::OnURLRedirectResponse(bool allow, |
1484 int resource_id) { | 1485 int resource_id) { |
1485 if (!plugin_) | 1486 if (!plugin_) |
1486 return; | 1487 return; |
1487 | 1488 |
1488 plugin_->URLRedirectResponse(allow, resource_id); | 1489 plugin_->URLRedirectResponse(allow, resource_id); |
1489 } | 1490 } |
OLD | NEW |