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 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); }
void copyContextProperties(cairo_t* srcCr, cairo_t* dstCr) { cairo_set_antialias(dstCr, cairo_get_antialias(srcCr)); size_t dashCount = cairo_get_dash_count(srcCr); Vector<double> dashes(dashCount); double offset; cairo_get_dash(srcCr, dashes.data(), &offset); cairo_set_dash(dstCr, dashes.data(), dashCount, offset); cairo_set_line_cap(dstCr, cairo_get_line_cap(srcCr)); cairo_set_line_join(dstCr, cairo_get_line_join(srcCr)); cairo_set_line_width(dstCr, cairo_get_line_width(srcCr)); cairo_set_miter_limit(dstCr, cairo_get_miter_limit(srcCr)); cairo_set_fill_rule(dstCr, cairo_get_fill_rule(srcCr)); }
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); }
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); }
void GraphicsContext::clipOut(const IntRect& r) { if (paintingDisabled()) return; #if CAIRO_VERSION >= CAIRO_VERSION_ENCODE(1,4,0) cairo_t* cr = m_data->cr; double x1, y1, x2, y2; cairo_clip_extents(cr, &x1, &y1, &x2, &y2); cairo_rectangle(cr, x1, x2, 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); #else notImplemented(); #endif }
void GraphicsContext::clip(const Path& path, WindRule windRule) { if (paintingDisabled()) return; cairo_t* cr = platformContext()->cr(); OwnPtr<cairo_path_t> pathCopy; if (!path.isNull()) { pathCopy = adoptPtr(cairo_copy_path(path.platformPath()->context())); cairo_append_path(cr, pathCopy.get()); } cairo_fill_rule_t savedFillRule = cairo_get_fill_rule(cr); if (windRule == RULE_NONZERO) cairo_set_fill_rule(cr, CAIRO_FILL_RULE_WINDING); else cairo_set_fill_rule(cr, CAIRO_FILL_RULE_EVEN_ODD); cairo_clip(cr); cairo_set_fill_rule(cr, savedFillRule); m_data->clip(path); }
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); // The rectangular clip function is traditionally not expected to // antialias. If we don't force antialiased clipping here, // edge fringe artifacts may occur at the layer edges // when a transformation is applied to the GraphicsContext // while drawing the transformed layer. cairo_antialias_t savedAntialiasRule = cairo_get_antialias(cr); cairo_set_antialias(cr, CAIRO_ANTIALIAS_NONE); cairo_clip(cr); cairo_set_fill_rule(cr, savedFillRule); cairo_set_antialias(cr, savedAntialiasRule); m_data->clip(rect); }
void GraphicsContext::addInnerRoundedRectClip(const IntRect& rect, int thickness) { if (paintingDisabled()) return; cairo_t* cr = platformContext()->cr(); clip(rect); Path p; FloatRect r(rect); // Add outer ellipse p.addEllipse(r); // Add inner ellipse r.inflate(-thickness); p.addEllipse(r); appendWebCorePathToCairoContext(cr, p); 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); }
void GraphicsContext::clipOut(const IntRect& rect) { if (paintingDisabled()) return; #if USE(WXGC) wxGraphicsContext* gc = m_data->context->GetGraphicsContext(); #if wxUSE_CAIRO double x1, y1, x2, y2; cairo_t* cr = (cairo_t*)gc->GetNativeContext(); cairo_clip_extents(cr, &x1, &y1, &x2, &y2); cairo_rectangle(cr, x1, y1, x2 - x1, y2 - y1); 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_EVEN_ODD); cairo_clip(cr); cairo_set_fill_rule(cr, savedFillRule); #elif __WXMAC__ CGContextRef context = (CGContextRef)gc->GetNativeContext(); CGRect rects[2] = { CGContextGetClipBoundingBox(context), CGRectMake(rect.x(), rect.y(), rect.width(), rect.height()) }; CGContextBeginPath(context); CGContextAddRects(context, rects, 2); CGContextEOClip(context); return; #elif __WXMSW__ Gdiplus::Graphics* g = (Gdiplus::Graphics*)gc->GetNativeContext(); Gdiplus::Region excludeRegion(Gdiplus::Rect(rect.x(), rect.y(), rect.width(), rect.height())); g->ExcludeClip(&excludeRegion); return; #endif #endif // USE(WXGC) notImplemented(); }
void GraphicsContext::clipConvexPolygon(size_t numPoints, const FloatPoint* points, bool antialiased) { if (paintingDisabled()) return; if (numPoints <= 1) return; cairo_t* cr = platformContext()->cr(); cairo_new_path(cr); cairo_fill_rule_t savedFillRule = cairo_get_fill_rule(cr); cairo_antialias_t savedAntialiasRule = cairo_get_antialias(cr); cairo_set_antialias(cr, antialiased ? CAIRO_ANTIALIAS_DEFAULT : CAIRO_ANTIALIAS_NONE); cairo_set_fill_rule(cr, CAIRO_FILL_RULE_WINDING); addConvexPolygonToContext(cr, numPoints, points); cairo_clip(cr); cairo_set_antialias(cr, savedAntialiasRule); cairo_set_fill_rule(cr, savedFillRule); }
static int settings_get (cairo_t *cr, settings_t *settings) { int count; settings->op = cairo_get_operator (cr); settings->tolerance = cairo_get_tolerance (cr); settings->fill_rule = cairo_get_fill_rule (cr); settings->line_width = cairo_get_line_width (cr); settings->line_cap = cairo_get_line_cap (cr); settings->line_join = cairo_get_line_join (cr); settings->miter_limit = cairo_get_miter_limit (cr); cairo_get_matrix (cr, &settings->matrix); count = cairo_get_dash_count (cr); if (count != 5) return -1; cairo_get_dash (cr, settings->dash, &settings->dash_offset); return 0; }
int lime_cairo_get_fill_rule (value handle) { return cairo_get_fill_rule ((cairo_t*)val_data (handle)); }
int lime_cairo_get_fill_rule (double handle) { return cairo_get_fill_rule ((cairo_t*)(intptr_t)handle); }
static PyObject * pycairo_get_fill_rule (PycairoContext *o) { return PyInt_FromLong(cairo_get_fill_rule (o->ctx)); }
static int cr_get_fill_rule (lua_State *L) { cairo_t **obj = luaL_checkudata(L, 1, OOCAIRO_MT_NAME_CONTEXT); return fill_rule_to_lua(L, cairo_get_fill_rule(*obj)); }
static VALUE cr_get_fill_rule (VALUE self) { return INT2FIX (cairo_get_fill_rule (_SELF)); }
gfxContext::FillRule gfxContext::CurrentFillRule() const { return (FillRule)cairo_get_fill_rule(mCairo); }
int32_t Context::getFillRule() { return static_cast<int32_t>( cairo_get_fill_rule( mCairo ) ); }
static cairo_test_status_t draw (cairo_t *cr, int width, int height) { const cairo_test_context_t *ctx = cairo_test_get_context (cr); cairo_surface_t *surface; cairo_pattern_t *pattern; cairo_t *cr2; /* * 1. Test file-not-found from surface->pattern->cairo_t */ /* Make a custom context to not interfere with the one passed in. */ cr2 = cairo_create (cairo_get_target (cr)); /* First, let's make a nil surface. */ surface = cairo_image_surface_create_from_png ("___THIS_FILE_DOES_NOT_EXIST___"); /* Let the error propagate into a nil pattern. */ pattern = cairo_pattern_create_for_surface (surface); /* Then let it propagate into the cairo_t. */ cairo_set_source (cr2, pattern); cairo_paint (cr2); cairo_pattern_destroy (pattern); cairo_surface_destroy (surface); /* Check that the error made it all that way. */ if (cairo_status (cr2) != CAIRO_STATUS_FILE_NOT_FOUND) { cairo_test_log (ctx, "Error: Received status of \"%s\" rather than expected \"%s\"\n", cairo_status_to_string (cairo_status (cr2)), cairo_status_to_string (CAIRO_STATUS_FILE_NOT_FOUND)); cairo_destroy (cr2); return CAIRO_TEST_FAILURE; } cairo_destroy (cr2); /* * 2. Test NULL pointer pattern->cairo_t */ cr2 = cairo_create (cairo_get_target (cr)); /* First, trigger the NULL pointer status. */ pattern = cairo_pattern_create_for_surface (NULL); /* Then let it propagate into the cairo_t. */ cairo_set_source (cr2, pattern); cairo_paint (cr2); cairo_pattern_destroy (pattern); /* Check that the error made it all that way. */ if (cairo_status (cr2) != CAIRO_STATUS_NULL_POINTER) { cairo_test_log (ctx, "Error: Received status of \"%s\" rather than expected \"%s\"\n", cairo_status_to_string (cairo_status (cr2)), cairo_status_to_string (CAIRO_STATUS_NULL_POINTER)); cairo_destroy (cr2); return CAIRO_TEST_FAILURE; } cairo_destroy (cr2); /* * 3. Test that cairo_surface_finish can accept NULL or a nil * surface without crashing. */ cairo_surface_finish (NULL); surface = cairo_image_surface_create_from_png ("___THIS_FILE_DOES_NOT_EXIST___"); cairo_surface_finish (surface); cairo_surface_destroy (surface); /* * 4. OK, we're straying from the original name, but it's still a * similar kind of testing of error paths. Here we're making sure * we can still call a cairo_get_* function after triggering an * INVALID_RESTORE error. */ cr2 = cairo_create (cairo_get_target (cr)); /* Trigger invalid restore. */ cairo_restore (cr2); if (cairo_status (cr2) != CAIRO_STATUS_INVALID_RESTORE) { cairo_test_log (ctx, "Error: Received status of \"%s\" rather than expected \"%s\"\n", cairo_status_to_string (cairo_status (cr2)), cairo_status_to_string (CAIRO_STATUS_INVALID_RESTORE)); cairo_destroy (cr2); return CAIRO_TEST_FAILURE; } /* Test that we can still call cairo_get_fill_rule without crashing. */ cairo_get_fill_rule (cr2); cairo_destroy (cr2); /* * 5. Create a cairo_t for the NULL surface. */ cr2 = cairo_create (NULL); if (cairo_status (cr2) != CAIRO_STATUS_NULL_POINTER) { cairo_test_log (ctx, "Error: Received status of \"%s\" rather than expected \"%s\"\n", cairo_status_to_string (cairo_status (cr2)), cairo_status_to_string (CAIRO_STATUS_NULL_POINTER)); cairo_destroy (cr2); return CAIRO_TEST_FAILURE; } /* Test that get_target returns something valid */ if (cairo_get_target (cr2) == NULL) { cairo_test_log (ctx, "Error: cairo_get_target() returned NULL\n"); cairo_destroy (cr2); return CAIRO_TEST_FAILURE; } /* Test that push_group doesn't crash */ cairo_push_group (cr2); cairo_stroke (cr2); cairo_pop_group (cr2); cairo_destroy (cr2); return CAIRO_TEST_SUCCESS; }