gdiplus: Give a nice warning when we try to draw to an HDC-less graphics.
This commit is contained in:
parent
5601860b76
commit
c3ca6be2b9
|
@ -94,10 +94,17 @@ static INT prepare_dc(GpGraphics *graphics, GpPen *pen)
|
||||||
{
|
{
|
||||||
HPEN gdipen;
|
HPEN gdipen;
|
||||||
REAL width;
|
REAL width;
|
||||||
INT save_state = SaveDC(graphics->hdc), i, numdashes;
|
INT save_state, i, numdashes;
|
||||||
GpPointF pt[2];
|
GpPointF pt[2];
|
||||||
DWORD dash_array[MAX_DASHLEN];
|
DWORD dash_array[MAX_DASHLEN];
|
||||||
|
|
||||||
|
if (!graphics->hdc)
|
||||||
|
{
|
||||||
|
FIXME("graphics object has no HDC\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
save_state = SaveDC(graphics->hdc);
|
||||||
|
|
||||||
EndPath(graphics->hdc);
|
EndPath(graphics->hdc);
|
||||||
|
|
||||||
if(pen->unit == UnitPixel){
|
if(pen->unit == UnitPixel){
|
||||||
|
@ -1973,6 +1980,11 @@ GpStatus WINGDIPAPI GdipDrawImagePointsRect(GpGraphics *graphics, GpImage *image
|
||||||
|
|
||||||
if (image->picture)
|
if (image->picture)
|
||||||
{
|
{
|
||||||
|
if (!graphics->hdc)
|
||||||
|
{
|
||||||
|
FIXME("graphics object has no HDC\n");
|
||||||
|
}
|
||||||
|
|
||||||
/* FIXME: partially implemented (only works for rectangular parallelograms) */
|
/* FIXME: partially implemented (only works for rectangular parallelograms) */
|
||||||
if(srcUnit == UnitInch)
|
if(srcUnit == UnitInch)
|
||||||
dx = dy = (REAL) INCH_HIMETRIC;
|
dx = dy = (REAL) INCH_HIMETRIC;
|
||||||
|
@ -2772,6 +2784,12 @@ GpStatus WINGDIPAPI GdipFillEllipse(GpGraphics *graphics, GpBrush *brush, REAL x
|
||||||
if(graphics->busy)
|
if(graphics->busy)
|
||||||
return ObjectBusy;
|
return ObjectBusy;
|
||||||
|
|
||||||
|
if(!graphics->hdc)
|
||||||
|
{
|
||||||
|
FIXME("graphics object has no HDC\n");
|
||||||
|
return Ok;
|
||||||
|
}
|
||||||
|
|
||||||
ptf[0].X = x;
|
ptf[0].X = x;
|
||||||
ptf[0].Y = y;
|
ptf[0].Y = y;
|
||||||
ptf[1].X = x + width;
|
ptf[1].X = x + width;
|
||||||
|
@ -2814,6 +2832,12 @@ GpStatus WINGDIPAPI GdipFillPath(GpGraphics *graphics, GpBrush *brush, GpPath *p
|
||||||
if(graphics->busy)
|
if(graphics->busy)
|
||||||
return ObjectBusy;
|
return ObjectBusy;
|
||||||
|
|
||||||
|
if(!graphics->hdc)
|
||||||
|
{
|
||||||
|
FIXME("graphics object has no HDC\n");
|
||||||
|
return Ok;
|
||||||
|
}
|
||||||
|
|
||||||
save_state = SaveDC(graphics->hdc);
|
save_state = SaveDC(graphics->hdc);
|
||||||
EndPath(graphics->hdc);
|
EndPath(graphics->hdc);
|
||||||
SetPolyFillMode(graphics->hdc, (path->fill == FillModeAlternate ? ALTERNATE
|
SetPolyFillMode(graphics->hdc, (path->fill == FillModeAlternate ? ALTERNATE
|
||||||
|
@ -2851,6 +2875,12 @@ GpStatus WINGDIPAPI GdipFillPie(GpGraphics *graphics, GpBrush *brush, REAL x,
|
||||||
if(graphics->busy)
|
if(graphics->busy)
|
||||||
return ObjectBusy;
|
return ObjectBusy;
|
||||||
|
|
||||||
|
if(!graphics->hdc)
|
||||||
|
{
|
||||||
|
FIXME("graphics object has no HDC\n");
|
||||||
|
return Ok;
|
||||||
|
}
|
||||||
|
|
||||||
save_state = SaveDC(graphics->hdc);
|
save_state = SaveDC(graphics->hdc);
|
||||||
EndPath(graphics->hdc);
|
EndPath(graphics->hdc);
|
||||||
|
|
||||||
|
@ -2890,6 +2920,12 @@ GpStatus WINGDIPAPI GdipFillPolygon(GpGraphics *graphics, GpBrush *brush,
|
||||||
if(graphics->busy)
|
if(graphics->busy)
|
||||||
return ObjectBusy;
|
return ObjectBusy;
|
||||||
|
|
||||||
|
if(!graphics->hdc)
|
||||||
|
{
|
||||||
|
FIXME("graphics object has no HDC\n");
|
||||||
|
return Ok;
|
||||||
|
}
|
||||||
|
|
||||||
ptf = GdipAlloc(count * sizeof(GpPointF));
|
ptf = GdipAlloc(count * sizeof(GpPointF));
|
||||||
pti = GdipAlloc(count * sizeof(POINT));
|
pti = GdipAlloc(count * sizeof(POINT));
|
||||||
if(!ptf || !pti){
|
if(!ptf || !pti){
|
||||||
|
@ -2937,6 +2973,12 @@ GpStatus WINGDIPAPI GdipFillPolygonI(GpGraphics *graphics, GpBrush *brush,
|
||||||
if(graphics->busy)
|
if(graphics->busy)
|
||||||
return ObjectBusy;
|
return ObjectBusy;
|
||||||
|
|
||||||
|
if(!graphics->hdc)
|
||||||
|
{
|
||||||
|
FIXME("graphics object has no HDC\n");
|
||||||
|
return Ok;
|
||||||
|
}
|
||||||
|
|
||||||
ptf = GdipAlloc(count * sizeof(GpPointF));
|
ptf = GdipAlloc(count * sizeof(GpPointF));
|
||||||
pti = GdipAlloc(count * sizeof(POINT));
|
pti = GdipAlloc(count * sizeof(POINT));
|
||||||
if(!ptf || !pti){
|
if(!ptf || !pti){
|
||||||
|
@ -3002,6 +3044,12 @@ GpStatus WINGDIPAPI GdipFillRectangle(GpGraphics *graphics, GpBrush *brush,
|
||||||
if(graphics->busy)
|
if(graphics->busy)
|
||||||
return ObjectBusy;
|
return ObjectBusy;
|
||||||
|
|
||||||
|
if(!graphics->hdc)
|
||||||
|
{
|
||||||
|
FIXME("graphics object has no HDC\n");
|
||||||
|
return Ok;
|
||||||
|
}
|
||||||
|
|
||||||
ptf[0].X = x;
|
ptf[0].X = x;
|
||||||
ptf[0].Y = y;
|
ptf[0].Y = y;
|
||||||
ptf[1].X = x + width;
|
ptf[1].X = x + width;
|
||||||
|
@ -3042,6 +3090,12 @@ GpStatus WINGDIPAPI GdipFillRectangleI(GpGraphics *graphics, GpBrush *brush,
|
||||||
if(graphics->busy)
|
if(graphics->busy)
|
||||||
return ObjectBusy;
|
return ObjectBusy;
|
||||||
|
|
||||||
|
if(!graphics->hdc)
|
||||||
|
{
|
||||||
|
FIXME("graphics object has no HDC\n");
|
||||||
|
return Ok;
|
||||||
|
}
|
||||||
|
|
||||||
ptf[0].X = x;
|
ptf[0].X = x;
|
||||||
ptf[0].Y = y;
|
ptf[0].Y = y;
|
||||||
ptf[1].X = x + width;
|
ptf[1].X = x + width;
|
||||||
|
@ -3134,6 +3188,12 @@ GpStatus WINGDIPAPI GdipFillRegion(GpGraphics* graphics, GpBrush* brush,
|
||||||
if(graphics->busy)
|
if(graphics->busy)
|
||||||
return ObjectBusy;
|
return ObjectBusy;
|
||||||
|
|
||||||
|
if(!graphics->hdc)
|
||||||
|
{
|
||||||
|
FIXME("graphics object has no HDC\n");
|
||||||
|
return Ok;
|
||||||
|
}
|
||||||
|
|
||||||
status = GdipGetRegionHRgn(region, graphics, &hrgn);
|
status = GdipGetRegionHRgn(region, graphics, &hrgn);
|
||||||
if(status != Ok)
|
if(status != Ok)
|
||||||
return status;
|
return status;
|
||||||
|
@ -3744,6 +3804,12 @@ GpStatus WINGDIPAPI GdipMeasureCharacterRanges(GpGraphics* graphics,
|
||||||
if (regionCount < stringFormat->range_count)
|
if (regionCount < stringFormat->range_count)
|
||||||
return InvalidParameter;
|
return InvalidParameter;
|
||||||
|
|
||||||
|
if(!graphics->hdc)
|
||||||
|
{
|
||||||
|
FIXME("graphics object has no HDC\n");
|
||||||
|
return NotImplemented;
|
||||||
|
}
|
||||||
|
|
||||||
if (stringFormat->attr)
|
if (stringFormat->attr)
|
||||||
TRACE("may be ignoring some format flags: attr %x\n", stringFormat->attr);
|
TRACE("may be ignoring some format flags: attr %x\n", stringFormat->attr);
|
||||||
|
|
||||||
|
@ -3813,6 +3879,12 @@ GpStatus WINGDIPAPI GdipMeasureString(GpGraphics *graphics,
|
||||||
if(!graphics || !string || !font || !rect || !bounds)
|
if(!graphics || !string || !font || !rect || !bounds)
|
||||||
return InvalidParameter;
|
return InvalidParameter;
|
||||||
|
|
||||||
|
if(!graphics->hdc)
|
||||||
|
{
|
||||||
|
FIXME("graphics object has no HDC\n");
|
||||||
|
return NotImplemented;
|
||||||
|
}
|
||||||
|
|
||||||
if(linesfilled) *linesfilled = 0;
|
if(linesfilled) *linesfilled = 0;
|
||||||
if(codepointsfitted) *codepointsfitted = 0;
|
if(codepointsfitted) *codepointsfitted = 0;
|
||||||
|
|
||||||
|
@ -3886,6 +3958,12 @@ GpStatus WINGDIPAPI GdipDrawString(GpGraphics *graphics, GDIPCONST WCHAR *string
|
||||||
return NotImplemented;
|
return NotImplemented;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(!graphics->hdc)
|
||||||
|
{
|
||||||
|
FIXME("graphics object has no HDC\n");
|
||||||
|
return NotImplemented;
|
||||||
|
}
|
||||||
|
|
||||||
if(format){
|
if(format){
|
||||||
TRACE("may be ignoring some format flags: attr %x\n", format->attr);
|
TRACE("may be ignoring some format flags: attr %x\n", format->attr);
|
||||||
|
|
||||||
|
@ -4549,6 +4627,13 @@ GpStatus WINGDIPAPI GdipGetDC(GpGraphics *graphics, HDC *hdc)
|
||||||
if(graphics->busy)
|
if(graphics->busy)
|
||||||
return ObjectBusy;
|
return ObjectBusy;
|
||||||
|
|
||||||
|
if (!graphics->hdc)
|
||||||
|
{
|
||||||
|
WARN("no HDC for this graphics\n");
|
||||||
|
*hdc = NULL;
|
||||||
|
return GenericError;
|
||||||
|
}
|
||||||
|
|
||||||
*hdc = graphics->hdc;
|
*hdc = graphics->hdc;
|
||||||
graphics->busy = TRUE;
|
graphics->busy = TRUE;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue