From 74dc990bbffa268f5fbd76618bbd8975737b57c5 Mon Sep 17 00:00:00 2001 From: Nikolay Sivov Date: Wed, 23 Jul 2008 02:07:28 +0400 Subject: [PATCH] gdiplus: Implemented GdipGetPathGradientRect with test. --- dlls/gdiplus/brush.c | 45 ++++++++++++++++++++++++++++++++++++++ dlls/gdiplus/gdiplus.spec | 4 ++-- dlls/gdiplus/tests/brush.c | 31 ++++++++++++++++++++++++++ include/gdiplusflat.h | 2 ++ 4 files changed, 80 insertions(+), 2 deletions(-) diff --git a/dlls/gdiplus/brush.c b/dlls/gdiplus/brush.c index 7e4ac9e58cb..13cd3abdf05 100644 --- a/dlls/gdiplus/brush.c +++ b/dlls/gdiplus/brush.c @@ -641,6 +641,51 @@ GpStatus WINGDIPAPI GdipGetPathGradientPointCount(GpPathGradient *grad, return Ok; } +GpStatus WINGDIPAPI GdipGetPathGradientRect(GpPathGradient *brush, GpRectF *rect) +{ + GpRectF r; + GpPath* path; + GpStatus stat; + + if(!brush || !rect) + return InvalidParameter; + + stat = GdipCreatePath2(brush->pathdata.Points, brush->pathdata.Types, + brush->pathdata.Count, FillModeAlternate, &path); + if(stat != Ok) return stat; + + stat = GdipGetPathWorldBounds(path, &r, NULL, NULL); + if(stat != Ok){ + GdipDeletePath(path); + return stat; + } + + memcpy(rect, &r, sizeof(GpRectF)); + + GdipDeletePath(path); + + return Ok; +} + +GpStatus WINGDIPAPI GdipGetPathGradientRectI(GpPathGradient *brush, GpRect *rect) +{ + GpRectF rectf; + GpStatus stat; + + if(!brush || !rect) + return InvalidParameter; + + stat = GdipGetPathGradientRect(brush, &rectf); + if(stat != Ok) return stat; + + rect->X = roundr(rectf.X); + rect->Y = roundr(rectf.Y); + rect->Width = roundr(rectf.Width); + rect->Height = roundr(rectf.Height); + + return Ok; +} + GpStatus WINGDIPAPI GdipGetPathGradientSurroundColorsWithCount(GpPathGradient *grad, ARGB *argb, INT *count) { diff --git a/dlls/gdiplus/gdiplus.spec b/dlls/gdiplus/gdiplus.spec index 4bfc93a7ccf..cbbc9c37988 100644 --- a/dlls/gdiplus/gdiplus.spec +++ b/dlls/gdiplus/gdiplus.spec @@ -336,8 +336,8 @@ @ stdcall GdipGetPathGradientPointCount(ptr ptr) @ stub GdipGetPathGradientPresetBlend @ stub GdipGetPathGradientPresetBlendCount -@ stub GdipGetPathGradientRect -@ stub GdipGetPathGradientRectI +@ stdcall GdipGetPathGradientRect(ptr ptr) +@ stdcall GdipGetPathGradientRectI(ptr ptr) @ stub GdipGetPathGradientSurroundColorCount @ stdcall GdipGetPathGradientSurroundColorsWithCount(ptr ptr ptr) @ stub GdipGetPathGradientTransform diff --git a/dlls/gdiplus/tests/brush.c b/dlls/gdiplus/tests/brush.c index 1f7974442c0..5ef7fcaa0c6 100644 --- a/dlls/gdiplus/tests/brush.c +++ b/dlls/gdiplus/tests/brush.c @@ -115,6 +115,36 @@ static void test_getblend(void) GdipDeleteBrush((GpBrush*) brush); } +static GpPointF getbounds_ptf[] = {{0.0, 20.0}, + {50.0, 50.0}, + {21.0, 25.0}, + {25.0, 46.0}}; +static void test_getbounds(void) +{ + GpStatus status; + GpPathGradient *brush; + GpRectF bounds; + + status = GdipCreatePathGradient(getbounds_ptf, 4, WrapModeClamp, &brush); + expect(Ok, status); + + status = GdipGetPathGradientRect(NULL, NULL); + expect(InvalidParameter, status); + status = GdipGetPathGradientRect(brush, NULL); + expect(InvalidParameter, status); + status = GdipGetPathGradientRect(NULL, &bounds); + expect(InvalidParameter, status); + + status = GdipGetPathGradientRect(brush, &bounds); + expect(Ok, status); + expectf(0.0, bounds.X); + expectf(20.0, bounds.Y); + expectf(50.0, bounds.Width); + expectf(30.0, bounds.Height); + + GdipDeleteBrush((GpBrush*) brush); +} + START_TEST(brush) { struct GdiplusStartupInput gdiplusStartupInput; @@ -131,6 +161,7 @@ START_TEST(brush) test_type(); test_gradientblendcount(); test_getblend(); + test_getbounds(); GdiplusShutdown(gdiplusToken); } diff --git a/include/gdiplusflat.h b/include/gdiplusflat.h index 8a683b7eae0..841a46ee1d3 100644 --- a/include/gdiplusflat.h +++ b/include/gdiplusflat.h @@ -207,6 +207,8 @@ GpStatus WINGDIPAPI GdipGetPathGradientCenterPointI(GpPathGradient*,GpPoint*); GpStatus WINGDIPAPI GdipGetPathGradientFocusScales(GpPathGradient*,REAL*,REAL*); GpStatus WINGDIPAPI GdipGetPathGradientGammaCorrection(GpPathGradient*,BOOL*); GpStatus WINGDIPAPI GdipGetPathGradientPointCount(GpPathGradient*,INT*); +GpStatus WINGDIPAPI GdipGetPathGradientRect(GpPathGradient*,GpRectF*); +GpStatus WINGDIPAPI GdipGetPathGradientRectI(GpPathGradient*,GpRect*); GpStatus WINGDIPAPI GdipGetPathGradientSurroundColorsWithCount(GpPathGradient*, ARGB*,INT*); GpStatus WINGDIPAPI GdipGetPathGradientWrapMode(GpPathGradient*,GpWrapMode*);