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

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

Issue 6691067: Fixed a few styles issues in skia::PlatformDevice. Made function names consistent. Added Begin/En... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' 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 | « skia/ext/vector_platform_device_emf_win.cc ('k') | no next file » | 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 1302 matching lines...) Expand 10 before | Expand all | Expand 10 after
1313 canvas->drawBitmapRect(*bitmap, &src_rect, dest_rect); 1313 canvas->drawBitmapRect(*bitmap, &src_rect, dest_rect);
1314 #endif // defined(OS_MACOSX) 1314 #endif // defined(OS_MACOSX)
1315 return true; 1315 return true;
1316 } 1316 }
1317 1317
1318 #if defined(OS_WIN) 1318 #if defined(OS_WIN)
1319 bool PluginInstance::DrawJPEGToPlatformDC( 1319 bool PluginInstance::DrawJPEGToPlatformDC(
1320 const SkBitmap& bitmap, 1320 const SkBitmap& bitmap,
1321 const gfx::Rect& printable_area, 1321 const gfx::Rect& printable_area,
1322 WebKit::WebCanvas* canvas) { 1322 WebKit::WebCanvas* canvas) {
1323 HDC dc = canvas->beginPlatformPaint();
1324 // TODO(sanjeevr): This is a temporary hack. If we output a JPEG
1325 // to the EMF, the EnumEnhMetaFile call fails in the browser
1326 // process. The failure also happens if we output nothing here.
1327 // We need to investigate the reason for this failure and fix it.
1328 // In the meantime this temporary hack of drawing an empty
1329 // rectangle in the DC gets us by.
1330 Rectangle(dc, 0, 0, 0, 0);
1331
1332 // Ideally we should add JPEG compression to the VectorPlatformDevice class 1323 // Ideally we should add JPEG compression to the VectorPlatformDevice class
1333 // However, Skia currently has no JPEG compression code and we cannot 1324 // However, Skia currently has no JPEG compression code and we cannot
1334 // depend on gfx/jpeg_codec.h in Skia. So we do the compression here. 1325 // depend on gfx/jpeg_codec.h in Skia. So we do the compression here.
1335 SkAutoLockPixels lock(bitmap); 1326 SkAutoLockPixels lock(bitmap);
1336 DCHECK(bitmap.getConfig() == SkBitmap::kARGB_8888_Config); 1327 DCHECK(bitmap.getConfig() == SkBitmap::kARGB_8888_Config);
1337 const uint32_t* pixels = 1328 const uint32_t* pixels =
1338 static_cast<const uint32_t*>(bitmap.getPixels()); 1329 static_cast<const uint32_t*>(bitmap.getPixels());
1339 std::vector<unsigned char> compressed_image; 1330 std::vector<unsigned char> compressed_image;
1340 base::TimeTicks start_time = base::TimeTicks::Now(); 1331 base::TimeTicks start_time = base::TimeTicks::Now();
1341 bool encoded = gfx::JPEGCodec::Encode( 1332 bool encoded = gfx::JPEGCodec::Encode(
1342 reinterpret_cast<const unsigned char*>(pixels), 1333 reinterpret_cast<const unsigned char*>(pixels),
1343 gfx::JPEGCodec::FORMAT_BGRA, bitmap.width(), bitmap.height(), 1334 gfx::JPEGCodec::FORMAT_BGRA, bitmap.width(), bitmap.height(),
1344 static_cast<int>(bitmap.rowBytes()), 100, &compressed_image); 1335 static_cast<int>(bitmap.rowBytes()), 100, &compressed_image);
1345 UMA_HISTOGRAM_TIMES("PepperPluginPrint.RasterBitmapCompressTime", 1336 UMA_HISTOGRAM_TIMES("PepperPluginPrint.RasterBitmapCompressTime",
1346 base::TimeTicks::Now() - start_time); 1337 base::TimeTicks::Now() - start_time);
1347 if (!encoded) { 1338 if (!encoded) {
1348 NOTREACHED(); 1339 NOTREACHED();
1349 return false; 1340 return false;
1350 } 1341 }
1342
1343 HDC dc = canvas->beginPlatformPaint();
1344 // TODO(sanjeevr): This is a temporary hack. If we output a JPEG
1345 // to the EMF, the EnumEnhMetaFile call fails in the browser
1346 // process. The failure also happens if we output nothing here.
1347 // We need to investigate the reason for this failure and fix it.
1348 // In the meantime this temporary hack of drawing an empty
1349 // rectangle in the DC gets us by.
1350 Rectangle(dc, 0, 0, 0, 0);
1351 BITMAPINFOHEADER bmi = {0}; 1351 BITMAPINFOHEADER bmi = {0};
1352 gfx::CreateBitmapHeader(bitmap.width(), bitmap.height(), &bmi); 1352 gfx::CreateBitmapHeader(bitmap.width(), bitmap.height(), &bmi);
1353 bmi.biCompression = BI_JPEG; 1353 bmi.biCompression = BI_JPEG;
1354 bmi.biSizeImage = compressed_image.size(); 1354 bmi.biSizeImage = compressed_image.size();
1355 bmi.biHeight = -bmi.biHeight; 1355 bmi.biHeight = -bmi.biHeight;
1356 StretchDIBits(dc, printable_area.x(), printable_area.y(), 1356 StretchDIBits(dc, printable_area.x(), printable_area.y(),
1357 printable_area.width(), printable_area.height(), 1357 printable_area.width(), printable_area.height(),
1358 0, 0, bitmap.width(), bitmap.height(), 1358 0, 0, bitmap.width(), bitmap.height(),
1359 &compressed_image.front(), 1359 &compressed_image.front(),
1360 reinterpret_cast<const BITMAPINFO*>(&bmi), 1360 reinterpret_cast<const BITMAPINFO*>(&bmi),
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
1468 return found->second; 1468 return found->second;
1469 } 1469 }
1470 1470
1471 bool PluginInstance::IsFullPagePlugin() const { 1471 bool PluginInstance::IsFullPagePlugin() const {
1472 WebFrame* frame = container()->element().document().frame(); 1472 WebFrame* frame = container()->element().document().frame();
1473 return frame->view()->mainFrame()->document().isPluginDocument(); 1473 return frame->view()->mainFrame()->document().isPluginDocument();
1474 } 1474 }
1475 1475
1476 } // namespace ppapi 1476 } // namespace ppapi
1477 } // namespace webkit 1477 } // namespace webkit
OLDNEW
« no previous file with comments | « skia/ext/vector_platform_device_emf_win.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698