diff options
Diffstat (limited to 'src/gallium/state_trackers/vega')
-rw-r--r-- | src/gallium/state_trackers/vega/api_masks.c | 19 | ||||
-rw-r--r-- | src/gallium/state_trackers/vega/mask.c | 46 | ||||
-rw-r--r-- | src/gallium/state_trackers/vega/renderer.c | 38 | ||||
-rw-r--r-- | src/gallium/state_trackers/vega/renderer.h | 3 | ||||
-rw-r--r-- | src/gallium/state_trackers/vega/vg_context.c | 5 |
5 files changed, 64 insertions, 47 deletions
diff --git a/src/gallium/state_trackers/vega/api_masks.c b/src/gallium/state_trackers/vega/api_masks.c index 3cc4a0b5a32..beb15c33a59 100644 --- a/src/gallium/state_trackers/vega/api_masks.c +++ b/src/gallium/state_trackers/vega/api_masks.c @@ -37,8 +37,6 @@ #include "util/u_pack_color.h" #include "util/u_draw_quad.h" -#define DISABLE_1_1_MASKING 1 - void vegaMask(VGHandle mask, VGMaskOperation operation, VGint x, VGint y, VGint width, VGint height) @@ -66,12 +64,8 @@ void vegaMask(VGHandle mask, VGMaskOperation operation, struct vg_image *image = (struct vg_image *)mask; mask_using_image(image, operation, x, y, width, height); } else if (vg_object_is_valid((void*)mask, VG_OBJECT_MASK)) { -#if DISABLE_1_1_MASKING - return; -#else struct vg_mask_layer *layer = (struct vg_mask_layer *)mask; mask_using_layer(layer, operation, x, y, width, height); -#endif } else { vg_set_error(ctx, VG_BAD_HANDLE_ERROR); } @@ -138,10 +132,6 @@ void vegaRenderToMask(VGPath path, return; } -#if DISABLE_1_1_MASKING - return; -#endif - vg_validate_state(ctx); mask_render_to((struct path *)path, paintModes, operation); @@ -219,9 +209,8 @@ void vegaFillMaskLayer(VGMaskLayer maskLayer, return; } -#if DISABLE_1_1_MASKING - return; -#endif + vg_validate_state(ctx); + mask_layer_fill(mask, x, y, width, height, value); } @@ -246,9 +235,7 @@ void vegaCopyMask(VGMaskLayer maskLayer, return; } -#if DISABLE_1_1_MASKING - return; -#endif + vg_validate_state(ctx); mask = (struct vg_mask_layer*)maskLayer; mask_copy(mask, sx, sy, dx, dy, width, height); diff --git a/src/gallium/state_trackers/vega/mask.c b/src/gallium/state_trackers/vega/mask.c index e8a017d9c43..0e25833cda3 100644 --- a/src/gallium/state_trackers/vega/mask.c +++ b/src/gallium/state_trackers/vega/mask.c @@ -280,6 +280,7 @@ static void mask_resource_fill(struct pipe_resource *dst, static void mask_using_texture(struct pipe_sampler_view *sampler_view, + VGboolean is_layer, VGMaskOperation operation, VGint x, VGint y, VGint width, VGint height) @@ -320,6 +321,11 @@ static void mask_using_texture(struct pipe_sampler_view *sampler_view, if (renderer_filter_begin(ctx->renderer, dst, VG_FALSE, ~0, samplers, views, 2, fs, (const void *) ones, sizeof(ones))) { + /* layer should be flipped when used as a texture */ + if (is_layer) { + offsets[1] += offsets[3]; + offsets[3] = -offsets[3]; + } renderer_filter(ctx->renderer, loc[0], loc[1], loc[2], loc[3], offsets[0], offsets[1], offsets[2], offsets[3]); @@ -407,6 +413,10 @@ void mask_copy(struct vg_mask_layer *layer, surf = ctx->pipe->screen->get_tex_surface(ctx->pipe->screen, layer->sampler_view->texture, 0, 0, 0, PIPE_BIND_RENDER_TARGET); if (surf && renderer_copy_begin(ctx->renderer, surf, VG_FALSE, src)) { + /* layer should be flipped when used as a texture */ + sy += height; + height = -height; + renderer_copy(ctx->renderer, dx, dy, width, height, sx, sy, width, height); @@ -420,22 +430,13 @@ static void mask_layer_render_to(struct vg_mask_layer *layer, struct path *path, VGbitfield paint_modes) { -#if 0 struct vg_context *ctx = vg_current_context(); - const VGfloat fill_color[4] = {1.f, 1.f, 1.f, 1.f}; - struct pipe_screen *screen = ctx->pipe->screen; struct matrix *mat = &ctx->state.vg.path_user_to_surface_matrix; - struct pipe_surface *surface; - - surface = screen->get_tex_surface(screen, layer->sampler_view->texture, 0, 0, 0, - PIPE_BIND_RENDER_TARGET); + struct pipe_surface *surf; - cso_save_framebuffer(ctx->cso_context); - cso_save_fragment_shader(ctx->cso_context); + surf = alpha_mask_surface(ctx, PIPE_BIND_RENDER_TARGET); - setup_mask_blend(); - setup_mask_fill(fill_color); - setup_mask_framebuffer(surface, layer->width, layer->height); + renderer_validate_for_mask_rendering(ctx->renderer, surf); if (paint_modes & VG_FILL_PATH) { path_fill(path, mat); @@ -444,17 +445,6 @@ static void mask_layer_render_to(struct vg_mask_layer *layer, if (paint_modes & VG_STROKE_PATH){ path_stroke(path, mat); } - - - /* make sure rendering has completed */ - ctx->pipe->flush(ctx->pipe, PIPE_FLUSH_RENDER_CACHE, NULL); - - cso_restore_framebuffer(ctx->cso_context); - cso_restore_fragment_shader(ctx->cso_context); - ctx->state.dirty |= BLEND_DIRTY; - - pipe_surface_reference(&surface, NULL); -#endif } void mask_render_to(struct path *path, @@ -467,14 +457,14 @@ void mask_render_to(struct path *path, VGint width, height; width = fb_buffers->alpha_mask_view->texture->width0; - height = fb_buffers->alpha_mask_view->texture->width0; + height = fb_buffers->alpha_mask_view->texture->height0; temp_layer = mask_layer_create(width, height); + mask_layer_fill(temp_layer, 0, 0, width, height, 0.0f); mask_layer_render_to(temp_layer, path, paint_modes); - mask_using_layer(temp_layer, 0, 0, width, height, - operation); + mask_using_layer(temp_layer, operation, 0, 0, width, height); mask_layer_destroy(temp_layer); } @@ -484,7 +474,7 @@ void mask_using_layer(struct vg_mask_layer *layer, VGint x, VGint y, VGint width, VGint height) { - mask_using_texture(layer->sampler_view, operation, + mask_using_texture(layer->sampler_view, VG_TRUE, operation, x, y, width, height); } @@ -506,7 +496,7 @@ void mask_using_image(struct vg_image *image, VGint x, VGint y, VGint width, VGint height) { - mask_using_texture(image->sampler_view, operation, + mask_using_texture(image->sampler_view, VG_FALSE, operation, x, y, width, height); } diff --git a/src/gallium/state_trackers/vega/renderer.c b/src/gallium/state_trackers/vega/renderer.c index f436ee56fe9..8a195f316be 100644 --- a/src/gallium/state_trackers/vega/renderer.c +++ b/src/gallium/state_trackers/vega/renderer.c @@ -68,6 +68,7 @@ typedef enum { RENDERER_FS_COLOR, RENDERER_FS_TEXTURE, RENDERER_FS_SCISSOR, + RENDERER_FS_WHITE, NUM_RENDERER_FS } RendererFs; @@ -75,6 +76,7 @@ struct renderer { struct pipe_context *pipe; struct cso_context *cso; + VGbitfield dirty; struct { struct pipe_rasterizer_state rasterizer; struct pipe_depth_stencil_alpha_state dsa; @@ -222,6 +224,25 @@ static void *create_scissor_fs(struct pipe_context *pipe) } /** + * Create a simple fragment shader that sets the color to white. + */ +static void *create_white_fs(struct pipe_context *pipe) +{ + struct ureg_program *ureg; + struct ureg_dst out; + struct ureg_src imm; + + ureg = ureg_create(TGSI_PROCESSOR_FRAGMENT); + out = ureg_DECL_output(ureg, TGSI_SEMANTIC_COLOR, 0); + imm = ureg_imm4f(ureg, 1.0f, 1.0f, 1.0f, 1.0f); + + ureg_MOV(ureg, out, imm); + ureg_END(ureg); + + return ureg_create_shader_and_destroy(ureg, pipe); +} + +/** * Set renderer fragment shader. * * This function modifies fragment_shader state. @@ -243,6 +264,9 @@ static void renderer_set_fs(struct renderer *r, RendererFs id) case RENDERER_FS_SCISSOR: fs = create_scissor_fs(r->pipe); break; + case RENDERER_FS_WHITE: + fs = create_white_fs(r->pipe); + break; default: assert(!"Unknown renderer fs id"); break; @@ -1171,6 +1195,9 @@ void renderer_validate(struct renderer *renderer, { assert(renderer->state == RENDERER_STATE_INIT); + dirty |= renderer->dirty; + renderer->dirty = 0; + if (dirty & BLEND_DIRTY) { struct pipe_blend_state blend; memset(&blend, 0, sizeof(blend)); @@ -1308,6 +1335,17 @@ void renderer_validate_for_shader(struct renderer *renderer, const_buffer, const_buffer_len); } +void renderer_validate_for_mask_rendering(struct renderer *renderer, + struct pipe_surface *dst) +{ + renderer_set_target(renderer, dst, renderer->g3d.fb.zsbuf, VG_FALSE); + renderer_set_blend(renderer, ~0); + renderer_set_fs(renderer, RENDERER_FS_WHITE); + + /* set internal dirty flags (hacky!) */ + renderer->dirty = FRAMEBUFFER_DIRTY | BLEND_DIRTY; +} + void renderer_copy_surface(struct renderer *ctx, struct pipe_surface *src, int srcX0, int srcY0, diff --git a/src/gallium/state_trackers/vega/renderer.h b/src/gallium/state_trackers/vega/renderer.h index 3cbd1c5e692..a21d78af252 100644 --- a/src/gallium/state_trackers/vega/renderer.h +++ b/src/gallium/state_trackers/vega/renderer.h @@ -58,6 +58,9 @@ void renderer_validate_for_shader(struct renderer *renderer, const void *const_buffer, VGint const_buffer_len); +void renderer_validate_for_mask_rendering(struct renderer *renderer, + struct pipe_surface *dst); + VGboolean renderer_copy_begin(struct renderer *renderer, struct pipe_surface *dst, VGboolean y0_top, diff --git a/src/gallium/state_trackers/vega/vg_context.c b/src/gallium/state_trackers/vega/vg_context.c index f2966fc72e9..19f4e71e0d9 100644 --- a/src/gallium/state_trackers/vega/vg_context.c +++ b/src/gallium/state_trackers/vega/vg_context.c @@ -493,11 +493,10 @@ void vg_prepare_blend_surface_from_mask(struct vg_context *ctx) 0, 0, 0, PIPE_BIND_RENDER_TARGET); - /* flip it, because we want to use it as a sampler */ util_blit_pixels_tex(ctx->blit, stfb->alpha_mask_view, - 0, strb->height, - strb->width, 0, + 0, 0, + strb->width, strb->height, dest_surface, 0, 0, strb->width, strb->height, |