Andrew Eikum : gdiplus: Implement GdipIsVisiblePoint.

Alexandre Julliard julliard at winehq.org
Thu Aug 27 10:31:32 CDT 2009


Module: wine
Branch: master
Commit: d06dd2d7cb1511c15a5bc71a68caa656f418ba47
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=d06dd2d7cb1511c15a5bc71a68caa656f418ba47

Author: Andrew Eikum <aeikum at codeweavers.com>
Date:   Wed Aug 26 18:03:11 2009 -0500

gdiplus: Implement GdipIsVisiblePoint.

---

 dlls/gdiplus/graphics.c       |   34 +++++---
 dlls/gdiplus/tests/graphics.c |  180 +++++++++++++++++++++++++++++++++++++++++
 2 files changed, 203 insertions(+), 11 deletions(-)

diff --git a/dlls/gdiplus/graphics.c b/dlls/gdiplus/graphics.c
index 297393a..3d35f74 100644
--- a/dlls/gdiplus/graphics.c
+++ b/dlls/gdiplus/graphics.c
@@ -3252,7 +3252,11 @@ GpStatus WINGDIPAPI GdipIsClipEmpty(GpGraphics *graphics, BOOL *res)
 
 GpStatus WINGDIPAPI GdipIsVisiblePoint(GpGraphics *graphics, REAL x, REAL y, BOOL *result)
 {
-    FIXME("(%p, %.2f, %.2f, %p) stub\n", graphics, x, y, result);
+    GpStatus stat;
+    GpRegion* rgn;
+    GpPointF pt;
+
+    TRACE("(%p, %.2f, %.2f, %p)\n", graphics, x, y, result);
 
     if(!graphics || !result)
         return InvalidParameter;
@@ -3260,20 +3264,28 @@ GpStatus WINGDIPAPI GdipIsVisiblePoint(GpGraphics *graphics, REAL x, REAL y, BOO
     if(graphics->busy)
         return ObjectBusy;
 
-    return NotImplemented;
-}
+    pt.X = x;
+    pt.Y = y;
+    if((stat = GdipTransformPoints(graphics, CoordinateSpaceDevice,
+                   CoordinateSpaceWorld, &pt, 1)) != Ok)
+        return stat;
 
-GpStatus WINGDIPAPI GdipIsVisiblePointI(GpGraphics *graphics, INT x, INT y, BOOL *result)
-{
-    FIXME("(%p, %d, %d, %p) stub\n", graphics, x, y, result);
+    if((stat = GdipCreateRegion(&rgn)) != Ok)
+        return stat;
 
-    if(!graphics || !result)
-        return InvalidParameter;
+    if((stat = get_visible_clip_region(graphics, rgn)) != Ok)
+        goto cleanup;
 
-    if(graphics->busy)
-        return ObjectBusy;
+    stat = GdipIsVisibleRegionPoint(rgn, pt.X, pt.Y, graphics, result);
 
-    return NotImplemented;
+cleanup:
+    GdipDeleteRegion(rgn);
+    return stat;
+}
+
+GpStatus WINGDIPAPI GdipIsVisiblePointI(GpGraphics *graphics, INT x, INT y, BOOL *result)
+{
+    return GdipIsVisiblePoint(graphics, (REAL)x, (REAL)y, result);
 }
 
 GpStatus WINGDIPAPI GdipMeasureCharacterRanges(GpGraphics* graphics,
diff --git a/dlls/gdiplus/tests/graphics.c b/dlls/gdiplus/tests/graphics.c
index 26794d8..f74f7af 100644
--- a/dlls/gdiplus/tests/graphics.c
+++ b/dlls/gdiplus/tests/graphics.c
@@ -1928,6 +1928,185 @@ static void test_fromMemoryBitmap(void)
     GdipDisposeImage((GpImage*)bitmap);
 }
 
+static void test_GdipIsVisiblePoint(void)
+{
+    GpStatus status;
+    GpGraphics *graphics = NULL;
+    HDC hdc = GetDC(0);
+    REAL x, y;
+    BOOL val;
+
+    ok(hdc != NULL, "Expected HDC to be initialized\n");
+
+    status = GdipCreateFromHDC(hdc, &graphics);
+    expect(Ok, status);
+    ok(graphics != NULL, "Expected graphics to be initialized\n");
+
+    /* null parameters */
+    status = GdipIsVisiblePoint(NULL, 0, 0, &val);
+    expect(InvalidParameter, status);
+
+    status = GdipIsVisiblePoint(graphics, 0, 0, NULL);
+    expect(InvalidParameter, status);
+
+    status = GdipIsVisiblePointI(NULL, 0, 0, &val);
+    expect(InvalidParameter, status);
+
+    status = GdipIsVisiblePointI(graphics, 0, 0, NULL);
+    expect(InvalidParameter, status);
+
+    x = 0;
+    y = 0;
+    status = GdipIsVisiblePoint(graphics, x, y, &val);
+    expect(Ok, status);
+    ok(val == TRUE, "Expected (%.2f, %.2f) to be visible\n", x, y);
+
+    x = -10;
+    y = 0;
+    status = GdipIsVisiblePoint(graphics, x, y, &val);
+    expect(Ok, status);
+    ok(val == FALSE, "Expected (%.2f, %.2f) not to be visible\n", x, y);
+
+    x = 0;
+    y = -5;
+    status = GdipIsVisiblePoint(graphics, x, y, &val);
+    expect(Ok, status);
+    ok(val == FALSE, "Expected (%.2f, %.2f) not to be visible\n", x, y);
+
+    x = 1;
+    y = 1;
+    status = GdipIsVisiblePoint(graphics, x, y, &val);
+    expect(Ok, status);
+    ok(val == TRUE, "Expected (%.2f, %.2f) to be visible\n", x, y);
+
+    status = GdipSetClipRect(graphics, 10, 20, 30, 40, CombineModeReplace);
+    expect(Ok, status);
+
+    x = 1;
+    y = 1;
+    status = GdipIsVisiblePoint(graphics, x, y, &val);
+    expect(Ok, status);
+    ok(val == FALSE, "After clipping, expected (%.2f, %.2f) not to be visible\n", x, y);
+
+    x = 15.5;
+    y = 40.5;
+    status = GdipIsVisiblePoint(graphics, x, y, &val);
+    expect(Ok, status);
+    ok(val == TRUE, "After clipping, expected (%.2f, %.2f) to be visible\n", x, y);
+
+    /* translate into the center of the rect */
+    GdipTranslateWorldTransform(graphics, 25, 40, MatrixOrderAppend);
+
+    x = 0;
+    y = 0;
+    status = GdipIsVisiblePoint(graphics, x, y, &val);
+    expect(Ok, status);
+    ok(val == TRUE, "Expected (%.2f, %.2f) to be visible\n", x, y);
+
+    x = 25;
+    y = 40;
+    status = GdipIsVisiblePoint(graphics, x, y, &val);
+    expect(Ok, status);
+    ok(val == FALSE, "Expected (%.2f, %.2f) not to be visible\n", x, y);
+
+    GdipTranslateWorldTransform(graphics, -25, -40, MatrixOrderAppend);
+
+    /* corner cases */
+    x = 9;
+    y = 19;
+    status = GdipIsVisiblePoint(graphics, x, y, &val);
+    expect(Ok, status);
+    ok(val == FALSE, "After clipping, expected (%.2f, %.2f) not to be visible\n", x, y);
+
+    x = 9.25;
+    y = 19.25;
+    status = GdipIsVisiblePoint(graphics, x, y, &val);
+    expect(Ok, status);
+    ok(val == FALSE, "After clipping, expected (%.2f, %.2f) not to be visible\n", x, y);
+
+    x = 9.5;
+    y = 19.5;
+    status = GdipIsVisiblePoint(graphics, x, y, &val);
+    expect(Ok, status);
+    ok(val == TRUE, "After clipping, expected (%.2f, %.2f) to be visible\n", x, y);
+
+    x = 9.75;
+    y = 19.75;
+    status = GdipIsVisiblePoint(graphics, x, y, &val);
+    expect(Ok, status);
+    ok(val == TRUE, "After clipping, expected (%.2f, %.2f) to be visible\n", x, y);
+
+    x = 10;
+    y = 20;
+    status = GdipIsVisiblePoint(graphics, x, y, &val);
+    expect(Ok, status);
+    ok(val == TRUE, "After clipping, expected (%.2f, %.2f) to be visible\n", x, y);
+
+    x = 40;
+    y = 20;
+    status = GdipIsVisiblePoint(graphics, x, y, &val);
+    expect(Ok, status);
+    ok(val == FALSE, "After clipping, expected (%.2f, %.2f) not to be visible\n", x, y);
+
+    x = 39;
+    y = 59;
+    status = GdipIsVisiblePoint(graphics, x, y, &val);
+    expect(Ok, status);
+    ok(val == TRUE, "After clipping, expected (%.2f, %.2f) to be visible\n", x, y);
+
+    x = 39.25;
+    y = 59.25;
+    status = GdipIsVisiblePoint(graphics, x, y, &val);
+    expect(Ok, status);
+    ok(val == TRUE, "After clipping, expected (%.2f, %.2f) to be visible\n", x, y);
+
+    x = 39.5;
+    y = 39.5;
+    status = GdipIsVisiblePoint(graphics, x, y, &val);
+    expect(Ok, status);
+    ok(val == FALSE, "After clipping, expected (%.2f, %.2f) not to be visible\n", x, y);
+
+    x = 39.75;
+    y = 59.75;
+    status = GdipIsVisiblePoint(graphics, x, y, &val);
+    expect(Ok, status);
+    ok(val == FALSE, "After clipping, expected (%.2f, %.2f) not to be visible\n", x, y);
+
+    x = 40;
+    y = 60;
+    status = GdipIsVisiblePoint(graphics, x, y, &val);
+    expect(Ok, status);
+    ok(val == FALSE, "After clipping, expected (%.2f, %.2f) not to be visible\n", x, y);
+
+    x = 40.15;
+    y = 60.15;
+    status = GdipIsVisiblePoint(graphics, x, y, &val);
+    expect(Ok, status);
+    ok(val == FALSE, "After clipping, expected (%.2f, %.2f) not to be visible\n", x, y);
+
+    x = 10;
+    y = 60;
+    status = GdipIsVisiblePoint(graphics, x, y, &val);
+    expect(Ok, status);
+    ok(val == FALSE, "After clipping, expected (%.2f, %.2f) not to be visible\n", x, y);
+
+    /* integer version */
+    x = 25;
+    y = 30;
+    status = GdipIsVisiblePointI(graphics, (INT)x, (INT)y, &val);
+    expect(Ok, status);
+    ok(val == TRUE, "After clipping, expected (%.2f, %.2f) to be visible\n", x, y);
+
+    x = 50;
+    y = 100;
+    status = GdipIsVisiblePointI(graphics, (INT)x, (INT)y, &val);
+    expect(Ok, status);
+    ok(val == FALSE, "After clipping, expected (%.2f, %.2f) not to be visible\n", x, y);
+
+    GdipDeleteGraphics(graphics);
+    ReleaseDC(0, hdc);
+}
+
 START_TEST(graphics)
 {
     struct GdiplusStartupInput gdiplusStartupInput;
@@ -1955,6 +2134,7 @@ START_TEST(graphics)
     test_GdipDrawLinesI();
     test_GdipDrawString();
     test_GdipGetVisibleClipBounds();
+    test_GdipIsVisiblePoint();
     test_Get_Release_DC();
     test_BeginContainer2();
     test_transformpoints();




More information about the wine-cvs mailing list