Finishes the rendering cycle, either by drawing to a canvas or passing a pixel array to the callback function.
Due to the multiple ways of drawing the rendered image, getBuffer() has multiple ways of executing.
Single-Threaded: If multi-threading is not being used, then getBuffer will simply fetch the pixel buffer and either draw it to screen or send it to the callback function.
Multi-Threading: If threads are being used, getBuffer() will trigger all the queued instructions to be sent out to each thread. Then once the image has been rendered, it is then drawn or sent to the callback function.
Canvas Drawing: If a canvas element was provided to WebRender, getBuffer() will draw the pixel buffer into the canvas. Once complete, it will either return to the calling application (single-threaded), or wait for further messages (multi-threaded). Canvas drawing is the fastest way to get the rendered image onto the screen, but can be used in conjunction with a callback function.
Callback Function If a callback function is provided, getBuffer() will send a reference to the pixel buffer as a parameter to the provided callback function. This is useful for rendered images that are not to be drawn to screen, or to do a post-effect on the image. The callback function is very important for multi-threading as it allows for the application to know when the image is rendered, prehaps so that the next image can then be started. The callback function can be used in conjunction with canvas drawing.
No matter how it is executed, getBuffer() should be one of the final instructions in your rendering pipeline.
See more detailed information about multi-threading here.
Developer Note: I have found it best to use both canvas and a callback function in my applications. The canvas is used to draw the image internally, while the callback is used to tell the program to start another draw loop.
Unlike most functions, an error in getBuffer may be quite deep within WebRender, therefore it is most important to look for console log messages for errors.