Skip to content
This repository was archived by the owner on Jun 8, 2021. It is now read-only.

Commit fb1e10e

Browse files
committed
Update comments for the cairo-threads example as we now send around image surfaces
1 parent 64707da commit fb1e10e

File tree

1 file changed

+5
-10
lines changed

1 file changed

+5
-10
lines changed

src/bin/cairo_threads.rs

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -44,18 +44,17 @@ macro_rules! clone {
4444
// | 2 | 3 |
4545
// +---+---+
4646
//
47-
// Each worker thread waits for a buffer (Box<[u8]>) to render into, wraps
48-
// it into ImageSurface, sleeps for a while, does the drawing, then sends the
49-
// underlying buffer back and waits for the next one.
47+
// Each worker thread waits for an image (cairo::ImageSurface) to render into, sleeps for a while,
48+
// does the drawing, then sends the image back and waits for the next one.
5049
//
5150
// The GUI thread holds an ImageSurface per image part at all times, these
5251
// surfaces are painted on a DrawingArea in its 'draw' signal handler. This
53-
// thread periodically checks if any worker has sent a freshly rendered buffer.
52+
// thread periodically checks if any worker has sent a freshly rendered image.
5453
// Upon receipt it's wrapped in ImageSurface and swapped with the previously
55-
// held surface, whose buffer is sent to the worker thread again. Then the
54+
// held surface, whose image is sent to the worker thread again. Then the
5655
// appropriate part of the DrawingArea is invalidated prompting a redraw.
5756
//
58-
// The two buffers per thread are allocated and initialized once and sent back
57+
// The two images per thread are allocated and initialized once and sent back
5958
// and forth repeatedly.
6059

6160
fn build_ui(application: &gtk::Application) {
@@ -123,10 +122,6 @@ fn build_ui(application: &gtk::Application) {
123122
let (ref images, ref origins, _) = *cell.borrow();
124123
for (image, origin) in images.iter().zip(origins.iter()) {
125124
draw_image_if_dirty(&cr, image, *origin, (width, height));
126-
// if we don't reset the source, the context may hold on to
127-
// the surface indefinitely, the buffer will be stuck there
128-
// and the worker thread will starve
129-
cr.set_source_rgb(0., 0., 0.);
130125
}
131126
Inhibit(false)
132127
}));

0 commit comments

Comments
 (0)