From 2607e3bbc370ef99dc9a5fa85e84fee07f938737 Mon Sep 17 00:00:00 2001 From: Hal Canary Date: Tue, 13 Mar 2018 10:57:34 -0400 Subject: scripts to generate [m]skps, documentation NoTry: true Change-Id: Ibd5244fa7099cbbe18e5f68e5a28abb52e03127d Reviewed-on: https://skia-review.googlesource.com/114086 Reviewed-by: Hal Canary Commit-Queue: Hal Canary --- experimental/tools/web_to_mskp | 34 ++++++++++++++++++++++++++++++++++ experimental/tools/web_to_skp | 34 ++++++++++++++++++++++++++++++++++ site/user/tips.md | 12 ++++++++---- 3 files changed, 76 insertions(+), 4 deletions(-) create mode 100755 experimental/tools/web_to_mskp create mode 100755 experimental/tools/web_to_skp diff --git a/experimental/tools/web_to_mskp b/experimental/tools/web_to_mskp new file mode 100755 index 0000000000..c2df8a30cc --- /dev/null +++ b/experimental/tools/web_to_mskp @@ -0,0 +1,34 @@ +#! /bin/sh + +# Copyright 2018 Google Inc. +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +if [ "$(uname)" = Linux ]; then + EXAMPLE='/opt/google/chrome/chrome' +elif [ "$(uname)" = Darwin ]; then + EXAMPLE='"/Applications/Google Chrome.app/Contents/MacOS/Google Chrome"' +else + EXAMPLE='"/c/Program Files (x86)/Google/Chrome/Application/chrome.exe"' +fi + +if [ $# -ne 3 ] || ! [ -x "$1" ]; then + cat >&2 << EOF +usage: + $0 CHROMIUM_BINARY SOURCE_URL DESTINATION_PATH +e.g: + $0 $EXAMPLE https://www.google.com/ /tmp/foo.mskp +EOF + exit 1 +fi + +EXE="$1" +URL="$2" +DST="$3" + +CRASH=~/tmp/headless_crash_dumps +mkdir -p "$CRASH" + +printf 'chrome.gpuBenchmarking.printPagesToSkPictures("%s");\nquit\n' "$DST" | \ + "$EXE" --headless --disable-gpu --repl -crash-dumps-dir="$CRASH" \ + --no-sandbox --enable-gpu-benchmarking "$URL" diff --git a/experimental/tools/web_to_skp b/experimental/tools/web_to_skp new file mode 100755 index 0000000000..cde5dce645 --- /dev/null +++ b/experimental/tools/web_to_skp @@ -0,0 +1,34 @@ +#! /bin/sh + +# Copyright 2018 Google Inc. +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +if [ "$(uname)" = Linux ]; then + EXAMPLE='/opt/google/chrome/chrome' +elif [ "$(uname)" = Darwin ]; then + EXAMPLE='"/Applications/Google Chrome.app/Contents/MacOS/Google Chrome"' +else + EXAMPLE='"/c/Program Files (x86)/Google/Chrome/Application/chrome.exe"' +fi + +if [ $# -ne 3 ] || ! [ -x "$1" ]; then + cat >&2 << EOF +usage: + $0 CHROMIUM_BINARY SOURCE_URL DESTINATION_DIRECTORY +e.g: + $0 $EXAMPLE https://www.google.com/ /tmp/ +EOF + exit 1 +fi + +EXE="$1" +URL="$2" +DST="$3" + +CRASH=~/tmp/headless_crash_dumps +mkdir -p "$CRASH" "$DST" + +printf 'chrome.gpuBenchmarking.printToSkPicture("%s");\nquit\n' "$DST" | \ + "$EXE" --headless --disable-gpu --repl -crash-dumps-dir="$CRASH" \ + --no-sandbox --enable-gpu-benchmarking "$URL" diff --git a/site/user/tips.md b/site/user/tips.md index 9458ace310..78ba5aaaac 100644 --- a/site/user/tips.md +++ b/site/user/tips.md @@ -32,13 +32,15 @@ drawBitmapNine(): Capture a `.skp` file on a web page in Chromium ----------------------------------------------------------------------------- +Use the script `experimental/tools/web_to_skp` , *or* do the following: + 1. Launch Chrome or Chromium with `--no-sandbox --enable-gpu-benchmarking` -2. Open the JS console (ctrl-shift-J) +2. Open the JS console (Ctrl+Shift+J (Windows / Linux) or Cmd+Opt+J (MacOS)) 3. Execute: `chrome.gpuBenchmarking.printToSkPicture('/tmp')` This returns "undefined" on success. Open the resulting file in the [Skia Debugger](/dev/tools/debugger), rasterize it with `dm`, -or use Skia's `SampleApp` to view it: +or use Skia's `viewer` to view it: @@ -46,7 +48,7 @@ or use Skia's `SampleApp` to view it: --config 8888 gpu pdf --verbose ls -l /tmp/*/skp/layer_0.skp.* - out/Release/SampleApp --picture /tmp/layer_0.skp + out/Release/viewer --skps /tmp --slide layer_0.skp * * * @@ -56,8 +58,10 @@ or use Skia's `SampleApp` to view it: Multipage Skia Picture files capture the commands sent to produce PDFs and printed documents. +Use the script `experimental/tools/web_to_mskp` , *or* do the following: + 1. Launch Chrome or Chromium with `--no-sandbox --enable-gpu-benchmarking` -2. Open the JS console (ctrl-shift-J) +2. Open the JS console (Ctrl+Shift+J (Windows / Linux) or Cmd+Opt+J (MacOS)) 3. Execute: `chrome.gpuBenchmarking.printPagesToSkPictures('/tmp/filename.mskp')` This returns "undefined" on success. -- cgit v1.2.3