summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChia-I Wu <olv@lunarg.com>2010-11-28 01:37:35 +0800
committerChia-I Wu <olv@lunarg.com>2010-12-01 11:23:50 +0800
commit96c6637a1360f146bbf49ffb207ae943ecbbdf49 (patch)
tree1189ca0bdede78540ba2377801c325c9152f40bd
parent438359597cd4254558f4d2fd5b54eb32c03e1b4c (diff)
st/vega: Use st_framebuffer for fb width/height.
This allows us to eventually make g3d states opaque.
-rw-r--r--src/gallium/state_trackers/vega/api_images.c19
-rw-r--r--src/gallium/state_trackers/vega/api_masks.c5
-rw-r--r--src/gallium/state_trackers/vega/mask.c23
-rw-r--r--src/gallium/state_trackers/vega/vg_context.c10
4 files changed, 27 insertions, 30 deletions
diff --git a/src/gallium/state_trackers/vega/api_images.c b/src/gallium/state_trackers/vega/api_images.c
index e9f038c5f9..23ab37513f 100644
--- a/src/gallium/state_trackers/vega/api_images.c
+++ b/src/gallium/state_trackers/vega/api_images.c
@@ -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);
diff --git a/src/gallium/state_trackers/vega/api_masks.c b/src/gallium/state_trackers/vega/api_masks.c
index 45f77d7d70..3cc4a0b5a3 100644
--- a/src/gallium/state_trackers/vega/api_masks.c
+++ b/src/gallium/state_trackers/vega/api_masks.c
@@ -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)) {
diff --git a/src/gallium/state_trackers/vega/mask.c b/src/gallium/state_trackers/vega/mask.c
index 3bd9a1e598..3b042cec0e 100644
--- a/src/gallium/state_trackers/vega/mask.c
+++ b/src/gallium/state_trackers/vega/mask.c
@@ -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);
diff --git a/src/gallium/state_trackers/vega/vg_context.c b/src/gallium/state_trackers/vega/vg_context.c
index 037505e236..afb9579c1d 100644
--- a/src/gallium/state_trackers/vega/vg_context.c
+++ b/src/gallium/state_trackers/vega/vg_context.c
@@ -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;