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