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

Side by Side Diff: printing/emf_win.cc

Issue 9428046: Remove histograms from printing/emf_win.cc. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 8 years, 10 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 | « no previous file | 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) 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 "printing/emf_win.h" 5 #include "printing/emf_win.h"
6 6
7 #include "base/file_path.h" 7 #include "base/file_path.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "base/memory/scoped_ptr.h" 9 #include "base/memory/scoped_ptr.h"
10 #include "base/metrics/histogram.h"
11 #include "base/time.h"
12 #include "skia/ext/vector_platform_device_emf_win.h" 10 #include "skia/ext/vector_platform_device_emf_win.h"
13 #include "third_party/skia/include/core/SkBitmap.h" 11 #include "third_party/skia/include/core/SkBitmap.h"
14 #include "ui/gfx/codec/jpeg_codec.h" 12 #include "ui/gfx/codec/jpeg_codec.h"
15 #include "ui/gfx/codec/png_codec.h" 13 #include "ui/gfx/codec/png_codec.h"
16 #include "ui/gfx/gdi_util.h" 14 #include "ui/gfx/gdi_util.h"
17 #include "ui/gfx/point.h"
18 #include "ui/gfx/rect.h" 15 #include "ui/gfx/rect.h"
19 #include "ui/gfx/size.h" 16 #include "ui/gfx/size.h"
20 17
21 namespace { 18 namespace {
22 const int kCustomGdiCommentSignature = 0xdeadbabe; 19 const int kCustomGdiCommentSignature = 0xdeadbabe;
23 struct PageBreakRecord { 20 struct PageBreakRecord {
24 int signature; 21 int signature;
25 enum PageBreakType { 22 enum PageBreakType {
26 START_PAGE, 23 START_PAGE,
27 END_PAGE, 24 END_PAGE,
(...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after
273 sdib_record->offBmiSrc); 270 sdib_record->offBmiSrc);
274 const BYTE* bits = record_start + sdib_record->offBitsSrc; 271 const BYTE* bits = record_start + sdib_record->offBitsSrc;
275 bool play_normally = true; 272 bool play_normally = true;
276 res = false; 273 res = false;
277 HDC hdc = context_->hdc; 274 HDC hdc = context_->hdc;
278 scoped_ptr<SkBitmap> bitmap; 275 scoped_ptr<SkBitmap> bitmap;
279 if (bmih->biCompression == BI_JPEG) { 276 if (bmih->biCompression == BI_JPEG) {
280 if (!DIBFormatNativelySupported(hdc, CHECKJPEGFORMAT, bits, 277 if (!DIBFormatNativelySupported(hdc, CHECKJPEGFORMAT, bits,
281 bmih->biSizeImage)) { 278 bmih->biSizeImage)) {
282 play_normally = false; 279 play_normally = false;
283 base::TimeTicks start_time = base::TimeTicks::Now();
284 bitmap.reset(gfx::JPEGCodec::Decode(bits, bmih->biSizeImage)); 280 bitmap.reset(gfx::JPEGCodec::Decode(bits, bmih->biSizeImage));
285 UMA_HISTOGRAM_TIMES("Printing.JPEGDecompressTime",
286 base::TimeTicks::Now() - start_time);
287 } 281 }
288 } else if (bmih->biCompression == BI_PNG) { 282 } else if (bmih->biCompression == BI_PNG) {
289 if (!DIBFormatNativelySupported(hdc, CHECKPNGFORMAT, bits, 283 if (!DIBFormatNativelySupported(hdc, CHECKPNGFORMAT, bits,
290 bmih->biSizeImage)) { 284 bmih->biSizeImage)) {
291 play_normally = false; 285 play_normally = false;
292 bitmap.reset(new SkBitmap()); 286 bitmap.reset(new SkBitmap());
293 base::TimeTicks start_time = base::TimeTicks::Now();
294 gfx::PNGCodec::Decode(bits, bmih->biSizeImage, bitmap.get()); 287 gfx::PNGCodec::Decode(bits, bmih->biSizeImage, bitmap.get());
295 UMA_HISTOGRAM_TIMES("Printing.PNGDecompressTime",
296 base::TimeTicks::Now() - start_time);
297 } 288 }
298 } 289 }
299 if (!play_normally) { 290 if (!play_normally) {
300 DCHECK(bitmap.get()); 291 DCHECK(bitmap.get());
301 if (bitmap.get()) { 292 if (bitmap.get()) {
302 SkAutoLockPixels lock(*bitmap.get()); 293 SkAutoLockPixels lock(*bitmap.get());
303 DCHECK_EQ(bitmap->getConfig(), SkBitmap::kARGB_8888_Config); 294 DCHECK_EQ(bitmap->getConfig(), SkBitmap::kARGB_8888_Config);
304 const uint32_t* pixels = 295 const uint32_t* pixels =
305 static_cast<const uint32_t*>(bitmap->getPixels()); 296 static_cast<const uint32_t*>(bitmap->getPixels());
306 if (pixels == NULL) { 297 if (pixels == NULL) {
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after
474 } else { 465 } else {
475 DCHECK_EQ(emf.context_.handle_table, handle_table); 466 DCHECK_EQ(emf.context_.handle_table, handle_table);
476 DCHECK_EQ(emf.context_.objects_count, objects_count); 467 DCHECK_EQ(emf.context_.objects_count, objects_count);
477 DCHECK_EQ(emf.context_.hdc, hdc); 468 DCHECK_EQ(emf.context_.hdc, hdc);
478 } 469 }
479 emf.items_.push_back(Record(&emf.context_, record)); 470 emf.items_.push_back(Record(&emf.context_, record));
480 return 1; 471 return 1;
481 } 472 }
482 473
483 } // namespace printing 474 } // namespace printing
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698