static void test_polygon(void) { GpStatus status; GpPath *path; GpPointF points[5]; points[0].X = 0.0; points[0].Y = 0.0; points[1].X = 10.0; points[1].Y = 10.0; points[2].X = 10.0; points[2].Y = 20.0; points[3].X = 30.0; points[3].Y = 10.0; points[4].X = 20.0; points[4].Y = 0.0; GdipCreatePath(FillModeAlternate, &path); /* NULL args */ status = GdipAddPathPolygon(NULL, points, 5); expect(InvalidParameter, status); status = GdipAddPathPolygon(path, NULL, 5); expect(InvalidParameter, status); /* Polygon should have 3 points at least */ status = GdipAddPathPolygon(path, points, 2); expect(InvalidParameter, status); /* to test how it prolongs not empty path */ status = GdipAddPathLine(path, 5.0, 5.0, 6.0, 8.0); expect(Ok, status); status = GdipAddPathPolygon(path, points, 5); expect(Ok, status); /* check resulting path */ ok_path(path, poly_path, sizeof(poly_path)/sizeof(path_test_t), FALSE); GdipDeletePath(path); }
GpStatus WINGDIPAPI GdipEnumerateMetafileSrcRectDestPoints(GpGraphics *graphics, GDIPCONST GpMetafile *metafile, GDIPCONST GpPointF *destPoints, INT count, GDIPCONST GpRectF *srcRect, Unit srcUnit, EnumerateMetafileProc callback, VOID *callbackData, GDIPCONST GpImageAttributes *imageAttributes) { struct enum_metafile_data data; GpStatus stat; GpMetafile *real_metafile = (GpMetafile*)metafile; /* whoever made this const was joking */ GraphicsContainer state; GpPath *dst_path; TRACE("(%p,%p,%p,%i,%p,%i,%p,%p,%p)\n", graphics, metafile, destPoints, count, srcRect, srcUnit, callback, callbackData, imageAttributes); if (!graphics || !metafile || !destPoints || count != 3 || !srcRect) return InvalidParameter; if (!metafile->hemf) return InvalidParameter; if (metafile->playback_graphics) return ObjectBusy; TRACE("%s %i -> %s %s %s\n", debugstr_rectf(srcRect), srcUnit, debugstr_pointf(&destPoints[0]), debugstr_pointf(&destPoints[1]), debugstr_pointf(&destPoints[2])); data.callback = callback; data.callback_data = callbackData; data.metafile = real_metafile; real_metafile->playback_graphics = graphics; real_metafile->playback_dc = NULL; real_metafile->src_rect = *srcRect; memcpy(real_metafile->playback_points, destPoints, sizeof(PointF) * 3); stat = GdipTransformPoints(graphics, CoordinateSpaceDevice, CoordinateSpaceWorld, real_metafile->playback_points, 3); if (stat == Ok) stat = GdipBeginContainer2(graphics, &state); if (stat == Ok) { stat = GdipSetPageScale(graphics, 1.0); if (stat == Ok) stat = GdipSetPageUnit(graphics, UnitPixel); if (stat == Ok) stat = GdipResetWorldTransform(graphics); if (stat == Ok) stat = GdipCreateRegion(&real_metafile->base_clip); if (stat == Ok) stat = GdipGetClip(graphics, real_metafile->base_clip); if (stat == Ok) stat = GdipCreatePath(FillModeAlternate, &dst_path); if (stat == Ok) { GpPointF clip_points[4]; clip_points[0] = real_metafile->playback_points[0]; clip_points[1] = real_metafile->playback_points[1]; clip_points[2].X = real_metafile->playback_points[1].X + real_metafile->playback_points[2].X - real_metafile->playback_points[0].X; clip_points[2].Y = real_metafile->playback_points[1].Y + real_metafile->playback_points[2].Y - real_metafile->playback_points[0].Y; clip_points[3] = real_metafile->playback_points[2]; stat = GdipAddPathPolygon(dst_path, clip_points, 4); if (stat == Ok) stat = GdipCombineRegionPath(real_metafile->base_clip, dst_path, CombineModeIntersect); GdipDeletePath(dst_path); } if (stat == Ok) stat = GdipCreateMatrix(&real_metafile->world_transform); if (stat == Ok) { real_metafile->page_unit = UnitDisplay; real_metafile->page_scale = 1.0; stat = METAFILE_PlaybackUpdateWorldTransform(real_metafile); } if (stat == Ok) { stat = METAFILE_PlaybackUpdateClip(real_metafile); } if (stat == Ok && (metafile->metafile_type == MetafileTypeEmf || metafile->metafile_type == MetafileTypeWmfPlaceable || metafile->metafile_type == MetafileTypeWmf)) stat = METAFILE_PlaybackGetDC(real_metafile); if (stat == Ok) EnumEnhMetaFile(0, metafile->hemf, enum_metafile_proc, &data, NULL); METAFILE_PlaybackReleaseDC(real_metafile); GdipDeleteMatrix(real_metafile->world_transform); real_metafile->world_transform = NULL; GdipDeleteRegion(real_metafile->base_clip); real_metafile->base_clip = NULL; GdipEndContainer(graphics, state); } real_metafile->playback_graphics = NULL; return stat; }