Re: [1/2] gdiplus: Implement GdipGetVisibleClipBounds

2009-08-12 Thread Henri Verbeet
2009/8/12 Andrew Eikum aei...@codeweavers.com:
 +GpStatus stat = Ok;
The initialization is redundant, since you always initialize stat
before using it.

 +if((stat = GdipCreateRegionRect(wnd_rectf, wnd_rgn) != Ok))
 +return stat;
I don't think that does what you want it to do.




Re: [1/2] gdiplus: Implement GdipGetVisibleClipBounds

2009-08-12 Thread Andrew Eikum

Henri Verbeet wrote:

2009/8/12 Andrew Eikum aei...@codeweavers.com:

+GpStatus stat = Ok;

The initialization is redundant, since you always initialize stat
before using it.


+if((stat = GdipCreateRegionRect(wnd_rectf, wnd_rgn) != Ok))
+return stat;

I don't think that does what you want it to do.


Thanks for the reply. Does this sit better with you?
diff --git a/dlls/gdiplus/gdiplus.spec b/dlls/gdiplus/gdiplus.spec
index 8863c37..51c6d06 100644
--- a/dlls/gdiplus/gdiplus.spec
+++ b/dlls/gdiplus/gdiplus.spec
@@ -400,7 +400,7 @@
 @ stub GdipGetTextureImage
 @ stdcall GdipGetTextureTransform(ptr ptr)
 @ stdcall GdipGetTextureWrapMode(ptr ptr)
-@ stub GdipGetVisibleClipBounds
+@ stdcall GdipGetVisibleClipBounds(ptr ptr)
 @ stdcall GdipGetVisibleClipBoundsI(ptr ptr)
 @ stdcall GdipGetWorldTransform(ptr ptr)
 @ stdcall GdipGraphicsClear(ptr long)
diff --git a/dlls/gdiplus/graphics.c b/dlls/gdiplus/graphics.c
index 10799c7..fde49f0 100644
--- a/dlls/gdiplus/graphics.c
+++ b/dlls/gdiplus/graphics.c
@@ -3102,6 +3102,71 @@ GpStatus WINGDIPAPI GdipGetTextRenderingHint(GpGraphics *graphics,
 return Ok;
 }
 
+GpStatus WINGDIPAPI GdipGetVisibleClipBounds(GpGraphics *graphics, GpRectF *rect)
+{
+GpRegion *clip_rgn;
+GpStatus stat;
+GpRectF wnd_rectf;
+RECT wnd_rect;
+
+TRACE((%p, %p)\n, graphics, rect);
+
+if(!graphics || !rect)
+return InvalidParameter;
+
+if(graphics-busy)
+return ObjectBusy;
+
+/* get window bounds */
+if(!GetClientRect(graphics-hwnd, wnd_rect))
+return GenericError;
+
+wnd_rectf.X = wnd_rect.left;
+wnd_rectf.Y = wnd_rect.top;
+wnd_rectf.Width = wnd_rect.right - wnd_rect.left;
+wnd_rectf.Height = wnd_rect.bottom - wnd_rect.top;
+
+/* intersect window and graphics clipping regions */
+if((stat = GdipCreateRegion(clip_rgn)) != Ok)
+return stat;
+
+if((stat = GdipCombineRegionRect(clip_rgn, wnd_rectf, CombineModeIntersect)) != Ok)
+goto cleanup;
+
+if((stat = GdipCombineRegionRegion(clip_rgn, graphics-clip, CombineModeIntersect)) != Ok)
+goto cleanup;
+
+/* get bounds of the region */
+if((stat = GdipGetRegionBounds(clip_rgn, graphics, rect)) != Ok)
+goto cleanup;
+
+cleanup:
+GdipDeleteRegion(clip_rgn);
+
+return stat;
+}
+
+GpStatus WINGDIPAPI GdipGetVisibleClipBoundsI(GpGraphics *graphics, GpRect *rect)
+{
+GpRectF rectf;
+GpStatus stat;
+
+TRACE((%p, %p)\n, graphics, rect);
+
+if(!graphics || !rect)
+return InvalidParameter;
+
+if((stat = GdipGetVisibleClipBounds(graphics, rectf)) == Ok)
+{
+rect-X = roundr(rectf.X);
+rect-Y = roundr(rectf.Y);
+rect-Width  = roundr(rectf.Width);
+rect-Height = roundr(rectf.Height);
+}
+
+return stat;
+}
+
 GpStatus WINGDIPAPI GdipGetWorldTransform(GpGraphics *graphics, GpMatrix *matrix)
 {
 TRACE((%p, %p)\n, graphics, matrix);
@@ -4069,15 +4134,6 @@ GpStatus WINGDIPAPI GdipMeasureDriverString(GpGraphics *graphics, GDIPCONST UINT
 }
 
 /*
- * GdipGetVisibleClipBoundsI [gdipl...@]
- */
-GpStatus WINGDIPAPI GdipGetVisibleClipBoundsI(GpGraphics *graphics, GpRect *rect)
-{
-FIXME((%p %p): stub\n, graphics, rect);
-return NotImplemented;
-}
-
-/*
  * GdipDrawDriverString [gdipl...@]
  */
 GpStatus WINGDIPAPI GdipDrawDriverString(GpGraphics *graphics, GDIPCONST UINT16 *text, INT length,
diff --git a/include/gdiplusflat.h b/include/gdiplusflat.h
index 71101ce..704be0a 100644
--- a/include/gdiplusflat.h
+++ b/include/gdiplusflat.h
@@ -227,6 +227,8 @@ GpStatus WINGDIPAPI GdipGetTextContrast(GpGraphics*,UINT*);
 GpStatus WINGDIPAPI GdipGetTextRenderingHint(GpGraphics*,TextRenderingHint*);
 GpStatus WINGDIPAPI GdipGetWorldTransform(GpGraphics*,GpMatrix*);
 GpStatus WINGDIPAPI GdipGraphicsClear(GpGraphics*,ARGB);
+GpStatus WINGDIPAPI GdipGetVisibleClipBounds(GpGraphics*,GpRectF*);
+GpStatus WINGDIPAPI GdipGetVisibleClipBoundsI(GpGraphics*,GpRect*);
 GpStatus WINGDIPAPI GdipIsClipEmpty(GpGraphics*, BOOL*);
 GpStatus WINGDIPAPI GdipIsVisiblePoint(GpGraphics*,REAL,REAL,BOOL*);
 GpStatus WINGDIPAPI GdipIsVisiblePointI(GpGraphics*,INT,INT,BOOL*);



Re: [1/2] gdiplus: Implement GdipGetVisibleClipBounds

2009-08-12 Thread Vincent Povirk
 +/* get window bounds */
 +if(!GetClientRect(graphics-hwnd, wnd_rect))
 +return GenericError;

What if the Graphics object doesn't have a window?

-- 
Vincent Povirk