本文整理汇总了C++中cairo_get_source函数的典型用法代码示例。如果您正苦于以下问题:C++ cairo_get_source函数的具体用法?C++ cairo_get_source怎么用?C++ cairo_get_source使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了cairo_get_source函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: draw
static cairo_test_status_t
draw (cairo_t *cr, int width, int height)
{
cairo_surface_t *surface;
uint32_t data[16] = {
0xffffffff, 0xffffffff, 0xffff0000, 0xffff0000,
0xffffffff, 0xffffffff, 0xffff0000, 0xffff0000,
0xff00ff00, 0xff00ff00, 0xff0000ff, 0xff0000ff,
0xff00ff00, 0xff00ff00, 0xff0000ff, 0xff0000ff
};
surface = cairo_image_surface_create_for_data ((unsigned char *) data,
CAIRO_FORMAT_RGB24, 4, 4, 16);
/* We use a non-zero offset larger than the source surface size to
* stress cairo out a bit more. */
cairo_set_source_surface (cr, surface, 10, 10);
cairo_pattern_set_filter (cairo_get_source (cr), CAIRO_FILTER_NEAREST);
cairo_pattern_set_extend (cairo_get_source (cr), CAIRO_EXTEND_REPEAT);
cairo_paint (cr);
cairo_surface_destroy (surface);
return CAIRO_TEST_SUCCESS;
}
示例2: draw
static cairo_test_status_t
draw (cairo_t *cr, int width, int height)
{
cairo_surface_t *image;
cairo_t *cr2;
image = cairo_image_surface_create (CAIRO_FORMAT_RGB24, 2, 2);
/* Fill with an opaque background to avoid a separate rgb24 ref image */
cairo_set_source_rgb (cr, 0, 0, 0);
cairo_paint (cr);
/* First check handling of pattern extents > surface extents */
cairo_save (cr);
cairo_scale (cr, width/2., height/2.);
/* Create a solid black source to merge with the background */
cr2 = cairo_create (image);
cairo_set_source_rgb (cr2, 0, 0 ,0);
cairo_paint (cr2);
cairo_set_source_surface (cr, cairo_get_target (cr2), 0, 0);
cairo_destroy (cr2);
cairo_pattern_set_filter (cairo_get_source (cr), CAIRO_FILTER_BILINEAR);
cairo_paint (cr);
cairo_restore (cr);
/* Then scale to smaller so we can see the full bilinear extents */
cairo_save (cr);
cairo_translate (cr, PAD, PAD);
cairo_scale (cr, SCALE, SCALE);
cairo_translate (cr, 0.5, 0.5);
/* Create a 2x2 blue+red checkerboard source */
cr2 = cairo_create (image);
cairo_set_source_rgb (cr2, 1, 0 ,0); /* red */
cairo_paint (cr2);
cairo_set_source_rgb (cr2, 0, 0, 1); /* blue */
cairo_rectangle (cr2, 0, 1, 1, 1);
cairo_rectangle (cr2, 1, 0, 1, 1);
cairo_fill (cr2);
cairo_set_source_surface (cr, cairo_get_target (cr2), 0, 0);
cairo_destroy (cr2);
cairo_pattern_set_filter (cairo_get_source (cr), CAIRO_FILTER_BILINEAR);
cairo_paint (cr);
cairo_restore (cr);
cairo_surface_destroy (image);
return CAIRO_TEST_SUCCESS;
}
示例3: cairo_pattern_get_rgba
void CairoDevice::PushPenColor( const VGColor & color)
{
double r, g, b, a;
cairo_pattern_get_rgba (cairo_get_source(fNativeDevice), &r, &g, &b, &a);
fPenColorStack.push (VGColor(cc2c(r), cc2c(g), cc2c(b), cc2c(a)));
SelectPenColor (color);
}
示例4: cairo_image_surface_get_width
/* Scale the surface with the width and height requested */
cairo_surface_t *
scale_surface (cairo_surface_t *surface,
gdouble width,
gdouble height)
{
gdouble old_width = cairo_image_surface_get_width (surface);
gdouble old_height = cairo_image_surface_get_height (surface);
cairo_surface_t *new_surface = cairo_surface_create_similar(surface, CAIRO_CONTENT_COLOR_ALPHA, width, height);
cairo_t *cr = cairo_create (new_surface);
/* Scale *before* setting the source surface (1) */
cairo_scale (cr, width / old_width, height / old_height);
cairo_set_source_surface (cr, surface, 0, 0);
/* To avoid getting the edge pixels blended with 0 alpha, which would
* occur with the default EXTEND_NONE. Use EXTEND_PAD for 1.2 or newer (2)
*/
cairo_pattern_set_extend (cairo_get_source(cr), CAIRO_EXTEND_REFLECT);
/* Replace the destination with the source instead of overlaying */
cairo_set_operator (cr, CAIRO_OPERATOR_SOURCE);
/* Do the actual drawing */
cairo_paint (cr);
cairo_destroy (cr);
return new_surface;
}
示例5: lime_cairo_get_source
value lime_cairo_get_source (value handle) {
cairo_pattern_t* pattern = cairo_get_source ((cairo_t*)val_data (handle));
cairo_pattern_reference (pattern);
return CFFIPointer (pattern, gc_cairo_pattern);
}
示例6: cr_get_source
static VALUE
cr_get_source (VALUE self)
{
VALUE rb_source = Qnil;
cairo_pattern_t *source;
source = cairo_get_source (_SELF);
if (source)
{
rb_cairo_check_status (cairo_pattern_status (source));
rb_source = rb_ivar_get (self, cr_id_source);
if (NIL_P (rb_source) || RVAL2CRPATTERN (rb_source) != source)
{
rb_source = CRPATTERN2RVAL (source);
rb_ivar_set (self, cr_id_source, rb_source);
}
}
else
{
rb_source = Qnil;
rb_ivar_set (self, cr_id_source, rb_source);
}
return rb_source;
}
示例7: matenu_menu_bar_reset_bg_pixmap
static void matenu_menu_bar_reset_bg_pixmap (MatenuMenuBar* self) {
GdkPixmap* pixmap;
cairo_t* cairo;
cairo_pattern_t* pattern;
GtkStyle* style;
GdkPixmap* _tmp0_;
g_return_if_fail (self != NULL);
if (matenu_menu_bar_get_background (self)->type != MATENU_BACKGROUND_TYPE_PIXMAP) {
return;
}
if (!GTK_WIDGET_REALIZED ((GtkWidget*) self)) {
return;
}
g_assert (GDK_IS_DRAWABLE (((GtkWidget*) self)->window));
g_assert (GDK_IS_DRAWABLE (self->priv->_background->pixmap));
pixmap = gdk_pixmap_new ((GdkDrawable*) ((GtkWidget*) self)->window, ((GtkWidget*) self)->allocation.width, ((GtkWidget*) self)->allocation.height, -1);
g_assert (GDK_IS_DRAWABLE (pixmap));
cairo = gdk_cairo_create ((GdkDrawable*) pixmap);
g_assert (cairo != NULL);
gdk_cairo_set_source_pixmap (cairo, self->priv->_background->pixmap, (double) (-self->priv->_background->offset_x), (double) (-self->priv->_background->offset_y));
pattern = cairo_get_source (cairo);
cairo_pattern_set_extend (pattern, CAIRO_EXTEND_REPEAT);
cairo_rectangle (cairo, (double) 0, (double) 0, (double) ((GtkWidget*) self)->allocation.width, (double) ((GtkWidget*) self)->allocation.height);
cairo_fill (cairo);
style = _g_object_ref0 (gtk_widget_get_style ((GtkWidget*) self));
style->bg_pixmap[(gint) GTK_STATE_NORMAL] = (_tmp0_ = _g_object_ref0 (pixmap), _g_object_unref0 (style->bg_pixmap[(gint) GTK_STATE_NORMAL]), _tmp0_);
gtk_style_set_background (style, ((GtkWidget*) self)->window, GTK_STATE_NORMAL);
gtk_widget_queue_draw ((GtkWidget*) self);
_g_object_unref0 (style);
_cairo_destroy0 (cairo);
_g_object_unref0 (pixmap);
}
示例8: _cairo_image_surface_scale_bilinear_2x2
static cairo_surface_t *
_cairo_image_surface_scale_bilinear_2x2 (cairo_surface_t *image,
int new_width,
int new_height)
{
cairo_surface_t *output;
cairo_t *cr;
output = cairo_image_surface_create (CAIRO_FORMAT_ARGB32,
new_width,
new_height);
cr = cairo_create (output);
cairo_scale (cr,
(double) new_width / cairo_image_surface_get_width (image),
(double) new_height / cairo_image_surface_get_height (image));
cairo_set_source_surface (cr, image, 0.0, 0.0);
cairo_pattern_set_filter (cairo_get_source (cr), CAIRO_FILTER_BILINEAR);
cairo_rectangle (cr, 0.0, 0.0, cairo_image_surface_get_width (image), cairo_image_surface_get_height (image));
cairo_fill (cr);
cairo_surface_flush (output);
cairo_destroy (cr);
return output;
}
示例9: cairo_matrix_init_scale
cairo_surface_t* Win32UIBinding::ScaleCairoSurface(
cairo_surface_t* oldSurface, int newWidth, int newHeight)
{
cairo_matrix_t scaleMatrix;
cairo_matrix_init_scale(&scaleMatrix,
(double) cairo_image_surface_get_width(oldSurface) / (double) newWidth,
(double) cairo_image_surface_get_height(oldSurface) / (double) newHeight);
cairo_pattern_t* surfacePattern = cairo_pattern_create_for_surface(oldSurface);
cairo_pattern_set_matrix(surfacePattern, &scaleMatrix);
cairo_pattern_set_filter(surfacePattern, CAIRO_FILTER_BEST);
cairo_surface_t* newSurface = cairo_surface_create_similar(
oldSurface, CAIRO_CONTENT_COLOR_ALPHA, newWidth, newHeight);
cairo_t* cr = cairo_create(newSurface);
cairo_set_source(cr, surfacePattern);
/* To avoid getting the edge pixels blended with 0 alpha, which would
* occur with the default EXTEND_NONE. Use EXTEND_PAD for 1.2 or newer (2) */
cairo_pattern_set_extend(cairo_get_source(cr), CAIRO_EXTEND_REFLECT);
/* Replace the destination with the source instead of overlaying */
cairo_set_operator(cr, CAIRO_OPERATOR_SOURCE);
/* Do the actual drawing */
cairo_paint(cr);
cairo_destroy(cr);
return newSurface;
}
示例10: getSource_func
static JSBool
getSource_func(JSContext *context,
unsigned argc,
jsval *vp)
{
JS::CallReceiver rec = JS::CallReceiverFromVp(vp);
JSObject *obj = JSVAL_TO_OBJECT(rec.thisv());
cairo_t *cr;
cairo_pattern_t *pattern;
JSObject *pattern_wrapper;
if (argc > 0) {
gjs_throw(context, "Context.getSource() takes no arguments");
return JS_FALSE;
}
cr = gjs_cairo_context_get_context(context, obj);
pattern = cairo_get_source(cr);
if (!gjs_cairo_check_status(context, cairo_status(cr), "context"))
return JS_FALSE;
/* pattern belongs to the context, so keep the reference */
pattern_wrapper = gjs_cairo_pattern_from_pattern(context, pattern);
if (!pattern_wrapper) {
gjs_throw(context, "failed to create pattern");
return JS_FALSE;
}
rec.rval().set(OBJECT_TO_JSVAL(pattern_wrapper));
return JS_TRUE;
}
示例11: pp_piksl_draw
static gboolean pp_piksl_draw(GtkWidget* widget, cairo_t* cr) {
ppPiksl* piksl = PP_PIKSL(widget);
cairo_set_source(cr, PP_APP->checker);
cairo_rectangle(cr, 0, 0,
piksl->img_width*piksl->zoom,
piksl->img_height*piksl->zoom);
cairo_fill(cr);
// Render the graphics data...
// Zoom the surface
cairo_scale(cr, piksl->zoom, piksl->zoom);
// Render each layer
guint i;
ppLayer* layer = NULL;
for (i = 0; i < piksl->layers->len; ++i) {
layer = g_ptr_array_index(piksl->layers, i);
cairo_set_source_surface(cr, layer->surface, layer->x, layer->y);
// Disable the gaussian filtering to preserve pixels
cairo_pattern_set_filter(cairo_get_source(cr), CAIRO_FILTER_NEAREST);
cairo_paint(cr);
}
return FALSE;
}
示例12: getSource_func
static bool
getSource_func(JSContext *context,
unsigned argc,
JS::Value *vp)
{
GJS_GET_PRIV(context, argc, vp, rec, obj, GjsCairoContext, priv);
cairo_t *cr = priv ? priv->cr : NULL;
cairo_pattern_t *pattern;
JSObject *pattern_wrapper;
if (argc > 0) {
gjs_throw(context, "Context.getSource() takes no arguments");
return false;
}
pattern = cairo_get_source(cr);
if (!gjs_cairo_check_status(context, cairo_status(cr), "context"))
return false;
/* pattern belongs to the context, so keep the reference */
pattern_wrapper = gjs_cairo_pattern_from_pattern(context, pattern);
if (!pattern_wrapper) {
gjs_throw(context, "failed to create pattern");
return false;
}
rec.rval().setObject(*pattern_wrapper);
return true;
}
示例13: draw
static cairo_test_status_t
draw (cairo_t *cr, int width, int height)
{
cairo_surface_t *surface;
uint32_t data[16] = {
0x80808080, 0x80808080, 0x80800000, 0x80800000,
0x80808080, 0x80808080, 0x80800000, 0x80800000,
0x80008000, 0x80008000, 0x80000080, 0x80000080,
0x80008000, 0x80008000, 0x80000080, 0x80000080
};
surface = cairo_image_surface_create_for_data ((unsigned char *) data,
CAIRO_FORMAT_ARGB32, 4, 4, 16);
cairo_test_paint_checkered (cr);
cairo_scale (cr, 4, 4);
cairo_set_source_surface (cr, surface, 2 , 2);
cairo_pattern_set_filter (cairo_get_source (cr), CAIRO_FILTER_NEAREST);
cairo_paint (cr);
cairo_surface_destroy (surface);
return CAIRO_TEST_SUCCESS;
}
示例14: on_draw
static gint
on_draw(GtkWidget *widget, cairo_t *cr, gpointer userdata) {
GdkPixbuf *pixbuf;
pixbuf = gdk_pixbuf_new_from_file("/usr/share/themes/Ambiance/gtk-2.0/apps/img/panel.png", NULL);
if (!pixbuf) {
pixbuf = gdk_pixbuf_new_from_file("/usr/share/lxpanel/images/lubuntu-background.png", NULL);
}
if (!pixbuf) {
pixbuf = gdk_pixbuf_new_from_file("/usr/share/themes/Greybird/ubiquity-panel-bg.png", NULL);
}
if (!pixbuf) {
pixbuf = gdk_pixbuf_new_from_file("/usr/share/budgie-desktop/ubiquity-panel-bg.png", NULL);
}
if (!pixbuf) {
pixbuf = gdk_pixbuf_new_from_file("/usr/share/ubiquity/pixmaps/panel.png", NULL);
}
if (pixbuf) {
gdk_cairo_set_source_pixbuf(cr, pixbuf, 0, 0);
cairo_pattern_set_extend(cairo_get_source(cr), CAIRO_EXTEND_PAD);
cairo_paint(cr);
g_object_unref(pixbuf);
} else {
g_warning("Could not find background image.");
}
struct {
GtkWidget *container;
cairo_t *cr;
} data;
data.container = widget;
data.cr = cr;
gtk_container_forall (GTK_CONTAINER(widget), draw_child, &data);
return FALSE;
}
示例15: scheduleScratchBufferPurge
WidgetRenderingContext::~WidgetRenderingContext()
{
// We do not need to blit back to the target in the fallback case. See above.
RenderThemeGtk* theme = static_cast<RenderThemeGtk*>(RenderTheme::defaultTheme().get());
if (!theme->m_themePartsHaveRGBAColormap && m_graphicsContext->gdkWindow())
return;
// Don't paint the results back if there was an error.
if (m_hadError) {
scheduleScratchBufferPurge();
return;
}
// FIXME: It's unclear if it is necessary to preserve the current source here.
cairo_t* cairoContext = m_graphicsContext->platformContext()->cr();
RefPtr<cairo_pattern_t> previousSource(cairo_get_source(cairoContext));
// The blit rectangle is the original target rectangle adjusted for any extra space.
IntRect fullTargetRect(m_targetRect);
fullTargetRect.inflateX(m_extraSpace.width());
fullTargetRect.inflateY(m_extraSpace.height());
gdk_cairo_set_source_pixmap(cairoContext, gScratchBuffer, fullTargetRect.x(), fullTargetRect.y());
cairo_rectangle(cairoContext, fullTargetRect.x(), fullTargetRect.y(), fullTargetRect.width(), fullTargetRect.height());
cairo_fill(cairoContext);
cairo_set_source(cairoContext, previousSource.get());
scheduleScratchBufferPurge();
}