void render() { draw_fill(ctx, rgba(0,0,0,127)); int stride = cairo_format_stride_for_width(CAIRO_FORMAT_ARGB32, window->width); cairo_surface_t * surface = cairo_image_surface_create_for_data(ctx->buffer, CAIRO_FORMAT_ARGB32, window->width, window->height, stride); cairo_t * cr = cairo_create(surface); cairo_set_line_width (cr, 6); cairo_rectangle (cr, 12, 12, 232, 70); cairo_new_sub_path (cr); cairo_arc (cr, 64, 64, 40, 0, 2*M_PI); cairo_new_sub_path (cr); cairo_arc_negative (cr, 192, 64, 40, 0, -2*M_PI); cairo_set_fill_rule (cr, CAIRO_FILL_RULE_EVEN_ODD); cairo_set_source_rgb (cr, 0, 0.7, 0); cairo_fill_preserve (cr); cairo_set_source_rgb (cr, 0, 0, 0); cairo_stroke (cr); cairo_translate (cr, 0, 128); cairo_rectangle (cr, 12, 12, 232, 70); cairo_new_sub_path (cr); cairo_arc (cr, 64, 64, 40, 0, 2*M_PI); cairo_new_sub_path (cr); cairo_arc_negative (cr, 192, 64, 40, 0, -2*M_PI); cairo_set_fill_rule (cr, CAIRO_FILL_RULE_WINDING); cairo_set_source_rgb (cr, 0, 0, 0.9); cairo_fill_preserve (cr); cairo_set_source_rgb (cr, 0, 0, 0); cairo_stroke (cr); cairo_surface_flush(surface); cairo_destroy(cr); cairo_surface_flush(surface); cairo_surface_destroy(surface); }
/* Fill the same path twice, once with each fill rule */ static cairo_test_status_t draw (cairo_t *cr, int width, int height) { cairo_set_source_rgb (cr, 1, 0, 0); cairo_translate (cr, 1, 1); little_star_path (cr); cairo_set_fill_rule (cr, CAIRO_FILL_RULE_WINDING); cairo_fill (cr); cairo_translate (cr, LITTLE_STAR_SIZE + 1, 0); little_star_path (cr); cairo_set_fill_rule (cr, CAIRO_FILL_RULE_EVEN_ODD); cairo_fill (cr); cairo_translate (cr, -(LITTLE_STAR_SIZE + 1), LITTLE_STAR_SIZE + 1); big_star_path (cr); cairo_set_fill_rule (cr, CAIRO_FILL_RULE_WINDING); cairo_fill (cr); cairo_translate (cr, BIG_STAR_SIZE + 1, 0); big_star_path (cr); cairo_set_fill_rule (cr, CAIRO_FILL_RULE_EVEN_ODD); cairo_fill (cr); return CAIRO_TEST_SUCCESS; }
static void clip_2 (cairo_t *cr) { cairo_set_fill_rule (cr, CAIRO_FILL_RULE_EVEN_ODD); rounded_rectangle (cr, 50, 50, 100, 100, 15); rounded_rectangle (cr, 60, 60, 80, 80, 5); cairo_clip (cr); cairo_set_fill_rule (cr, CAIRO_FILL_RULE_WINDING); }
bool Path::contains(const FloatPoint& point, WindRule rule) const { if (!isfinite(point.x()) || !isfinite(point.y())) return false; cairo_t* cr = platformPath()->context(); cairo_fill_rule_t cur = cairo_get_fill_rule(cr); cairo_set_fill_rule(cr, rule == RULE_EVENODD ? CAIRO_FILL_RULE_EVEN_ODD : CAIRO_FILL_RULE_WINDING); bool contains = cairo_in_fill(cr, point.x(), point.y()); cairo_set_fill_rule(cr, cur); return contains; }
void QCairoPaintEngine::drawPolygon(const QPointF *points, int pointCount, QPaintEngine::PolygonDrawMode mode) { if (!cr || !surface) { qDebug()<<"Cairo Error [QCairoPaintEngine::drawPolygon]: no cairo or no surface!"; return; } /*if (cpen.style()==Qt::NoPen) { qDebug()<<"Cairo Error [QCairoPaintEngine::drawPolygon]: no pen set!"; return; }*/ if (mode!=QPaintEngine::PolylineMode && cbrush.style()==Qt::NoBrush && cpen.style()==Qt::NoPen) { qDebug()<<"Cairo Error [QCairoPaintEngine::drawPolygon]: no pen and no brush set!"; return; } //updatePen(); //qDebug()<<"drawPolygon n="<<pointCount; if (pointCount>1) { cairo_new_path(cr); cairo_move_to(cr, points[0].x(), points[0].y()); for (int i=1; i<pointCount; i++) { cairo_line_to(cr, points[i].x(), points[i].y()); } if (points[0].x()==points[pointCount-1].x() && points[0].y()==points[pointCount-1].y()){ cairo_close_path(cr); } else if (mode!=QPaintEngine::PolylineMode) { cairo_close_path(cr); } if (mode==QPaintEngine::PolylineMode) { updatePen(); cairo_stroke(cr); } else { switch (mode) { case QPaintEngine::WindingMode: cairo_set_fill_rule(cr, CAIRO_FILL_RULE_WINDING); break; default: case QPaintEngine::OddEvenMode: cairo_set_fill_rule(cr, CAIRO_FILL_RULE_EVEN_ODD); break; } updateBrush(); if (cpen.style()!=Qt::NoPen) { cairo_fill_preserve(cr); updatePen(); cairo_stroke(cr); } else cairo_fill(cr); } } }
void uiDrawClip(uiDrawContext *c, uiDrawPath *path) { runPath(path, c->cr); switch (pathFillMode(path)) { case uiDrawFillModeWinding: cairo_set_fill_rule(c->cr, CAIRO_FILL_RULE_WINDING); break; case uiDrawFillModeAlternate: cairo_set_fill_rule(c->cr, CAIRO_FILL_RULE_EVEN_ODD); break; } cairo_clip(c->cr); }
void GraphicsContext::clip(const FloatRect& rect) { if (paintingDisabled()) return; cairo_t* cr = platformContext()->cr(); cairo_rectangle(cr, rect.x(), rect.y(), rect.width(), rect.height()); cairo_fill_rule_t savedFillRule = cairo_get_fill_rule(cr); cairo_set_fill_rule(cr, CAIRO_FILL_RULE_WINDING); cairo_clip(cr); cairo_set_fill_rule(cr, savedFillRule); m_data->clip(rect); }
void GraphicsContext::clip(const Path& path) { if (paintingDisabled()) return; cairo_t* cr = platformContext()->cr(); OwnPtr<cairo_path_t> pathCopy = adoptPtr(cairo_copy_path(path.platformPath()->context())); cairo_append_path(cr, pathCopy.get()); cairo_fill_rule_t savedFillRule = cairo_get_fill_rule(cr); cairo_set_fill_rule(cr, CAIRO_FILL_RULE_WINDING); cairo_clip(cr); cairo_set_fill_rule(cr, savedFillRule); m_data->clip(path); }
void GraphicsContext::clip(const Path& path) { if (paintingDisabled()) return; cairo_t* cr = m_data->cr; cairo_path_t* p = cairo_copy_path(path.platformPath()->m_cr); cairo_append_path(cr, p); cairo_path_destroy(p); cairo_fill_rule_t savedFillRule = cairo_get_fill_rule(cr); cairo_set_fill_rule(cr, CAIRO_FILL_RULE_WINDING); cairo_clip(cr); cairo_set_fill_rule(cr, savedFillRule); m_data->clip(path); }
void GraphicsContext::clipOut(const IntRect& r) { if (paintingDisabled()) return; cairo_t* cr = platformContext()->cr(); double x1, y1, x2, y2; cairo_clip_extents(cr, &x1, &y1, &x2, &y2); cairo_rectangle(cr, x1, y1, x2 - x1, y2 - y1); cairo_rectangle(cr, r.x(), r.y(), r.width(), r.height()); cairo_fill_rule_t savedFillRule = cairo_get_fill_rule(cr); cairo_set_fill_rule(cr, CAIRO_FILL_RULE_EVEN_ODD); cairo_clip(cr); cairo_set_fill_rule(cr, savedFillRule); }
static cairo_time_t box_outline_aa_fill (cairo_t *cr, int width, int height, int loops) { cairo_set_source_rgb (cr, 0, 0, 1); /* blue */ cairo_paint (cr); cairo_translate (cr, .5, .5); cairo_rectangle (cr, 1.0, 1.0, width - 2, height - 2); cairo_rectangle (cr, 2.0, 2.0, width - 4, height - 4); cairo_set_fill_rule (cr, CAIRO_FILL_RULE_EVEN_ODD); cairo_set_source_rgb (cr, 0, 1, 0); /* green */ cairo_perf_timer_start (); cairo_perf_set_thread_aware (cr, FALSE); while (loops--) { if (loops == 0) cairo_perf_set_thread_aware (cr, TRUE); cairo_fill_preserve (cr); } cairo_perf_timer_stop (); cairo_new_path (cr); return cairo_perf_timer_elapsed (); }
void GraphicsContext::drawConvexPolygon(size_t npoints, const FloatPoint* points, bool shouldAntialias) { if (paintingDisabled()) return; if (npoints <= 1) return; cairo_t* cr = m_data->cr; cairo_save(cr); cairo_set_antialias(cr, shouldAntialias ? CAIRO_ANTIALIAS_DEFAULT : CAIRO_ANTIALIAS_NONE); cairo_move_to(cr, points[0].x(), points[0].y()); for (size_t i = 1; i < npoints; i++) cairo_line_to(cr, points[i].x(), points[i].y()); cairo_close_path(cr); if (fillColor().alpha()) { setColor(cr, fillColor()); cairo_set_fill_rule(cr, CAIRO_FILL_RULE_EVEN_ODD); cairo_fill_preserve(cr); } if (strokeStyle() != NoStroke) { setColor(cr, strokeColor()); cairo_set_line_width(cr, strokeThickness()); cairo_stroke(cr); } cairo_new_path(cr); cairo_restore(cr); }
void GraphicsContext::fillPath() { if (paintingDisabled()) return; cairo_t* cr = m_data->cr; cairo_save(cr); cairo_set_fill_rule(cr, fillRule() == RULE_EVENODD ? CAIRO_FILL_RULE_EVEN_ODD : CAIRO_FILL_RULE_WINDING); switch (m_common->state.fillColorSpace) { case SolidColorSpace: setColor(cr, fillColor()); cairo_clip(cr); cairo_paint_with_alpha(cr, m_common->state.globalAlpha); break; case PatternColorSpace: { TransformationMatrix affine; cairo_set_source(cr, m_common->state.fillPattern->createPlatformPattern(affine)); cairo_clip(cr); cairo_paint_with_alpha(cr, m_common->state.globalAlpha); break; } case GradientColorSpace: cairo_pattern_t* pattern = m_common->state.fillGradient->platformGradient(); pattern = applySpreadMethod(pattern, spreadMethod()); cairo_set_source(cr, pattern); cairo_clip(cr); cairo_paint_with_alpha(cr, m_common->state.globalAlpha); break; } cairo_restore(cr); }
void GraphicsContext::clipOut(const Path& path) { if (paintingDisabled()) return; cairo_t* cr = m_data->cr; double x1, y1, x2, y2; cairo_clip_extents(cr, &x1, &y1, &x2, &y2); cairo_rectangle(cr, x1, y1, x2 - x1, y2 - y1); addPath(path); cairo_fill_rule_t savedFillRule = cairo_get_fill_rule(cr); cairo_set_fill_rule(cr, CAIRO_FILL_RULE_EVEN_ODD); cairo_clip(cr); cairo_set_fill_rule(cr, savedFillRule); }
static gboolean process (GeglOperation *operation, GeglBuffer *input, GeglBuffer *output, const GeglRectangle *result, gint level) { GeglChantO *o = GEGL_CHANT_PROPERTIES (operation); gboolean need_fill = FALSE; gdouble r,g,b,a; if (input) { gegl_buffer_copy (input, result, output, result); } else { gegl_buffer_clear (output, result); } if (o->opacity > 0.0001 && o->color) { gegl_color_get_rgba (o->color, &r,&g,&b,&a); a *= o->opacity; if (a>0.001) need_fill=TRUE; } if (need_fill) { GStaticMutex mutex = G_STATIC_MUTEX_INIT; cairo_t *cr; cairo_surface_t *surface; guchar *data; g_static_mutex_lock (&mutex); data = (void*)gegl_buffer_linear_open (output, result, NULL, babl_format ("B'aG'aR'aA u8")); surface = cairo_image_surface_create_for_data (data, CAIRO_FORMAT_ARGB32, result->width, result->height, result->width * 4); cr = cairo_create (surface); cairo_translate (cr, -result->x, -result->y); if (g_str_equal (o->fill_rule, "evenodd")) cairo_set_fill_rule (cr, CAIRO_FILL_RULE_EVEN_ODD); gegl_path_cairo_play (o->d, cr); cairo_set_source_rgba (cr, r,g,b,a); cairo_fill (cr); cairo_destroy (cr); gegl_buffer_linear_close (output, data); g_static_mutex_unlock (&mutex); } return TRUE; }
void GraphicsContext::clipOut(const Path& path) { if (paintingDisabled()) return; cairo_t* cr = platformContext()->cr(); double x1, y1, x2, y2; cairo_clip_extents(cr, &x1, &y1, &x2, &y2); cairo_rectangle(cr, x1, y1, x2 - x1, y2 - y1); appendWebCorePathToCairoContext(cr, path); cairo_fill_rule_t savedFillRule = cairo_get_fill_rule(cr); cairo_set_fill_rule(cr, CAIRO_FILL_RULE_EVEN_ODD); cairo_clip(cr); cairo_set_fill_rule(cr, savedFillRule); }
static void begin_render(DiaRenderer *self) { DiaCairoInteractiveRenderer *renderer = DIA_CAIRO_INTERACTIVE_RENDERER (self); DiaCairoRenderer *base_renderer = DIA_CAIRO_RENDERER (self); g_return_if_fail (base_renderer->cr == NULL); #if GTK_CHECK_VERSION(2,8,0) base_renderer->cr = gdk_cairo_create(renderer->pixmap); #else base_renderer->surface = cairo_image_surface_create ( CAIRO_FORMAT_ARGB32, get_width_pixels (self), get_height_pixels (self)); base_renderer->cr = cairo_create (base_renderer->surface); #endif cairo_scale (base_renderer->cr, *renderer->zoom_factor, *renderer->zoom_factor); cairo_translate (base_renderer->cr, -renderer->visible->left, -renderer->visible->top); #ifdef HAVE_PANGOCAIRO_H base_renderer->layout = pango_cairo_create_layout (base_renderer->cr); #endif cairo_set_fill_rule (base_renderer->cr, CAIRO_FILL_RULE_EVEN_ODD); #if 0 /* should we set the background color? Or do nothing at all? */ /* if this is drawn you can see 'clipping in action', outside of the clip it gets yellow ;) */ cairo_set_source_rgba (base_renderer->cr, 1.0, 1.0, .8, 1.0); cairo_set_operator (base_renderer->cr, CAIRO_OPERATOR_OVER); cairo_rectangle (base_renderer->cr, 0, 0, renderer->width, renderer->height); cairo_fill (base_renderer->cr); #endif }
void GraphicsContext::drawConvexPolygon(size_t npoints, const FloatPoint* points, bool shouldAntialias) { if (paintingDisabled()) return; if (npoints <= 1) return; cairo_t* cr = platformContext()->cr(); cairo_save(cr); cairo_set_antialias(cr, shouldAntialias ? CAIRO_ANTIALIAS_DEFAULT : CAIRO_ANTIALIAS_NONE); addConvexPolygonToContext(cr, npoints, points); if (fillColor().alpha()) { setSourceRGBAFromColor(cr, fillColor()); cairo_set_fill_rule(cr, CAIRO_FILL_RULE_EVEN_ODD); cairo_fill_preserve(cr); } if (strokeStyle() != NoStroke) { setSourceRGBAFromColor(cr, strokeColor()); cairo_set_line_width(cr, strokeThickness()); cairo_stroke(cr); } else cairo_new_path(cr); cairo_restore(cr); }
static cairo_perf_ticks_t box_outline_fill (cairo_t *cr, int width, int height, int loops) { cairo_set_source_rgb (cr, 0, 0, 1); /* blue */ cairo_paint (cr); cairo_rectangle (cr, 1.0, 1.0, width - 2, height - 2); cairo_rectangle (cr, 2.0, 2.0, width - 4, height - 4); cairo_set_fill_rule (cr, CAIRO_FILL_RULE_EVEN_ODD); cairo_set_source_rgb (cr, 0, 1, 0); /* green */ cairo_perf_timer_start (); while (loops--) cairo_fill_preserve (cr); cairo_perf_timer_stop (); cairo_new_path (cr); return cairo_perf_timer_elapsed (); }
void GeometryGroup::Draw (cairo_t *cr) { Transform *transform = GetTransform (); cairo_matrix_t saved; cairo_get_matrix (cr, &saved); if (transform) { cairo_matrix_t matrix; transform->GetTransform (&matrix); cairo_transform (cr, &matrix); } GeometryCollection *children = GetChildren (); Geometry *geometry; // GeometryGroup is used for Clip (as a Geometry) so Fill (normally setting the fill rule) is never called cairo_set_fill_rule (cr, convert_fill_rule (GetFillRule ())); int children_count = children->GetCount (); for (int i = 0; i < children_count; i++) { geometry = children->GetValueAt (i)->AsGeometry (); geometry->Draw (cr); } cairo_set_matrix (cr, &saved); }
void SVGResourceClipper::applyClip(GraphicsContext* context, const FloatRect& boundingBox) const { cairo_t* cr = context->platformContext(); if (m_clipData.clipData().size() < 1) return; cairo_reset_clip(cr); context->beginPath(); for (unsigned int x = 0; x < m_clipData.clipData().size(); x++) { ClipData data = m_clipData.clipData()[x]; Path path = data.path; if (path.isEmpty()) continue; path.closeSubpath(); if (data.bboxUnits) { // Make use of the clipping units AffineTransform transform; transform.translate(boundingBox.x(), boundingBox.y()); transform.scale(boundingBox.width(), boundingBox.height()); path.transform(transform); } cairo_path_t* clipPath = cairo_copy_path(path.platformPath()->m_cr); cairo_append_path(cr, clipPath); cairo_set_fill_rule(cr, data.windRule == RULE_EVENODD ? CAIRO_FILL_RULE_EVEN_ODD : CAIRO_FILL_RULE_WINDING); } cairo_clip(cr); }
static VALUE cr_set_fill_rule (VALUE self, VALUE rule) { cairo_set_fill_rule (_SELF, RVAL2CRFILLRULE (rule)); cr_check_status (_SELF); return self; }
JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GdkGraphics2D_cairoSetFillRule (JNIEnv *env, jobject obj, jint rule) { struct graphics2d *gr = NULL; gr = (struct graphics2d *) NSA_GET_G2D_PTR (env, obj); if (gr->debug) printf ("cairo_set_fill_rule %d\n", rule); g_assert (gr != NULL); switch ((enum java_awt_geom_path_iterator_winding_rule) rule) { case java_awt_geom_path_iterator_WIND_NON_ZERO: cairo_set_fill_rule (gr->cr, CAIRO_FILL_RULE_WINDING); break; case java_awt_geom_path_iterator_WIND_EVEN_ODD: cairo_set_fill_rule (gr->cr, CAIRO_FILL_RULE_EVEN_ODD); break; } }
void PlatformContextCairo::prepareForFilling(const GraphicsContextState& state, PatternAdjustment patternAdjustment) { cairo_set_fill_rule(m_cr.get(), state.fillRule == RULE_EVENODD ? CAIRO_FILL_RULE_EVEN_ODD : CAIRO_FILL_RULE_WINDING); prepareCairoContextSource(m_cr.get(), state.fillPattern.get(), state.fillGradient.get(), state.fillColor, patternAdjustment == AdjustPatternForGlobalAlpha ? globalAlpha() : 1); }
void uiDrawFill(uiDrawContext *c, uiDrawPath *path, uiDrawBrush *b) { cairo_pattern_t *pat; runPath(path, c->cr); pat = mkbrush(b); cairo_set_source(c->cr, pat); switch (pathFillMode(path)) { case uiDrawFillModeWinding: cairo_set_fill_rule(c->cr, CAIRO_FILL_RULE_WINDING); break; case uiDrawFillModeAlternate: cairo_set_fill_rule(c->cr, CAIRO_FILL_RULE_EVEN_ODD); break; } cairo_fill(c->cr); cairo_pattern_destroy(pat); }
void GraphicsContext::clipPath(WindRule clipRule) { if (paintingDisabled()) return; cairo_t* cr = m_data->cr; cairo_set_fill_rule(cr, clipRule == RULE_EVENODD ? CAIRO_FILL_RULE_EVEN_ODD : CAIRO_FILL_RULE_WINDING); cairo_clip(cr); }
/* Draws a rounded rectangle with text inside. */ static gboolean numbers_draw_cb (GtkWidget *widget, cairo_t *ctx, gpointer data) { double x, y, w, h; PangoLayout * layout; gint font_size = gtk_widget_get_font_size (widget); #if (INDICATOR_MESSAGES_HAS_LOZENGE == 1) gboolean is_lozenge = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (widget), "is-lozenge")); /* let the label handle the drawing if it's not a lozenge */ if (!is_lozenge) return FALSE; #endif if (!GTK_IS_WIDGET (widget)) return FALSE; /* get style + arrow position / dimensions */ double red, green, blue; GtkStyleContext *style = gtk_widget_get_style_context (widget); GdkRGBA color; gtk_style_context_get_color (style, gtk_widget_get_state(widget), &color); red = color.red; green = color.green; blue = color.blue; GtkAllocation allocation; gtk_widget_get_allocation (widget, &allocation); w = allocation.width; h = allocation.height; x = y = 0; layout = gtk_label_get_layout (GTK_LABEL(widget)); PangoRectangle layout_extents; pango_layout_get_extents (layout, NULL, &layout_extents); pango_extents_to_pixels (&layout_extents, NULL); if (layout_extents.width == 0) return TRUE; cairo_set_line_width (ctx, 1.0); cairo_set_fill_rule (ctx, CAIRO_FILL_RULE_EVEN_ODD); /* cairo drawing code */ custom_cairo_rounded_rectangle (ctx, x - font_size/2.0, y, w + font_size, h); cairo_set_source_rgba (ctx, red, green, blue, 0.5); x += (allocation.width - layout_extents.width) / 2.0; y += (allocation.height - layout_extents.height) / 2.0; cairo_move_to (ctx, floor (x), floor (y)); pango_cairo_layout_path (ctx, layout); cairo_fill (ctx); return TRUE; }
void Border::Render (cairo_t *cr, Region *region, bool path_only) { Brush *background = GetBackground (); Brush *border_brush = GetBorderBrush (); cairo_save (cr); if (!path_only) RenderLayoutClip (cr); CornerRadius r = *GetCornerRadius (); CornerRadius *round = &r; Thickness thickness = *GetBorderThickness (); Rect paint_border = extents; Rect paint_background = paint_border.GrowBy (-thickness); CornerRadius inner_adjusted = *round; inner_adjusted.topLeft = MAX (round->topLeft - MAX (thickness.left, thickness.top) * .5, 0); inner_adjusted.topRight = MAX (round->topRight - MAX (thickness.right, thickness.top) * .5, 0); inner_adjusted.bottomRight = MAX (round->bottomRight - MAX (thickness.right, thickness.bottom) * .5, 0); inner_adjusted.bottomLeft = MAX (round->bottomLeft - MAX (thickness.left, thickness.bottom) * .5, 0); CornerRadius outer_adjusted = *round; outer_adjusted.topLeft = outer_adjusted.topLeft ? MAX (round->topLeft + MAX (thickness.left, thickness.top) * .5, 0) : 0; outer_adjusted.topRight = outer_adjusted.topRight ? MAX (round->topRight + MAX (thickness.right, thickness.top) * .5, 0) : 0; outer_adjusted.bottomRight = outer_adjusted.bottomRight ? MAX (round->bottomRight + MAX (thickness.right, thickness.bottom) * .5, 0) : 0; outer_adjusted.bottomLeft = outer_adjusted.bottomLeft ? MAX (round->bottomLeft + MAX (thickness.left, thickness.bottom) * .5, 0) : 0; /* * NOTE filling this way can leave alpha artifacts between the border fill and bg fill * but some simple inspection of the ms results make me think that is what happens there * too. */ cairo_new_path (cr); cairo_set_fill_rule (cr, CAIRO_FILL_RULE_EVEN_ODD); if (border_brush && !paint_border.IsEmpty ()) { border_brush->SetupBrush (cr, paint_border); paint_border.Draw (cr, &outer_adjusted); paint_background.Draw (cr, &inner_adjusted); if (!path_only) border_brush->Fill (cr); } if (background && !paint_background.IsEmpty ()) { background->SetupBrush (cr, paint_background); paint_background.Draw (cr, &inner_adjusted); if (!path_only) background->Fill (cr); } cairo_restore (cr); }
static void cell_renderer_caption_render (GtkCellRenderer *cell, GdkWindow *window, GtkWidget *widget, GdkRectangle *background_area, GdkRectangle *cell_area, GdkRectangle *expose_area, GtkCellRendererState flags) { (* GTK_CELL_RENDERER_CLASS (cell_renderer_caption_parent_class)->render) (cell, window, widget, background_area, cell_area, expose_area, flags); if ((flags & (GTK_CELL_RENDERER_SELECTED|GTK_CELL_RENDERER_PRELIT)) != 0) { cairo_t *cr; int radius = 5; int x, y, w, h; GtkStateType state; x = background_area->x; y = background_area->y; w = background_area->width; h = background_area->height; /* sometimes width is -1 - not sure what to do here */ if (w == -1) return; if ((flags & GTK_CELL_RENDERER_SELECTED) != 0) { if (GTK_WIDGET_HAS_FOCUS (widget)) state = GTK_STATE_SELECTED; else state = GTK_STATE_ACTIVE; } else state = GTK_STATE_PRELIGHT; /* add rounded corners to the selection indicator */ cr = gdk_cairo_create (GDK_DRAWABLE (window)); gdk_cairo_set_source_color (cr, &widget->style->base[GTK_STATE_NORMAL]); cairo_rectangle (cr, x, y, w, h); cairo_arc (cr, x + radius, y + radius, radius, M_PI, M_PI * 1.5); cairo_arc (cr, x + w - radius, y + radius, radius, M_PI * 1.5, 0); cairo_arc (cr, x + w - radius, y + h - radius, radius, 0, M_PI * 0.5); cairo_arc (cr, x + radius, y + h - radius, radius, M_PI * 0.5, M_PI); cairo_close_path (cr); cairo_set_fill_rule (cr, CAIRO_FILL_RULE_EVEN_ODD); cairo_fill (cr); cairo_destroy (cr); } }
void GraphicsContext::clipPath(const Path& path, WindRule clipRule) { if (paintingDisabled()) return; cairo_t* cr = platformContext()->cr(); setPathOnCairoContext(cr, path.platformPath()->context()); cairo_set_fill_rule(cr, clipRule == RULE_EVENODD ? CAIRO_FILL_RULE_EVEN_ODD : CAIRO_FILL_RULE_WINDING); cairo_clip(cr); }