The old test to verify if the modifier was enabled in render mode used G_RENDER_OGL flag, but for new draw manager, there is a function for that: DRW_state_is_image_render()
Also fixed the problem the cache was not set as dirty before render, so the flags were not updated to draw the correct image.
Fix problem with buffer when cursor outside camera view
Before, the stroke buffer was converted using the 3D cursor location, but if the camera moves and the cursor was on back of camera, the stroke buffer was not visible while painting.
Now, the conversion is done using the origin of the object and this avoid this problem.
In some weird situations, the normal vector of the stroke cannot be calculated and this produces errors, specially in modifiers like lighting modifier.
Now, if the stroke selected is not valid, try with the next stroke to get a right value.