@ -517,47 +517,6 @@ calculate_edges(struct weston_surface *es, pixman_box32_t *rect,
return n ;
return n ;
}
}
static void
transform_texcoord ( struct weston_surface * es , GLfloat sx , GLfloat sy ,
GLfloat * tx , GLfloat * ty )
{
switch ( es - > buffer_transform ) {
case WL_OUTPUT_TRANSFORM_NORMAL :
default :
* tx = sx ;
* ty = sy ;
break ;
case WL_OUTPUT_TRANSFORM_FLIPPED :
* tx = 1.0 - sx ;
* ty = sy ;
break ;
case WL_OUTPUT_TRANSFORM_90 :
* tx = 1.0 - sy ;
* ty = sx ;
break ;
case WL_OUTPUT_TRANSFORM_FLIPPED_90 :
* tx = 1.0 - sy ;
* ty = 1.0 - sx ;
break ;
case WL_OUTPUT_TRANSFORM_180 :
* tx = 1.0 - sx ;
* ty = 1.0 - sy ;
break ;
case WL_OUTPUT_TRANSFORM_FLIPPED_180 :
* tx = sx ;
* ty = 1.0 - sy ;
break ;
case WL_OUTPUT_TRANSFORM_270 :
* tx = sy ;
* ty = 1.0 - sx ;
break ;
case WL_OUTPUT_TRANSFORM_FLIPPED_270 :
* tx = sy ;
* ty = sx ;
break ;
}
}
static int
static int
texture_region ( struct weston_surface * es , pixman_region32_t * region ,
texture_region ( struct weston_surface * es , pixman_region32_t * region ,
pixman_region32_t * surf_region )
pixman_region32_t * surf_region )
@ -578,13 +537,23 @@ texture_region(struct weston_surface *es, pixman_region32_t *region,
vtxcnt = wl_array_add ( & ec - > vtxcnt , nrects * nsurf * sizeof * vtxcnt ) ;
vtxcnt = wl_array_add ( & ec - > vtxcnt , nrects * nsurf * sizeof * vtxcnt ) ;
inv_width = 1.0 / es - > pitch ;
inv_width = 1.0 / es - > pitch ;
switch ( es - > buffer_transform ) {
case WL_OUTPUT_TRANSFORM_90 :
case WL_OUTPUT_TRANSFORM_270 :
case WL_OUTPUT_TRANSFORM_FLIPPED_90 :
case WL_OUTPUT_TRANSFORM_FLIPPED_270 :
inv_height = 1.0 / es - > geometry . width ;
break ;
default :
inv_height = 1.0 / es - > geometry . height ;
inv_height = 1.0 / es - > geometry . height ;
}
for ( i = 0 ; i < nrects ; i + + ) {
for ( i = 0 ; i < nrects ; i + + ) {
pixman_box32_t * rect = & rects [ i ] ;
pixman_box32_t * rect = & rects [ i ] ;
for ( j = 0 ; j < nsurf ; j + + ) {
for ( j = 0 ; j < nsurf ; j + + ) {
pixman_box32_t * surf_rect = & surf_rects [ j ] ;
pixman_box32_t * surf_rect = & surf_rects [ j ] ;
GLfloat sx , sy , tx , ty ;
GLfloat sx , sy , bx , b y;
GLfloat ex [ 8 ] , ey [ 8 ] ; /* edge points in screen space */
GLfloat ex [ 8 ] , ey [ 8 ] ; /* edge points in screen space */
int n ;
int n ;
@ -613,12 +582,10 @@ texture_region(struct weston_surface *es, pixman_region32_t *region,
* ( v + + ) = ex [ k ] ;
* ( v + + ) = ex [ k ] ;
* ( v + + ) = ey [ k ] ;
* ( v + + ) = ey [ k ] ;
/* texcoord: */
/* texcoord: */
transform_texcoord ( es ,
weston_surface_to_buffer_float ( es , sx , sy ,
sx * inv_width ,
& bx , & by ) ;
sy * inv_height ,
* ( v + + ) = bx * inv_width ;
& tx , & ty ) ;
* ( v + + ) = by * inv_height ;
* ( v + + ) = tx ;
* ( v + + ) = ty ;
}
}
vtxcnt [ nvtx + + ] = n ;
vtxcnt [ nvtx + + ] = n ;
@ -1107,12 +1074,14 @@ gl_renderer_flush_damage(struct weston_surface *surface)
data = wl_shm_buffer_get_data ( surface - > buffer ) ;
data = wl_shm_buffer_get_data ( surface - > buffer ) ;
rectangles = pixman_region32_rectangles ( & surface - > texture_damage , & n ) ;
rectangles = pixman_region32_rectangles ( & surface - > texture_damage , & n ) ;
for ( i = 0 ; i < n ; i + + ) {
for ( i = 0 ; i < n ; i + + ) {
glPixelStorei ( GL_UNPACK_SKIP_PIXELS , rectangles [ i ] . x1 ) ;
pixman_box32_t r ;
glPixelStorei ( GL_UNPACK_SKIP_ROWS , rectangles [ i ] . y1 ) ;
glTexSubImage2D ( GL_TEXTURE_2D , 0 ,
r = weston_surface_to_buffer_rect ( surface , rectangles [ i ] ) ;
rectangles [ i ] . x1 , rectangles [ i ] . y1 ,
rectangles [ i ] . x2 - rectangles [ i ] . x1 ,
glPixelStorei ( GL_UNPACK_SKIP_PIXELS , r . x1 ) ;
rectangles [ i ] . y2 - rectangles [ i ] . y1 ,
glPixelStorei ( GL_UNPACK_SKIP_ROWS , r . y1 ) ;
glTexSubImage2D ( GL_TEXTURE_2D , 0 , r . x1 , r . y1 ,
r . x2 - r . x1 , r . y2 - r . y1 ,
GL_BGRA_EXT , GL_UNSIGNED_BYTE , data ) ;
GL_BGRA_EXT , GL_UNSIGNED_BYTE , data ) ;
}
}
# endif
# endif
@ -1228,16 +1197,7 @@ gl_renderer_attach(struct weston_surface *es, struct wl_buffer *buffer)
gs - > images [ i ] ) ;
gs - > images [ i ] ) ;
}
}
switch ( es - > buffer_transform ) {
case WL_OUTPUT_TRANSFORM_90 :
case WL_OUTPUT_TRANSFORM_270 :
case WL_OUTPUT_TRANSFORM_FLIPPED_90 :
case WL_OUTPUT_TRANSFORM_FLIPPED_270 :
es - > pitch = buffer - > height ;
break ;
default :
es - > pitch = buffer - > width ;
es - > pitch = buffer - > width ;
}
} else {
} else {
weston_log ( " unhandled buffer type! \n " ) ;
weston_log ( " unhandled buffer type! \n " ) ;
}
}