1 2--- 3title: "Skia Viewer" 4linkTitle: "Skia Viewer" 5 6--- 7 8The Skia Viewer displays a series of slides that exhibit specific features of Skia, including the Skia GMs and programmed samples that allow interaction. In addition, the Viewer is used to debug and understand different parts of the Skia system: 9 10* Observe rendering performance - placing the Viewer in stats mode displays average frame times. 11* Try different rendering methods - it's possible to cycle among the three rendering methods: raster, OpenGL and Vulkan (on supported platforms). You can use this with stats mode to see the effect that the different rendering methods have on drawing performance. 12* Display and manipulate your own pictures. 13 14Some slides require resources stored outside the program. These resources are stored in the `<skia-path>/resources` directory. 15 16Linux, Macintosh and Windows 17---------------------------- 18 19The Viewer can be built using the regular GN build process, e.g. 20 21 bin/gn gen out/Release --args='is_debug=false' 22 ninja -C out/Release viewer 23 24To load resources in the desktop Viewers, use the `--resourcePath` option: 25 26 <skia-path>/out/Release/viewer --resourcePath <skia-path>/resources 27 28Similarly, `--skps <skp-file-path>` will load any `.skp` files in that directory 29for display within the Viewer. 30 31Other useful command-line options: using `--match <pattern>` will load only SKPs or slides 32matching that name; using `--slide <name>` will launch at that slide; and you can start up 33with a particular rendering method by using `--backend`, i.e., `--backend sw`, `--backend gl`, 34`--backend vk`, or `--backend mtl`. 35 36The desktop Viewers are controlled using the keyboard and mouse: left (←) and right 37(→) arrows to move from slide to slide; up (↑) and down (↓) arrows to 38zoom in and out; clicking and dragging will translate. Other display options and a slide 39picker can be found in the Tools UI, which can be toggled by hitting the spacebar. 40 41Key | Action 42-------|------------- 43← → | Move between the slides 44↑ ↓ | Zoom in / out 45d | Change render methods among raster, OpenGL and Vulkan 46s | Display rendering times and graph 47Space | Toggle display of Tools UI 48 49Android 50------- 51 52To build Viewer as an Android App, first follow the 53[Android build instructions](/docs/user/build#android) to set up the 54Android NDK and a ninja out directory. In addition, you will need the 55[Android SDK](https://developer.android.com/studio/#command-tools) installed and your 56`ANDROID_HOME` environment variable set. 57 58 mkdir ~/android-sdk 59 ( cd ~/android-sdk; unzip ~/Downloads/sdk-tools-*.zip ) 60 yes | ~/android-sdk/tools/bin/sdkmanager --licenses 61 export ANDROID_HOME=~/android-sdk # Or wherever you installed the Android SDK. 62 63If you are not using the NDK included with the Android SDK (at ~/android-sdk/ndk-bundle 64in this example) you'll need to set the environmental variable `ANDROID_NDK_HOME`, e.g., 65 66 export ANDROID_NDK_HOME=/tmp/ndk 67 68The Viewer APK must be built by gradle which can be invoked on the command line 69with the following script: 70 71 platform_tools/android/bin/android_build_app -C <out_dir> viewer 72 73where `<out_dir>` is the ninja out directory (e.g., `out/arm64`) 74that you created. Upon completion of the script the APK 75can be found at `<out_dir>/viewer.apk` 76 77To load resources in the Android Viewer place them in 78`/data/local/tmp/resources`; to load SKPs place them in `/data/local/tmp/skps`. 79 80Swiping left and right will switch slides, pinch-zoom will zoom in and out, and 81display options are available in the UI. 82 83iOS 84--- 85 86Viewer on iOS is built using the regular GN process, e.g. 87 88 bin/gn gen out/Release --args='target_os="ios" is_debug=false' 89 ninja -C out/Release viewer 90 91Like other iOS apps it can be deployed either by using something like 92[ios-deploy](https://github.com/ios-control/ios-deploy) 93or by building within Xcode and launching via the IDE. See the 94[iOS build instructions](https://skia.org/docs/user/build#ios) for more information 95on managing provisioning profiles for signing and deployment. 96 97Viewer will 98automatically bundle the `resources` directory in the top-level Skia directory, 99and will bundle an `skps` directory if also placed in the Skia directory. 100 101On iOS the Viewer provides basic touch functionality: you can view slides, 102swipe between them, pinch-zoom to scale, and translate via panning. There is not 103yet support for display options or selecting from a list of slides. 104 105