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 "webkit/plugins/ppapi/ppapi_plugin_instance.h" | 5 #include "webkit/plugins/ppapi/ppapi_plugin_instance.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
9 #include "base/message_loop.h" | 9 #include "base/message_loop.h" |
10 #include "base/metrics/histogram.h" | 10 #include "base/metrics/histogram.h" |
(...skipping 1211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1222 page_rect.origin.y = current_print_settings_.printable_area.point.y; | 1222 page_rect.origin.y = current_print_settings_.printable_area.point.y; |
1223 page_rect.size.width = current_print_settings_.printable_area.size.width; | 1223 page_rect.size.width = current_print_settings_.printable_area.size.width; |
1224 page_rect.size.height = current_print_settings_.printable_area.size.height; | 1224 page_rect.size.height = current_print_settings_.printable_area.size.height; |
1225 | 1225 |
1226 ret = metafile->RenderPage(1, canvas, page_rect, true, false, true, true); | 1226 ret = metafile->RenderPage(1, canvas, page_rect, true, false, true, true); |
1227 CGContextRestoreGState(canvas); | 1227 CGContextRestoreGState(canvas); |
1228 } | 1228 } |
1229 #elif defined(OS_WIN) | 1229 #elif defined(OS_WIN) |
1230 // On Windows, we now need to render the PDF to the DC that backs the | 1230 // On Windows, we now need to render the PDF to the DC that backs the |
1231 // supplied canvas. | 1231 // supplied canvas. |
1232 skia::PlatformCanvas* platform_canvas = | |
1233 static_cast<skia::PlatformCanvas*>(canvas); | |
vangelis
2011/04/01 23:35:54
This seems like a potentially dangerous cast once
alokp
2011/04/04 17:00:13
Ok. Working with reed@ get rid of these static cas
| |
1232 skia::VectorPlatformDevice& device = | 1234 skia::VectorPlatformDevice& device = |
1233 static_cast<skia::VectorPlatformDevice&>( | 1235 static_cast<skia::VectorPlatformDevice&>( |
1234 canvas->getTopPlatformDevice()); | 1236 platform_canvas->getTopPlatformDevice()); |
1235 HDC dc = device.getBitmapDC(); | 1237 HDC dc = device.getBitmapDC(); |
1236 gfx::Size size_in_pixels; | 1238 gfx::Size size_in_pixels; |
1237 size_in_pixels.set_width( | 1239 size_in_pixels.set_width( |
1238 printing::ConvertUnit(current_print_settings_.printable_area.size.width, | 1240 printing::ConvertUnit(current_print_settings_.printable_area.size.width, |
1239 static_cast<int>(printing::kPointsPerInch), | 1241 static_cast<int>(printing::kPointsPerInch), |
1240 current_print_settings_.dpi)); | 1242 current_print_settings_.dpi)); |
1241 size_in_pixels.set_height( | 1243 size_in_pixels.set_height( |
1242 printing::ConvertUnit(current_print_settings_.printable_area.size.height, | 1244 printing::ConvertUnit(current_print_settings_.printable_area.size.height, |
1243 static_cast<int>(printing::kPointsPerInch), | 1245 static_cast<int>(printing::kPointsPerInch), |
1244 current_print_settings_.dpi)); | 1246 current_print_settings_.dpi)); |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1313 canvas->drawBitmapRect(*bitmap, &src_rect, dest_rect); | 1315 canvas->drawBitmapRect(*bitmap, &src_rect, dest_rect); |
1314 #endif // defined(OS_MACOSX) | 1316 #endif // defined(OS_MACOSX) |
1315 return true; | 1317 return true; |
1316 } | 1318 } |
1317 | 1319 |
1318 #if defined(OS_WIN) | 1320 #if defined(OS_WIN) |
1319 bool PluginInstance::DrawJPEGToPlatformDC( | 1321 bool PluginInstance::DrawJPEGToPlatformDC( |
1320 const SkBitmap& bitmap, | 1322 const SkBitmap& bitmap, |
1321 const gfx::Rect& printable_area, | 1323 const gfx::Rect& printable_area, |
1322 WebKit::WebCanvas* canvas) { | 1324 WebKit::WebCanvas* canvas) { |
1325 skia::PlatformCanvas* platform_canvas = | |
1326 static_cast<skia::PlatformCanvas*>(canvas); | |
1323 skia::VectorPlatformDevice& device = | 1327 skia::VectorPlatformDevice& device = |
1324 static_cast<skia::VectorPlatformDevice&>( | 1328 static_cast<skia::VectorPlatformDevice&>( |
1325 canvas->getTopPlatformDevice()); | 1329 platform_canvas->getTopPlatformDevice()); |
1326 HDC dc = device.getBitmapDC(); | 1330 HDC dc = device.getBitmapDC(); |
1327 // TODO(sanjeevr): This is a temporary hack. If we output a JPEG | 1331 // TODO(sanjeevr): This is a temporary hack. If we output a JPEG |
1328 // to the EMF, the EnumEnhMetaFile call fails in the browser | 1332 // to the EMF, the EnumEnhMetaFile call fails in the browser |
1329 // process. The failure also happens if we output nothing here. | 1333 // process. The failure also happens if we output nothing here. |
1330 // We need to investigate the reason for this failure and fix it. | 1334 // We need to investigate the reason for this failure and fix it. |
1331 // In the meantime this temporary hack of drawing an empty | 1335 // In the meantime this temporary hack of drawing an empty |
1332 // rectangle in the DC gets us by. | 1336 // rectangle in the DC gets us by. |
1333 Rectangle(dc, 0, 0, 0, 0); | 1337 Rectangle(dc, 0, 0, 0, 0); |
1334 | 1338 |
1335 // Ideally we should add JPEG compression to the VectorPlatformDevice class | 1339 // Ideally we should add JPEG compression to the VectorPlatformDevice class |
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1470 return found->second; | 1474 return found->second; |
1471 } | 1475 } |
1472 | 1476 |
1473 bool PluginInstance::IsFullPagePlugin() const { | 1477 bool PluginInstance::IsFullPagePlugin() const { |
1474 WebFrame* frame = container()->element().document().frame(); | 1478 WebFrame* frame = container()->element().document().frame(); |
1475 return frame->view()->mainFrame()->document().isPluginDocument(); | 1479 return frame->view()->mainFrame()->document().isPluginDocument(); |
1476 } | 1480 } |
1477 | 1481 |
1478 } // namespace ppapi | 1482 } // namespace ppapi |
1479 } // namespace webkit | 1483 } // namespace webkit |
OLD | NEW |