| 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 <string> | 9 #include <string> |
| 10 #include <utility> | 10 #include <utility> |
| (...skipping 17 matching lines...) Expand all Loading... |
| 28 #include "content/public/renderer/chrome_object_extensions_utils.h" | 28 #include "content/public/renderer/chrome_object_extensions_utils.h" |
| 29 #include "content/public/renderer/render_thread.h" | 29 #include "content/public/renderer/render_thread.h" |
| 30 #include "content/renderer/gpu/render_widget_compositor.h" | 30 #include "content/renderer/gpu/render_widget_compositor.h" |
| 31 #include "content/renderer/render_thread_impl.h" | 31 #include "content/renderer/render_thread_impl.h" |
| 32 #include "content/renderer/render_view_impl.h" | 32 #include "content/renderer/render_view_impl.h" |
| 33 #include "content/renderer/skia_benchmarking_extension.h" | 33 #include "content/renderer/skia_benchmarking_extension.h" |
| 34 #include "gin/arguments.h" | 34 #include "gin/arguments.h" |
| 35 #include "gin/handle.h" | 35 #include "gin/handle.h" |
| 36 #include "gin/object_template_builder.h" | 36 #include "gin/object_template_builder.h" |
| 37 #include "gpu/ipc/common/gpu_messages.h" | 37 #include "gpu/ipc/common/gpu_messages.h" |
| 38 #include "skia/ext/skia_encode_image.h" |
| 38 #include "third_party/WebKit/public/web/WebImageCache.h" | 39 #include "third_party/WebKit/public/web/WebImageCache.h" |
| 39 #include "third_party/WebKit/public/web/WebKit.h" | 40 #include "third_party/WebKit/public/web/WebKit.h" |
| 40 #include "third_party/WebKit/public/web/WebLocalFrame.h" | 41 #include "third_party/WebKit/public/web/WebLocalFrame.h" |
| 41 #include "third_party/WebKit/public/web/WebPrintParams.h" | 42 #include "third_party/WebKit/public/web/WebPrintParams.h" |
| 42 #include "third_party/WebKit/public/web/WebSettings.h" | 43 #include "third_party/WebKit/public/web/WebSettings.h" |
| 43 #include "third_party/WebKit/public/web/WebView.h" | 44 #include "third_party/WebKit/public/web/WebView.h" |
| 44 #include "third_party/skia/include/core/SkData.h" | 45 #include "third_party/skia/include/core/SkData.h" |
| 45 #include "third_party/skia/include/core/SkGraphics.h" | 46 #include "third_party/skia/include/core/SkGraphics.h" |
| 46 #include "third_party/skia/include/core/SkPicture.h" | 47 #include "third_party/skia/include/core/SkPicture.h" |
| 47 #include "third_party/skia/include/core/SkPictureRecorder.h" | 48 #include "third_party/skia/include/core/SkPictureRecorder.h" |
| 48 #include "third_party/skia/include/core/SkPixelRef.h" | 49 #include "third_party/skia/include/core/SkPixelRef.h" |
| 49 #include "third_party/skia/include/core/SkPixelSerializer.h" | 50 #include "third_party/skia/include/core/SkPixelSerializer.h" |
| 50 #include "third_party/skia/include/core/SkStream.h" | 51 #include "third_party/skia/include/core/SkStream.h" |
| 51 // Note that headers in third_party/skia/src are fragile. This is | 52 // Note that headers in third_party/skia/src are fragile. This is |
| 52 // an experimental, fragile, and diagnostic-only document type. | 53 // an experimental, fragile, and diagnostic-only document type. |
| 53 #include "third_party/skia/src/utils/SkMultiPictureDocument.h" | 54 #include "third_party/skia/src/utils/SkMultiPictureDocument.h" |
| 55 #include "ui/gfx/codec/install_skia_codec.h" |
| 54 #include "ui/gfx/codec/png_codec.h" | 56 #include "ui/gfx/codec/png_codec.h" |
| 55 #include "v8/include/v8.h" | 57 #include "v8/include/v8.h" |
| 56 | 58 |
| 57 using blink::WebCanvas; | 59 using blink::WebCanvas; |
| 58 using blink::WebLocalFrame; | 60 using blink::WebLocalFrame; |
| 59 using blink::WebImageCache; | 61 using blink::WebImageCache; |
| 60 using blink::WebPrivatePtr; | 62 using blink::WebPrivatePtr; |
| 61 using blink::WebSize; | 63 using blink::WebSize; |
| 62 using blink::WebView; | 64 using blink::WebView; |
| 63 | 65 |
| (...skipping 523 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 587 context.compositor()->SetRasterizeOnlyVisibleContent(); | 589 context.compositor()->SetRasterizeOnlyVisibleContent(); |
| 588 } | 590 } |
| 589 | 591 |
| 590 void GpuBenchmarking::PrintPagesToSkPictures(v8::Isolate* isolate, | 592 void GpuBenchmarking::PrintPagesToSkPictures(v8::Isolate* isolate, |
| 591 const std::string& filename) { | 593 const std::string& filename) { |
| 592 PrintDocumentTofile(isolate, filename, &SkMakeMultiPictureDocument); | 594 PrintDocumentTofile(isolate, filename, &SkMakeMultiPictureDocument); |
| 593 } | 595 } |
| 594 | 596 |
| 595 void GpuBenchmarking::PrintPagesToXPS(v8::Isolate* isolate, | 597 void GpuBenchmarking::PrintPagesToXPS(v8::Isolate* isolate, |
| 596 const std::string& filename) { | 598 const std::string& filename) { |
| 597 PrintDocumentTofile(isolate, filename, | 599 // SkXPS requires an image encoder be set up. XPS needs to me configured to |
| 598 [](SkWStream* s) { return SkDocument::MakeXPS(s); }); | 600 // work outside of the sandbox. TODO(halcanary) implement that, and |
| 601 // call SetImageEncoder will be performed when the sandbox is set up. |
| 602 skia::SetImageEncoder(&gfx::EncodeImage); |
| 603 PrintDocumentTofile(isolate, filename, |
| 604 [](SkWStream* s) { return SkDocument::MakeXPS(s); }); |
| 599 } | 605 } |
| 600 | 606 |
| 601 void GpuBenchmarking::PrintToSkPicture(v8::Isolate* isolate, | 607 void GpuBenchmarking::PrintToSkPicture(v8::Isolate* isolate, |
| 602 const std::string& dirname) { | 608 const std::string& dirname) { |
| 603 GpuBenchmarkingContext context; | 609 GpuBenchmarkingContext context; |
| 604 if (!context.Init(true)) | 610 if (!context.Init(true)) |
| 605 return; | 611 return; |
| 606 | 612 |
| 607 const cc::Layer* root_layer = context.compositor()->GetRootLayer(); | 613 const cc::Layer* root_layer = context.compositor()->GetRootLayer(); |
| 608 if (!root_layer) | 614 if (!root_layer) |
| (...skipping 433 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1042 &gpu_driver_bug_workarounds))) { | 1048 &gpu_driver_bug_workarounds))) { |
| 1043 return; | 1049 return; |
| 1044 } | 1050 } |
| 1045 | 1051 |
| 1046 v8::Local<v8::Value> result; | 1052 v8::Local<v8::Value> result; |
| 1047 if (gin::TryConvertToV8(args->isolate(), gpu_driver_bug_workarounds, &result)) | 1053 if (gin::TryConvertToV8(args->isolate(), gpu_driver_bug_workarounds, &result)) |
| 1048 args->Return(result); | 1054 args->Return(result); |
| 1049 } | 1055 } |
| 1050 | 1056 |
| 1051 } // namespace content | 1057 } // namespace content |
| OLD | NEW |