本文整理汇总了C++中cairo_surface_destroy函数的典型用法代码示例。如果您正苦于以下问题:C++ cairo_surface_destroy函数的具体用法?C++ cairo_surface_destroy怎么用?C++ cairo_surface_destroy使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了cairo_surface_destroy函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: canvas_free
/****************************************************************************
Free any resources associated with this canvas and the canvas struct
itself.
****************************************************************************/
void canvas_free(struct canvas *store)
{
cairo_surface_destroy(store->surface);
free(store);
}
开发者ID:valisc,项目名称:freeciv,代码行数:9,代码来源:canvas.c
示例2: draw_rectangles
void draw_rectangles(cairo_t *fbcr, struct tsdev *ts, cairo_linuxfb_device_t *device)
{
int bufid = 1; /* start drawing into second buffer */
float r, g, b;
int fbsizex = device->fb_vinfo.xres;
int fbsizey = device->fb_vinfo.yres;
int startx, starty, sizex, sizey;
struct ts_sample sample;
cairo_surface_t *surface;
cairo_t *cr;
float scale = 1.0f;
surface = cairo_image_surface_create(CAIRO_FORMAT_RGB16_565,
fbsizex, fbsizey);
cr = cairo_create(surface);
/*
* We clear the cairo surface here before drawing
* This is required in case something was drawn on this surface
* previously, the previous contents would not be cleared without this.
*/
cairo_set_operator(cr, CAIRO_OPERATOR_CLEAR);
cairo_paint(cr);
cairo_set_operator(cr, CAIRO_OPERATOR_OVER);
srand(time(NULL));
while (!cancel) {
r = (rand() % 100) / 100.0;
g = (rand() % 100) / 100.0;
b = (rand() % 100) / 100.0;
startx = rand() % fbsizex;
starty = rand() % fbsizey;
sizex = rand() % (fbsizex - startx);
sizey = rand() % (fbsizey - starty);
cairo_identity_matrix(cr);
if (ts) {
int pressed = 0;
/* Pressure is our identication whether we act on axis... */
while (ts_read(ts, &sample, 1)) {
if (sample.pressure > 0)
pressed = 1;
}
if (pressed) {
scale *= 1.05f;
cairo_translate(cr, sample.x, sample.y);
cairo_scale(cr, scale, scale);
//r = g = b = 0;
startx = -5;
starty = -5;
sizex = 10;
sizey = 10;
} else {
scale = 1.0f;
}
}
cairo_set_source_rgb(cr, r, g, b);
cairo_rectangle(cr, startx, starty, sizex, sizey);
cairo_stroke_preserve(cr);
cairo_fill(cr);
/* Draw to framebuffer at y offset according to current buffer.. */
cairo_set_source_surface(fbcr, surface, 0, bufid * fbsizey);
cairo_paint(fbcr);
flip_buffer(device, 1, bufid);
/* Switch buffer ID for next draw */
bufid = !bufid;
usleep(20000);
}
/* Make sure we leave with buffer 0 enabled */
flip_buffer(device, 1, 0);
/* Destroy and release all cairo related contexts */
cairo_destroy(cr);
cairo_surface_destroy(surface);
}
开发者ID:MaxKrummenacher,项目名称:cairo-fb-examples,代码行数:83,代码来源:rectangles.c
示例3: fo_doc_cairo_place_image
//.........这里部分代码省略.........
rsvg_init();
rsvg_set_default_dpi_x_y (PIXELS_PER_INCH, PIXELS_PER_INCH);
rsvg = rsvg_handle_new_from_file (fo_image_get_uri(fo_image), &error);
rsvg_handle_render_cairo (rsvg, FO_DOC_CAIRO(fo_doc)->cr);
rsvg_term();
cairo_restore (FO_DOC_CAIRO(fo_doc)->cr);
if (error) {
g_log (G_LOG_DOMAIN,
G_LOG_LEVEL_ERROR,
error->message);
g_error_free (error);
}
return;
}
#endif
if (n_channels == 3)
{
format = CAIRO_FORMAT_RGB24;
}
else
{
format = CAIRO_FORMAT_ARGB32;
}
cairo_pixels = g_malloc (4 * width * height);
surface = cairo_image_surface_create_for_data ((unsigned char *)cairo_pixels,
format,
width, height, 4 * width);
cairo_surface_set_user_data (surface, &key,
cairo_pixels, (cairo_destroy_func_t)g_free);
for (j = height; j; j--)
{
guchar *p = gdk_pixels;
guchar *q = cairo_pixels;
if (n_channels == 3)
{
guchar *end = p + 3 * width;
while (p < end)
{
#if G_BYTE_ORDER == G_LITTLE_ENDIAN
q[0] = p[2];
q[1] = p[1];
q[2] = p[0];
#else
q[1] = p[0];
q[2] = p[1];
q[3] = p[2];
#endif
p += 3;
q += 4;
}
}
else
{
guchar *end = p + 4 * width;
guint t1,t2,t3;
#define MULT(d,c,a,t) G_STMT_START { t = c * a + 0x7f; d = ((t >> 8) + t) >> 8; } G_STMT_END
while (p < end)
{
#if G_BYTE_ORDER == G_LITTLE_ENDIAN
MULT(q[0], p[2], p[3], t1);
MULT(q[1], p[1], p[3], t2);
MULT(q[2], p[0], p[3], t3);
q[3] = p[3];
#else
q[0] = p[3];
MULT(q[1], p[0], p[3], t1);
MULT(q[2], p[1], p[3], t2);
MULT(q[3], p[2], p[3], t3);
#endif
p += 4;
q += 4;
}
#undef MULT
}
gdk_pixels += gdk_rowstride;
cairo_pixels += 4 * width;
}
cairo_surface_set_fallback_resolution (surface,
PIXELS_PER_INCH,
PIXELS_PER_INCH);
cairo_set_source_surface (FO_DOC_CAIRO (fo_doc)->cr, surface, 0, 0);
cairo_pattern_t *pattern = cairo_get_source (FO_DOC_CAIRO (fo_doc)->cr);
cairo_pattern_set_extend (pattern,
CAIRO_EXTEND_NONE);
cairo_paint (FO_DOC_CAIRO (fo_doc)->cr);
cairo_surface_destroy (surface);
g_object_unref (pixbuf);
cairo_restore (FO_DOC_CAIRO(fo_doc)->cr);
}
开发者ID:hrs-allbsd,项目名称:xmlroff,代码行数:101,代码来源:fo-doc-cairo.c
示例4: cairo_test_target_has_similar
cairo_test_similar_t
cairo_test_target_has_similar (const cairo_test_context_t *ctx,
const cairo_boilerplate_target_t *target)
{
cairo_surface_t *surface;
cairo_test_similar_t has_similar;
cairo_t * cr;
cairo_surface_t *similar;
cairo_status_t status;
void *closure;
char *path;
/* ignore image intermediate targets */
if (target->expected_type == CAIRO_SURFACE_TYPE_IMAGE)
return DIRECT;
if (getenv ("CAIRO_TEST_IGNORE_SIMILAR"))
return DIRECT;
xasprintf (&path, "%s/%s",
_cairo_test_mkdir (ctx->output) ? ctx->output : ".",
ctx->test_name);
has_similar = DIRECT;
do {
do {
surface = (target->create_surface) (path,
target->content,
ctx->test->width,
ctx->test->height,
ctx->test->width + 25 * NUM_DEVICE_OFFSETS,
ctx->test->height + 25 * NUM_DEVICE_OFFSETS,
CAIRO_BOILERPLATE_MODE_TEST,
&closure);
if (surface == NULL)
goto out;
} while (cairo_test_malloc_failure (ctx, cairo_surface_status (surface)));
if (cairo_surface_status (surface))
goto out;
cr = cairo_create (surface);
cairo_push_group_with_content (cr,
cairo_boilerplate_content (target->content));
similar = cairo_get_group_target (cr);
status = cairo_surface_status (similar);
if (cairo_surface_get_type (similar) == cairo_surface_get_type (surface))
has_similar = SIMILAR;
else
has_similar = DIRECT;
cairo_destroy (cr);
cairo_surface_destroy (surface);
if (target->cleanup)
target->cleanup (closure);
} while (! has_similar && cairo_test_malloc_failure (ctx, status));
out:
free (path);
return has_similar;
}
开发者ID:mrobinson,项目名称:cairo,代码行数:63,代码来源:cairo-test.c
示例5: ReadPANGOImage
//.........这里部分代码省略.........
}
if (image->rows == 0)
{
pango_layout_get_extents(layout,NULL,&extent);
image->rows=(extent.y+extent.height+PANGO_SCALE/2)/PANGO_SCALE+2*page.y;
}
else
{
image->rows-=2*page.y;
pango_layout_set_height(layout,(int) ((PANGO_SCALE*image->rows*
(image->resolution.y == 0.0 ? 90.0 : image->resolution.y)+45.0)/90.0+
0.5));
}
status=SetImageExtent(image,image->columns,image->rows,exception);
if (status == MagickFalse)
return(DestroyImageList(image));
/*
Render markup.
*/
stride=(size_t) cairo_format_stride_for_width(CAIRO_FORMAT_ARGB32,
(int) image->columns);
pixel_info=AcquireVirtualMemory(image->rows,stride*sizeof(*pixels));
if (pixel_info == (MemoryInfo *) NULL)
{
draw_info=DestroyDrawInfo(draw_info);
caption=DestroyString(caption);
ThrowReaderException(ResourceLimitError,"MemoryAllocationFailed");
}
pixels=(unsigned char *) GetVirtualMemoryBlob(pixel_info);
surface=cairo_image_surface_create_for_data(pixels,CAIRO_FORMAT_ARGB32,
(int) image->columns,(int) image->rows,(int) stride);
cairo_image=cairo_create(surface);
cairo_set_operator(cairo_image,CAIRO_OPERATOR_CLEAR);
cairo_paint(cairo_image);
cairo_set_operator(cairo_image,CAIRO_OPERATOR_OVER);
cairo_translate(cairo_image,page.x,page.y);
cairo_set_source_rgba(cairo_image,QuantumScale*draw_info->fill.red,
QuantumScale*draw_info->fill.green,QuantumScale*draw_info->fill.blue,
QuantumScale*draw_info->fill.alpha);
pango_cairo_show_layout(cairo_image,layout);
cairo_destroy(cairo_image);
cairo_surface_destroy(surface);
g_object_unref(layout);
g_object_unref(fontmap);
/*
Convert surface to image.
*/
(void) SetImageBackgroundColor(image,exception);
p=pixels;
GetPixelInfo(image,&fill_color);
for (y=0; y < (ssize_t) image->rows; y++)
{
register Quantum
*q;
register ssize_t
x;
q=GetAuthenticPixels(image,0,y,image->columns,1,exception);
if (q == (Quantum *) NULL)
break;
for (x=0; x < (ssize_t) image->columns; x++)
{
double
gamma;
fill_color.blue=(double) ScaleCharToQuantum(*p++);
fill_color.green=(double) ScaleCharToQuantum(*p++);
fill_color.red=(double) ScaleCharToQuantum(*p++);
fill_color.alpha=(double) ScaleCharToQuantum(*p++);
/*
Disassociate alpha.
*/
gamma=QuantumScale*fill_color.alpha;
gamma=PerceptibleReciprocal(gamma);
fill_color.blue*=gamma;
fill_color.green*=gamma;
fill_color.red*=gamma;
CompositePixelOver(image,&fill_color,fill_color.alpha,q,(double)
GetPixelAlpha(image,q),q);
q+=GetPixelChannels(image);
}
if (SyncAuthenticPixels(image,exception) == MagickFalse)
break;
if (image->previous == (Image *) NULL)
{
status=SetImageProgress(image,LoadImageTag,(MagickOffsetType) y,
image->rows);
if (status == MagickFalse)
break;
}
}
/*
Relinquish resources.
*/
pixel_info=RelinquishVirtualMemory(pixel_info);
draw_info=DestroyDrawInfo(draw_info);
caption=DestroyString(caption);
return(GetFirstImageInList(image));
}
开发者ID:riingo,项目名称:ImageMagick,代码行数:101,代码来源:pango.c
示例6: copyright
//.........这里部分代码省略.........
y1 = buf.height;
break;
case 3:
x0 = 0.0;
y0 = buf.height * lib->splitline_y;
x1 = buf.width;
y1 = buf.height;
break;
default:
fprintf(stderr, "OMFG, the world will collapse, this shouldn't be reachable!\n");
return;
}
cairo_rectangle(cr, x0, y0, x1, y1);
cairo_clip(cr);
}
cairo_set_source_surface(cr, surface, 0, 0);
// set filter no nearest:
// in skull mode, we want to see big pixels.
// in 1 iir mode for the right mip, we want to see exactly what the pipe gave us, 1:1 pixel for pixel.
// in between, filtering just makes stuff go unsharp.
if((buf.width <= 8 && buf.height <= 8) || fabsf(scale - 1.0f) < 0.01f)
cairo_pattern_set_filter(cairo_get_source(cr), CAIRO_FILTER_NEAREST);
cairo_rectangle(cr, 0, 0, buf.width, buf.height);
int overlay_modes_index = dt_bauhaus_combobox_get(lib->overlay_mode);
if(overlay_modes_index >= 0)
{
cairo_operator_t mode = _overlay_modes[overlay_modes_index];
cairo_set_operator(cr, mode);
}
cairo_fill(cr);
cairo_set_operator(cr, CAIRO_OPERATOR_OVER);
cairo_surface_destroy(surface);
}
cairo_restore(cr);
if(buf.buf) dt_mipmap_cache_release(darktable.mipmap_cache, &buf);
if(img) dt_image_cache_read_release(darktable.image_cache, img);
// ON CANVAS CONTROLS
if(use_splitline)
{
float scale = fminf(1.0, fminf(w / pw, h / ph));
// image coordinates
lib->overlay_x0 = 0.5 * (width - pw * scale);
lib->overlay_y0 = 0.5 * (height - ph * scale + BAR_HEIGHT);
lib->overlay_x1 = lib->overlay_x0 + pw * scale;
lib->overlay_y1 = lib->overlay_y0 + ph * scale;
// splitline position to absolute coords:
double sl_x = lib->overlay_x0 + lib->splitline_x * pw * scale;
double sl_y = lib->overlay_y0 + lib->splitline_y * ph * scale;
int x0 = sl_x, y0 = 0.0, x1 = x0, y1 = height;
if(lib->splitline_rotation % 2 != 0)
{
x0 = 0.0;
y0 = sl_y;
x1 = width;
y1 = y0;
}
gboolean mouse_over_control = (lib->splitline_rotation % 2 == 0) ? (fabs(sl_x - pointerx) < 5)
: (fabs(sl_y - pointery) < 5);
cairo_save(cr);
cairo_set_source_rgb(cr, .7, .7, .7);
开发者ID:CarVac,项目名称:darktable,代码行数:67,代码来源:live_view.c
示例7: dt_cairo_image_surface_get_width
//.........这里部分代码省略.........
cairo_rectangle(cr, 0, 0, width - 2 * tb, height - 2 * tb);
cairo_clip(cr);
cairo_new_path(cr);
// draw view
dt_view_manager_expose(darktable.view_manager, cr, width - 2 * tb, height - 2 * tb, pointerx - tb,
pointery - tb);
cairo_restore(cr);
// draw log message, if any
dt_pthread_mutex_lock(&darktable.control->log_mutex);
if(darktable.control->log_ack != darktable.control->log_pos)
{
PangoRectangle ink;
PangoLayout *layout;
PangoFontDescription *desc = pango_font_description_copy_static(darktable.bauhaus->pango_font_desc);
const float fontsize = DT_PIXEL_APPLY_DPI(14);
pango_font_description_set_absolute_size(desc, fontsize * PANGO_SCALE);
pango_font_description_set_weight(desc, PANGO_WEIGHT_BOLD);
layout = pango_cairo_create_layout(cr);
pango_layout_set_font_description(layout, desc);
pango_layout_set_text(layout, darktable.control->log_message[darktable.control->log_ack], -1);
pango_layout_get_pixel_extents(layout, &ink, NULL);
const float pad = DT_PIXEL_APPLY_DPI(20.0f), xc = width / 2.0;
const float yc = height * 0.85 + DT_PIXEL_APPLY_DPI(10), wd = pad + ink.width * .5f;
float rad = DT_PIXEL_APPLY_DPI(14);
cairo_set_line_width(cr, 1.);
cairo_move_to(cr, xc - wd, yc + rad);
for(int k = 0; k < 5; k++)
{
cairo_arc(cr, xc - wd, yc, rad, M_PI / 2.0, 3.0 / 2.0 * M_PI);
cairo_line_to(cr, xc + wd, yc - rad);
cairo_arc(cr, xc + wd, yc, rad, 3.0 * M_PI / 2.0, M_PI / 2.0);
cairo_line_to(cr, xc - wd, yc + rad);
if(k == 0)
{
color_found = gtk_style_context_lookup_color (context, "selected_bg_color", &color);
if(!color_found)
{
color.red = 1.0;
color.green = 0.0;
color.blue = 0.0;
color.alpha = 1.0;
}
gdk_cairo_set_source_rgba(cr, &color);
cairo_fill_preserve(cr);
}
cairo_set_source_rgba(cr, 0., 0., 0., 1.0 / (1 + k));
cairo_stroke(cr);
rad += .5f;
}
color_found = gtk_style_context_lookup_color (context, "fg_color", &color);
if(!color_found)
{
color.red = 1.0;
color.green = 0.0;
color.blue = 0.0;
color.alpha = 1.0;
}
gdk_cairo_set_source_rgba(cr, &color);
cairo_move_to(cr, xc - wd + .5f * pad, (yc + 1. / 3. * fontsize) - fontsize);
pango_cairo_show_layout(cr, layout);
pango_font_description_free(desc);
g_object_unref(layout);
}
// draw busy indicator
if(darktable.control->log_busy > 0)
{
PangoRectangle ink;
PangoLayout *layout;
PangoFontDescription *desc = pango_font_description_copy_static(darktable.bauhaus->pango_font_desc);
const float fontsize = DT_PIXEL_APPLY_DPI(14);
pango_font_description_set_absolute_size(desc, fontsize * PANGO_SCALE);
pango_font_description_set_weight(desc, PANGO_WEIGHT_BOLD);
layout = pango_cairo_create_layout(cr);
pango_layout_set_font_description(layout, desc);
pango_layout_set_text(layout, _("working.."), -1);
pango_layout_get_pixel_extents(layout, &ink, NULL);
const float xc = width / 2.0, yc = height * 0.85 - DT_PIXEL_APPLY_DPI(30), wd = ink.width * .5f;
cairo_move_to(cr, xc - wd, yc + 1. / 3. * fontsize - fontsize);
pango_cairo_layout_path(cr, layout);
cairo_set_source_rgb(cr, 0.7, 0.7, 0.7);
cairo_fill_preserve(cr);
cairo_set_line_width(cr, 0.7);
cairo_set_source_rgb(cr, 0.3, 0.3, 0.3);
cairo_stroke(cr);
pango_font_description_free(desc);
g_object_unref(layout);
}
dt_pthread_mutex_unlock(&darktable.control->log_mutex);
cairo_destroy(cr);
cairo_t *cr_pixmap = cairo_create(darktable.gui->surface);
cairo_set_source_surface(cr_pixmap, cst, 0, 0);
cairo_paint(cr_pixmap);
cairo_destroy(cr_pixmap);
cairo_surface_destroy(cst);
return NULL;
}
开发者ID:fhrtms,项目名称:darktable,代码行数:101,代码来源:control.c
示例8: main
//.........这里部分代码省略.........
},
{
"max-per-advance", '\0', 0, G_OPTION_ARG_INT, &max_per_advance,
"Maximum runtime in seconds allowed for each advance (default 10)", NULL
},
{
G_OPTION_REMAINING, '\0', 0, G_OPTION_ARG_FILENAME_ARRAY, &filenames,
NULL, "<INPUT FILE> <OUTPUT FILE>"
},
{
NULL
}
};
// catch asserts and don't spew debug output by default
g_log_set_always_fatal (G_LOG_LEVEL_ERROR | G_LOG_LEVEL_CRITICAL | G_LOG_LEVEL_WARNING);
g_setenv ("SWFDEC_DEBUG", "0", FALSE);
// init
swfdec_init ();
// read command line params
context = g_option_context_new ("Run a Flash file trying to crash Swfdec");
g_option_context_add_main_entries (context, entries, NULL);
if (g_option_context_parse (context, &argc, &argv, &err) == FALSE) {
g_printerr ("Couldn't parse command-line options: %s\n", err->message);
g_error_free (err);
return 1;
}
if (filenames == NULL || g_strv_length (filenames) < 1) {
g_printerr ("At least one input filename is required\n");
return 1;
}
// make them milliseconds
play_per_file *= 1000;
max_per_file *= 1000;
max_per_advance *= 1000;
// create surface
surface = cairo_image_surface_create (CAIRO_FORMAT_ARGB32, 1, 1);
cr = cairo_create (surface);
aborts = FALSE;
for (i = 0; i < g_strv_length (filenames); i++)
{
glong played, advance, elapsed;
g_print ("Running: %s\n", filenames[i]);
// start timer
timer = g_timer_new ();
player = swfdec_player_new (NULL);
url = swfdec_url_new_from_input (filenames[i]);
swfdec_player_set_url (player, url);
swfdec_url_free (url);
// loop until we have played what we wanted, or timelimit is hit
played = 0;
elapsed = 0;
while (played < play_per_file &&
!swfdec_as_context_is_aborted (SWFDEC_AS_CONTEXT (player)))
{
elapsed = (glong)(g_timer_elapsed (timer, NULL) * 1000);
if (elapsed >= max_per_file)
break;
swfdec_player_set_maximum_runtime (player,
MIN (max_per_advance, max_per_file - elapsed));
advance = swfdec_player_get_next_event (player);
if (advance == -1)
break;
played += swfdec_player_advance (player, advance);
swfdec_player_render (player, cr);
}
if (elapsed >= max_per_file ||
swfdec_as_context_is_aborted (SWFDEC_AS_CONTEXT (player))) {
g_print ("*** Aborted ***\n");
aborts = TRUE;
}
// clean up
g_object_unref (player);
g_timer_destroy (timer);
}
cairo_destroy (cr);
cairo_surface_destroy (surface);
if (aborts) {
return 1;
} else {
return 0;
}
}
开发者ID:fengye,项目名称:swfdec,代码行数:101,代码来源:crashfinder.c
示例9: _cairo_clip_intersect_mask
static cairo_status_t
_cairo_clip_intersect_mask (cairo_clip_t *clip,
cairo_traps_t *traps,
cairo_antialias_t antialias,
cairo_surface_t *target)
{
cairo_pattern_union_t pattern;
cairo_box_t extents;
cairo_rectangle_t surface_rect, target_rect;
cairo_surface_t *surface;
cairo_status_t status;
/* Represent the clip as a mask surface. We create a new surface
* the size of the intersection of the old mask surface and the
* extents of the new clip path. */
_cairo_traps_extents (traps, &extents);
_cairo_box_round_to_rectangle (&extents, &surface_rect);
if (clip->surface != NULL)
_cairo_rectangle_intersect (&surface_rect, &clip->surface_rect);
/* Intersect with the target surface rectangle so we don't use
* more memory and time than we need to. */
status = _cairo_surface_get_extents (target, &target_rect);
if (!status)
_cairo_rectangle_intersect (&surface_rect, &target_rect);
surface = _cairo_surface_create_similar_solid (target,
CAIRO_CONTENT_ALPHA,
surface_rect.width,
surface_rect.height,
CAIRO_COLOR_WHITE);
if (surface->status)
return CAIRO_STATUS_NO_MEMORY;
/* Render the new clipping path into the new mask surface. */
_cairo_traps_translate (traps, -surface_rect.x, -surface_rect.y);
_cairo_pattern_init_solid (&pattern.solid, CAIRO_COLOR_WHITE);
status = _cairo_surface_composite_trapezoids (CAIRO_OPERATOR_IN,
&pattern.base,
surface,
antialias,
0, 0,
0, 0,
surface_rect.width,
surface_rect.height,
traps->traps,
traps->num_traps);
_cairo_pattern_fini (&pattern.base);
if (status) {
cairo_surface_destroy (surface);
return status;
}
/* If there was a clip surface already, combine it with the new
* mask surface using the IN operator, so we get the intersection
* of the old and new clipping paths. */
if (clip->surface != NULL) {
_cairo_pattern_init_for_surface (&pattern.surface, clip->surface);
status = _cairo_surface_composite (CAIRO_OPERATOR_IN,
&pattern.base,
NULL,
surface,
surface_rect.x - clip->surface_rect.x,
surface_rect.y - clip->surface_rect.y,
0, 0,
0, 0,
surface_rect.width,
surface_rect.height);
_cairo_pattern_fini (&pattern.base);
if (status) {
cairo_surface_destroy (surface);
return status;
}
cairo_surface_destroy (clip->surface);
}
clip->surface = surface;
clip->surface_rect = surface_rect;
clip->serial = _cairo_surface_allocate_clip_serial (target);
return status;
}
开发者ID:jackiekaon,项目名称:owb-mirror,代码行数:94,代码来源:cairo-clip.c
示例10: DEBUG
NS_IMETHODIMP
compzillaRenderingContext::CopyImageDataFrom (Display *dpy,
Window drawable,
PRInt32 src_x, PRInt32 src_y,
PRUint32 w, PRUint32 h)
{
DEBUG ("CopyImageDataFrom (%d,%d)\n", w, h);
// XXX this is wrong, but it'll do for now. it needs to create a
// (possibly smaller) subimage and composite it into the larger
// mSurface.
XImage *image = XGetImage (dpy, drawable, src_x, src_y, w, h, AllPlanes, ZPixmap);
#ifdef MOZ_CAIRO_GFX
DEBUG ("thebes\n");
gfxImageSurface *imagesurf = new gfxImageSurface(gfxIntSize (w, h), gfxASurface::ImageFormatARGB32);
unsigned char *r = imagesurf->Data();
unsigned char *p = (unsigned char*)image->data;
for (int i = 0; i < w * h; i ++) {
*r++ = *p++;
*r++ = *p++;
*r++ = *p++;
*r = 255; r++; p++;
}
mThebesContext->SetSource (imagesurf, gfxPoint (src_x, src_y));
mThebesContext->Paint ();
#if 0
mThebesContext->DrawSurface (imagesurf, gfxSize (w, h));
#endif
#else
// Fix colors
unsigned char *r = (unsigned char*)image->data;
for (int i = 0; i < w * h; i ++) {
r[3] = 255; r += 4;
}
if (mImageSurfaceData) {
int stride = mWidth*4;
PRUint8 *dest = mImageSurfaceData + stride*src_y + src_x*4;
for (int32 i = 0; i < src_y; i++) {
memcpy(dest, image->data + (w*4)*i, w*4);
dest += stride;
}
}
else {
cairo_surface_t *imgsurf;
imgsurf = cairo_image_surface_create_for_data ((unsigned char*)image->data,
CAIRO_FORMAT_ARGB32,
w, h, w*4);
cairo_save (mCairo);
cairo_identity_matrix (mCairo);
cairo_translate (mCairo, src_x, src_y);
cairo_new_path (mCairo);
cairo_rectangle (mCairo, 0, 0, w, h);
cairo_set_source_surface (mCairo, imgsurf, 0, 0);
cairo_set_operator (mCairo, CAIRO_OPERATOR_SOURCE);
cairo_fill (mCairo);
cairo_restore (mCairo);
cairo_surface_destroy (imgsurf);
}
#endif
XFree (image);
// XXX this redraws the entire canvas element. we only need to
// force a redraw of the affected rectangle.
return Redraw ();
}
开发者ID:Happy-Ferret,项目名称:pyrodesktop,代码行数:75,代码来源:compzillaRenderingContext.cpp
示例11: st_drawing_area_paint
static void
st_drawing_area_paint (ClutterActor *self)
{
StDrawingArea *area = ST_DRAWING_AREA (self);
StDrawingAreaPrivate *priv = area->priv;
StThemeNode *theme_node = st_widget_get_theme_node (ST_WIDGET (self));
ClutterActorBox allocation_box;
ClutterActorBox content_box;
int width, height;
CoglColor color;
guint8 paint_opacity;
(CLUTTER_ACTOR_CLASS (st_drawing_area_parent_class))->paint (self);
clutter_actor_get_allocation_box (self, &allocation_box);
st_theme_node_get_content_box (theme_node, &allocation_box, &content_box);
width = (int)(0.5 + content_box.x2 - content_box.x1);
height = (int)(0.5 + content_box.y2 - content_box.y1);
if (priv->material == COGL_INVALID_HANDLE)
priv->material = cogl_material_new ();
if (priv->texture != COGL_INVALID_HANDLE &&
(width != cogl_texture_get_width (priv->texture) ||
height != cogl_texture_get_height (priv->texture)))
{
cogl_handle_unref (priv->texture);
priv->texture = COGL_INVALID_HANDLE;
}
if (width > 0 && height > 0)
{
if (priv->texture == COGL_INVALID_HANDLE)
{
priv->texture = st_cogl_texture_new_with_size_wrapper (width, height,
COGL_TEXTURE_NONE,
CLUTTER_CAIRO_FORMAT_ARGB32);
priv->needs_repaint = TRUE;
}
if (priv->needs_repaint)
{
cairo_surface_t *surface;
surface = cairo_image_surface_create (CAIRO_FORMAT_ARGB32, width, height);
priv->context = cairo_create (surface);
priv->in_repaint = TRUE;
priv->needs_repaint = FALSE;
g_signal_emit ((GObject*)area, st_drawing_area_signals[REPAINT], 0);
priv->in_repaint = FALSE;
cairo_destroy (priv->context);
priv->context = NULL;
cogl_texture_set_region (priv->texture, 0, 0, 0, 0, width, height, width, height,
CLUTTER_CAIRO_FORMAT_ARGB32,
cairo_image_surface_get_stride (surface),
cairo_image_surface_get_data (surface));
cairo_surface_destroy (surface);
}
}
cogl_material_set_layer (priv->material, 0, priv->texture);
if (priv->texture)
{
paint_opacity = clutter_actor_get_paint_opacity (self);
cogl_color_set_from_4ub (&color,
paint_opacity, paint_opacity, paint_opacity, paint_opacity);
cogl_material_set_color (priv->material, &color);
cogl_set_source (priv->material);
cogl_rectangle_with_texture_coords (content_box.x1, content_box.y1,
width, height,
0.0f, 0.0f, 1.0f, 1.0f);
}
}
开发者ID:2gud4u,项目名称:Cinnamon,代码行数:80,代码来源:st-drawing-area.c
示例12: XOJ_CHECK_TYPE
void RenderJob::run() {
XOJ_CHECK_TYPE(RenderJob);
if(handler == NULL) {
handler = new RepaintWidgetHandler(this->view->getXournal()->getWidget());
}
double zoom = this->view->xournal->getZoom();
g_mutex_lock(this->view->repaintRectMutex);
bool rerenderComplete = this->view->rerenderComplete;
GList * rerenderRects = this->view->rerenderRects;
this->view->rerenderRects = NULL;
this->view->rerenderComplete = false;
g_mutex_unlock(this->view->repaintRectMutex);
if (rerenderComplete) {
Document * doc = this->view->xournal->getDocument();
int dispWidth = this->view->getDisplayWidth();
int dispHeight = this->view->getDisplayHeight();
cairo_surface_t * crBuffer = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, dispWidth, dispHeight);
cairo_t * cr2 = cairo_create(crBuffer);
cairo_scale(cr2, zoom, zoom);
XojPopplerPage * popplerPage = NULL;
doc->lock();
if (this->view->page.getBackgroundType() == BACKGROUND_TYPE_PDF) {
int pgNo = this->view->page.getPdfPageNr();
popplerPage = doc->getPdfPage(pgNo);
}
DocumentView view;
int width = this->view->page.getWidth();
int height = this->view->page.getHeight();
PdfView::drawPage(this->view->xournal->getCache(), popplerPage, cr2, zoom, width, height);
view.drawPage(this->view->page, cr2, false);
cairo_destroy(cr2);
g_mutex_lock(this->view->drawingMutex);
if (this->view->crBuffer) {
cairo_surface_destroy(this->view->crBuffer);
}
this->view->crBuffer = crBuffer;
g_mutex_unlock(this->view->drawingMutex);
doc->unlock();
handler->repaintComplete();
} else {
for (GList * l = rerenderRects; l != NULL; l = l->next) {
Rectangle * rect = (Rectangle *) l->data;
rerenderRectangle(rect);
rect = this->view->rectOnWidget(rect->x, rect->y, rect->width, rect->height);
handler->repaintRects(rect);
}
}
// delete all rectangles
for (GList * l = rerenderRects; l != NULL; l = l->next) {
Rectangle * rect = (Rectangle *) l->data;
delete rect;
}
g_list_free(rerenderRects);
}
开发者ID:wbrenna,项目名称:xournalpp,代码行数:76,代码来源:RenderJob.cpp
示例13: cd_clock_clear_theme
void cd_clock_clear_theme (GldiModuleInstance *myApplet, gboolean bClearAll)
{
if (myData.pBackgroundSurface != NULL)
{
cairo_surface_destroy (myData.pBackgroundSurface);
myData.pBackgroundSurface = NULL;
}
if (myData.pForegroundSurface != NULL)
{
cairo_surface_destroy (myData.pForegroundSurface);
myData.pForegroundSurface = NULL;
}
if (myData.iBgTexture != 0)
{
_cairo_dock_delete_texture (myData.iBgTexture);
myData.iBgTexture = 0;
}
if (myData.iFgTexture != 0)
{
_cairo_dock_delete_texture (myData.iFgTexture);
myData.iFgTexture = 0;
}
if (myData.iHourNeedleTexture != 0)
{
_cairo_dock_delete_texture (myData.iHourNeedleTexture);
myData.iHourNeedleTexture = 0;
}
if (myData.iMinuteNeedleTexture != 0)
{
_cairo_dock_delete_texture (myData.iMinuteNeedleTexture);
myData.iMinuteNeedleTexture = 0;
}
if (myData.iSecondNeedleTexture != 0)
{
_cairo_dock_delete_texture (myData.iSecondNeedleTexture);
myData.iSecondNeedleTexture = 0;
}
if (myData.iDateTexture != 0)
{
_cairo_dock_delete_texture (myData.iDateTexture);
myData.iDateTexture = 0;
}
if (myData.pNumericBgSurface != NULL)
{
cairo_surface_destroy (myData.pNumericBgSurface);
myData.pNumericBgSurface = NULL;
}
if (bClearAll)
{
int i;
for (i = 0; i < CLOCK_ELEMENTS; i ++)
{
if (myData.pSvgHandles[i] != NULL)
{
g_object_unref (myData.pSvgHandles[i]);
myData.pSvgHandles[i] = NULL;
}
}
}
}
开发者ID:Cairo-Dock,项目名称:cairo-dock-plug-ins,代码行数:62,代码来源:applet-theme.c
示例14: gimp_view_renderer_set_viewable
void
gimp_view_renderer_set_viewable (GimpViewRenderer *renderer,
GimpViewable *viewable)
{
g_return_if_fail (GIMP_IS_VIEW_RENDERER (renderer));
g_return_if_fail (viewable == NULL || GIMP_IS_VIEWABLE (viewable));
if (viewable)
g_return_if_fail (g_type_is_a (G_TYPE_FROM_INSTANCE (viewable),
renderer->viewable_type));
if (viewable == renderer->viewable)
return;
if (renderer->surface)
{
cairo_surface_destroy (renderer->surface);
renderer->surface = NULL;
}
if (renderer->pixbuf)
{
g_object_unref (renderer->pixbuf);
renderer->pixbuf = NULL;
}
gimp_view_renderer_transform_free (renderer);
if (renderer->viewable)
{
g_object_weak_unref (G_OBJECT (renderer->viewable),
(GWeakNotify) gimp_view_renderer_weak_notify,
renderer);
g_signal_handlers_disconnect_by_func (renderer->viewable,
G_CALLBACK (gimp_view_renderer_invalidate),
renderer);
g_signal_handlers_disconnect_by_func (renderer->viewable,
G_CALLBACK (gimp_view_renderer_size_changed),
renderer);
if (GIMP_IS_COLOR_MANAGED (renderer->viewable))
g_signal_handlers_disconnect_by_func (renderer->viewable,
G_CALLBACK (gimp_view_renderer_profile_changed),
renderer);
}
renderer->viewable = viewable;
if (renderer->viewable)
{
g_object_weak_ref (G_OBJECT (renderer->viewable),
(GWeakNotify) gimp_view_renderer_weak_notify,
renderer);
g_signal_connect_swapped (renderer->viewable,
"invalidate-preview",
G_CALLBACK (gimp_view_renderer_invalidate),
renderer);
g_signal_connect_swapped (renderer->viewable,
"size-changed",
G_CALLBACK (gimp_view_renderer_size_changed),
renderer);
if (GIMP_IS_COLOR_MANAGED (renderer->viewable))
g_signal_connect_swapped (renderer->viewable,
"profile-changed",
G_CALLBACK (gimp_view_renderer_profile_changed),
renderer);
if (renderer->size != -1)
gimp_view_renderer_set_size (renderer, renderer->size,
renderer->border_width);
gimp_view_renderer_invalidate (renderer);
}
else
{
gimp_view_renderer_update_idle (renderer);
}
}
开发者ID:ni1son,项目名称:gimp,代码行数:83,代码来源:gimpviewrenderer.c
示例15: cairo_perf_trace
static void
cairo_perf_trace (cairo_perf_t *perf,
const cairo_boilerplate_target_t *target,
const char *trace)
{
static cairo_bool_t first_run = TRUE;
unsigned int i;
cairo_time_t *times, *paint, *mask, *fill, *stroke, *glyphs;
cairo_stats_t stats = {0.0, 0.0};
struct trace args = { target };
int low_std_dev_count;
char *trace_cpy, *name;
const cairo_script_interpreter_hooks_t hooks = {
&args,
perf->tile_size ? _tiling_surface_create : _similar_surface_create,
NULL, /* surface_destroy */
_context_create,
NULL, /* context_destroy */
NULL, /* show_page */
NULL, /* copy_page */
_source_image_create,
};
args.tile_size = perf->tile_size;
args.observe = perf->observe;
trace_cpy = xstrdup (trace);
name = basename_no_ext (trace_cpy);
if (perf->list_only) {
printf ("%s\n", name);
free (trace_cpy);
return;
}
if (first_run) {
if (perf->raw) {
printf ("[ # ] %s.%-s %s %s %s ...\n",
"backend", "content", "test-size", "ticks-per-ms", "time(ticks)");
}
if (perf->summary) {
if (perf->observe) {
fprintf (perf->summary,
"[ # ] %8s %28s %9s %9s %9s %9s %9s %9s %5s\n",
"backend", "test",
"total(s)", "paint(s)", "mask(s)", "fill(s)", "stroke(s)", "glyphs(s)",
"count");
} else {
fprintf (perf->summary,
"[ # ] %8s %28s %8s %5s %5s %s\n",
"backend", "test", "min(s)", "median(s)",
"stddev.", "count");
}
}
first_run = FALSE;
}
times = perf->times;
paint = times + perf->iterations;
mask = paint + perf->iterations;
stroke = mask + perf->iterations;
fill = stroke + perf->iterations;
glyphs = fill + perf->iterations;
low_std_dev_count = 0;
for (i = 0; i < perf->iterations && ! user_interrupt; i++) {
cairo_script_interpreter_t *csi;
cairo_status_t status;
unsigned int line_no;
args.surface = target->create_surface (NULL,
CAIRO_CONTENT_COLOR_ALPHA,
1, 1,
1, 1,
CAIRO_BOILERPLATE_MODE_PERF,
&args.closure);
fill_surface(args.surface); /* remove any clear flags */
if (perf->observe) {
cairo_surface_t *obs;
obs = cairo_surface_create_observer (args.surface,
CAIRO_SURFACE_OBSERVER_NORMAL);
cairo_surface_destroy (args.surface);
args.surface = obs;
}
if (cairo_surface_status (args.surface)) {
fprintf (stderr,
"Error: Failed to create target surface: %s\n",
target->name);
return;
}
cairo_perf_timer_set_synchronize (target->synchronize, args.closure);
if (i == 0) {
describe (perf, args.closure);
if (perf->summary) {
fprintf (perf->summary,
"[%3d] %8s %28s ",
//.........这里部分代码省略.........
开发者ID:AlexiaChen,项目名称:ImageMagick_Cmake,代码行数:101,代码来源:cairo-perf-trace.c
示例16: gimp_view_render_temp_buf_to_surface
//.........这里部分代码省略.........
if (renderer->profile_transform)
{
gimp_gegl_convert_color_transform (src_buffer,
GEGL_RECTANGLE (x - temp_buf_x,
y - temp_buf_y,
width, height),
renderer->profile_src_format,
dest_buffer,
GEGL_RECTANGLE (0, 0, 0, 0),
renderer->profile_dest_format,
renderer->profile_transform);
}
else
{
gegl_buffer_copy (src_buffer,
GEGL_RECTANGLE (x - temp_buf_x,
y - temp_buf_y,
width, height),
GEGL_ABYSS_NONE,
dest_buffer,
GEGL_RECTANGLE (0, 0, 0, 0));
}
g_object_unref (src_buffer);
g_object_unref (dest_buffer);
cairo_surface_mark_dirty (alpha_surface);
cairo_translate (cr, x, y);
cairo_rectangle (cr, 0, 0, width, height);
cairo_set_source_surface (cr, alpha_surface, 0, 0);
cairo_fill (cr);
cairo_surface_destroy (alpha_surface);
}
else if (channel == -1)
{
GeglBuffer *src_buffer;
GeglBuffer *dest_buffer;
cairo_surface_flush (surface);
src_buffer = gimp_temp_buf_create_buffer (temp_buf);
dest_buffer = gimp_cairo_surface_create_buffer (surface);
if (! renderer->profile_transform)
gimp_view_renderer_transform_create (renderer, widget,
src_buffer, dest_buffer);
if (renderer->profile_transform)
{
gimp_gegl_convert_color_transform (src_buffer,
GEGL_RECTANGLE (x - temp_buf_x,
y - temp_buf_y,
width, height),
renderer->profile_src_format,
dest_buffer,
GEGL_RECTANGLE (x, y, 0, 0),
renderer->profile_dest_format,
renderer->profile_transform);
}
else
{
gegl_buffer_copy (src_buffer,
GEGL_RECTANGLE (x - temp_buf_x,
y - temp_buf_y,
开发者ID:ni1son,项目名称:gimp,代码行数:67,代码来源:gimpviewrenderer.c
示例17: main
//.........这里部分代码省略.........
} else if (strcmp(scaling_mode_str, "fill") == 0) {
scaling_mode = SCALING_MODE_FILL;
|
请发表评论