OLD | NEW |
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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 "chrome/renderer/webplugin_delegate_proxy.h" | 5 #include "chrome/renderer/webplugin_delegate_proxy.h" |
6 | 6 |
7 #include "build/build_config.h" | 7 #include "build/build_config.h" |
8 | 8 |
9 #if defined(OS_WIN) | 9 #if defined(OS_WIN) |
10 #include <atlbase.h> | 10 #include <atlbase.h> |
(...skipping 842 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
853 | 853 |
854 void WebPluginDelegateProxy::OnMissingPluginStatus(int status) { | 854 void WebPluginDelegateProxy::OnMissingPluginStatus(int status) { |
855 if (render_view_) | 855 if (render_view_) |
856 render_view_->OnMissingPluginStatus(this, status); | 856 render_view_->OnMissingPluginStatus(this, status); |
857 } | 857 } |
858 | 858 |
859 void WebPluginDelegateProxy::OnGetCPBrowsingContext(uint32* context) { | 859 void WebPluginDelegateProxy::OnGetCPBrowsingContext(uint32* context) { |
860 *context = render_view_ ? render_view_->GetCPBrowsingContext() : 0; | 860 *context = render_view_ ? render_view_->GetCPBrowsingContext() : 0; |
861 } | 861 } |
862 | 862 |
863 void WebPluginDelegateProxy::PaintSadPlugin(gfx::NativeDrawingContext hdc, | 863 void WebPluginDelegateProxy::PaintSadPlugin(gfx::NativeDrawingContext context, |
864 const gfx::Rect& rect) { | 864 const gfx::Rect& rect) { |
865 const int width = plugin_rect_.width(); | 865 const int width = plugin_rect_.width(); |
866 const int height = plugin_rect_.height(); | 866 const int height = plugin_rect_.height(); |
867 | 867 |
868 gfx::Canvas canvas(width, height, false); | 868 gfx::Canvas canvas(width, height, false); |
869 SkPaint paint; | 869 SkPaint paint; |
870 | 870 |
871 paint.setStyle(SkPaint::kFill_Style); | 871 paint.setStyle(SkPaint::kFill_Style); |
872 paint.setColor(SK_ColorBLACK); | 872 paint.setColor(SK_ColorBLACK); |
873 canvas.drawRectCoords(0, 0, SkIntToScalar(width), SkIntToScalar(height), | 873 canvas.drawRectCoords(0, 0, SkIntToScalar(width), SkIntToScalar(height), |
874 paint); | 874 paint); |
875 | 875 |
876 if (!sad_plugin_) { | 876 if (!sad_plugin_) { |
877 sad_plugin_ = ResourceBundle::GetSharedInstance().GetBitmapNamed( | 877 sad_plugin_ = ResourceBundle::GetSharedInstance().GetBitmapNamed( |
878 IDR_SAD_PLUGIN); | 878 IDR_SAD_PLUGIN); |
879 } | 879 } |
880 | 880 |
881 if (sad_plugin_) { | 881 if (sad_plugin_) { |
882 canvas.DrawBitmapInt(*sad_plugin_, | 882 canvas.DrawBitmapInt(*sad_plugin_, |
883 std::max(0, (width - sad_plugin_->width())/2), | 883 std::max(0, (width - sad_plugin_->width())/2), |
884 std::max(0, (height - sad_plugin_->height())/2)); | 884 std::max(0, (height - sad_plugin_->height())/2)); |
885 } | 885 } |
886 | 886 |
887 #if defined(OS_WIN) | 887 #if defined(OS_WIN) |
888 skia::PlatformDevice& device = canvas.getTopPlatformDevice(); | 888 skia::PlatformDevice& device = canvas.getTopPlatformDevice(); |
889 device.drawToHDC(hdc, plugin_rect_.x(), plugin_rect_.y(), NULL); | 889 device.drawToHDC(context, plugin_rect_.x(), plugin_rect_.y(), NULL); |
890 #elif defined(OS_LINUX) | 890 #elif defined(OS_LINUX) |
891 // Though conceptually we've been handed a cairo_surface_t* and we | 891 cairo_t* cairo = canvas.getTopPlatformDevice().beginPlatformPaint(); |
892 // could've just hooked up the canvas to draw directly onto it, our | 892 cairo_set_source_surface(cairo, cairo_get_target(context), |
893 // canvas implementation currently uses cairo as a dumb pixel buffer | 893 plugin_rect_.x(), plugin_rect_.y()); |
894 // and would have done the following copy anyway. | |
895 // TODO(evanm): revisit when we have printing hooked up, as that might | |
896 // change our usage of cairo. | |
897 skia::PlatformDevice& device = canvas.getTopPlatformDevice(); | |
898 cairo_t* cairo = cairo_create(hdc); | |
899 cairo_surface_t* source_surface = device.beginPlatformPaint(); | |
900 cairo_set_source_surface(cairo, source_surface, plugin_rect_.x(), plugin_rect_
.y()); | |
901 cairo_paint(cairo); | 894 cairo_paint(cairo); |
902 cairo_destroy(cairo); | 895 cairo_destroy(cairo); |
903 // We have no endPlatformPaint() on the Linux PlatformDevice. | 896 // We have no endPlatformPaint() on the Linux PlatformDevice. |
904 // The surface is owned by the device. | 897 // The surface is owned by the device. |
905 #else | 898 #else |
906 NOTIMPLEMENTED(); | 899 NOTIMPLEMENTED(); |
907 #endif | 900 #endif |
908 } | 901 } |
909 | 902 |
910 void WebPluginDelegateProxy::CopyFromTransportToBacking(const gfx::Rect& rect) { | 903 void WebPluginDelegateProxy::CopyFromTransportToBacking(const gfx::Rect& rect) { |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
962 plugin_->CancelDocumentLoad(); | 955 plugin_->CancelDocumentLoad(); |
963 } | 956 } |
964 | 957 |
965 void WebPluginDelegateProxy::OnInitiateHTTPRangeRequest( | 958 void WebPluginDelegateProxy::OnInitiateHTTPRangeRequest( |
966 const std::string& url, const std::string& range_info, | 959 const std::string& url, const std::string& range_info, |
967 intptr_t existing_stream, bool notify_needed, intptr_t notify_data) { | 960 intptr_t existing_stream, bool notify_needed, intptr_t notify_data) { |
968 plugin_->InitiateHTTPRangeRequest(url.c_str(), range_info.c_str(), | 961 plugin_->InitiateHTTPRangeRequest(url.c_str(), range_info.c_str(), |
969 existing_stream, notify_needed, | 962 existing_stream, notify_needed, |
970 notify_data); | 963 notify_data); |
971 } | 964 } |
OLD | NEW |