本文整理汇总了C++中cairo_surface_set_device_offset函数的典型用法代码示例。如果您正苦于以下问题:C++ cairo_surface_set_device_offset函数的具体用法?C++ cairo_surface_set_device_offset怎么用?C++ cairo_surface_set_device_offset使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了cairo_surface_set_device_offset函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: byzanz_recorder_create_snapshot
static cairo_surface_t *
byzanz_recorder_create_snapshot (ByzanzRecorder *recorder, const cairo_region_t *invalid)
{
cairo_rectangle_int_t extents;
cairo_surface_t *surface;
cairo_t *cr;
GSequenceIter *iter;
int i, num_rects;
cairo_region_get_extents (invalid, &extents);
cr = gdk_cairo_create (recorder->window);
surface = cairo_surface_create_similar (cairo_get_target (cr), CAIRO_CONTENT_COLOR,
extents.width, extents.height);
cairo_destroy (cr);
cairo_surface_set_device_offset (surface, -extents.x, -extents.y);
cr = cairo_create (surface);
num_rects = cairo_region_num_rectangles (invalid);
for (i = 0; i < num_rects; i++) {
cairo_rectangle_int_t rect;
cairo_region_get_rectangle (invalid, i, &rect);
cairo_rectangle (cr, rect.x, rect.y,
rect.width, rect.height);
}
cairo_clip (cr);
for (iter = g_sequence_get_begin_iter (recorder->layers);
!g_sequence_iter_is_end (iter);
iter = g_sequence_iter_next (iter)) {
ByzanzLayer *layer = g_sequence_get (iter);
ByzanzLayerClass *klass = BYZANZ_LAYER_GET_CLASS (layer);
cairo_save (cr);
klass->render (layer, cr);
if (cairo_status (cr))
g_critical ("error capturing image: %s", cairo_status_to_string (cairo_status (cr)));
cairo_restore (cr);
}
cairo_destroy (cr);
surface = ensure_image_surface (surface, invalid);
/* adjust device offset here - the layers work in GdkScreen coordinates, the rest
* of the code works in coordinates realtive to the passed in area. */
cairo_surface_set_device_offset (surface,
recorder->area.x - extents.x, recorder->area.y - extents.y);
return surface;
}
示例2: draw
static cairo_test_status_t
draw (cairo_t *cr, int width, int height)
{
cairo_surface_t *surface, *target;
cairo_t *cr2;
/* First draw a shape in blue on the original destination. */
cairo_set_source_rgb (cr, 0, 0, 1); /* blue */
draw_square (cr);
/* Then, create an offset surface and repeat the drawing in red. */
target = cairo_get_group_target (cr);
surface = cairo_surface_create_similar (target,
cairo_surface_get_content (target),
SIZE / 2, SIZE / 2);
cr2 = cairo_create (surface);
cairo_set_source_rgb (cr2, 1, 0, 0); /* red */
draw_square (cr2);
cairo_destroy (cr2);
cairo_surface_set_device_offset (surface, + SIZE / 2, + SIZE / 2);
/* Finally, copy the offset surface to the original destination.
* The final result should be a blue square with the upper-left
* quarter red. */
cairo_set_source_surface (cr, surface, SIZE / 2, SIZE / 2);
cairo_paint (cr);
cairo_surface_destroy (surface);
return CAIRO_TEST_SUCCESS;
}
示例3: surface_set_device_offset
static int
surface_set_device_offset (lua_State *L) {
cairo_surface_t **obj = luaL_checkudata(L, 1, OOCAIRO_MT_NAME_SURFACE);
cairo_surface_set_device_offset(*obj, luaL_checknumber(L, 2),
luaL_checknumber(L, 3));
return 0;
}
示例4: _cairo_xcb_surface_map_to_image
static cairo_surface_t *
_cairo_xcb_surface_map_to_image (void *abstract_surface,
const cairo_rectangle_int_t *extents)
{
cairo_xcb_surface_t *surface = abstract_surface;
cairo_surface_t *image;
if (surface->fallback)
return surface->fallback->base.backend->map_to_image (&surface->fallback->base, extents);
image = _get_image (surface, TRUE,
extents->x, extents->y,
extents->width, extents->height);
if (unlikely (image->status))
return image;
/* Do we have a deferred clear and this image surface does NOT cover the
* whole xcb surface? Have to apply the clear in that case, else
* uploading the image will handle the problem for us.
*/
if (surface->deferred_clear &&
! (extents->width == surface->width &&
extents->height == surface->height)) {
cairo_status_t status = _cairo_xcb_surface_clear (surface);
if (unlikely (status)) {
cairo_surface_destroy(image);
return _cairo_surface_create_in_error (status);
}
}
surface->deferred_clear = FALSE;
cairo_surface_set_device_offset (image, -extents->x, -extents->y);
return image;
}
示例5: _cairo_image_surface_clone
/* A convenience function for when one needs to coerce an image
* surface to an alternate format. */
cairo_image_surface_t *
_cairo_image_surface_clone (cairo_image_surface_t *surface,
cairo_format_t format)
{
cairo_image_surface_t *clone;
cairo_status_t status;
cairo_t *cr;
double x, y;
clone = (cairo_image_surface_t *)
cairo_image_surface_create (format,
surface->width, surface->height);
cairo_surface_get_device_offset (&surface->base, &x, &y);
cairo_surface_set_device_offset (&clone->base, x, y);
clone->transparency = CAIRO_IMAGE_UNKNOWN;
/* XXX Use _cairo_surface_composite directly */
cr = cairo_create (&clone->base);
cairo_set_source_surface (cr, &surface->base, 0, 0);
cairo_set_operator (cr, CAIRO_OPERATOR_SOURCE);
cairo_paint (cr);
status = cairo_status (cr);
cairo_destroy (cr);
if (status) {
cairo_surface_destroy (&clone->base);
return (cairo_image_surface_t *) _cairo_surface_create_in_error (status);
}
return clone;
}
示例6: seed_cairo_surface_set_device_offset
static gboolean
seed_cairo_surface_set_device_offset(SeedContext ctx,
SeedObject this_object,
SeedString property_name,
SeedValue value,
SeedException *exception)
{
cairo_surface_t *surf;
gdouble x, y;
SeedValue jsx, jsy;
CHECK_THIS_BOOL();
if (!seed_value_is_object (ctx, value))
{
seed_make_exception(ctx, exception, "ArgumentError", "Cairo.Surface.device_offset must be an array [x,y]");
return FALSE;
}
jsx = seed_object_get_property_at_index (ctx, (SeedObject) value, 0, exception);
jsy = seed_object_get_property_at_index (ctx, (SeedObject) value, 1, exception);
surf = seed_object_to_cairo_surface (ctx, this_object, exception);
x = seed_value_to_double (ctx, jsx, exception);
y = seed_value_to_double (ctx, jsy, exception);
cairo_surface_set_device_offset (surf, x, y);
return TRUE;
}
示例7: ensure_image_surface
static cairo_surface_t *
ensure_image_surface (cairo_surface_t *surface, const cairo_region_t *region)
{
cairo_rectangle_int_t extents;
cairo_surface_t *image;
cairo_t *cr;
int i, num_rects;
if (cairo_surface_get_type (surface) == CAIRO_SURFACE_TYPE_IMAGE)
return surface;
cairo_region_get_extents (region, &extents);
image = cairo_image_surface_create (CAIRO_FORMAT_RGB24, extents.width, extents.height);
cairo_surface_set_device_offset (image, -extents.x, -extents.y);
cr = cairo_create (image);
cairo_set_source_surface (cr, surface, 0, 0);
cairo_set_operator (cr, CAIRO_OPERATOR_SOURCE);
num_rects = cairo_region_num_rectangles (region);
for (i = 0; i < num_rects; i++) {
cairo_rectangle_int_t rect;
cairo_region_get_rectangle (region, i, &rect);
cairo_rectangle (cr, rect.x, rect.y,
rect.width, rect.height);
}
cairo_fill (cr);
cairo_destroy (cr);
cairo_surface_destroy (surface);
return image;
}
示例8: draw_tile
void draw_tile(cairo_t *cr, cairo_matrix_t m, cairo_rectangle_t r, int tx, int ty)
{
if (cr !=NULL)
{
cairo_save(cr);
/* Use the rect and pattern */
c_rect(cr, r);
cairo_set_source (cr, tile_pattern);
/* Pull the tile we need */
cairo_surface_set_device_offset(graphical_tiles, tx - r.x, ty - r.y);
/* Use transparency */
cairo_set_operator(cr, CAIRO_OPERATOR_ADD);
/* Use the matrix with our pattern */
cairo_pattern_set_matrix(tile_pattern, &m);
/* Draw it */
cairo_fill(cr);
cairo_restore(cr);
}
}
示例9: drag_begin_callback
static void
drag_begin_callback (GtkWidget *widget,
GdkDragContext *context,
gpointer data)
{
NemoIconContainer *container;
cairo_surface_t *surface;
double x1, y1, x2, y2, winx, winy;
int x_offset, y_offset;
int start_x, start_y;
container = NEMO_ICON_CONTAINER (widget);
start_x = container->details->dnd_info->drag_info.start_x +
gtk_adjustment_get_value (gtk_scrollable_get_hadjustment (GTK_SCROLLABLE (container)));
start_y = container->details->dnd_info->drag_info.start_y +
gtk_adjustment_get_value (gtk_scrollable_get_vadjustment (GTK_SCROLLABLE (container)));
/* create a pixmap and mask to drag with */
surface = nemo_icon_canvas_item_get_drag_surface (container->details->drag_icon->item);
/* compute the image's offset */
eel_canvas_item_get_bounds (EEL_CANVAS_ITEM (container->details->drag_icon->item),
&x1, &y1, &x2, &y2);
eel_canvas_world_to_window (EEL_CANVAS (container),
x1, y1, &winx, &winy);
x_offset = start_x - winx;
y_offset = start_y - winy;
cairo_surface_set_device_offset (surface, -x_offset, -y_offset);
gtk_drag_set_icon_surface (context, surface);
cairo_surface_destroy (surface);
}
示例10: GTK_CHECK_VERSION
void DragAndDropHandler::startDrag(Ref<SelectionData>&& selection, DragOperation dragOperation, RefPtr<ShareableBitmap>&& dragImage)
{
#if GTK_CHECK_VERSION(3, 16, 0)
m_draggingSelectionData = WTFMove(selection);
GRefPtr<GtkTargetList> targetList = PasteboardHelper::singleton().targetListForSelectionData(*m_draggingSelectionData);
#else
RefPtr<SelectionData> selectionData = WTFMove(selection);
GRefPtr<GtkTargetList> targetList = PasteboardHelper::singleton().targetListForSelectionData(*selectionData);
#endif
GUniquePtr<GdkEvent> currentEvent(gtk_get_current_event());
GdkDragContext* context = gtk_drag_begin(m_page.viewWidget(), targetList.get(), dragOperationToGdkDragActions(dragOperation),
GDK_BUTTON_PRIMARY, currentEvent.get());
#if GTK_CHECK_VERSION(3, 16, 0)
// WebCore::EventHandler does not support more than one DnD operation at the same time for
// a given page, so we should cancel any previous operation whose context we might have
// stored, should we receive a new startDrag event before finishing a previous DnD operation.
if (m_dragContext)
gtk_drag_cancel(m_dragContext.get());
m_dragContext = context;
#else
// We don't have gtk_drag_cancel() in GTK+ < 3.16, so we use the old code.
// See https://bugs.webkit.org/show_bug.cgi?id=138468
m_draggingSelectionDataMap.set(context, WTFMove(selectionData));
#endif
if (dragImage) {
RefPtr<cairo_surface_t> image(dragImage->createCairoSurface());
// Use the center of the drag image as hotspot.
cairo_surface_set_device_offset(image.get(), -cairo_image_surface_get_width(image.get()) / 2, -cairo_image_surface_get_height(image.get()) / 2);
gtk_drag_set_icon_surface(context, image.get());
} else
gtk_drag_set_icon_default(context);
}
示例11: cr_surface_set_device_offset
static VALUE
cr_surface_set_device_offset (VALUE self, VALUE x_offset, VALUE y_offset)
{
cairo_surface_set_device_offset (_SELF,
NUM2DBL (x_offset),
NUM2DBL (y_offset));
cr_surface_check_status (_SELF);
return self;
}
示例12: IoMessage_locals_doubleArgAt_
IoObject *IoCairoSurface_setDeviceOffset(IoCairoSurface *self, IoObject *locals, IoMessage *m)
{
double x = IoMessage_locals_doubleArgAt_(m, locals, 0);
double y = IoMessage_locals_doubleArgAt_(m, locals, 1);
cairo_surface_set_device_offset(SURFACE(self), x, y);
CHECK_STATUS(self);
return self;
}
示例13: gsk_cairo_blur_start_drawing
cairo_t *
gsk_cairo_blur_start_drawing (cairo_t *cr,
float radius,
GskBlurFlags blur_flags)
{
cairo_rectangle_int_t clip_rect;
cairo_surface_t *surface;
cairo_t *blur_cr;
gdouble clip_radius;
gdouble x_scale, y_scale;
gboolean blur_x = (blur_flags & GSK_BLUR_X) != 0;
gboolean blur_y = (blur_flags & GSK_BLUR_Y) != 0;
if (!needs_blur (radius))
return cr;
gdk_cairo_get_clip_rectangle (cr, &clip_rect);
clip_radius = gsk_cairo_blur_compute_pixels (radius);
x_scale = y_scale = 1;
cairo_surface_get_device_scale (cairo_get_target (cr), &x_scale, &y_scale);
if (blur_flags & GSK_BLUR_REPEAT)
{
if (!blur_x)
clip_rect.width = 1;
if (!blur_y)
clip_rect.height = 1;
}
/* Create a larger surface to center the blur. */
surface = cairo_surface_create_similar_image (cairo_get_target (cr),
CAIRO_FORMAT_A8,
x_scale * (clip_rect.width + (blur_x ? 2 * clip_radius : 0)),
y_scale * (clip_rect.height + (blur_y ? 2 * clip_radius : 0)));
cairo_surface_set_device_scale (surface, x_scale, y_scale);
cairo_surface_set_device_offset (surface,
x_scale * ((blur_x ? clip_radius : 0) - clip_rect.x),
y_scale * ((blur_y ? clip_radius : 0) - clip_rect.y));
blur_cr = cairo_create (surface);
cairo_set_user_data (blur_cr, &original_cr_key, cairo_reference (cr), (cairo_destroy_func_t) cairo_destroy);
if (cairo_has_current_point (cr))
{
double x, y;
cairo_get_current_point (cr, &x, &y);
cairo_move_to (blur_cr, x, y);
}
return blur_cr;
}
示例14: _cairo_boilerplate_xcb_finish_surface
static cairo_status_t
_cairo_boilerplate_xcb_finish_surface (cairo_surface_t *surface)
{
xcb_target_closure_t *xtc = cairo_surface_get_user_data (surface,
&xcb_closure_key);
xcb_generic_event_t *ev;
if (xtc->surface != NULL) {
cairo_t *cr;
cr = cairo_create (xtc->surface);
cairo_surface_set_device_offset (surface, 0, 0);
cairo_set_source_surface (cr, surface, 0, 0);
cairo_set_operator (cr, CAIRO_OPERATOR_SOURCE);
cairo_paint (cr);
cairo_destroy (cr);
surface = xtc->surface;
}
cairo_surface_flush (surface);
if (cairo_surface_status (surface))
return cairo_surface_status (surface);
while ((ev = xcb_poll_for_event (xtc->c)) != NULL) {
cairo_status_t status = CAIRO_STATUS_SUCCESS;
if (ev->response_type == 0 /* trust me! */) {
xcb_generic_error_t *error = (xcb_generic_error_t *) ev;
#if XCB_GENERIC_ERROR_HAS_MAJOR_MINOR_CODES
fprintf (stderr,
"Detected error during xcb run: %d major=%d, minor=%d\n",
error->error_code, error->major_code, error->minor_code);
#else
fprintf (stderr,
"Detected error during xcb run: %d\n",
error->error_code);
#endif
free (error);
status = CAIRO_STATUS_WRITE_ERROR;
}
if (status)
return status;
}
if (xcb_connection_has_error (xtc->c))
return CAIRO_STATUS_WRITE_ERROR;
return CAIRO_STATUS_SUCCESS;
}
示例15: surface_set_device_offset
static PyObject *
surface_set_device_offset (PycairoSurface *o, PyObject *args)
{
double x_offset, y_offset;
if (!PyArg_ParseTuple (args, "dd:Surface.set_device_offset",
&x_offset, &y_offset))
return NULL;
cairo_surface_set_device_offset (o->surface, x_offset, y_offset);
Py_RETURN_NONE;
}