comparison src/video/ps3/SDL_ps3render.c @ 3157:cce01ba54174 gsoc2009_ps3

Added comments, clean up.
author Martin Lowinski <martin@goldtopf.org>
date Thu, 27 Aug 2009 11:33:56 +0000
parents a16c4ec43631
children
comparison
equal deleted inserted replaced
3156:4ead4cef6b7b 3157:cce01ba54174
41 /* Stores the executable name */ 41 /* Stores the executable name */
42 extern spe_program_handle_t yuv2rgb_spu; 42 extern spe_program_handle_t yuv2rgb_spu;
43 extern spe_program_handle_t bilin_scaler_spu; 43 extern spe_program_handle_t bilin_scaler_spu;
44 44
45 /* SDL surface based renderer implementation */ 45 /* SDL surface based renderer implementation */
46
47 static SDL_Renderer *SDL_PS3_CreateRenderer(SDL_Window * window, 46 static SDL_Renderer *SDL_PS3_CreateRenderer(SDL_Window * window,
48 Uint32 flags); 47 Uint32 flags);
49 static int SDL_PS3_DisplayModeChanged(SDL_Renderer * renderer); 48 static int SDL_PS3_DisplayModeChanged(SDL_Renderer * renderer);
50 static int SDL_PS3_ActivateRenderer(SDL_Renderer * renderer); 49 static int SDL_PS3_ActivateRenderer(SDL_Renderer * renderer);
51 static int SDL_PS3_RenderPoint(SDL_Renderer * renderer, int x, int y); 50 static int SDL_PS3_RenderPoint(SDL_Renderer * renderer, int x, int y);
105 /* width of screen which is writeable */ 104 /* width of screen which is writeable */
106 unsigned int wr_height; 105 unsigned int wr_height;
107 /* size of a screen line: width * bpp/8 */ 106 /* size of a screen line: width * bpp/8 */
108 unsigned int line_length; 107 unsigned int line_length;
109 108
110 /* Use two buffers in fb? res < 720p */ 109 /* Is the kernels fb size bigger than ~12MB
110 * double buffering will work for 1080p */
111 unsigned int double_buffering; 111 unsigned int double_buffering;
112 112
113 /* SPE threading stuff */ 113 /* SPE threading stuff */
114 spu_data_t *converter_thread_data; 114 spu_data_t *converter_thread_data;
115 spu_data_t *scaler_thread_data; 115 spu_data_t *scaler_thread_data;
230 SDL_PS3_DestroyRenderer(renderer); 230 SDL_PS3_DestroyRenderer(renderer);
231 SDL_OutOfMemory(); 231 SDL_OutOfMemory();
232 return NULL; 232 return NULL;
233 } 233 }
234 234
235 /* Set up the SPEs */ 235 /* Set up the SPE threading data */
236 data->converter_thread_data = (spu_data_t *) malloc(sizeof(spu_data_t)); 236 data->converter_thread_data = (spu_data_t *) malloc(sizeof(spu_data_t));
237 data->scaler_thread_data = (spu_data_t *) malloc(sizeof(spu_data_t)); 237 data->scaler_thread_data = (spu_data_t *) malloc(sizeof(spu_data_t));
238 if (data->converter_thread_data == NULL || data->scaler_thread_data == NULL) { 238 if (data->converter_thread_data == NULL || data->scaler_thread_data == NULL) {
239 SDL_PS3_DestroyRenderer(renderer); 239 SDL_PS3_DestroyRenderer(renderer);
240 SDL_OutOfMemory(); 240 SDL_OutOfMemory();
375 375
376 src = (Uint8 *) pixels; 376 src = (Uint8 *) pixels;
377 dst = (Uint8 *) dstpixels + rect->y * data->pitch + rect->x 377 dst = (Uint8 *) dstpixels + rect->y * data->pitch + rect->x
378 * SDL_BYTESPERPIXEL(texture->format); 378 * SDL_BYTESPERPIXEL(texture->format);
379 length = rect->w * SDL_BYTESPERPIXEL(texture->format); 379 length = rect->w * SDL_BYTESPERPIXEL(texture->format);
380 /* Update the texture */
380 for (row = 0; row < rect->h; ++row) { 381 for (row = 0; row < rect->h; ++row) {
381 SDL_memcpy(dst, src, length); 382 SDL_memcpy(dst, src, length);
382 src += pitch; 383 src += pitch;
383 dst += data->pitch; 384 dst += data->pitch;
384 } 385 }
517 (SDL_PS3_RenderData *) renderer->driverdata; 518 (SDL_PS3_RenderData *) renderer->driverdata;
518 SDL_Window *window = SDL_GetWindowFromID(renderer->window); 519 SDL_Window *window = SDL_GetWindowFromID(renderer->window);
519 SDL_VideoDisplay *display = SDL_GetDisplayFromWindow(window); 520 SDL_VideoDisplay *display = SDL_GetDisplayFromWindow(window);
520 PS3_TextureData *txdata = (PS3_TextureData *) texture->driverdata; 521 PS3_TextureData *txdata = (PS3_TextureData *) texture->driverdata;
521 SDL_VideoData *devdata = display->device->driverdata; 522 SDL_VideoData *devdata = display->device->driverdata;
522
523 /* Debug info */
524 deprintf(1, "srcrect->w = %u\n", srcrect->w);
525 deprintf(1, "srcrect->h = %u\n", srcrect->h);
526 deprintf(1, "srcrect->x = %u\n", srcrect->x);
527 deprintf(1, "srcrect->y = %u\n", srcrect->y);
528 deprintf(1, "dstrect->w = %u\n", dstrect->w);
529 deprintf(1, "dstrect->h = %u\n", dstrect->h);
530 deprintf(1, "dstrect->x = %u\n", dstrect->x);
531 deprintf(1, "dstrect->y = %u\n", dstrect->y);
532 deprintf(1, "texture->w = %u\n", texture->w);
533 deprintf(1, "texture->h = %u\n", texture->h);
534 523
535 if (SDL_ISPIXELFORMAT_FOURCC(texture->format)) { 524 if (SDL_ISPIXELFORMAT_FOURCC(texture->format)) {
536 deprintf(1, "Texture is in a FOURCC format\n"); 525 deprintf(1, "Texture is in a FOURCC format\n");
537 if ((texture->format == SDL_PIXELFORMAT_YV12 || texture->format == SDL_PIXELFORMAT_IYUV) 526 if ((texture->format == SDL_PIXELFORMAT_YV12 || texture->format == SDL_PIXELFORMAT_IYUV)
538 && texture->w % 8 == 0 && texture->h % 8 == 0 527 && texture->w % 8 == 0 && texture->h % 8 == 0