mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-05-06 11:38:05 +02:00
st/vega: Use st_framebuffer for fb width/height.
This allows us to eventually make g3d states opaque.
This commit is contained in:
parent
438359597c
commit
96c6637a13
4 changed files with 27 additions and 30 deletions
|
|
@ -399,7 +399,6 @@ void vegaReadPixels(void * data, VGint dataStride,
|
|||
|
||||
struct st_framebuffer *stfb = ctx->draw_buffer;
|
||||
struct st_renderbuffer *strb = stfb->strb;
|
||||
struct pipe_framebuffer_state *fb = &ctx->state.g3d.fb;
|
||||
|
||||
VGfloat temp[VEGA_MAX_IMAGE_WIDTH][4];
|
||||
VGfloat *df = (VGfloat*)temp;
|
||||
|
|
@ -435,21 +434,21 @@ void vegaReadPixels(void * data, VGint dataStride,
|
|||
sy = 0;
|
||||
}
|
||||
|
||||
if (sx + width > fb->width || sy + height > fb->height) {
|
||||
width = fb->width - sx;
|
||||
height = fb->height - sy;
|
||||
if (sx + width > stfb->width || sy + height > stfb->height) {
|
||||
width = stfb->width - sx;
|
||||
height = stfb->height - sy;
|
||||
/* nothing to read */
|
||||
if (width <= 0 || height <= 0)
|
||||
return;
|
||||
}
|
||||
|
||||
{
|
||||
VGint y = (fb->height - sy) - 1, yStep = -1;
|
||||
VGint y = (stfb->height - sy) - 1, yStep = -1;
|
||||
struct pipe_transfer *transfer;
|
||||
|
||||
transfer = pipe_get_transfer(pipe, strb->texture, 0, 0, 0,
|
||||
PIPE_TRANSFER_READ,
|
||||
0, 0, sx + width, fb->height - sy);
|
||||
0, 0, sx + width, stfb->height - sy);
|
||||
|
||||
/* Do a row at a time to flip image data vertically */
|
||||
for (i = 0; i < height; i++) {
|
||||
|
|
@ -472,8 +471,8 @@ void vegaCopyPixels(VGint dx, VGint dy,
|
|||
VGint width, VGint height)
|
||||
{
|
||||
struct vg_context *ctx = vg_current_context();
|
||||
struct pipe_framebuffer_state *fb = &ctx->state.g3d.fb;
|
||||
struct st_renderbuffer *strb = ctx->draw_buffer->strb;
|
||||
struct st_framebuffer *stfb = ctx->draw_buffer;
|
||||
struct st_renderbuffer *strb = stfb->strb;
|
||||
|
||||
if (width <= 0 || height <= 0) {
|
||||
vg_set_error(ctx, VG_ILLEGAL_ARGUMENT_ERROR);
|
||||
|
|
@ -481,8 +480,8 @@ void vegaCopyPixels(VGint dx, VGint dy,
|
|||
}
|
||||
|
||||
/* do nothing if we copy from outside the fb */
|
||||
if (dx >= (VGint)fb->width || dy >= (VGint)fb->height ||
|
||||
sx >= (VGint)fb->width || sy >= (VGint)fb->height)
|
||||
if (dx >= (VGint)stfb->width || dy >= (VGint)stfb->height ||
|
||||
sx >= (VGint)stfb->width || sy >= (VGint)stfb->height)
|
||||
return;
|
||||
|
||||
vg_validate_state(ctx);
|
||||
|
|
|
|||
|
|
@ -81,7 +81,7 @@ void vegaClear(VGint x, VGint y,
|
|||
VGint width, VGint height)
|
||||
{
|
||||
struct vg_context *ctx = vg_current_context();
|
||||
struct pipe_framebuffer_state *fb;
|
||||
struct st_framebuffer *stfb = ctx->draw_buffer;
|
||||
|
||||
if (width <= 0 || height <= 0) {
|
||||
vg_set_error(ctx, VG_ILLEGAL_ARGUMENT_ERROR);
|
||||
|
|
@ -98,10 +98,9 @@ void vegaClear(VGint x, VGint y,
|
|||
ctx->state.vg.clear_color[3]);
|
||||
#endif
|
||||
|
||||
fb = &ctx->state.g3d.fb;
|
||||
/* check for a whole surface clear */
|
||||
if (!ctx->state.vg.scissoring &&
|
||||
(x == 0 && y == 0 && width == fb->width && height == fb->height)) {
|
||||
(x == 0 && y == 0 && width == stfb->width && height == stfb->height)) {
|
||||
ctx->pipe->clear(ctx->pipe, PIPE_CLEAR_COLOR | PIPE_CLEAR_DEPTHSTENCIL,
|
||||
ctx->state.vg.clear_color, 1., 0);
|
||||
} else if (renderer_clear_begin(ctx->renderer)) {
|
||||
|
|
|
|||
|
|
@ -114,11 +114,10 @@ static void read_alpha_mask(void * data, VGint dataStride,
|
|||
|
||||
struct st_framebuffer *stfb = ctx->draw_buffer;
|
||||
struct st_renderbuffer *strb = stfb->alpha_mask;
|
||||
struct pipe_framebuffer_state *fb = &ctx->state.g3d.fb;
|
||||
|
||||
VGfloat temp[VEGA_MAX_IMAGE_WIDTH][4];
|
||||
VGfloat *df = (VGfloat*)temp;
|
||||
VGint y = (fb->height - sy) - 1, yStep = -1;
|
||||
VGint y = (stfb->height - sy) - 1, yStep = -1;
|
||||
VGint i;
|
||||
VGubyte *dst = (VGubyte *)data;
|
||||
VGint xoffset = 0, yoffset = 0;
|
||||
|
|
@ -135,7 +134,7 @@ static void read_alpha_mask(void * data, VGint dataStride,
|
|||
yoffset = -sy;
|
||||
height += sy;
|
||||
sy = 0;
|
||||
y = (fb->height - sy) - 1;
|
||||
y = (stfb->height - sy) - 1;
|
||||
yoffset *= dataStride;
|
||||
}
|
||||
|
||||
|
|
@ -164,23 +163,23 @@ static void read_alpha_mask(void * data, VGint dataStride,
|
|||
void save_alpha_to_file(const char *filename)
|
||||
{
|
||||
struct vg_context *ctx = vg_current_context();
|
||||
struct pipe_framebuffer_state *fb = &ctx->state.g3d.fb;
|
||||
struct st_framebuffer *stfb = ctx->draw_buffer;
|
||||
VGint *data;
|
||||
int i, j;
|
||||
|
||||
data = malloc(sizeof(int) * fb->width * fb->height);
|
||||
read_alpha_mask(data, fb->width * sizeof(int),
|
||||
data = malloc(sizeof(int) * stfb->width * stfb->height);
|
||||
read_alpha_mask(data, stfb->width * sizeof(int),
|
||||
VG_sRGBA_8888,
|
||||
0, 0, fb->width, fb->height);
|
||||
0, 0, stfb->width, stfb->height);
|
||||
fprintf(stderr, "/*---------- start */\n");
|
||||
fprintf(stderr, "const int image_width = %d;\n",
|
||||
fb->width);
|
||||
stfb->width);
|
||||
fprintf(stderr, "const int image_height = %d;\n",
|
||||
fb->height);
|
||||
stfb->height);
|
||||
fprintf(stderr, "const int image_data = {\n");
|
||||
for (i = 0; i < fb->height; ++i) {
|
||||
for (j = 0; j < fb->width; ++j) {
|
||||
int rgba = data[i * fb->height + j];
|
||||
for (i = 0; i < stfb->height; ++i) {
|
||||
for (j = 0; j < stfb->width; ++j) {
|
||||
int rgba = data[i * stfb->height + j];
|
||||
int argb = 0;
|
||||
argb = (rgba >> 8);
|
||||
argb |= ((rgba & 0xff) << 24);
|
||||
|
|
|
|||
|
|
@ -575,16 +575,16 @@ void * vg_texture_vs(struct vg_context *ctx)
|
|||
|
||||
void vg_set_viewport(struct vg_context *ctx, VegaOrientation orientation)
|
||||
{
|
||||
struct st_framebuffer *stfb = ctx->draw_buffer;
|
||||
struct pipe_viewport_state viewport;
|
||||
struct pipe_framebuffer_state *fb = &ctx->state.g3d.fb;
|
||||
VGfloat y_scale = (orientation == VEGA_Y0_BOTTOM) ? -2.f : 2.f;
|
||||
|
||||
viewport.scale[0] = fb->width / 2.f;
|
||||
viewport.scale[1] = fb->height / y_scale;
|
||||
viewport.scale[0] = stfb->width / 2.f;
|
||||
viewport.scale[1] = stfb->height / y_scale;
|
||||
viewport.scale[2] = 1.0;
|
||||
viewport.scale[3] = 1.0;
|
||||
viewport.translate[0] = fb->width / 2.f;
|
||||
viewport.translate[1] = fb->height / 2.f;
|
||||
viewport.translate[0] = stfb->width / 2.f;
|
||||
viewport.translate[1] = stfb->height / 2.f;
|
||||
viewport.translate[2] = 0.0;
|
||||
viewport.translate[3] = 0.0;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue