Go to the source code of this file.
Functions | |
void | st_sample_pixel_block (enum pipe_format format, const struct pipe_format_block *block, void *raw, float *rgba, unsigned rgba_stride, unsigned w, unsigned h) |
Randomly sample pixels. | |
void | st_sample_surface (struct pipe_surface *surface, float *rgba) |
void st_sample_pixel_block | ( | enum pipe_format | format, | |
const struct pipe_format_block * | block, | |||
void * | raw, | |||
float * | rgba, | |||
unsigned | rgba_stride, | |||
unsigned | w, | |||
unsigned | h | |||
) |
Randomly sample pixels.
Definition at line 503 of file st_sample.c.
References PIPE_FORMAT_DXT1_RGB, PIPE_FORMAT_DXT1_RGBA, PIPE_FORMAT_DXT3_RGBA, PIPE_FORMAT_DXT5_RGBA, st_sample_dxt_pixel_block(), and st_sample_generic_pixel_block().
00508 { 00509 switch(format) { 00510 case PIPE_FORMAT_DXT1_RGB: 00511 case PIPE_FORMAT_DXT1_RGBA: 00512 case PIPE_FORMAT_DXT3_RGBA: 00513 case PIPE_FORMAT_DXT5_RGBA: 00514 st_sample_dxt_pixel_block(format, block, raw, rgba, rgba_stride, w, h); 00515 break; 00516 00517 default: 00518 st_sample_generic_pixel_block(format, block, raw, rgba, rgba_stride, w, h); 00519 break; 00520 } 00521 }
void st_sample_surface | ( | struct pipe_surface * | surface, | |
float * | rgba | |||
) |
Definition at line 525 of file st_sample.c.
References pipe_surface::block, block(), pipe_surface::format, pipe_surface::height, pipe_format_block::height, MIN2, pipe_surface::nblocksx, pipe_surface::nblocksy, PIPE_BUFFER_USAGE_CPU_READ, pipe_surface_map(), pipe_surface_unmap(), pipe_format_block::size, st_sample_pixel_block(), pipe_surface::stride, pipe_format_block::width, and pipe_surface::width.
00526 { 00527 const struct pipe_format_block *block = &surface->block; 00528 unsigned rgba_stride = surface->width*4; 00529 void *raw; 00530 unsigned x, y; 00531 00532 raw = pipe_surface_map(surface, PIPE_BUFFER_USAGE_CPU_READ); 00533 if(!raw) 00534 return; 00535 00536 for (y = 0; y < surface->nblocksy; ++y) { 00537 for(x = 0; x < surface->nblocksx; ++x) { 00538 st_sample_pixel_block(surface->format, 00539 block, 00540 (uint8_t*)raw + y*surface->stride + x*block->size, 00541 rgba + y*block->height*rgba_stride + x*block->width*4, 00542 rgba_stride, 00543 MIN2(block->width, surface->width - x*block->width), 00544 MIN2(block->height, surface->height - y*block->height)); 00545 } 00546 } 00547 00548 pipe_surface_unmap(surface); 00549 }