/* FIXME: This should take a context pointer for Cogl 2.0 Technically * we could make it so we can retrieve a context reference from the * pipeline, but this would not by symmetric with cogl_pop_source. */ void cogl_push_source (void *material_or_pipeline) { CoglPipeline *pipeline = COGL_PIPELINE (material_or_pipeline); _COGL_RETURN_IF_FAIL (cogl_is_pipeline (pipeline)); _cogl_push_source (pipeline, TRUE); }
static gboolean _cogl_blit_texture_render_begin (CoglBlitData *data) { CoglHandle fbo; CoglPipeline *pipeline; unsigned int dst_width, dst_height; _COGL_GET_CONTEXT (ctx, FALSE); fbo = _cogl_offscreen_new_to_texture_full (data->dst_tex, COGL_OFFSCREEN_DISABLE_DEPTH_AND_STENCIL, 0 /* level */); if (fbo == COGL_INVALID_HANDLE) return FALSE; if (!cogl_framebuffer_allocate (fbo, NULL)) { cogl_handle_unref (fbo); return FALSE; } cogl_push_framebuffer (fbo); cogl_handle_unref (fbo); dst_width = cogl_texture_get_width (data->dst_tex); dst_height = cogl_texture_get_height (data->dst_tex); /* Set up an orthographic projection so we can use pixel coordinates to render to the texture */ cogl_ortho (0, /* left */ dst_width, /* right */ dst_height, /* bottom */ 0, /* top */ -1, /* near */ 1 /* far */); /* We cache a pipeline used for migrating on to the context so that it doesn't have to continuously regenerate a shader program */ if (ctx->blit_texture_pipeline == NULL) { ctx->blit_texture_pipeline = cogl_pipeline_new (); cogl_pipeline_set_layer_filters (ctx->blit_texture_pipeline, 0, COGL_PIPELINE_FILTER_NEAREST, COGL_PIPELINE_FILTER_NEAREST); /* Disable blending by just directly taking the contents of the source texture */ cogl_pipeline_set_blend (ctx->blit_texture_pipeline, "RGBA = ADD(SRC_COLOR, 0)", NULL); } pipeline = ctx->blit_texture_pipeline; cogl_pipeline_set_layer_texture (pipeline, 0, data->src_tex); _cogl_push_source (pipeline, FALSE); return TRUE; }