[gdal-dev] RE: progressive rendering
Adam Nowacki
nowak at xpam.de
Sat Aug 23 20:08:05 EDT 2008
Norman Barker wrote:
> I have created RFC 24 on
>
> http://trac.osgeo.org/gdal/wiki/rfc24_progressive_data_support
I'd suggest creating completely new interface for this.
Why is this better (imo):
- application decides when and how ofter the updates occur, minimal
threading issues
- clearly defined synchronization points: NextAsyncRasterIOMessage(),
LockBuffer(), UnlockBuffer()
- requests can be aborted with EndAsyncRasterIO();
class GDALAsyncRasterIOMessage {
GDALAsyncRasterIO *asyncrasterio;
void *userptr;
// GARM_UPDATE, GARM_COMPLETE, GARM_ERROR, ...
int what;
int xoff, yoff;
int xsize, ysize;
// ...
};
class GDALAsyncRasterIO {
// lock a whole buffer
void LockBuffer();
// lock only a block
void LockBuffer(int xbufoff, int ybufoff, int xbufsize, int ybufsize);
void UnlockBuffer();
};
class GDALAsyncDataset : public GDALDataset {
GDALAsyncRasterIO *AsyncRasterIO( /* same as RasterIO */ , void
*userptr);
void EndAsyncRasterIO(GDALAsyncRasterIO *);
// if there are no new messages return NULL if wait is false or wait for
new message if wait is true
GDALAsyncRasterIOMessage *NextAsyncRasterIOMessage(bool wait);
void ReleaseAsyncRasterIOMessage(GDALAsyncRasterIOMessage *m);
};
// ###############
// How to use it
// ###############
GDALDataset *ds = GDALOpen( /* ... */, GA_ReadOnly);
// start asynchronous raster io, can have multiple running at same time
GDALAsyncRasterIO *r = ds->AsyncRasterIO(GF_Read, xoff, yoff, xsize,
ysize, bufptr, bufxsize, bufysize, bufdatatype, 3, NULL, 0, 0, 0, userptr);
while (...) {
GDALAsyncRasterIOMessage *m = ds->NextAsyncRasterIOMessage(true);
if (m) {
if (m->what == GARM_UPDATE) {
// lock the buffer so there will be no updates while we read from it
m->asyncrasterio->LockBuffer( /* ... */ );
// display updated region
m->asyncrasterio->UnlockBuffer();
} else {
// handle completion, display error message, ...
}
ds->ReleaseAsyncRasterIOMessage(m);
}
}
ds->EndAsyncRasterIO(r);
More information about the gdal-dev
mailing list