Google Summer Of Code, 2021 - Project Report


Project Insights

The project that I have been working on during this GSoC is titled "Add Tests for the VCL graphics backend" and as the name in the title itself suggests this project required adding some tests for efficiently diagnosing the quality of graphics rendering within LibreOffice, however, this project had more to it than that. This project mainly revolved around the VCL module of LibreOffice, and so here's a short description about VCL, the VCL module stands for Visual Class Library and it's one of the most prominent modules of LibreOffice whose function is to manage various visual components be it native widget rendering(like button, scrollbar, etc.), or be it the dialog boxes that are usable in LibreOffice, the code within the VCL library handles everything, all in all, the VCL handles basic graphics rendering within LibreOffice. The most important thing that sparked the need for this project was that sometimes the graphics rendering(which is handled by the VCL module) is inconsistent or is faulty among different graphics backend leading to poor user experience and so there should be something to determine if there's an anomaly with the rendering or not and fortunately for handling the former we already had some tests which ran as unit tests to check and assert the drawing of the shapes thereby helping in checking our graphics backend thoroughly. 

                                However, There was also a need to run those tests on the client's system to check the graphics quality there and to switch between different graphics backend if the result is not up to the mark(only in the case of skia's Vulkan) and a dialog box which the users could use to run the tests manually and check the results for themselves and submit the results to bug tracker if any anomaly is present thereby helping in analyzing the quality of the graphics rendering among different systems and improving the user experience in the process. This project took care of everything mentioned above and introduced some new test cases to better the VCL testing module.



Some basic Know-Hows(Q/A)

1.) What is a graphics backend? How's it relevant to this project?

A.1) A graphics backend is nothing but an interface with which LibreOffice handles its visual components, For example:-  Handling a bitmap, Rendering a JPEG, or Drawing a shape(as in LibreOffice draw), etc. Skia, OpenGL, and Gtk are some of the graphics backends LibreOffice uses to render its component on different client systems. The problem, however, is that there are instances when different graphics backend doesn't show consistent behavior, for example-  backend1 renders the image as expected i.e all the details of the image are preserved but backend2 is not rendering the very same image as expected, thus resulting into an improper user experience and hence, it's very important to minimize the occurrence of such instances and which can be done by analyzing the backend beforehand so that it can be fixed if it's showing some faulty or inconsistent behavior.

2.) What is the need to run the tests on the client's system?

A.2) Well, running the tests on the client's system can help us a lot in asserting the quality of graphics rendering there and whose results can then be used to present to the bug tracker if the user faces some issue with LibreOffice's graphics rendering.

3.) How do the tests actually work?

A.3) A particular graphics test first draws a specific shape on a virtual device( A virtual device is nothing but an apparatus to draw something to) and then returns a bitmap which is then tested by traversing each of its pixels and checking if the shape is drawn to the expected patch, for example:- If a rectangle is being drawn the test traverses in a rectangular fashion layer by layer and then checks the if the color of the pixel on that path is as expected or not. The test results are of three types - PASSED( when every pixel's color is as expected), QUIRKY (when some pixel's color has somewhat deviated), and FAILED (when some pixel's color is very different from what is expected). The test structure looks something like this.



Feats Accomplished 

The work done during this project has been listed serial wise below:

1.) Added the functionality to run the graphics backend tests on the client's system during the first installation or up-gradation of LibreOffice. Now the graphics tests are tested on the client's system and the results are stored in the user directory for future reference.

2.)Implemented the dialog box to run the graphics tests manually by choosing the view/options/Run Graphics Tests option.

3.)Added the functionality for viewing the test's resultant bitmap easily, thus allowing the user to view the results in real-time.

4.)Added the support for storing the graphics test results in the user directory in zip format which would consist of the log file and the bitmap images, thus enabling the user to submit the details to the bug tracker to demonstrate the anomaly easily if present.

The Final Product of the above commits:

(I) The "Run Graphics Tests" Dialog box looks like this:



(II)The resultant bitmap window looks like(which is being triggered when the test status has been clicked):



(III) When the "Download Results" button is clicked, a window opens showing the location of the results stored, clicking which the location window would pop up:


5.)Added some more test cases for enhancing the pre-existing VCL graphics testing module(Note: Most of these test cases are drawn using all the possible drawing methods available within LibreOffice):

    (I) Added a test to draw a drop-like shape using polyline and polygon drawing methods, this test intends to check if the graphics backend properly renders Bézier curve or not which is an utmost part of drawing when it comes to curvy shapes. The figure drawn in this test looks like this:

    

    (II) Added a test for drawing and checking an irregular-half ellipse, this test was also intended to test the Bézier curve rendering. The figure drawn in this test looks like this:


    (III)Added a test case for drawing and checking a closed bézier loop, this test was intended to test one of the Bézier curve's important property i.e they always lie within their convex polygon whose vertices consists of the normal points and the control points. The figure drawn in this test looks like this:


    (IV) Added the test for drawing a filled asymmetrical drop-like shape using a polygon, this test was intended to check if there's any discrepancy with the drawing by checking if the shape is drawn on the expected axis(i.e the height = y-axis and the width = x-axis). The figure drawn in this test looks like this:

    (V) Added the test for testing the drawing and rendering of text, this test checks if the text is drawn where it was supposed to be drawn. The figure drawn in this test looks like this:


    (VI) Added the test for testing the even-odd rule when drawing intersecting shapes, this test intends to check the even-odd color filling rule by drawing multiple rectangular shapes on top of each other and specifying the fill color which would then result in a shape that is colored in a specific pattern - in accordance to the even-odd filling rule. The figure drawn in this test looks like this:


    (VII) Added the test to check the rendering of bitmaps other than 24 bpp(bit-per-pixel)[Types of bitmaps] namely 8-bit greyscale and 32 bpp. One of the greyscale images drawn in this test looks like this:


    (VIII) Added the test to draw and check shape drawing using all the possible methods on a wide surface(1028x1028 and 4096x4096). The figure is not shown since it's not visible due to the virtual device's large size.

    (IX) Added the test for drawing an open polygon using various drawing methods. The figure drawn in this test looks like this:


    (X) Added the test for drawing an open cubic-bézier curve. The figure drawn in this test looks like this:


6.) Reconfigured the pre-existing symmetrically drawn rectangle tests to not be symmetrical anymore. Both non-filled and filled rectangular figures look like this:




Link to the commits


Acknowledgment

I would like to thank my mentor Mr. Tomaž Vajngerl for giving me this wonderful opportunity and for mentoring me throughout this GSoC - guiding me whenever I was stuck and reviewing my code and without whom I don't think that I would've made this far in this project and thanks to him, I got to learn a lot of new things and practices under his mentorship which will sure as hell come a lot in handy to me in the future, I just really can't thank him enough for this. Also, I would like to thank Mr. Luboš Luňák for co-mentoring me in this project. Lastly, I would like to assert that I am obliged to be a part of this wonderful community called LibreOffice Developers, which helped me to grow as a better developer. Thank you so much, everyone, LibreOffice rocks! :D



Comments