From fd8185132ee15873bb15404d8fcfcc699dd32879 Mon Sep 17 00:00:00 2001 From: Nikolay Sivov Date: Fri, 3 Nov 2017 09:49:15 +0300 Subject: [PATCH] gdiplus/metafile: Add brush object if needed in FillRectangles(). Signed-off-by: Nikolay Sivov Signed-off-by: Vincent Povirk Signed-off-by: Alexandre Julliard --- dlls/gdiplus/metafile.c | 141 ++++++++++++++++++++-------------------- 1 file changed, 71 insertions(+), 70 deletions(-) diff --git a/dlls/gdiplus/metafile.c b/dlls/gdiplus/metafile.c index 3a9c8a82198..f923a9be824 100644 --- a/dlls/gdiplus/metafile.c +++ b/dlls/gdiplus/metafile.c @@ -931,6 +931,74 @@ static BOOL is_integer_rect(const GpRectF *rect) return TRUE; } +static GpStatus METAFILE_PrepareBrushData(GpBrush *brush, DWORD *size) +{ + switch (brush->bt) + { + case BrushTypeSolidColor: + *size = FIELD_OFFSET(EmfPlusBrush, BrushData) + sizeof(EmfPlusSolidBrushData); + break; + case BrushTypeHatchFill: + *size = FIELD_OFFSET(EmfPlusBrush, BrushData) + sizeof(EmfPlusHatchBrushData); + break; + default: + FIXME("unsupported brush type: %d\n", brush->bt); + return NotImplemented; + } + + return Ok; +} + +static void METAFILE_FillBrushData(GpBrush *brush, EmfPlusBrush *data) +{ + data->Version = VERSION_MAGIC2; + data->Type = brush->bt; + + switch (brush->bt) + { + case BrushTypeSolidColor: + { + GpSolidFill *solid = (GpSolidFill *)brush; + data->BrushData.solid.SolidColor = solid->color; + break; + } + case BrushTypeHatchFill: + { + GpHatch *hatch = (GpHatch *)brush; + data->BrushData.hatch.HatchStyle = hatch->hatchstyle; + data->BrushData.hatch.ForeColor = hatch->forecol; + data->BrushData.hatch.BackColor = hatch->backcol; + break; + } + default: + FIXME("unsupported brush type: %d\n", brush->bt); + } +} + +static GpStatus METAFILE_AddBrushObject(GpMetafile *metafile, GpBrush *brush, DWORD *id) +{ + EmfPlusObject *object_record; + GpStatus stat; + DWORD size; + + *id = -1; + if (metafile->metafile_type != MetafileTypeEmfPlusOnly && metafile->metafile_type != MetafileTypeEmfPlusDual) + return Ok; + + stat = METAFILE_PrepareBrushData(brush, &size); + if (stat != Ok) return stat; + + stat = METAFILE_AllocateRecord(metafile, + FIELD_OFFSET(EmfPlusObject, ObjectData) + size, (void**)&object_record); + if (stat != Ok) return stat; + + *id = METAFILE_AddObjectId(metafile); + object_record->Header.Type = EmfPlusRecordTypeObject; + object_record->Header.Flags = *id | ObjectTypeBrush << 8; + METAFILE_FillBrushData(brush, &object_record->ObjectData.brush); + return Ok; +} + GpStatus METAFILE_FillRectangles(GpMetafile* metafile, GpBrush* brush, GDIPCONST GpRectF* rects, INT count) { @@ -950,8 +1018,9 @@ GpStatus METAFILE_FillRectangles(GpMetafile* metafile, GpBrush* brush, } else { - FIXME("brush serialization not implemented\n"); - return NotImplemented; + stat = METAFILE_AddBrushObject(metafile, brush, &brushid); + if (stat != Ok) + return stat; } for (i=0; ibt) - { - case BrushTypeSolidColor: - *size = FIELD_OFFSET(EmfPlusBrush, BrushData) + sizeof(EmfPlusSolidBrushData); - break; - case BrushTypeHatchFill: - *size = FIELD_OFFSET(EmfPlusBrush, BrushData) + sizeof(EmfPlusHatchBrushData); - break; - default: - FIXME("unsupported brush type: %d\n", brush->bt); - return NotImplemented; - } - - return Ok; -} - -static void METAFILE_FillBrushData(GpBrush *brush, EmfPlusBrush *data) -{ - data->Version = VERSION_MAGIC2; - data->Type = brush->bt; - - switch (brush->bt) - { - case BrushTypeSolidColor: - { - GpSolidFill *solid = (GpSolidFill *)brush; - data->BrushData.solid.SolidColor = solid->color; - break; - } - case BrushTypeHatchFill: - { - GpHatch *hatch = (GpHatch *)brush; - data->BrushData.hatch.HatchStyle = hatch->hatchstyle; - data->BrushData.hatch.ForeColor = hatch->forecol; - data->BrushData.hatch.BackColor = hatch->backcol; - break; - } - default: - FIXME("unsupported brush type: %d\n", brush->bt); - } -} - static GpStatus METAFILE_AddPenObject(GpMetafile *metafile, GpPen *pen, DWORD *id) { DWORD i, data_flags, pen_data_size, brush_size; @@ -4228,30 +4253,6 @@ GpStatus METAFILE_DrawPath(GpMetafile *metafile, GpPen *pen, GpPath *path) return Ok; } -static GpStatus METAFILE_AddBrushObject(GpMetafile *metafile, GpBrush *brush, DWORD *id) -{ - EmfPlusObject *object_record; - GpStatus stat; - DWORD size; - - *id = -1; - if (metafile->metafile_type != MetafileTypeEmfPlusOnly && metafile->metafile_type != MetafileTypeEmfPlusDual) - return Ok; - - stat = METAFILE_PrepareBrushData(brush, &size); - if (stat != Ok) return stat; - - stat = METAFILE_AllocateRecord(metafile, - FIELD_OFFSET(EmfPlusObject, ObjectData) + size, (void**)&object_record); - if (stat != Ok) return stat; - - *id = METAFILE_AddObjectId(metafile); - object_record->Header.Type = EmfPlusRecordTypeObject; - object_record->Header.Flags = *id | ObjectTypeBrush << 8; - METAFILE_FillBrushData(brush, &object_record->ObjectData.brush); - return Ok; -} - GpStatus METAFILE_FillPath(GpMetafile *metafile, GpBrush *brush, GpPath *path) { EmfPlusFillPath *fill_path_record;