Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(99)

Side by Side Diff: webkit/plugins/ppapi/ppapi_plugin_instance.cc

Issue 6677142: rename getBitmapDC to beginPlatformPaint and add calls to endPlatformPaint (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Address comments Created 9 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « views/widget/widget_win.cc ('k') | webkit/tools/test_shell/webwidget_host_win.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 1213 matching lines...) Expand 10 before | Expand all | Expand 10 after
1224 page_rect.origin.y = current_print_settings_.printable_area.point.y; 1224 page_rect.origin.y = current_print_settings_.printable_area.point.y;
1225 page_rect.size.width = current_print_settings_.printable_area.size.width; 1225 page_rect.size.width = current_print_settings_.printable_area.size.width;
1226 page_rect.size.height = current_print_settings_.printable_area.size.height; 1226 page_rect.size.height = current_print_settings_.printable_area.size.height;
1227 1227
1228 ret = metafile->RenderPage(1, canvas, page_rect, true, false, true, true); 1228 ret = metafile->RenderPage(1, canvas, page_rect, true, false, true, true);
1229 CGContextRestoreGState(canvas); 1229 CGContextRestoreGState(canvas);
1230 } 1230 }
1231 #elif defined(OS_WIN) 1231 #elif defined(OS_WIN)
1232 // On Windows, we now need to render the PDF to the DC that backs the 1232 // On Windows, we now need to render the PDF to the DC that backs the
1233 // supplied canvas. 1233 // supplied canvas.
1234 skia::VectorPlatformDeviceEmf& device = 1234 HDC dc = canvas->beginPlatformPaint();
1235 static_cast<skia::VectorPlatformDeviceEmf&>(
1236 canvas->getTopPlatformDevice());
1237 HDC dc = device.getBitmapDC();
1238 gfx::Size size_in_pixels; 1235 gfx::Size size_in_pixels;
1239 size_in_pixels.set_width( 1236 size_in_pixels.set_width(
1240 printing::ConvertUnit(current_print_settings_.printable_area.size.width, 1237 printing::ConvertUnit(current_print_settings_.printable_area.size.width,
1241 static_cast<int>(printing::kPointsPerInch), 1238 static_cast<int>(printing::kPointsPerInch),
1242 current_print_settings_.dpi)); 1239 current_print_settings_.dpi));
1243 size_in_pixels.set_height( 1240 size_in_pixels.set_height(
1244 printing::ConvertUnit(current_print_settings_.printable_area.size.height, 1241 printing::ConvertUnit(current_print_settings_.printable_area.size.height,
1245 static_cast<int>(printing::kPointsPerInch), 1242 static_cast<int>(printing::kPointsPerInch),
1246 current_print_settings_.dpi)); 1243 current_print_settings_.dpi));
1247 // We need to render using the actual printer DPI (rendering to a smaller 1244 // We need to render using the actual printer DPI (rendering to a smaller
1248 // set of pixels leads to a blurry output). However, we need to counter the 1245 // set of pixels leads to a blurry output). However, we need to counter the
1249 // scaling up that will happen in the browser. 1246 // scaling up that will happen in the browser.
1250 XFORM xform = {0}; 1247 XFORM xform = {0};
1251 xform.eM11 = xform.eM22 = static_cast<float>(printing::kPointsPerInch) / 1248 xform.eM11 = xform.eM22 = static_cast<float>(printing::kPointsPerInch) /
1252 static_cast<float>(current_print_settings_.dpi); 1249 static_cast<float>(current_print_settings_.dpi);
1253 ModifyWorldTransform(dc, &xform, MWT_LEFTMULTIPLY); 1250 ModifyWorldTransform(dc, &xform, MWT_LEFTMULTIPLY);
1254 1251
1255 ret = render_proc(buffer->mapped_buffer(), buffer->size(), 0, dc, 1252 ret = render_proc(buffer->mapped_buffer(), buffer->size(), 0, dc,
1256 current_print_settings_.dpi, current_print_settings_.dpi, 1253 current_print_settings_.dpi, current_print_settings_.dpi,
1257 0, 0, size_in_pixels.width(), 1254 0, 0, size_in_pixels.width(),
1258 size_in_pixels.height(), true, false, true, true); 1255 size_in_pixels.height(), true, false, true, true);
1256 canvas->endPlatformPaint();
1259 #endif // defined(OS_WIN) 1257 #endif // defined(OS_WIN)
1260 1258
1261 return ret; 1259 return ret;
1262 } 1260 }
1263 1261
1264 bool PluginInstance::PrintRasterOutput(PP_Resource print_output, 1262 bool PluginInstance::PrintRasterOutput(PP_Resource print_output,
1265 WebKit::WebCanvas* canvas) { 1263 WebKit::WebCanvas* canvas) {
1266 scoped_refptr<PPB_ImageData_Impl> image( 1264 scoped_refptr<PPB_ImageData_Impl> image(
1267 Resource::GetAs<PPB_ImageData_Impl>(print_output)); 1265 Resource::GetAs<PPB_ImageData_Impl>(print_output));
1268 if (!image.get() || !image->is_mapped()) 1266 if (!image.get() || !image->is_mapped())
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
1315 canvas->drawBitmapRect(*bitmap, &src_rect, dest_rect); 1313 canvas->drawBitmapRect(*bitmap, &src_rect, dest_rect);
1316 #endif // defined(OS_MACOSX) 1314 #endif // defined(OS_MACOSX)
1317 return true; 1315 return true;
1318 } 1316 }
1319 1317
1320 #if defined(OS_WIN) 1318 #if defined(OS_WIN)
1321 bool PluginInstance::DrawJPEGToPlatformDC( 1319 bool PluginInstance::DrawJPEGToPlatformDC(
1322 const SkBitmap& bitmap, 1320 const SkBitmap& bitmap,
1323 const gfx::Rect& printable_area, 1321 const gfx::Rect& printable_area,
1324 WebKit::WebCanvas* canvas) { 1322 WebKit::WebCanvas* canvas) {
1325 skia::VectorPlatformDeviceEmf& device = 1323 HDC dc = canvas->beginPlatformPaint();
1326 static_cast<skia::VectorPlatformDeviceEmf&>(
1327 canvas->getTopPlatformDevice());
1328 HDC dc = device.getBitmapDC();
1329 // TODO(sanjeevr): This is a temporary hack. If we output a JPEG 1324 // TODO(sanjeevr): This is a temporary hack. If we output a JPEG
1330 // to the EMF, the EnumEnhMetaFile call fails in the browser 1325 // to the EMF, the EnumEnhMetaFile call fails in the browser
1331 // process. The failure also happens if we output nothing here. 1326 // process. The failure also happens if we output nothing here.
1332 // We need to investigate the reason for this failure and fix it. 1327 // We need to investigate the reason for this failure and fix it.
1333 // In the meantime this temporary hack of drawing an empty 1328 // In the meantime this temporary hack of drawing an empty
1334 // rectangle in the DC gets us by. 1329 // rectangle in the DC gets us by.
1335 Rectangle(dc, 0, 0, 0, 0); 1330 Rectangle(dc, 0, 0, 0, 0);
1336 1331
1337 // Ideally we should add JPEG compression to the VectorPlatformDevice class 1332 // Ideally we should add JPEG compression to the VectorPlatformDevice class
1338 // However, Skia currently has no JPEG compression code and we cannot 1333 // However, Skia currently has no JPEG compression code and we cannot
(...skipping 18 matching lines...) Expand all
1357 gfx::CreateBitmapHeader(bitmap.width(), bitmap.height(), &bmi); 1352 gfx::CreateBitmapHeader(bitmap.width(), bitmap.height(), &bmi);
1358 bmi.biCompression = BI_JPEG; 1353 bmi.biCompression = BI_JPEG;
1359 bmi.biSizeImage = compressed_image.size(); 1354 bmi.biSizeImage = compressed_image.size();
1360 bmi.biHeight = -bmi.biHeight; 1355 bmi.biHeight = -bmi.biHeight;
1361 StretchDIBits(dc, printable_area.x(), printable_area.y(), 1356 StretchDIBits(dc, printable_area.x(), printable_area.y(),
1362 printable_area.width(), printable_area.height(), 1357 printable_area.width(), printable_area.height(),
1363 0, 0, bitmap.width(), bitmap.height(), 1358 0, 0, bitmap.width(), bitmap.height(),
1364 &compressed_image.front(), 1359 &compressed_image.front(),
1365 reinterpret_cast<const BITMAPINFO*>(&bmi), 1360 reinterpret_cast<const BITMAPINFO*>(&bmi),
1366 DIB_RGB_COLORS, SRCCOPY); 1361 DIB_RGB_COLORS, SRCCOPY);
1362 canvas->endPlatformPaint();
1367 return true; 1363 return true;
1368 } 1364 }
1369 #endif // OS_WIN 1365 #endif // OS_WIN
1370 1366
1371 #if defined(OS_MACOSX) 1367 #if defined(OS_MACOSX)
1372 void PluginInstance::DrawSkBitmapToCanvas( 1368 void PluginInstance::DrawSkBitmapToCanvas(
1373 const SkBitmap& bitmap, WebKit::WebCanvas* canvas, 1369 const SkBitmap& bitmap, WebKit::WebCanvas* canvas,
1374 const gfx::Rect& dest_rect, 1370 const gfx::Rect& dest_rect,
1375 int canvas_height) { 1371 int canvas_height) {
1376 SkAutoLockPixels lock(bitmap); 1372 SkAutoLockPixels lock(bitmap);
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
1472 return found->second; 1468 return found->second;
1473 } 1469 }
1474 1470
1475 bool PluginInstance::IsFullPagePlugin() const { 1471 bool PluginInstance::IsFullPagePlugin() const {
1476 WebFrame* frame = container()->element().document().frame(); 1472 WebFrame* frame = container()->element().document().frame();
1477 return frame->view()->mainFrame()->document().isPluginDocument(); 1473 return frame->view()->mainFrame()->document().isPluginDocument();
1478 } 1474 }
1479 1475
1480 } // namespace ppapi 1476 } // namespace ppapi
1481 } // namespace webkit 1477 } // namespace webkit
OLDNEW
« no previous file with comments | « views/widget/widget_win.cc ('k') | webkit/tools/test_shell/webwidget_host_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698