Home | History | Annotate | Download | only in sample
      1 Skia Viewer
      2 ==========================
      3 The Skia Viewer displays a series of slides that exhibit specific features of Skia, including the Skia golden master images (or 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 
      9 Some slides require resources stored outside the program. These resources are stored in the `<skia-path>/resources` directory.
     10 
     11 Linux, Macintosh and Windows
     12 ----------------------------
     13 
     14 The 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 
     19 To load resources in the desktop Viewers, use the `--resourcePath` option:
     20 
     21     <skia-path>/out/Release/viewer --resourcePath <skia-path>/resources
     22 
     23 Similarly, `--skps <skp-file-path>` will load any `.skp` files in that directory for display within the Viewer.
     24 
     25 Other useful command-line options: using `--match <pattern>` will load only SKPs or slides matching that name; using `--slide <name>` will launch at that slide; and you can start up with a particular rendering method by using `--backend`, i.e., `--backend sw`, `--backend gl`, or `--backend vk`.
     26 
     27 The desktop Viewers are controlled using the keyboard and mouse: left (&#x2190;) and right (&#x2192;) arrows to move from slide to slide; up (&#x2191;) and down (&#x2193;) arrows to zoom in and out; clicking and dragging will translate. Other display options and a slide picker can be found in the Tools UI, which can be toggled by hitting the spacebar.
     28 
     29 Key                              | Action
     30 -----------------------------|-------------
     31 &#x2190; &#x2192; | Move between the slides
     32 &#x2191; &#x2193; | Zoom in / out
     33 d                 | Change render methods among raster, OpenGL and Vulkan
     34 s                 | Display rendering times and graph
     35 Space             | Toggle display of Tools UI
     36 
     37 Android
     38 -------
     39 
     40 To build Viewer as an Android App, you will need the
     41 [Android SDK](https://developer.android.com/studio/#command-tools) installed and your `ANDROID_HOME` environment variable set.
     42 
     43     mkdir ~/android-sdk
     44     ( cd ~/android-sdk; unzip ~/Downloads/sdk-tools-*.zip )
     45     yes | ~/android-sdk/tools/bin/sdkmanager --licenses
     46     export ANDROID_HOME=~/android-sdk  # Or wherever you installed the Android SDK.
     47 
     48 The Viewer APK must be built by gradle which can be invoked on the command line
     49 with the following script:
     50 
     51     platform_tools/android/bin/android_build_app -C <out_dir> viewer
     52 
     53 where `<out_dir>` is the ninja out directory for android (e.g., `out/arm64`)
     54 that you want to use to build the app. Upon completion of the script the APK
     55 can be found at `<out_dir>/viewer.apk`
     56 
     57 To load resources in the Android Viewer place them in
     58 `/data/local/tmp/resources`; to load SKPs place them in `/data/local/tmp/skps`.
     59 
     60 Swiping left and right will switch slides, pinch-zoom will zoom in and out, and
     61 display options are available in the UI.
     62 
     63 iOS
     64 ---
     65 
     66 The viewer is not yet fully supported on iOS, but can be used to display
     67 individual slides on a device by launching via `ios-deploy` with the `--match`
     68 or `--slide` command-line options. The viewer will automatically bundle the
     69 `resources` directory in the top-level Skia directory, and will bundle an
     70 `skps` directory if also placed in the Skia directory.
     71