本文整理汇总了C++中cairo_surface_status函数的典型用法代码示例。如果您正苦于以下问题:C++ cairo_surface_status函数的具体用法?C++ cairo_surface_status怎么用?C++ cairo_surface_status使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了cairo_surface_status函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: draw_tile_texture
/*
* functions to create different wrapmodes.
*/
static GpStatus
draw_tile_texture (cairo_t *ct, GpBitmap *bitmap, GpTexture *brush)
{
cairo_surface_t *original = NULL;
cairo_surface_t *texture;
cairo_pattern_t *pat;
GpStatus status;
GpRect *rect = &brush->rectangle;
cairo_t *ct2;
BYTE *premul = NULL;
if (!rect)
return InvalidParameter;
gdip_bitmap_ensure_surface (bitmap);
if (gdip_bitmap_format_needs_premultiplication (bitmap)) {
premul = gdip_bitmap_get_premultiplied_scan0 (bitmap);
if (premul) {
ActiveBitmapData *data = bitmap->active_bitmap;
original = cairo_image_surface_create_for_data (premul, CAIRO_FORMAT_ARGB32,
data->width, data->height, data->stride);
}
}
/* if premul isn't required (or couldn't be computed, e.g. out of memory) */
if (!original)
original = bitmap->surface;
/* Use the original as a pattern */
pat = cairo_pattern_create_for_surface (original);
status = gdip_get_pattern_status (pat);
if (status != Ok)
goto cleanup;
cairo_pattern_set_extend (pat, CAIRO_EXTEND_REPEAT);
/* texture surface to be created */
texture = cairo_surface_create_similar (original, from_cairoformat_to_content (bitmap->cairo_format),
rect->Width, rect->Height);
status = gdip_get_status (cairo_surface_status (texture));
if (status != Ok) {
cairo_pattern_destroy (pat);
goto cleanup;
}
/* Draw the texture */
ct2 = cairo_create (texture);
cairo_set_source (ct2, pat);
cairo_rectangle (ct2, 0, 0, rect->Width, rect->Height);
cairo_fill (ct2);
cairo_destroy (ct2);
brush->pattern = cairo_pattern_create_for_surface (texture);
status = gdip_get_pattern_status (brush->pattern);
if (status == Ok)
cairo_pattern_set_extend (brush->pattern, CAIRO_EXTEND_REPEAT);
cairo_pattern_destroy (pat);
cairo_surface_destroy (texture);
status = gdip_get_status (cairo_status (ct));
cleanup:
if (premul) {
cairo_surface_destroy (original);
GdipFree (premul);
}
return status;
}
开发者ID:mono,项目名称:libgdiplus,代码行数:73,代码来源:texturebrush.c
示例2: _cairo_quartz_init_glyph_surface
static cairo_int_status_t
_cairo_quartz_init_glyph_surface (cairo_quartz_scaled_font_t *font,
cairo_scaled_glyph_t *scaled_glyph)
{
cairo_int_status_t status = CAIRO_STATUS_SUCCESS;
cairo_quartz_font_face_t *font_face = _cairo_quartz_scaled_to_face(font);
cairo_image_surface_t *surface = NULL;
CGGlyph glyph = _cairo_quartz_scaled_glyph_index (scaled_glyph);
int advance;
CGRect bbox;
double width, height;
double emscale = CGFontGetUnitsPerEmPtr (font_face->cgFont);
CGContextRef cgContext = NULL;
CGAffineTransform textMatrix;
CGRect glyphRect, glyphRectInt;
CGPoint glyphOrigin;
//fprintf (stderr, "scaled_glyph: %p surface: %p\n", scaled_glyph, scaled_glyph->surface);
/* Create blank 2x2 image if we don't have this character.
* Maybe we should draw a better missing-glyph slug or something,
* but this is ok for now.
*/
if (glyph == INVALID_GLYPH) {
surface = (cairo_image_surface_t*) cairo_image_surface_create (CAIRO_FORMAT_A8, 2, 2);
status = cairo_surface_status ((cairo_surface_t *) surface);
if (status)
return status;
_cairo_scaled_glyph_set_surface (scaled_glyph,
&font->base,
surface);
return CAIRO_STATUS_SUCCESS;
}
if (!CGFontGetGlyphAdvancesPtr (font_face->cgFont, &glyph, 1, &advance) ||
!CGFontGetGlyphBBoxesPtr (font_face->cgFont, &glyph, 1, &bbox))
{
return CAIRO_INT_STATUS_UNSUPPORTED;
}
/* scale(1,-1) * font->base.scale * scale(1,-1) */
textMatrix = CGAffineTransformMake (font->base.scale.xx,
-font->base.scale.yx,
-font->base.scale.xy,
font->base.scale.yy,
0, -0);
glyphRect = CGRectMake (bbox.origin.x / emscale,
bbox.origin.y / emscale,
bbox.size.width / emscale,
bbox.size.height / emscale);
glyphRect = CGRectApplyAffineTransform (glyphRect, textMatrix);
/* Round the rectangle outwards, so that we don't have to deal
* with non-integer-pixel origins or dimensions.
*/
glyphRectInt = CGRectIntegral (glyphRect);
#if 0
fprintf (stderr, "glyphRect[o]: %f %f %f %f\n",
glyphRect.origin.x, glyphRect.origin.y, glyphRect.size.width, glyphRect.size.height);
fprintf (stderr, "glyphRectInt: %f %f %f %f\n",
glyphRectInt.origin.x, glyphRectInt.origin.y, glyphRectInt.size.width, glyphRectInt.size.height);
#endif
glyphOrigin = glyphRectInt.origin;
//textMatrix = CGAffineTransformConcat (textMatrix, CGAffineTransformInvert (ctm));
width = glyphRectInt.size.width;
height = glyphRectInt.size.height;
//fprintf (stderr, "glyphRect[n]: %f %f %f %f\n", glyphRect.origin.x, glyphRect.origin.y, glyphRect.size.width, glyphRect.size.height);
surface = (cairo_image_surface_t*) cairo_image_surface_create (CAIRO_FORMAT_A8, width, height);
if (surface->base.status)
return surface->base.status;
if (surface->width != 0 && surface->height != 0) {
cgContext = CGBitmapContextCreate (surface->data,
surface->width,
surface->height,
8,
surface->stride,
NULL,
kCGImageAlphaOnly);
if (cgContext == NULL) {
cairo_surface_destroy (&surface->base);
return _cairo_error (CAIRO_STATUS_NO_MEMORY);
}
CGContextSetFont (cgContext, font_face->cgFont);
CGContextSetFontSize (cgContext, 1.0);
//.........这里部分代码省略.........
开发者ID:Lucas-Gluchowski,项目名称:Indigo,代码行数:101,代码来源:cairo-quartz-font.c
示例3: preamble
//.........这里部分代码省略.........
free (base_name);
continue;
}
if (ret == CAIRO_TEST_UNTESTED)
ret = CAIRO_TEST_SUCCESS;
cairo_surface_destroy (surface);
if (target->cleanup)
target->cleanup (closure);
free (base_name);
/* we need to recreate the surface for each resolution as we include
* SVG in testing which does not support the paginated interface.
*/
for (n = 0; n < num_ppi; n++) {
char *test_name;
cairo_bool_t pass;
xasprintf (&test_name, "fallback-resolution.ppi%gx%g",
ppi[n].x, ppi[n].y);
xasprintf (&base_name, "%s.%s.%s",
test_name,
target->name,
format);
surface = (target->create_surface) (base_name,
target->content,
SIZE + 25, SIZE + 25,
SIZE + 25, SIZE + 25,
CAIRO_BOILERPLATE_MODE_TEST,
0,
&closure);
if (surface == NULL || cairo_surface_status (surface)) {
cairo_test_log (ctx, "Failed to generate surface: %s.%s\n",
target->name,
format);
free (base_name);
free (test_name);
ret = CAIRO_TEST_FAILURE;
continue;
}
cairo_test_log (ctx,
"Testing fallback-resolution %gx%g with %s target\n",
ppi[n].x, ppi[n].y, target->name);
printf ("%s:\t", base_name);
fflush (stdout);
if (target->force_fallbacks != NULL)
target->force_fallbacks (surface, ~0U);
cr = cairo_create (surface);
#if SET_TOLERANCE
cairo_set_tolerance (cr, 3.0);
#endif
cairo_surface_set_device_offset (surface, 25, 25);
cairo_surface_set_fallback_resolution (surface,
ppi[n].x, ppi[n].y);
cairo_save (cr); {
cairo_set_source_rgb (cr, 1, 1, 1);
cairo_paint (cr);
} cairo_restore (cr);
/* First draw the top half in a conventional way. */
开发者ID:jaglass,项目名称:WinCairoRequirements,代码行数:67,代码来源:fallback-resolution.c
示例4: GetMediaUpdateInfo
void MediaPlayerPrivateEA::paint(GraphicsContext* context, const IntRect& r)
{
if (!context)
return;
// Can get a NULL platform context so need to verify. Seems that UpdateControlTints does what is called a "fake" paint
// with a null platform context just to get an invalidate.
PlatformContextCairo* pPlatformContext = context->platformContext();
if (!pPlatformContext)
return;
cairo_t* cr = context->platformContext()->cr();
if (!cr)
return;
MediaUpdateInfo& info = GetMediaUpdateInfo();
const FrameView* pFV = mpWebCorePlayer->frameView();
if (!pFV)
return;
// Convert and store movie rect to device coords using the graphic context.
double x = (double) r.x();
double y = (double) r.y();
double w = (double) r.width();
double h = (double) r.height();
cairo_user_to_device (cr, &x, &y);
cairo_user_to_device_distance(cr, &w, &h);
const IntRect rect((int) x, (int) y, (int) w, (int) h);
// The intersection of frameView contents and the movie is used as clip rect for we just want to know what part of the movie is visible.
IntRect clip = pFV->windowClipRect(true);
clip.intersect(rect);
// Find controls intersection
HTMLMediaElement* element = static_cast<HTMLMediaElement*>(mpWebCorePlayer->mediaPlayerClient());
if(element && element->controls())
{
MediaControls* pControls = element->mediaControls();
bool hideControls = pControls->shouldHideControls();
if (!hideControls)
{
const int kControlHeight = 16; // EAWebKitTODO: Consider finding a way to extract this info directly from the controls or pass as a theme param.
IntRect boundingRect = pControls->getRect();
x = (double) boundingRect.x();
y = (double) boundingRect.y();
w = (double) boundingRect.width();
h = (double) (boundingRect.height() - kControlHeight);
cairo_user_to_device (cr, &x, &y);
cairo_user_to_device_distance(cr, &w, &h);
const IntRect ctrlRect((int) x, (int) y, (int) w, (int) h);
clip.intersect(ctrlRect);
}
}
if ((rect != mMovieRect) || (clip != mWindowRect))
{
mMovieRect = rect; // Store copy locally to detect changes.
mWindowRect = clip;
info.mMovieRect = rect;
info.mWindowRect = clip;
ClientUpdate(MediaUpdateInfo::kWindowSize);
}
ClientUpdate(MediaUpdateInfo::kPaint);
if (info.mReturnData)
{
// Draw surface to view
#ifndef NDEBUG
static bool sAssertChecked = false;
if(!sAssertChecked)
{
EAW_ASSERT(!info.mReturnData);
sAssertChecked = true;
}
#endif
context->save();
RefPtr<cairo_surface_t> cairoSurface = adoptRef(cairo_image_surface_create_for_data((unsigned char*) info.mReturnData, CAIRO_FORMAT_ARGB32, w, h, w * sizeof(uint32_t)));
EAW_ASSERT(cairo_surface_status(cairoSurface.get()) == CAIRO_STATUS_SUCCESS);
cairo_set_source_surface(cr, cairoSurface.get(), rect.x(), rect.y());
cairo_paint(cr);
context->restore();
}
else
{
// Draw a default black background.
context->save();
context->setStrokeStyle(NoStroke);
context->setFillColor(Color::black, ColorSpaceDeviceRGB);
context->drawRect(r);
context->restore();
}
}
开发者ID:Xertz,项目名称:EAWebKit,代码行数:94,代码来源:MediaPlayerPrivateEA.cpp
示例5: main
//.........这里部分代码省略.........
printf("Error: cannot create the cairo");
exit(EXIT_FAILURE);
}
path = rx_get_exe_path() +"/generated_polaroid.png";
cairo_surface_write_to_png(surf_bg, path.c_str());
printf("Created\n");
exit(0);
/* END TESTING */
#endif
}
}
else if (ext == "png") {
/* use cairo png load feature. */
surf_bg = cairo_image_surface_create_from_png(path.c_str());
if (NULL == surf_bg) {
printf("Error: cannot create s2\n");
exit(EXIT_FAILURE);
}
}
else {
printf("Error: unsupported file format: %s\n", ext.c_str());
exit(EXIT_FAILURE);
}
/* make sure the background is loaded correctly (aka the photo) */
if (NULL == surf_bg) {
printf("Error: cannot create background surface.\n");
exit(EXIT_FAILURE);
}
if (CAIRO_STATUS_SUCCESS != cairo_surface_status(surf_bg)) {
printf("Error: something went wrong: %d\n", cairo_surface_status(surf_bg));
exit(EXIT_FAILURE);
}
float source_width = cairo_image_surface_get_width(surf_bg);
float source_height = cairo_image_surface_get_height(surf_bg);
/* create output */
int dest_width = cairo_image_surface_get_width(surf_overlay);
int dest_height = cairo_image_surface_get_height(surf_overlay);
printf("+ Output size: %d x %d\n", dest_width, dest_height);
cairo_surface_t* surf_out = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, dest_width, dest_height);
if (NULL == surf_out) {
printf("Error: cannot create cairo_surface_t\n");
exit(EXIT_FAILURE);
}
printf("+ Info: creating output surface: %d x %d\n", dest_width, dest_height);
cairo_t* cr = cairo_create(surf_out);
if (NULL == cr) {
printf("Error: cannot create the cairo");
exit(EXIT_FAILURE);
}
/* fill background. */
cairo_set_source_rgba(cr, 1, 1, 1, 1);
cairo_paint(cr);
开发者ID:HellicarAndLewis,项目名称:Mosaic,代码行数:66,代码来源:test_cairo_png.cpp
示例6: surface_status
static int
surface_status (lua_State *L) {
cairo_surface_t **obj = luaL_checkudata(L, 1, OOCAIRO_MT_NAME_SURFACE);
return push_cairo_status(L, cairo_surface_status(*obj));
}
开发者ID:steelman,项目名称:oocairo,代码行数:5,代码来源:obj_surface.c
示例7: main
int main(int argc, char** argv)
{
cairo_t *cr;
cairo_status_t status;
cairo_surface_t *surface;
//FT_Bitmap bmp = {0};
int stride = 0;
int width = 640;
int height = 480;
bool ok = FcConfigAppFontAddFile(NULL, (FcChar8*)"fonts/ComicSansAfrica.ttf");
if (!ok)
{
printf("Failed to load ComicSansAfrica.ttf\n");
}
FcChar8 *configName = FcConfigFilename(NULL);
printf("%s", (const char*)configName);
printf("\n");
FcConfig* config = FcConfigCreate();
FcConfigParseAndLoad(config, configName, true);
FcConfigSetCurrent(config);
/* FT buffer */
//FT_Bitmap_New(&bmp);
//bmp.rows = height;
//bmp.width = width;
//bmp.buffer = (unsigned char*)malloc(bmp.rows * bmp.width * 4);
// if (NULL == bmp.buffer)
// {
// printf("+ error: cannot allocate the buffer for the output bitmap.\n");
// exit(EXIT_FAILURE);
// }
//bmp.pitch = ((width+3) & -4) * 4;
//bmp.pixel_mode = FT_PIXEL_MODE_BGRA;
//printf("%d\n", bmp.pitch);
//stride = cairo_format_stride_for_width(CAIRO_FORMAT_ARGB32, width);
//printf("%d\n", stride);
//surface = cairo_image_surface_create_for_data(bmp.buffer, CAIRO_FORMAT_ARGB32, width, height, stride);
surface = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, width, height);
if (CAIRO_STATUS_SUCCESS != cairo_surface_status(surface)) {
printf("+ error: couldn't create the surface.\n");
exit(EXIT_FAILURE);
}
cr = cairo_create(surface);
if (CAIRO_STATUS_NO_MEMORY == cairo_status(cr)) {
printf("+ error: out of memory, cannot create cairo_t*\n");
exit(EXIT_FAILURE);
}
cairo_set_source_rgba(cr, 1.0, 1.0, 1.0, 1.0);
cairo_paint(cr);
rendertext(cr);
status = cairo_surface_write_to_png(surface, "out.png");
cairo_surface_destroy(surface);
cairo_destroy(cr);
return 0;
}
开发者ID:guysherman,项目名称:pangoresearh,代码行数:72,代码来源:main.cpp
示例8: _cairo_quartz_init_glyph_surface
static cairo_int_status_t
_cairo_quartz_init_glyph_surface (cairo_quartz_scaled_font_t *font,
cairo_scaled_glyph_t *scaled_glyph)
{
cairo_int_status_t status = CAIRO_STATUS_SUCCESS;
cairo_quartz_font_face_t *font_face = _cairo_quartz_scaled_to_face(font);
cairo_image_surface_t *surface = NULL;
CGGlyph glyph = _cairo_quartz_scaled_glyph_index (scaled_glyph);
int advance;
CGRect bbox;
double width, height;
double xscale, yscale;
double emscale = CGFontGetUnitsPerEmPtr (font_face->cgFont);
CGColorSpaceRef gray;
CGContextRef cgContext = NULL;
CGAffineTransform textMatrix;
CGRect glyphRect, glyphRectInt;
CGPoint glyphOrigin;
//fprintf (stderr, "scaled_glyph: %p surface: %p\n", scaled_glyph, scaled_glyph->surface);
/* Create blank 2x2 image if we don't have this character.
* Maybe we should draw a better missing-glyph slug or something,
* but this is ok for now.
*/
if (glyph == INVALID_GLYPH) {
surface = (cairo_image_surface_t*) cairo_image_surface_create (CAIRO_FORMAT_A8, 2, 2);
status = cairo_surface_status ((cairo_surface_t *) surface);
if (status)
return status;
_cairo_scaled_glyph_set_surface (scaled_glyph,
&font->base,
surface);
return CAIRO_STATUS_SUCCESS;
}
if (!CGFontGetGlyphAdvancesPtr (font_face->cgFont, &glyph, 1, &advance) ||
!CGFontGetGlyphBBoxesPtr (font_face->cgFont, &glyph, 1, &bbox))
{
return CAIRO_INT_STATUS_UNSUPPORTED;
}
status = _cairo_matrix_compute_basis_scale_factors (&font->base.scale,
&xscale, &yscale, 1);
if (status)
return status;
textMatrix = CGAffineTransformMake (font->base.scale.xx,
-font->base.scale.yx,
-font->base.scale.xy,
font->base.scale.yy,
0.0f, 0.0f);
glyphRect = CGRectMake (bbox.origin.x / emscale,
bbox.origin.y / emscale,
bbox.size.width / emscale,
bbox.size.height / emscale);
glyphRect = CGRectApplyAffineTransform (glyphRect, textMatrix);
/* Round the rectangle outwards, so that we don't have to deal
* with non-integer-pixel origins or dimensions.
*/
glyphRectInt = CGRectIntegral (glyphRect);
#if 0
fprintf (stderr, "glyphRect[o]: %f %f %f %f\n",
glyphRect.origin.x, glyphRect.origin.y, glyphRect.size.width, glyphRect.size.height);
fprintf (stderr, "glyphRectInt: %f %f %f %f\n",
glyphRectInt.origin.x, glyphRectInt.origin.y, glyphRectInt.size.width, glyphRectInt.size.height);
#endif
glyphOrigin = glyphRectInt.origin;
//textMatrix = CGAffineTransformConcat (textMatrix, CGAffineTransformInvert (ctm));
width = glyphRectInt.size.width;
height = glyphRectInt.size.height;
//fprintf (stderr, "glyphRect[n]: %f %f %f %f\n", glyphRect.origin.x, glyphRect.origin.y, glyphRect.size.width, glyphRect.size.height);
surface = (cairo_image_surface_t*) cairo_image_surface_create (CAIRO_FORMAT_A8, width, height);
if (surface->base.status)
return surface->base.status;
gray = CGColorSpaceCreateDeviceGray ();
cgContext = CGBitmapContextCreate (surface->data,
surface->width,
surface->height,
8,
surface->stride,
gray,
kCGImageAlphaNone);
CGColorSpaceRelease (gray);
//.........这里部分代码省略.........
开发者ID:colama,项目名称:colama-3rdparty-tools,代码行数:101,代码来源:cairo-quartz-font.c
示例9: draw_shadow
void
draw_shadow (cairo_t* cr,
gdouble width,
gdouble height,
gint shadow_radius,
gint corner_radius)
{
cairo_surface_t* tmp_surface = NULL;
cairo_surface_t* new_surface = NULL;
cairo_pattern_t* pattern = NULL;
cairo_t* cr_surf = NULL;
cairo_matrix_t matrix;
raico_blur_t* blur = NULL;
tmp_surface = cairo_image_surface_create (CAIRO_FORMAT_ARGB32,
4 * shadow_radius,
4 * shadow_radius);
if (cairo_surface_status (tmp_surface) != CAIRO_STATUS_SUCCESS)
return;
cr_surf = cairo_create (tmp_surface);
if (cairo_status (cr_surf) != CAIRO_STATUS_SUCCESS)
{
cairo_surface_destroy (tmp_surface);
return;
}
cairo_scale (cr_surf, 1.0f, 1.0f);
cairo_set_operator (cr_surf, CAIRO_OPERATOR_CLEAR);
cairo_paint (cr_surf);
cairo_set_operator (cr_surf, CAIRO_OPERATOR_OVER);
cairo_set_source_rgba (cr_surf, 0.0f, 0.0f, 0.0f, 0.75f);
cairo_arc (cr_surf,
2 * shadow_radius,
2 * shadow_radius,
2.0f * corner_radius,
0.0f,
360.0f * (G_PI / 180.f));
cairo_fill (cr_surf);
cairo_destroy (cr_surf);
// create and setup blur
blur = raico_blur_create (RAICO_BLUR_QUALITY_LOW);
raico_blur_set_radius (blur, shadow_radius);
// now blur it
raico_blur_apply (blur, tmp_surface);
// blur no longer needed
raico_blur_destroy (blur);
new_surface = cairo_image_surface_create_for_data (
cairo_image_surface_get_data (tmp_surface),
cairo_image_surface_get_format (tmp_surface),
cairo_image_surface_get_width (tmp_surface) / 2,
cairo_image_surface_get_height (tmp_surface) / 2,
cairo_image_surface_get_stride (tmp_surface));
pattern = cairo_pattern_create_for_surface (new_surface);
if (cairo_pattern_status (pattern) != CAIRO_STATUS_SUCCESS)
{
cairo_surface_destroy (tmp_surface);
cairo_surface_destroy (new_surface);
return;
}
// top left
cairo_pattern_set_extend (pattern, CAIRO_EXTEND_PAD);
cairo_set_source (cr, pattern);
cairo_rectangle (cr,
0.0f,
0.0f,
width - 2 * shadow_radius,
2 * shadow_radius);
cairo_fill (cr);
// bottom left
cairo_matrix_init_scale (&matrix, 1.0f, -1.0f);
cairo_matrix_translate (&matrix, 0.0f, -height);
cairo_pattern_set_matrix (pattern, &matrix);
cairo_rectangle (cr,
0.0f,
2 * shadow_radius,
2 * shadow_radius,
height - 2 * shadow_radius);
cairo_fill (cr);
// top right
cairo_matrix_init_scale (&matrix, -1.0f, 1.0f);
cairo_matrix_translate (&matrix, -width, 0.0f);
cairo_pattern_set_matrix (pattern, &matrix);
cairo_rectangle (cr,
width - 2 * shadow_radius,
0.0f,
2 * shadow_radius,
height - 2 * shadow_radius);
cairo_fill (cr);
// bottom right
cairo_matrix_init_scale (&matrix, -1.0f, -1.0f);
cairo_matrix_translate (&matrix, -width, -height);
//.........这里部分代码省略.........
开发者ID:am0c,项目名称:notifyosd-lucid,代码行数:101,代码来源:test-grow-bubble.c
示例10: _cairo_boilerplate_gl_create_window
static cairo_surface_t *
_cairo_boilerplate_gl_create_window (const char *name,
cairo_content_t content,
double width,
double height,
double max_width,
double max_height,
cairo_boilerplate_mode_t mode,
void **closure)
{
int rgba_attribs[] = { GLX_RGBA,
GLX_RED_SIZE, 1,
GLX_GREEN_SIZE, 1,
GLX_BLUE_SIZE, 1,
GLX_ALPHA_SIZE, 1,
GLX_DOUBLEBUFFER,
None };
int msaa_attribs[] = { GLX_RGBA,
GLX_RED_SIZE, 1,
GLX_GREEN_SIZE, 1,
GLX_BLUE_SIZE, 1,
GLX_ALPHA_SIZE, 1,
GLX_STENCIL_SIZE, 1,
GLX_SAMPLES, 4,
GLX_SAMPLE_BUFFERS, 1,
GLX_DOUBLEBUFFER,
None };
XVisualInfo *vi;
GLXContext ctx;
gl_target_closure_t *gltc;
cairo_surface_t *surface;
Display *dpy;
XSetWindowAttributes attr;
gltc = calloc (1, sizeof (gl_target_closure_t));
*closure = gltc;
if (width == 0)
width = 1;
if (height == 0)
height = 1;
dpy = XOpenDisplay (NULL);
gltc->dpy = dpy;
if (!gltc->dpy) {
fprintf (stderr, "Failed to open display: %s\n", XDisplayName(0));
free (gltc);
return NULL;
}
if (mode == CAIRO_BOILERPLATE_MODE_TEST)
XSynchronize (gltc->dpy, 1);
vi = glXChooseVisual (dpy, DefaultScreen (dpy), msaa_attribs);
if (vi == NULL)
vi = glXChooseVisual (dpy, DefaultScreen (dpy), rgba_attribs);
if (vi == NULL) {
fprintf (stderr, "Failed to create RGBA, double-buffered visual\n");
XCloseDisplay (dpy);
free (gltc);
return NULL;
}
attr.colormap = XCreateColormap (dpy,
RootWindow (dpy, vi->screen),
vi->visual,
AllocNone);
attr.border_pixel = 0;
attr.override_redirect = True;
gltc->drawable = XCreateWindow (dpy, DefaultRootWindow (dpy), 0, 0,
width, height, 0, vi->depth,
InputOutput, vi->visual,
CWOverrideRedirect | CWBorderPixel | CWColormap,
&attr);
XMapWindow (dpy, gltc->drawable);
ctx = glXCreateContext (dpy, vi, NULL, True);
XFree (vi);
gltc->ctx = ctx;
gltc->device = cairo_glx_device_create (dpy, ctx);
gltc->surface = surface = cairo_gl_surface_create_for_window (gltc->device,
gltc->drawable,
ceil (width),
ceil (height));
if (cairo_surface_status (surface))
_cairo_boilerplate_gl_cleanup (gltc);
return surface;
}
开发者ID:tizenorg,项目名称:framework.graphics.cairo,代码行数:95,代码来源:cairo-boilerplate-glx.c
示例11: _cairo_boilerplate_gl_create_surface
static cairo_surface_t *
_cairo_boilerplate_gl_create_surface (const char *name,
cairo_content_t content,
double width,
double height,
double max_width,
double max_height,
cairo_boilerplate_mode_t mode,
void **closure)
{
int rgba_attribs[] = { GLX_RGBA,
GLX_RED_SIZE, 1,
GLX_GREEN_SIZE, 1,
GLX_BLUE_SIZE, 1,
GLX_ALPHA_SIZE, 1,
GLX_DOUBLEBUFFER,
None };
int rgb_attribs[] = { GLX_RGBA,
GLX_RED_SIZE, 1,
GLX_GREEN_SIZE, 1,
GLX_BLUE_SIZE, 1,
GLX_DOUBLEBUFFER,
None };
XVisualInfo *visinfo;
GLXContext ctx;
gl_target_closure_t *gltc;
cairo_surface_t *surface;
Display *dpy;
gltc = calloc (1, sizeof (gl_target_closure_t));
*closure = gltc;
if (width == 0)
width = 1;
if (height == 0)
height = 1;
dpy = XOpenDisplay (NULL);
gltc->dpy = dpy;
if (!gltc->dpy) {
fprintf (stderr, "Failed to open display: %s\n", XDisplayName(0));
free (gltc);
return NULL;
}
if (mode == CAIRO_BOILERPLATE_MODE_TEST)
XSynchronize (gltc->dpy, 1);
if (content == CAIRO_CONTENT_COLOR)
visinfo = glXChooseVisual (dpy, DefaultScreen (dpy), rgb_attribs);
else
visinfo = glXChooseVisual (dpy, DefaultScreen (dpy), rgba_attribs);
if (visinfo == NULL) {
fprintf (stderr, "Failed to create RGB, double-buffered visual\n");
XCloseDisplay (dpy);
free (gltc);
return NULL;
}
ctx = glXCreateContext (dpy, visinfo, NULL, True);
XFree (visinfo);
gltc->ctx = ctx;
gltc->device = cairo_glx_device_create (dpy, ctx);
gltc->surface = surface = cairo_gl_surface_create (gltc->device,
content,
ceil (width),
ceil (height));
if (cairo_surface_status (surface))
_cairo_boilerplate_gl_cleanup (gltc);
return surface;
}
开发者ID:tizenorg,项目名称:framework.graphics.cairo,代码行数:75,代码来源:cairo-boilerplate-glx.c
示例12: draw
static cairo_test_status_t
draw (cairo_t *cr, int width, int height)
{
const cairo_test_context_t *ctx = cairo_test_get_context (cr);
char *filename;
FILE *file;
cairo_surface_t *surface;
cairo_status_t status;
xasprintf (&filename, "%s/reference/%s", ctx->srcdir,
"create-from-png-stream.ref.png");
file = fopen (filename, "rb");
if (file == NULL) {
cairo_test_status_t ret;
ret = CAIRO_TEST_FAILURE;
if (errno == ENOMEM)
ret = cairo_test_status_from_status (ctx, CAIRO_STATUS_NO_MEMORY);
if (ret != CAIRO_TEST_NO_MEMORY)
cairo_test_log (ctx, "Error: failed to open file: %s\n", filename);
free (filename);
return ret;
}
surface = cairo_image_surface_create_from_png_stream (read_png_from_file,
file);
fclose (file);
status = cairo_surface_status (surface);
if (status) {
cairo_test_status_t ret;
cairo_surface_destroy (surface);
ret = cairo_test_status_from_status (ctx, status);
if (ret != CAIRO_TEST_NO_MEMORY) {
cairo_test_log (ctx,
"Error: failed to create surface from PNG: %s - %s\n",
filename,
cairo_status_to_string (status));
}
free (filename);
return ret;
}
free (filename);
/* Pretend we modify the surface data (which detaches the PNG mime data) */
cairo_surface_flush (surface);
cairo_surface_mark_dirty (surface);
cairo_set_source_surface (cr, surface, 0, 0);
cairo_pattern_set_filter (cairo_get_source (cr), CAIRO_FILTER_NEAREST);
cairo_paint (cr);
cairo_surface_destroy (surface);
return CAIRO_TEST_SUCCESS;
}
开发者ID:AZed,项目名称:cairo,代码行数:65,代码来源:create-from-png-stream.c
示例13: redraw_handler
static void
redraw_handler(struct widget *widget, void *data)
{
struct fullscreen *fullscreen = data;
struct rectangle allocation;
cairo_surface_t *surface;
cairo_t *cr;
int i;
double x, y, border;
const char *method_name[] = { "default", "center", "zoom", "zoom_crop", "stretch"};
surface = window_get_surface(fullscreen->window);
if (surface == NULL ||
cairo_surface_status(surface) != CAIRO_STATUS_SUCCESS) {
fprintf(stderr, "failed to create cairo egl surface\n");
return;
}
widget_get_allocation(fullscreen->widget, &allocation);
cr = widget_cairo_create(widget);
cairo_set_source_rgb(cr, 0, 0, 0);
cairo_paint (cr);
cairo_set_source_rgb(cr, 0, 0, 1);
cairo_set_line_width (cr, 10);
cairo_rectangle(cr, 5, 5, allocation.width - 10, allocation.height - 10);
cairo_stroke (cr);
cairo_move_to(cr,
allocation.x + 15,
allocation.y + 25);
cairo_set_source_rgb(cr, 1, 1, 1);
if (fullscreen->fshell) {
draw_string(cr,
"Surface size: %d, %d\n"
"Scale: %d, transform: %d\n"
"Pointer: %f,%f\n"
"Output: %s, present method: %s\n"
"Keys: (s)cale, (t)ransform, si(z)e, (m)ethod,\n"
" (o)utput, modes(w)itch, (q)uit\n",
fullscreen->width, fullscreen->height,
window_get_buffer_scale (fullscreen->window),
window_get_buffer_transform (fullscreen->window),
fullscreen->pointer_x, fullscreen->pointer_y,
method_name[fullscreen->present_method],
fullscreen->current_output ? output_get_model(fullscreen->current_output->output): "null");
} else {
draw_string(cr,
"Surface size: %d, %d\n"
"Scale: %d, transform: %d\n"
"Pointer: %f,%f\n"
"Fullscreen: %d\n"
"Keys: (s)cale, (t)ransform, si(z)e, (f)ullscreen, (q)uit\n",
fullscreen->width, fullscreen->height,
window_get_buffer_scale (fullscreen->window),
window_get_buffer_transform (fullscreen->window),
fullscreen->pointer_x, fullscreen->pointer_y,
fullscreen->fullscreen);
}
y = 100;
i = 0;
while (y + 60 < fullscreen->height) {
border = (i++ % 2 == 0) ? 1 : 0.5;
x = 50;
cairo_set_line_width (cr, border);
while (x + 70 < fullscreen->width) {
if (window_has_focus(fullscreen->window) &&
fullscreen->pointer_x >= x && fullscreen->pointer_x < x + 50 &&
fullscreen->pointer_y >= y && fullscreen->pointer_y < y + 40) {
cairo_set_source_rgb(cr, 1, 0, 0);
cairo_rectangle(cr,
x, y,
50, 40);
cairo_fill(cr);
}
cairo_set_source_rgb(cr, 0, 1, 0);
cairo_rectangle(cr,
x + border/2.0, y + border/2.0,
50, 40);
cairo_stroke(cr);
x += 60;
}
y += 50;
}
if (window_has_focus(fullscreen->window) && fullscreen->draw_cursor) {
cairo_set_source_rgb(cr, 1, 1, 1);
cairo_set_line_width (cr, 8);
cairo_move_to(cr,
fullscreen->pointer_x - 12,
fullscreen->pointer_y - 12);
cairo_line_to(cr,
fullscreen->pointer_x + 12,
fullscreen->pointer_y + 12);
//.........这里部分代码省略.........
开发者ID:rainbyte,项目名称:weston,代码行数:101,代码来源:fullscreen.c
示例14: preamble
static cairo_test_status_t
preamble (cairo_test_context_t *ctx)
{
char *filename;
cairo_surface_t *surface;
cairo_status_t status;
cairo_test_status_t result = CAIRO_TEST_SUCCESS;
surface = cairo_image_surface_create_from_png ("___THIS_FILE_DOES_NOT_EXIST___");
if (cairo_surface_status (surface) != CAIRO_STATUS_FILE_NOT_FOUND) {
result = cairo_test_status_from_status (ctx,
cairo_surface_status (surface));
if (result == CAIRO_TEST_FAILURE) {
cairo_test_log (ctx, "Error: expected \"file not found\", but got: %s\n",
cairo_status_to_string (cairo_surface_status (surface)));
}
}
cairo_surface_destroy (surface);
if (result != CAIRO_TEST_SUCCESS)
return result;
surface = cairo_image_surface_create_from_png_stream (no_memory_error, NULL);
if (cairo_surface_status (surface) != CAIRO_STATUS_NO_MEMORY) {
result = cairo_test_status_from_status (ctx,
cairo_surface_status (surface));
if (result == CAIRO_TEST_FAILURE) {
cairo_test_log (ctx, "Error: expected \"out of memory\", but got: %s\n",
cairo_status_to_string (cairo_surface_status (surface)));
}
}
cairo_surface_destroy (surface);
if (result != CAIRO_TEST_SUCCESS)
return result;
surface = cairo_image_surface_create_from_png_stream (read_error, NULL);
if (cairo_surface_status (surface) != CAIRO_STATUS_READ_ERROR) {
result = cairo_test_status_from_status (ctx,
cairo_surface_status (surface));
if (result == CAIRO_TEST_FAILURE) {
cairo_test_log (ctx, "Error: expected \"read error\", but got: %s\n",
cairo_status_to_string (cairo_surface_status (surface)));
}
}
cairo_surface_destroy (surface);
if (result != CAIRO_TEST_SUCCESS)
return result;
/* cheekily test error propagation from the user write funcs as well ... */
xasprintf (&filename, "%s/%s", ctx->srcdir,
"create-from-png.ref.png");
surface = cairo_image_surface_create_from_png (filename);
if (cairo_surface_status (surface)) {
result = cairo_test_status_from_status (ctx,
cairo_surface_status (surface));
if (result == CAIRO_TEST_FAILURE) {
cairo_test_log (ctx, "Error reading PNG image %s: %s\n",
filename,
cairo_status_to_string (cairo_surface_status (surface)));
}
} else {
status = cairo_surface_write_to_png_stream (surface,
(cairo_write_func_t) no_memory_error,
NULL);
if (status != CAIRO_STATUS_NO_MEMORY) {
result = cairo_test_status_from_status (ctx, status);
if (result == CAIRO_TEST_FAILURE) {
cairo_test_log (ctx, "Error: expected \"out of memory\", but got: %s\n",
cairo_status_to_string (status));
}
}
status = cairo_surface_write_to_png_stream (surface,
(cairo_write_func_t) read_error,
NULL);
if (status != CAIRO_STATUS_READ_ERROR) {
result = cairo_test_status_from_status (ctx, status);
if (result == CAIRO_TEST_FAILURE) {
cairo_test_log (ctx, "Error: expected \"read error\", but got: %s\n",
cairo_status_to_string (status));
}
}
/* and check that error has not propagated to the surface */
if (cairo_surface_status (surface)) {
result = cairo_test_status_from_status (ctx,
cairo_surface_status (surface));
if (result == CAIRO_TEST_FAILURE) {
cairo_test_log (ctx, "Error: user write error propagated to surface: %s",
cairo_status_to_string (cairo_surface_status (surface)));
}
}
}
cairo_surface_destroy (surface);
free (filename);
if (result != CAIRO_TEST_SUCCESS)
return result;
/* check that loading alpha/opaque PNGs generate the correct surfaces */
xasprintf (&filename, "%s/%s", ctx->srcdir,
//.........这里部分代码省略.........
开发者ID:499940913,项目名称:moon,代码行数:101,代码来源:create-from-png.c
示例15: cairogen_begin_page
static void cairogen_begin_page(GVJ_t * job)
{
cairo_t *cr = (cairo_t *) job->context;
cairo_surface_t *surface;
cairo_status_t status;
if (cr == NULL) {
switch (job->render.id) {
case FORMAT_PS:
#ifdef CAIRO_HAS_PS_SURFACE
surface = cairo_ps_surface_create_for_stream (writer,
job, job->width, job->height);
#endif
break;
case FORMAT_PDF:
#ifdef CAIRO_HAS_PDF_SURFACE
surface = cairo_pdf_surface_create_for_stream (writer,
job, job->width, job->height);
#endif
break;
case FORMAT_SVG:
#ifdef CAIRO_HAS_SVG_SURFACE
surface = cairo_svg_surface_create_for_stream (writer,
job, job->width, job->height);
#endif
break;
case FORMAT_CAIRO:
case FORMAT_PNG:
default:
if (job->width >= CAIRO_XMAX || job->height >= CAIRO_YMAX) {
double scale = MIN((double)CAIRO_XMAX / job->width,
(double)CAIRO_YMAX / job->height);
job->width *= scale;
job->height *= scale;
job->scale.x *= scale;
job->scale.y *= scale;
fprintf(stderr,
"%s: graph is too large for cairo-renderer bitmaps. Scaling by %g to fit\n",
job->common->cmdname, scale);
}
surface = cairo_image_surface_create (CAIRO_FORMAT_ARGB32,
job->width, job->height);
if (job->common->verbose)
fprintf(stderr,
"%s: allocating a %dK cairo image surface (%d x %d pixels)\n",
job->common->cmdname,
ROUND(job->width * job->height * 4 / 1024.),
job->width, job->height);
break;
}
status = cairo_surface_status(surface);
if (status != CAIRO_STATUS_SUCCESS) {
fprintf(stderr, "%s: failure to create cairo surface: %s\n",
job->common->cmdname,
cairo_status_to_string(status));
cairo_surface_destroy (surface);
return;
}
cr = cairo_create(surface);
cairo_surface_destroy (surface);
job->context = (void *) cr;
}
cairo_scale(cr, job->scale.x, job->scale.y);
cairo_rotate(cr, -job->rotation * M_PI / 180.);
cairo_translate(cr, job->translation.x, -job->translation.y);
cairo_rectangle(cr, job->clip.LL.x, - job->clip.LL.y,
job->clip.UR.x - job->clip.LL.x, - (job->clip.UR.y - job->clip.LL.y));
cairo_clip(cr);
/* cairo_set_line_join(cr, CAIRO_LINE_JOIN_ROUND); */
}
开发者ID:DanielEColi,项目名称:graphviz,代码行数:72,代码来源:gvrender_pango.c
示例16: setup_tile
void
setup_tile (gint w, gint h)
{
cairo_status_t status;
cairo_t* cr = NULL;
cairo_surface_t* cr_surf = NULL;
cairo_surface_t* tmp = NULL;
cairo_surface_t* dummy_surf = NULL;
cairo_surface_t* norm_surf = NULL;
cairo_surface_t* blur_surf = NULL;
gdouble width = (gdouble) w;
gdouble height = (gdouble) h;
raico_blur_t* blur = NULL;
cr_surf = cairo_image_surface_create (CAIRO_FORMAT_ARGB32,
3 * BUBBLE_SHADOW_SIZE,
3 * BUBBLE_SHADOW_SIZE);
status = cairo_surface_status (cr_surf);
if (status != CAIRO_STATUS_SUCCESS)
g_print ("Error: \"%s\"\n", cairo_status_to_string (status));
cr = cairo_create (cr_surf);
status = cairo_status (cr);
if (status != CAIRO_STATUS_SUCCESS)
{
cairo_surface_destroy (cr_surf);
g_print ("Error: \"%s\"\n", cairo_status_to_string (status));
}
// clear and render drop-shadow and bubble-background
cairo_scale (cr, 1.0f, 1.0f);
cairo_set_operator (cr, CAIRO_OPERATOR_CLEAR);
cairo_paint (cr);
cairo_set_operator (cr, CAIRO_OPERATOR_OVER);
if (g_composited)
{
draw_shadow (cr,
width,
height,
BUBBLE_SHADOW_SIZE,
CORNER_RADIUS);
cairo_set_operator (cr, CAIRO_OPERATOR_CLEAR);
draw_round_rect (cr,
1.0f,
(gdouble) BUBBLE_SHADOW_SIZE,
(gdouble) BUBBLE_SHADOW_SIZE,
(gdouble) CORNER_RADIUS,
(gdouble) (width - 2.0f * BUBBLE_SHADOW_SIZE),
(gdouble) (height - 2.0f* BUBBLE_SHADOW_SIZE));
cairo_fill (cr);
cairo_set_operator (cr, CAIRO_OPERATOR_OVER);
cairo_set_source_rgba (cr,
BUBBLE_BG_COLOR_R,
BUBBLE_BG_COLOR_G,
BUBBLE_BG_COLOR_B,
0.95f);
}
else
cairo_set_source_rgb (cr,
BUBBLE_BG_COLOR_R,
BUBBLE_BG_COLOR_G,
BUBBLE_BG_COLOR_B);
draw_round_rect (cr,
1.0f,
BUBBLE_SHADOW_SIZE,
BUBBLE_SHADOW_SIZE,
CORNER_RADIUS,
(gdouble) (width - 2.0f * BUBBLE_SHADOW_SIZE),
(gdouble) (height - 2.0f * BUBBLE_SHADOW_SIZE));
cairo_fill (cr);
tmp = cairo_image_surface_create_for_data (
cairo_image_surface_get_data (cr_surf),
cairo_image_surface_get_format (cr_surf),
3 * BUBBLE_SHADOW_SIZE,
3 * BUBBLE_SHADOW_SIZE,
cairo_image_surface_get_stride (cr_surf));
dummy_surf = copy_surface (tmp);
cairo_surface_destroy (tmp);
tmp = cairo_image_surface_create_for_data (
cairo_image_surface_get_data (dummy_surf),
cairo_image_surface_get_format (dummy_surf),
2 * BUBBLE_SHADOW_SIZE,
2 * BUBBLE_SHADOW_SIZE,
cairo_image_surface_get_stride (dummy_surf));
norm_surf = copy_surface (tmp);
cairo_surface_destroy (tmp);
blur = raico_blur_create (RAICO_BLUR_QUALITY_LOW);
raico_blur_set_radius (blur, 6);
raico_blur_apply (blur, dummy_surf);
raico_blur_destroy (blur);
tmp = cairo_image_surface_create_for_data (
cairo_image_surface_get_data (dummy_surf),
cairo_image_surface_get_format (dummy_surf),
2 * BUBBLE_SHADOW_SIZE,
2 * BUBBLE_SHADOW_SIZE,
//.........这里部分代码省略.........
开发者ID:am0c,项目名称:notifyosd-lucid,代码行数:101,代码来源:test-grow-bubble.c
示例17: BEGIN_METHOD_VOID
#include <cairo-pdf.h>
#include <cairo-ps.h>
#include <cairo-svg.h>
#include "c_surface.h"
BEGIN_METHOD_VOID(CairoSurface_free)
GB.FreeString(&THIS->path);
cairo
|
请发表评论