struct pipe_sampler_view *sampler_view;
};
-static INLINE struct pipe_surface *
-alpha_mask_surface(struct vg_context *ctx, int usage)
-{
- struct pipe_screen *screen = ctx->pipe->screen;
- struct st_framebuffer *stfb = ctx->draw_buffer;
- return screen->get_tex_surface(screen,
- stfb->alpha_mask_view->texture,
- 0, 0, 0,
- usage);
-}
-
static INLINE VGboolean
intersect_rectangles(VGint dwidth, VGint dheight,
VGint swidth, VGint sheight,
VGint width, VGint height)
{
struct vg_context *ctx = vg_current_context();
- struct pipe_resource *dst = ctx->draw_buffer->alpha_mask_view->texture;
+ struct pipe_sampler_view *dst_view = vg_get_surface_mask(ctx);
+ struct pipe_resource *dst = dst_view->texture;
struct pipe_resource *texture = sampler_view->texture;
const struct pipe_sampler_state *samplers[2];
struct pipe_sampler_view *views[2];
loc[1], loc[2], loc[3]);
#endif
+
sampler = ctx->mask.sampler;
sampler.normalized_coords = 1;
samplers[0] = &sampler;
VGint width, VGint height)
{
struct vg_context *ctx = vg_current_context();
- struct pipe_sampler_view *src = ctx->draw_buffer->alpha_mask_view;
+ struct pipe_sampler_view *src = vg_get_surface_mask(ctx);
struct pipe_surface *surf;
/* get the destination surface */
VGbitfield paint_modes)
{
struct vg_context *ctx = vg_current_context();
+ struct pipe_screen *screen = ctx->pipe->screen;
+ struct pipe_sampler_view *view = vg_get_surface_mask(ctx);
struct matrix *mat = &ctx->state.vg.path_user_to_surface_matrix;
struct pipe_surface *surf;
- surf = alpha_mask_surface(ctx, PIPE_BIND_RENDER_TARGET);
+ surf = screen->get_tex_surface(screen, view->texture,
+ 0, 0, 0, PIPE_BIND_RENDER_TARGET);
renderer_validate_for_mask_rendering(ctx->renderer, surf);
if (paint_modes & VG_STROKE_PATH){
path_stroke(path, mat);
}
+
+ pipe_surface_reference(&surf, NULL);
}
void mask_render_to(struct path *path,
VGMaskOperation operation)
{
struct vg_context *ctx = vg_current_context();
- struct st_framebuffer *fb_buffers = ctx->draw_buffer;
+ struct st_framebuffer *stfb = ctx->draw_buffer;
struct vg_mask_layer *temp_layer;
VGint width, height;
- width = fb_buffers->alpha_mask_view->texture->width0;
- height = fb_buffers->alpha_mask_view->texture->height0;
+ width = stfb->width;
+ height = stfb->height;
temp_layer = mask_layer_create(width, height);
mask_layer_fill(temp_layer, 0, 0, width, height, 0.0f);
VGfloat value)
{
struct vg_context *ctx = vg_current_context();
+ struct pipe_sampler_view *view = vg_get_surface_mask(ctx);
#if DEBUG_MASKS
debug_printf("mask_fill(%d, %d, %d, %d) with rgba(%f, %f, %f, %f)\n",
0.0f, 0.0f, 0.0f, value);
#endif
- mask_resource_fill(ctx->draw_buffer->alpha_mask_view->texture,
- x, y, width, height, value);
+ mask_resource_fill(view->texture, x, y, width, height, value);
}
VGint mask_bind_samplers(struct pipe_sampler_state **samplers,
struct vg_context *ctx = vg_current_context();
if (ctx->state.vg.masking) {
- struct st_framebuffer *fb_buffers = ctx->draw_buffer;
-
samplers[1] = &ctx->mask.sampler;
- sampler_views[1] = fb_buffers->alpha_mask_view;
+ sampler_views[1] = vg_get_surface_mask(ctx);
return 1;
} else
return 0;
}
static void
-vg_context_update_alpha_mask_view(struct vg_context *ctx,
- uint width, uint height)
+vg_context_update_surface_mask_view(struct vg_context *ctx,
+ uint width, uint height)
{
struct st_framebuffer *stfb = ctx->draw_buffer;
- struct pipe_sampler_view *old_sampler_view = stfb->alpha_mask_view;
+ struct pipe_sampler_view *old_sampler_view = stfb->surface_mask_view;
struct pipe_context *pipe = ctx->pipe;
if (old_sampler_view &&
this texture and use it as a sampler, so while this wastes some
space it makes both of those a lot simpler
*/
- stfb->alpha_mask_view = create_tex_and_view(pipe,
+ stfb->surface_mask_view = create_tex_and_view(pipe,
PIPE_FORMAT_B8G8R8A8_UNORM, width, height);
- if (!stfb->alpha_mask_view) {
+ if (!stfb->surface_mask_view) {
if (old_sampler_view)
pipe_sampler_view_reference(&old_sampler_view, NULL);
return;
subold_surf.face = 0;
subold_surf.level = 0;
pipe->resource_copy_region(pipe,
- stfb->alpha_mask_view->texture,
+ stfb->surface_mask_view->texture,
subsurf,
0, 0, 0,
old_sampler_view->texture,
subold_surf,
0, 0, 0,
MIN2(old_sampler_view->texture->width0,
- stfb->alpha_mask_view->texture->width0),
+ stfb->surface_mask_view->texture->width0),
MIN2(old_sampler_view->texture->height0,
- stfb->alpha_mask_view->texture->height0));
+ stfb->surface_mask_view->texture->height0));
}
/* Free the old texture
if (vg_context_update_depth_stencil_rb(ctx, stfb->width, stfb->height))
ctx->state.dirty |= DEPTH_STENCIL_DIRTY;
- /* TODO create as needed */
- vg_context_update_alpha_mask_view(ctx, stfb->width, stfb->height);
-
renderer_validate(ctx->renderer, ctx->state.dirty,
ctx->draw_buffer, &ctx->state.vg);
vg_validate_state(ctx);
- vg_prepare_blend_texture(ctx, stfb->alpha_mask_view);
+ vg_context_update_surface_mask_view(ctx, stfb->width, stfb->height);
+ vg_prepare_blend_texture(ctx, stfb->surface_mask_view);
return stfb->blend_texture_view;
}
+struct pipe_sampler_view *vg_get_surface_mask(struct vg_context *ctx)
+{
+ struct st_framebuffer *stfb = ctx->draw_buffer;
+
+ vg_context_update_surface_mask_view(ctx, stfb->width, stfb->height);
+
+ return stfb->surface_mask_view;
+}
+
/**
* A transformation from window coordinates to paint coordinates.
*/