Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Bitmap: optimize drawing of other images
The main idea is to remove calls to put/get pixels. This means we remove the offsets computations, range checks, and stack windings. Now, when the tab widgets window is maximized, I can almost change tabs "immediatelly" (before it took "a few moments"). Using valgrind, after this fix the hot function from (number is instruction set, as calculate by valgrind): Before: put_pixel: ~340,000,000 get_pixel: ~276,000,000 draw: ~259,000,000 After: draw: ~360,000,000 gnu_cxx::__enable_if_scalar: ~167,000,000 std::vector::insert: ~127,000,000 Which means we still have things to optimize (maybe using more direct access to memory?) and then even using some `memmove()` or something similar instead of the X axis loop (this will gain a lot of memory). We also need to take care of the extra layouts in the tab widget. Specific optimizations: 1. Optimize rectangle drawing: We can write directly to the buffer, instead of using `put_pixel()` this will gain: * speed up for not checking ranges * speed up for not calculating offsets on every pixel (a multiplication) * calling to another function 2. Optimize drawing another bitmap: reading the color other other image, by bypassing the `get_pixel()` function as we did before. 3. Optimize drawing image - `put_pixel()`: call to `put_pixel()` is removed, in favor of using offsets in the target image.
- Loading branch information