#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)
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);
}
return;
}
-#if DISABLE_1_1_MASKING
- return;
-#endif
-
vg_validate_state(ctx);
mask_render_to((struct path *)path, paintModes, operation);
return;
}
-#if DISABLE_1_1_MASKING
- return;
-#endif
+ vg_validate_state(ctx);
+
mask_layer_fill(mask, x, y, width, height, value);
}
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);
static void mask_using_texture(struct pipe_sampler_view *sampler_view,
+ VGboolean is_layer,
VGMaskOperation operation,
VGint x, VGint y,
VGint width, VGint height)
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]);
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);
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);
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,
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);
}
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);
}
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);
}
RENDERER_FS_COLOR,
RENDERER_FS_TEXTURE,
RENDERER_FS_SCISSOR,
+ RENDERER_FS_WHITE,
NUM_RENDERER_FS
} RendererFs;
struct pipe_context *pipe;
struct cso_context *cso;
+ VGbitfield dirty;
struct {
struct pipe_rasterizer_state rasterizer;
struct pipe_depth_stencil_alpha_state dsa;
return ureg_create_shader_and_destroy(ureg, 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.
*
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;
{
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));
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,