OLD | NEW |
1 // Copyright (c) 2012 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 "content/renderer/gpu/gpu_benchmarking_extension.h" | 5 #include "content/renderer/gpu/gpu_benchmarking_extension.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
| 9 #include <memory> |
9 #include <string> | 10 #include <string> |
10 #include <utility> | 11 #include <utility> |
| 12 #include <vector> |
11 | 13 |
12 #include "base/base64.h" | 14 #include "base/base64.h" |
13 #include "base/command_line.h" | 15 #include "base/command_line.h" |
14 #include "base/files/file_path.h" | 16 #include "base/files/file_path.h" |
15 #include "base/files/file_util.h" | 17 #include "base/files/file_util.h" |
16 #include "base/macros.h" | 18 #include "base/macros.h" |
17 #include "base/memory/ptr_util.h" | 19 #include "base/memory/ptr_util.h" |
18 #include "base/strings/string_number_conversions.h" | 20 #include "base/strings/string_number_conversions.h" |
19 #include "cc/layers/layer.h" | 21 #include "cc/layers/layer.h" |
20 #include "cc/paint/skia_paint_canvas.h" | 22 #include "cc/paint/skia_paint_canvas.h" |
(...skipping 439 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
460 // progress, we will leak the callback and context. This needs to be fixed, | 462 // progress, we will leak the callback and context. This needs to be fixed, |
461 // somehow, see https://crbug.com/678879. | 463 // somehow, see https://crbug.com/678879. |
462 context.render_view_impl()->GetWidget()->QueueSyntheticGesture( | 464 context.render_view_impl()->GetWidget()->QueueSyntheticGesture( |
463 std::move(gesture_params), | 465 std::move(gesture_params), |
464 base::Bind(&OnSyntheticGestureCompleted, | 466 base::Bind(&OnSyntheticGestureCompleted, |
465 base::RetainedRef(callback_and_context))); | 467 base::RetainedRef(callback_and_context))); |
466 | 468 |
467 return true; | 469 return true; |
468 } | 470 } |
469 | 471 |
470 static void PrintDocument(blink::WebFrame* frame, SkDocument* doc) { | 472 static void PrintDocument(blink::WebLocalFrame* frame, SkDocument* doc) { |
471 const float kPageWidth = 612.0f; // 8.5 inch | 473 const float kPageWidth = 612.0f; // 8.5 inch |
472 const float kPageHeight = 792.0f; // 11 inch | 474 const float kPageHeight = 792.0f; // 11 inch |
473 const float kMarginTop = 29.0f; // 0.40 inch | 475 const float kMarginTop = 29.0f; // 0.40 inch |
474 const float kMarginLeft = 29.0f; // 0.40 inch | 476 const float kMarginLeft = 29.0f; // 0.40 inch |
475 const int kContentWidth = 555; // 7.71 inch | 477 const int kContentWidth = 555; // 7.71 inch |
476 const int kContentHeight = 735; // 10.21 inch | 478 const int kContentHeight = 735; // 10.21 inch |
477 blink::WebPrintParams params(blink::WebSize(kContentWidth, kContentHeight)); | 479 blink::WebPrintParams params(blink::WebSize(kContentWidth, kContentHeight)); |
478 params.printer_dpi = 300; | 480 params.printer_dpi = 300; |
479 int page_count = frame->PrintBegin(params); | 481 int page_count = frame->PrintBegin(params); |
480 for (int i = 0; i < page_count; ++i) { | 482 for (int i = 0; i < page_count; ++i) { |
481 SkCanvas* sk_canvas = doc->beginPage(kPageWidth, kPageHeight); | 483 SkCanvas* sk_canvas = doc->beginPage(kPageWidth, kPageHeight); |
482 cc::SkiaPaintCanvas canvas(sk_canvas); | 484 cc::SkiaPaintCanvas canvas(sk_canvas); |
483 cc::PaintCanvasAutoRestore auto_restore(&canvas, true); | 485 cc::PaintCanvasAutoRestore auto_restore(&canvas, true); |
484 canvas.translate(kMarginLeft, kMarginTop); | 486 canvas.translate(kMarginLeft, kMarginTop); |
485 | 487 |
486 #if defined(OS_WIN) || defined(OS_MACOSX) | 488 #if defined(OS_WIN) || defined(OS_MACOSX) |
487 float page_shrink = frame->GetPrintPageShrink(i); | 489 float page_shrink = frame->GetPrintPageShrink(i); |
488 DCHECK(page_shrink > 0); | 490 DCHECK_GT(page_shrink, 0); |
489 canvas.scale(page_shrink, page_shrink); | 491 canvas.scale(page_shrink, page_shrink); |
490 #endif | 492 #endif |
491 | 493 |
492 frame->PrintPage(i, &canvas); | 494 frame->PrintPage(i, &canvas); |
493 } | 495 } |
494 frame->PrintEnd(); | 496 frame->PrintEnd(); |
495 } | 497 } |
496 | 498 |
497 static void PrintDocumentTofile(v8::Isolate* isolate, | 499 static void PrintDocumentTofile(v8::Isolate* isolate, |
498 const std::string& filename, | 500 const std::string& filename, |
(...skipping 634 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1133 &gpu_driver_bug_workarounds))) { | 1135 &gpu_driver_bug_workarounds))) { |
1134 return; | 1136 return; |
1135 } | 1137 } |
1136 | 1138 |
1137 v8::Local<v8::Value> result; | 1139 v8::Local<v8::Value> result; |
1138 if (gin::TryConvertToV8(args->isolate(), gpu_driver_bug_workarounds, &result)) | 1140 if (gin::TryConvertToV8(args->isolate(), gpu_driver_bug_workarounds, &result)) |
1139 args->Return(result); | 1141 args->Return(result); |
1140 } | 1142 } |
1141 | 1143 |
1142 } // namespace content | 1144 } // namespace content |
OLD | NEW |