We are excited to announce that a new library is available for use by PlayBook developers. Skia, an open-source 2D graphics library for drawing text, geometry and images can now be found at our Skia GitHub repository. One key feature of this version of the library is the inclusion of hardware acceleration for many drawing operations.
To showcase how to use Skia on the PlayBook, we have created a sample application as a part of the Skia GitHub repository (see image below). In addition, for a more extensive overview of Skia’s capabilities a detailed wiki page has also been added.
The remaining portion of this article looks at the steps involved in getting the Skia sample application up and running on a BlackBerry PlayBook.
Building the Sample
1. Obtain the Source
Download Skia from GitHub by either cloning the repository or downloading the source as a ZIP archive.
WARNING: Do not clone or unzip the source files into the NDK workspace directly. This will result in compilation errors when building the samples.
2. Import Projects into Momentics
Open the QNX Momentics IDE that was bundled with the BlackBerry NDK.
Import the grskia project into Momentics by selecting
File -> Import. The project can be found inside of the Skia folder that you checked out from GitHub.
Similarly, import the SkiaSample project into Momentics. The project can be found inside Skia/rim_samples/SkiaSample.
3. Set up Author Information for the sample
Open the bar-descriptor.xml for the SkiaSample project. Click the
Set from Debug Token button located on the General tab and save the file.
4. Enable/disable hardware acceleration in SkiaSample (Optional)
Open SkiaSample/main.cpp and find the USE_SKIA_OPENGL define near the top of the file.
To use hardware-accelerated Skia, set USE_SKIA_OPENGL to 1.
To use software Skia, set USE_SKIA_OPENGL to 0.
5. Build the Projects
Before proceeding, make sure that both the grskia and SkiaSample projects are set to use the same build configuration (Device-Release or Device-Debug). You can do so by right-clicking on each project in the Project Explorer tab and selecting
Build Configurations -> Set Active.
Build the grskia project first, by right-clicking on it and selecting
Build. Next, build the SkiaSample project.
6. Deploy SkiaSample to PlayBook
Deploy the executable to the device by selecting
Run-> Run As -> BlackBerry Tablet OS C/C++ Application from Momentics.