- if(phase==0)
- {
- if(raw_data)
- n_bytes = raw_data->get_size();
- else
- {
- image.load_headers(*img_loader);
- n_bytes = image.get_stride()*image.get_height();
- }
- }
- else if(phase==1)
- {
- pixel_buffer.storage(n_bytes);
- mapped_address = reinterpret_cast<char *>(pixel_buffer.map());
- }
- else if(phase==2)
- {
- if(raw_data)
- raw_data->load_into(mapped_address);
- else
- image.load_into(*img_loader, mapped_address);
- }
- else if(phase==3)
- {
- mapped_address = 0;
- if(!pixel_buffer.unmap())
- {
- phase = 1;
- return false;
- }