switch (format) { default: case CAIRO_FORMAT_INVALID: case CAIRO_FORMAT_RGB16_565: case CAIRO_FORMAT_RGB30: case CAIRO_FORMAT_RGB96F: case CAIRO_FORMAT_RGBA128F: return _cairo_error (CAIRO_STATUS_INVALID_FORMAT); case CAIRO_FORMAT_ARGB32: case CAIRO_FORMAT_RGB24:
num_palette = 0; break;
switch (format) { case CAIRO_FORMAT_INVALID: case CAIRO_FORMAT_RGB16_565: case CAIRO_FORMAT_RGB30: case CAIRO_FORMAT_RGB96F: case CAIRO_FORMAT_RGBA128F:
ASSERT_NOT_REACHED; /* We can't create real RGB24 bitmaps because something seems to *breakifwedo,especiallyifwedon'tsetupanimage *fallback.Itcouldbeabugwithusinga24bpppixmanimage *(andcreatingonewithmasks).Sotreatthemlike32bpp. *Note:ThiscausesproblemswhenusingBitBlt/AlphaBlend/etc! *seeendoffile.
*/ case CAIRO_FORMAT_RGB24: case CAIRO_FORMAT_ARGB32:
bitmap_info->bmiHeader.biBitCount = 32;
bitmap_info->bmiHeader.biCompression = BI_RGB;
bitmap_info->bmiHeader.biClrUsed = 0; /* unused */
bitmap_info->bmiHeader.biClrImportant = 0; break;
for (i = 0; i < 2; i++) {
bitmap_info->bmiColors[i].rgbBlue = i * 255;
bitmap_info->bmiColors[i].rgbGreen = i * 255;
bitmap_info->bmiColors[i].rgbRed = i * 255;
bitmap_info->bmiColors[i].rgbReserved = 0;
} break;
}
if (bitmap_info && num_palette > 2)
free (bitmap_info);
if (bits_out)
*bits_out = bits;
if (rowstride_out) { /* Windows bitmaps are padded to 32-bit (dword) boundaries */ switch (format) { case CAIRO_FORMAT_INVALID: case CAIRO_FORMAT_RGB16_565: case CAIRO_FORMAT_RGB30: case CAIRO_FORMAT_RGB96F: case CAIRO_FORMAT_RGBA128F:
ASSERT_NOT_REACHED; case CAIRO_FORMAT_ARGB32: case CAIRO_FORMAT_RGB24:
*rowstride_out = 4 * width; break;
case CAIRO_FORMAT_A8:
*rowstride_out = (width + 3) & ~3; break;
static cairo_surface_t *
_cairo_win32_display_surface_create_similar (void *abstract_src,
cairo_content_t content, int width, int height)
{
cairo_win32_display_surface_t *src = abstract_src;
cairo_format_t format = _cairo_format_from_content (content);
cairo_surface_t *new_surf = NULL;
/* We force a DIB always if: *-weneedalpha;or *-theparentisaDIB;or *-theparentisforprinting(becausewedon'tcareaboutthe *bitdepthatthatpoint) * *WealsomightendupwithaDIBevenifaDDBisrequestedif *DDBcreationfailedduetooutofmemory.
*/ if (!(src->is_dib || content & CAIRO_CONTENT_ALPHA)) { /* try to create a ddb */
new_surf = cairo_win32_surface_create_with_ddb (src->win32.dc, CAIRO_FORMAT_RGB24, width, height);
if (new_surf->status)
new_surf = NULL;
}
if (new_surf == NULL) {
new_surf = _cairo_win32_display_surface_create_for_dc (src->win32.dc, format, width, height);
}
return new_surf;
}
static cairo_surface_t *
_cairo_win32_display_surface_create_similar_image (void *abstract_other,
cairo_format_t format, int width, int height)
{
cairo_win32_display_surface_t *surface = abstract_other;
cairo_image_surface_t *image;
surface = (cairo_win32_display_surface_t *)
_cairo_win32_display_surface_create_for_dc (surface->win32.dc,
format, width, height); if (surface->win32.base.status) return &surface->win32.base;
/* And clear in order to comply with our user API semantics */
image = (cairo_image_surface_t *) surface->image; if (! image->base.is_clear) {
memset (image->data, 0, image->stride * height);
image->base.is_clear = TRUE;
}
if (surface->image && to_image_surface(surface->image)->parent) {
assert (to_image_surface(surface->image)->parent == &surface->win32.base); /* Unhook ourselves first to avoid the double-unref from the image */
to_image_surface(surface->image)->parent = NULL;
cairo_surface_finish (surface->image);
cairo_surface_destroy (surface->image);
}
/* If we created the Bitmap and DC, destroy them */ if (surface->bitmap) {
SelectObject (surface->win32.dc, surface->saved_dc_bitmap);
DeleteObject (surface->bitmap);
DeleteDC (surface->win32.dc);
}
/* Delay the download until the next flush, which means we also need *tomakesureoursourcesrareflushed.
*/
TRACE ((stderr, "%s (surface=%d)\n",
__FUNCTION__, to_win32_surface(surface)->base.unique_id));
static cairo_status_t
_cairo_win32_display_surface_mark_dirty (void *abstract_surface, int x, int y, int width, int height)
{
_cairo_win32_display_surface_discard_fallback (abstract_surface); return CAIRO_STATUS_SUCCESS;
}
static cairo_int_status_t
_cairo_win32_save_initial_clip (HDC hdc, cairo_win32_display_surface_t *surface)
{
RECT rect; int clipBoxType; int gm;
XFORM saved_xform;
/* GetClipBox/GetClipRgn and friends interact badly with a world transform *set.GetClipBoxreturnsvaluesinlogical(transformed)coordinates; *it'sunclearwhatGetClipRgnreturns,becausetheregionisemptyinthe *caseofaSIMPLEREGIONclip,butIassumedevice(untransformed)coordinates. *Similarly,IntersectClipRectworksinlogicalunits,whereasSelectClipRgn *worksindeviceunits. * *So,avoidthewholemessandgetridoftheworldtransform *whilewestoreourinitialdataandwhenwerestoreinitialcoordinates. * *XXXwemayneedtomodifyx/ybytheViewportOrgorWindowOrg *hereinGM_COMPATIBLE;unclear.
*/
gm = GetGraphicsMode (hdc); if (gm == GM_ADVANCED) {
GetWorldTransform (hdc, &saved_xform);
ModifyWorldTransform (hdc, NULL, MWT_IDENTITY);
}
clipBoxType = GetClipBox (hdc, &rect); if (clipBoxType == ERROR) {
fprintf (stderr, "%s:%s\n", __FUNCTION__, "GetClipBox");
SetGraphicsMode (hdc, gm); /* XXX: Can we make a more reasonable guess at the error cause here? */ return _cairo_error (CAIRO_STATUS_DEVICE_ERROR);
}
if (gm == GM_ADVANCED)
SetWorldTransform (hdc, &saved_xform);
return CAIRO_STATUS_SUCCESS;
}
cairo_status_t
_cairo_win32_display_surface_set_clip (cairo_win32_display_surface_t *surface,
cairo_clip_t *clip)
{ char stack[512];
cairo_rectangle_int_t extents; int num_rects;
RGNDATA *data;
size_t data_size;
RECT *rects; int i;
HRGN gdi_region;
cairo_status_t status;
cairo_region_t *region;
/* The semantics we want is that any clip set by cairo combines *isintersectedwiththeclipondevicecontextthatthe *surfacewascreatedfor.Toimplementthis,weneedto *savetheoriginalclipwhenfirstsettingacliponsurface.
*/
assert (_cairo_clip_is_region (clip));
region = _cairo_clip_get_region (clip); if (region == NULL) return CAIRO_STATUS_SUCCESS;
if (!gdi_region) return _cairo_error (CAIRO_STATUS_NO_MEMORY);
/* AND the new region into our DC */
status = CAIRO_STATUS_SUCCESS; if (ExtSelectClipRgn (surface->win32.dc, gdi_region, RGN_AND) == ERROR) {
fprintf (stderr, "%s:%s\n", __FUNCTION__, "ExtSelectClipRgn");
status = _cairo_error (CAIRO_STATUS_WIN32_GDI_ERROR);
}
/* initial_clip_rgn will either be a real region or NULL (which means reset to no clip region) */
SelectClipRgn (surface->win32.dc, surface->initial_clip_rgn);
if (surface->had_simple_clip) { /* then if we had a simple clip, intersect */
IntersectClipRect (surface->win32.dc,
surface->win32.extents.x,
surface->win32.extents.y,
surface->win32.extents.x + surface->win32.extents.width,
surface->win32.extents.y + surface->win32.extents.height);
}
if (gm == GM_ADVANCED)
SetWorldTransform (surface->win32.dc, &saved_xform);
}
switch (format) { case CAIRO_FORMAT_INVALID: case CAIRO_FORMAT_A8: case CAIRO_FORMAT_A1: case CAIRO_FORMAT_RGB16_565: case CAIRO_FORMAT_RGB30: case CAIRO_FORMAT_RGB96F: case CAIRO_FORMAT_RGBA128F: default: return _cairo_surface_create_in_error (_cairo_error (CAIRO_STATUS_INVALID_FORMAT)); case CAIRO_FORMAT_ARGB32: case CAIRO_FORMAT_RGB24: break;
}
switch (format) { /* XXX handle these eventually */ case CAIRO_FORMAT_INVALID: case CAIRO_FORMAT_A8: case CAIRO_FORMAT_A1: case CAIRO_FORMAT_RGB16_565: case CAIRO_FORMAT_RGB30: case CAIRO_FORMAT_RGB96F: case CAIRO_FORMAT_RGBA128F: default: return _cairo_surface_create_in_error (_cairo_error (CAIRO_STATUS_INVALID_FORMAT)); case CAIRO_FORMAT_ARGB32: case CAIRO_FORMAT_RGB24: break;
}
/* Note that if an app actually does hit this out of memory *condition,it'sgoingtohavelotsofotherissues,as *videomemoryisprobablyexhausted.However,itcanoften *continueusingDIBsinsteadofDDBs.
*/
new_surf = (cairo_win32_display_surface_t*) _cairo_surface_create_in_error (_cairo_error (CAIRO_STATUS_NO_MEMORY)); goto FINISH;
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.