static void vg_context_update_draw_buffer(struct vg_context *ctx, struct pipe_resource *pt) { struct st_framebuffer *stfb = ctx->draw_buffer; boolean new_cbuf, new_zsbuf, new_size; new_cbuf = vg_context_update_color_rb(ctx, pt); new_zsbuf = vg_context_update_depth_stencil_rb(ctx, pt->width0, pt->height0); new_size = (stfb->width != pt->width0 || stfb->height != pt->height0); stfb->width = pt->width0; stfb->height = pt->height0; if (new_cbuf || new_zsbuf || new_size) { struct pipe_framebuffer_state *state = &ctx->state.g3d.fb; memset(state, 0, sizeof(struct pipe_framebuffer_state)); state->width = stfb->width; state->height = stfb->height; state->nr_cbufs = 1; state->cbufs[0] = stfb->strb->surface; state->zsbuf = stfb->dsrb->surface; cso_set_framebuffer(ctx->cso_context, state); } if (new_zsbuf || new_size) { ctx->state.dirty |= VIEWPORT_DIRTY; ctx->state.dirty |= DEPTH_STENCIL_DIRTY;/*to reset the scissors*/ ctx->pipe->clear(ctx->pipe, PIPE_CLEAR_DEPTHSTENCIL, NULL, 0.0, 0); /* we need all the other state already set */ setup_new_alpha_mask(ctx, stfb); pipe_sampler_view_reference( &stfb->blend_texture_view, NULL); stfb->blend_texture_view = create_tex_and_view(ctx->pipe, PIPE_FORMAT_B8G8R8A8_UNORM, stfb->width, stfb->height); } }
void vg_validate_state(struct vg_context *ctx) { struct st_framebuffer *stfb = ctx->draw_buffer; vg_manager_validate_framebuffer(ctx); if (vg_context_update_depth_stencil_rb(ctx, stfb->width, stfb->height)) ctx->state.dirty |= DEPTH_STENCIL_DIRTY; /* blend state depends on fb format and paint color */ if ((ctx->state.dirty & FRAMEBUFFER_DIRTY) || (ctx->state.dirty & PAINT_DIRTY)) ctx->state.dirty |= BLEND_DIRTY; renderer_validate(ctx->renderer, ctx->state.dirty, ctx->draw_buffer, &ctx->state.vg); ctx->state.dirty = 0; shader_set_masking(ctx->shader, ctx->state.vg.masking); shader_set_image_mode(ctx->shader, ctx->state.vg.image_mode); shader_set_color_transform(ctx->shader, ctx->state.vg.color_transform); }