gdiplus: Implement GdipSetImageAttributesNoOp.

Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
Signed-off-by: Vincent Povirk <vincent@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Nikolay Sivov 2017-10-24 13:56:38 +03:00 committed by Alexandre Julliard
parent ef5a3ffe51
commit ab31b59f45
4 changed files with 148 additions and 6 deletions

View File

@ -481,6 +481,12 @@ struct color_remap_table{
ColorMap *colormap; ColorMap *colormap;
}; };
enum imageattr_noop{
IMAGEATTR_NOOP_UNDEFINED,
IMAGEATTR_NOOP_SET,
IMAGEATTR_NOOP_CLEAR,
};
struct GpImageAttributes{ struct GpImageAttributes{
WrapMode wrap; WrapMode wrap;
ARGB outside_color; ARGB outside_color;
@ -490,6 +496,7 @@ struct GpImageAttributes{
struct color_remap_table colorremaptables[ColorAdjustTypeCount]; struct color_remap_table colorremaptables[ColorAdjustTypeCount];
BOOL gamma_enabled[ColorAdjustTypeCount]; BOOL gamma_enabled[ColorAdjustTypeCount];
REAL gamma[ColorAdjustTypeCount]; REAL gamma[ColorAdjustTypeCount];
enum imageattr_noop noop[ColorAdjustTypeCount];
}; };
struct GpFont{ struct GpFont{

View File

@ -676,6 +676,11 @@ PixelFormat apply_image_attributes(const GpImageAttributes *attributes, LPBYTE d
UINT x, y; UINT x, y;
INT i; INT i;
if ((attributes->noop[type] == IMAGEATTR_NOOP_UNDEFINED &&
attributes->noop[ColorAdjustTypeDefault] == IMAGEATTR_NOOP_SET) ||
(attributes->noop[type] == IMAGEATTR_NOOP_SET))
return fmt;
if (attributes->colorkeys[type].enabled || if (attributes->colorkeys[type].enabled ||
attributes->colorkeys[ColorAdjustTypeDefault].enabled) attributes->colorkeys[ColorAdjustTypeDefault].enabled)
{ {

View File

@ -218,14 +218,14 @@ GpStatus WINGDIPAPI GdipSetImageAttributesGamma(GpImageAttributes *imageAttr,
GpStatus WINGDIPAPI GdipSetImageAttributesNoOp(GpImageAttributes *imageAttr, GpStatus WINGDIPAPI GdipSetImageAttributesNoOp(GpImageAttributes *imageAttr,
ColorAdjustType type, BOOL enableFlag) ColorAdjustType type, BOOL enableFlag)
{ {
static int calls;
TRACE("(%p,%u,%i)\n", imageAttr, type, enableFlag); TRACE("(%p,%u,%i)\n", imageAttr, type, enableFlag);
if(!(calls++)) if (type >= ColorAdjustTypeCount)
FIXME("not implemented\n"); return InvalidParameter;
return NotImplemented; imageAttr->noop[type] = enableFlag ? IMAGEATTR_NOOP_SET : IMAGEATTR_NOOP_CLEAR;
return Ok;
} }
GpStatus WINGDIPAPI GdipSetImageAttributesOutputChannel(GpImageAttributes *imageAttr, GpStatus WINGDIPAPI GdipSetImageAttributesOutputChannel(GpImageAttributes *imageAttr,
@ -332,6 +332,7 @@ GpStatus WINGDIPAPI GdipResetImageAttributes(GpImageAttributes *imageAttr,
GdipSetImageAttributesColorKeys(imageAttr, type, FALSE, 0, 0); GdipSetImageAttributesColorKeys(imageAttr, type, FALSE, 0, 0);
GdipSetImageAttributesRemapTable(imageAttr, type, FALSE, 0, NULL); GdipSetImageAttributesRemapTable(imageAttr, type, FALSE, 0, NULL);
GdipSetImageAttributesGamma(imageAttr, type, FALSE, 0.0); GdipSetImageAttributesGamma(imageAttr, type, FALSE, 0.0);
imageAttr->noop[type] = IMAGEATTR_NOOP_UNDEFINED;
return Ok; return Ok;
} }

View File

@ -2374,10 +2374,44 @@ static void test_colormatrix(void)
expect(Ok, stat); expect(Ok, stat);
ok(color_match(0xeeff40cc, color, 3), "expected 0xeeff40cc, got 0x%08x\n", color); ok(color_match(0xeeff40cc, color, 3), "expected 0xeeff40cc, got 0x%08x\n", color);
/* Toggle NoOp */
stat = GdipSetImageAttributesNoOp(imageattr, ColorAdjustTypeDefault, FALSE);
expect(Ok, stat);
stat = GdipDrawImageRectRectI(graphics, (GpImage *)bitmap1, 0, 0, 1, 1, 0, 0, 1, 1,
UnitPixel, imageattr, NULL, NULL);
expect(Ok, stat);
stat = GdipBitmapGetPixel(bitmap2, 0, 0, &color);
expect(Ok, stat);
ok(color_match(0xfefe40cc, color, 3), "expected 0xfefe40cc, got 0x%08x\n", color);
stat = GdipSetImageAttributesNoOp(imageattr, ColorAdjustTypeDefault, TRUE);
expect(Ok, stat);
stat = GdipDrawImageRectRectI(graphics, (GpImage *)bitmap1, 0, 0, 1, 1, 0, 0, 1, 1,
UnitPixel, imageattr, NULL, NULL);
expect(Ok, stat);
stat = GdipBitmapGetPixel(bitmap2, 0, 0, &color);
expect(Ok, stat);
ok(color_match(0xff40ccee, color, 3), "expected 0xff40ccee, got 0x%08x\n", color);
stat = GdipResetImageAttributes(imageattr, ColorAdjustTypeDefault); stat = GdipResetImageAttributes(imageattr, ColorAdjustTypeDefault);
expect(Ok, stat); expect(Ok, stat);
stat = GdipDrawImageRectRectI(graphics, (GpImage*)bitmap1, 0,0,1,1, 0,0,1,1, stat = GdipSetImageAttributesNoOp(imageattr, ColorAdjustTypeDefault, FALSE);
expect(Ok, stat);
stat = GdipDrawImageRectRectI(graphics, (GpImage *)bitmap1, 0, 0, 1, 1, 0, 0, 1, 1,
UnitPixel, imageattr, NULL, NULL);
expect(Ok, stat);
stat = GdipBitmapGetPixel(bitmap2, 0, 0, &color);
expect(Ok, stat);
ok(color_match(0xff40ccee, color, 3), "expected 0xff40ccee, got 0x%08x\n", color);
stat = GdipDrawImageRectRectI(graphics, (GpImage *)bitmap1, 0, 0, 1, 1, 0, 0, 1, 1,
UnitPixel, imageattr, NULL, NULL); UnitPixel, imageattr, NULL, NULL);
expect(Ok, stat); expect(Ok, stat);
@ -2385,6 +2419,101 @@ static void test_colormatrix(void)
expect(Ok, stat); expect(Ok, stat);
ok(color_match(0xff40ccee, color, 1), "Expected ff40ccee, got %.8x\n", color); ok(color_match(0xff40ccee, color, 1), "Expected ff40ccee, got %.8x\n", color);
/* Disable adjustment, toggle NoOp */
stat = GdipSetImageAttributesColorMatrix(imageattr, ColorAdjustTypeDefault,
FALSE, &colormatrix, NULL, ColorMatrixFlagsDefault);
expect(Ok, stat);
stat = GdipSetImageAttributesNoOp(imageattr, ColorAdjustTypeDefault, FALSE);
expect(Ok, stat);
stat = GdipDrawImageRectRectI(graphics, (GpImage *)bitmap1, 0, 0, 1, 1, 0, 0, 1, 1,
UnitPixel, imageattr, NULL, NULL);
expect(Ok, stat);
stat = GdipBitmapGetPixel(bitmap2, 0, 0, &color);
expect(Ok, stat);
ok(color_match(0xff40ccee, color, 3), "expected 0xff40ccee, got 0x%08x\n", color);
stat = GdipSetImageAttributesNoOp(imageattr, ColorAdjustTypeDefault, TRUE);
expect(Ok, stat);
stat = GdipDrawImageRectRectI(graphics, (GpImage *)bitmap1, 0, 0, 1, 1, 0, 0, 1, 1,
UnitPixel, imageattr, NULL, NULL);
expect(Ok, stat);
stat = GdipBitmapGetPixel(bitmap2, 0, 0, &color);
expect(Ok, stat);
ok(color_match(0xff40ccee, color, 3), "expected 0xff40ccee, got 0x%08x\n", color);
/* Reset with NoOp on, enable adjustment. */
stat = GdipResetImageAttributes(imageattr, ColorAdjustTypeDefault);
expect(Ok, stat);
stat = GdipSetImageAttributesColorMatrix(imageattr, ColorAdjustTypeDefault,
TRUE, &colormatrix, NULL, ColorMatrixFlagsDefault);
expect(Ok, stat);
stat = GdipDrawImageRectRectI(graphics, (GpImage *)bitmap1, 0, 0, 1, 1, 0, 0, 1, 1,
UnitPixel, imageattr, NULL, NULL);
expect(Ok, stat);
stat = GdipBitmapGetPixel(bitmap2, 0, 0, &color);
expect(Ok, stat);
ok(color_match(0xfff24ace, color, 3), "expected 0xfff24ace, got 0x%08x\n", color);
/* Now inhibit specific category. */
stat = GdipResetImageAttributes(imageattr, ColorAdjustTypeDefault);
expect(Ok, stat);
stat = GdipSetImageAttributesColorMatrix(imageattr, ColorAdjustTypeBitmap,
TRUE, &colormatrix, NULL, ColorMatrixFlagsDefault);
expect(Ok, stat);
stat = GdipDrawImageRectRectI(graphics, (GpImage *)bitmap1, 0, 0, 1, 1, 0, 0, 1, 1,
UnitPixel, imageattr, NULL, NULL);
expect(Ok, stat);
stat = GdipBitmapGetPixel(bitmap2, 0, 0, &color);
expect(Ok, stat);
ok(color_match(0xfffe41cc, color, 3), "expected 0xfffe41cc, got 0x%08x\n", color);
stat = GdipSetImageAttributesNoOp(imageattr, ColorAdjustTypeBitmap, TRUE);
expect(Ok, stat);
stat = GdipDrawImageRectRectI(graphics, (GpImage *)bitmap1, 0, 0, 1, 1, 0, 0, 1, 1,
UnitPixel, imageattr, NULL, NULL);
expect(Ok, stat);
stat = GdipBitmapGetPixel(bitmap2, 0, 0, &color);
expect(Ok, stat);
ok(color_match(0xff40ccee, color, 3), "expected 0xff40ccee, got 0x%08x\n", color);
stat = GdipSetImageAttributesNoOp(imageattr, ColorAdjustTypeBitmap, FALSE);
expect(Ok, stat);
stat = GdipSetImageAttributesNoOp(imageattr, ColorAdjustTypeDefault, TRUE);
expect(Ok, stat);
stat = GdipDrawImageRectRectI(graphics, (GpImage *)bitmap1, 0, 0, 1, 1, 0, 0, 1, 1,
UnitPixel, imageattr, NULL, NULL);
expect(Ok, stat);
stat = GdipBitmapGetPixel(bitmap2, 0, 0, &color);
expect(Ok, stat);
ok(color_match(0xfff24ace, color, 3), "expected 0xfff24ace, got 0x%08x\n", color);
stat = GdipResetImageAttributes(imageattr, ColorAdjustTypeBitmap);
expect(Ok, stat);
stat = GdipDrawImageRectRectI(graphics, (GpImage *)bitmap1, 0, 0, 1, 1, 0, 0, 1, 1,
UnitPixel, imageattr, NULL, NULL);
expect(Ok, stat);
stat = GdipBitmapGetPixel(bitmap2, 0, 0, &color);
expect(Ok, stat);
ok(color_match(0xff40ccee, color, 3), "expected 0xff40ccee, got 0x%08x\n", color);
GdipDeleteGraphics(graphics); GdipDeleteGraphics(graphics);
GdipDisposeImage((GpImage*)bitmap1); GdipDisposeImage((GpImage*)bitmap1);
GdipDisposeImage((GpImage*)bitmap2); GdipDisposeImage((GpImage*)bitmap2);