comparison libvo/vo_gl2.c @ 23649:404d35495770

Remove overly complex and unused per-subtexture "dirty" handling
author reimar
date Tue, 26 Jun 2007 15:51:49 +0000
parents 09f454fc4d79
children 9c935f7e5b22
comparison
equal deleted inserted replaced
23648:09f454fc4d79 23649:404d35495770
66 static int int_pause; 66 static int int_pause;
67 67
68 static uint32_t texture_width; 68 static uint32_t texture_width;
69 static uint32_t texture_height; 69 static uint32_t texture_height;
70 static int texnumx, texnumy, raw_line_len; 70 static int texnumx, texnumy, raw_line_len;
71 static int texdirty;
71 static struct TexSquare * texgrid = NULL; 72 static struct TexSquare * texgrid = NULL;
72 static GLuint fragprog; 73 static GLuint fragprog;
73 static GLuint lookupTex; 74 static GLuint lookupTex;
74 static GLint gl_internal_format; 75 static GLint gl_internal_format;
75 static int rgb_sz, r_sz, g_sz, b_sz, a_sz; 76 static int rgb_sz, r_sz, g_sz, b_sz, a_sz;
92 { 93 {
93 GLubyte *texture; 94 GLubyte *texture;
94 GLuint texobj; 95 GLuint texobj;
95 GLuint uvtexobjs[2]; 96 GLuint uvtexobjs[2];
96 GLfloat fx, fy, fw, fh; 97 GLfloat fx, fy, fw, fh;
97 int isDirty;
98 int dirtyXoff, dirtyYoff, dirtyWidth, dirtyHeight;
99 }; 98 };
100 99
101 static GLint getInternalFormat(void) 100 static GLint getInternalFormat(void)
102 { 101 {
103 #ifdef GL_WIN32 102 #ifdef GL_WIN32
244 tsq->fx = x * texpercx; 243 tsq->fx = x * texpercx;
245 tsq->fy = y * texpercy; 244 tsq->fy = y * texpercy;
246 tsq->fw = texpercx; 245 tsq->fw = texpercx;
247 tsq->fh = texpercy; 246 tsq->fh = texpercy;
248 247
249 tsq->isDirty=GL_FALSE;
250 tsq->texobj=0; 248 tsq->texobj=0;
251 tsq->uvtexobjs[0] = tsq->uvtexobjs[1] = 0; 249 tsq->uvtexobjs[0] = tsq->uvtexobjs[1] = 0;
252 tsq->dirtyXoff=0; tsq->dirtyYoff=0; tsq->dirtyWidth=-1; tsq->dirtyHeight=-1;
253 250
254 glGenTextures (1, &(tsq->texobj)); 251 glGenTextures (1, &(tsq->texobj));
255 252
256 glBindTexture (GL_TEXTURE_2D, tsq->texobj); 253 glBindTexture (GL_TEXTURE_2D, tsq->texobj);
257 if (image_format == IMGFMT_YV12) { 254 if (image_format == IMGFMT_YV12) {
301 texdata_start += texture_width * image_bytes; 298 texdata_start += texture_width * image_bytes;
302 tsq++; 299 tsq++;
303 } /* for all texnumx */ 300 } /* for all texnumx */
304 line_start += texture_height * raw_line_len; 301 line_start += texture_height * raw_line_len;
305 } /* for all texnumy */ 302 } /* for all texnumy */
306 }
307
308 static void setupTextureDirtyArea(int x, int y, int w,int h)
309 {
310 struct TexSquare *square;
311 int xi, yi, wd, ht, wh, hh;
312 int wdecr, hdecr, xh, yh;
313
314 wdecr=w; hdecr=h; xh=x; yh=y;
315
316 for (yi = 0; hdecr>0 && yi < texnumy; yi++)
317 {
318 if (yi < texnumy - 1)
319 ht = texture_height;
320 else
321 ht = image_height - texture_height * yi;
322
323 xh =x;
324 wdecr =w;
325
326 for (xi = 0; wdecr>0 && xi < texnumx; xi++)
327 {
328 square = texgrid + yi * texnumx + xi;
329
330 if (xi < texnumx - 1)
331 wd = texture_width;
332 else
333 wd = image_width - texture_width * xi;
334
335 if( 0 <= xh && xh < wd &&
336 0 <= yh && yh < ht
337 )
338 {
339 square->isDirty=GL_TRUE;
340
341 wh=(wdecr<wd)?wdecr:wd-xh;
342 if(wh<0) wh=0;
343
344 hh=(hdecr<ht)?hdecr:ht-yh;
345 if(hh<0) hh=0;
346
347 if(xh<square->dirtyXoff)
348 square->dirtyXoff=xh;
349
350 if(yh<square->dirtyYoff)
351 square->dirtyYoff=yh;
352
353 square->dirtyWidth = wd-square->dirtyXoff;
354 square->dirtyHeight = ht-square->dirtyYoff;
355
356 wdecr-=wh;
357
358 if ( xi == texnumx - 1 )
359 hdecr-=hh;
360 }
361
362 xh-=wd;
363 if(xh<0) xh=0;
364 }
365 yh-=ht;
366 if(yh<0) yh=0;
367 }
368 } 303 }
369 304
370 static void gl_set_bilinear (int val) 305 static void gl_set_bilinear (int val)
371 { 306 {
372 int x, y; 307 int x, y;
453 388
454 if (image_format == IMGFMT_YV12) 389 if (image_format == IMGFMT_YV12)
455 glEnableYUVConversion(GL_TEXTURE_2D, use_yuv); 390 glEnableYUVConversion(GL_TEXTURE_2D, use_yuv);
456 for (y = 0; y < texnumy; y++) 391 for (y = 0; y < texnumy; y++)
457 { 392 {
393 int thish = texture_height;
394 if (y == texnumy - 1 && image_height % texture_height)
395 thish = image_height % texture_height;
458 for (x = 0; x < texnumx; x++) 396 for (x = 0; x < texnumx; x++)
459 { 397 {
398 int thisw = texture_width;
399 if (x == texnumx - 1 && image_width % texture_width)
400 thisw = image_width % texture_width;
460 glBindTexture (GL_TEXTURE_2D, square->texobj); 401 glBindTexture (GL_TEXTURE_2D, square->texobj);
461 if (image_format == IMGFMT_YV12) { 402 if (image_format == IMGFMT_YV12) {
462 ActiveTexture(GL_TEXTURE1); 403 ActiveTexture(GL_TEXTURE1);
463 glBindTexture (GL_TEXTURE_2D, square->uvtexobjs[0]); 404 glBindTexture (GL_TEXTURE_2D, square->uvtexobjs[0]);
464 ActiveTexture(GL_TEXTURE2); 405 ActiveTexture(GL_TEXTURE2);
465 glBindTexture (GL_TEXTURE_2D, square->uvtexobjs[1]); 406 glBindTexture (GL_TEXTURE_2D, square->uvtexobjs[1]);
466 ActiveTexture(GL_TEXTURE0); 407 ActiveTexture(GL_TEXTURE0);
467 } 408 }
468 409
469 if(square->isDirty) 410 if (texdirty) {
470 {
471 glUploadTex(GL_TEXTURE_2D, gl_bitmap_format, gl_bitmap_type, 411 glUploadTex(GL_TEXTURE_2D, gl_bitmap_format, gl_bitmap_type,
472 square->texture, image_width * image_bytes, 412 square->texture, image_width * image_bytes,
473 square->dirtyXoff, square->dirtyYoff, 413 0, 0,
474 square->dirtyWidth, square->dirtyHeight, 414 thisw, thish,
475 0); 415 0);
476
477 square->isDirty=GL_FALSE;
478 square->dirtyXoff=0; square->dirtyYoff=0; square->dirtyWidth=-1; square->dirtyHeight=-1;
479 } 416 }
480
481 mp_msg (MSGT_VO, MSGL_DBG2, "[gl2] glTexSubImage2D texnum x=%d, y=%d, %d/%d - %d/%d\n",
482 x, y, square->dirtyXoff, square->dirtyYoff, square->dirtyWidth, square->dirtyHeight);
483 417
484 glDrawTex(square->fx, square->fy, square->fw, square->fh, 418 glDrawTex(square->fx, square->fy, square->fw, square->fh,
485 0, 0, texture_width, texture_height, 419 0, 0, texture_width, texture_height,
486 texture_width, texture_height, 420 texture_width, texture_height,
487 0, image_format == IMGFMT_YV12, 0); 421 0, image_format == IMGFMT_YV12, 0);
488 square++; 422 square++;
489 } /* for all texnumx */ 423 } /* for all texnumx */
490 } /* for all texnumy */ 424 } /* for all texnumy */
491 if (image_format == IMGFMT_YV12) 425 if (image_format == IMGFMT_YV12)
492 glDisableYUVConversion(GL_TEXTURE_2D, use_yuv); 426 glDisableYUVConversion(GL_TEXTURE_2D, use_yuv);
427 texdirty = 0;
493 } 428 }
494 429
495 430
496 static void resize(int *x,int *y){ 431 static void resize(int *x,int *y){
497 mp_msg(MSGT_VO,MSGL_V,"[gl2] Resize: %dx%d\n",*x,*y); 432 mp_msg(MSGT_VO,MSGL_V,"[gl2] Resize: %dx%d\n",*x,*y);
945 mp_msg(MSGT_VO, MSGL_ERR, "[gl2] error: draw_frame called for YV12!\n"); 880 mp_msg(MSGT_VO, MSGL_ERR, "[gl2] error: draw_frame called for YV12!\n");
946 return 0; 881 return 0;
947 } 882 }
948 ImageData=(unsigned char *)src[0]; 883 ImageData=(unsigned char *)src[0];
949 resetTexturePointers(ImageData); 884 resetTexturePointers(ImageData);
950 setupTextureDirtyArea(0, 0, image_width, image_height); 885 texdirty = 1;
951 return 0; 886 return 0;
952 } 887 }
953 888
954 static int 889 static int
955 query_format(uint32_t format) 890 query_format(uint32_t format)