Module: wine Branch: master Commit: ab31b59f45affe558b37651d3a00c0d8923f2e55 URL: http://source.winehq.org/git/wine.git/?a=commit;h=ab31b59f45affe558b37651d3a...
Author: Nikolay Sivov nsivov@codeweavers.com Date: Tue Oct 24 13:56:38 2017 +0300
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
---
dlls/gdiplus/gdiplus_private.h | 7 +++ dlls/gdiplus/graphics.c | 5 ++ dlls/gdiplus/imageattributes.c | 11 ++-- dlls/gdiplus/tests/image.c | 131 ++++++++++++++++++++++++++++++++++++++++- 4 files changed, 148 insertions(+), 6 deletions(-)
diff --git a/dlls/gdiplus/gdiplus_private.h b/dlls/gdiplus/gdiplus_private.h index ca2c022..76e5b9b 100644 --- a/dlls/gdiplus/gdiplus_private.h +++ b/dlls/gdiplus/gdiplus_private.h @@ -481,6 +481,12 @@ struct color_remap_table{ ColorMap *colormap; };
+enum imageattr_noop{ + IMAGEATTR_NOOP_UNDEFINED, + IMAGEATTR_NOOP_SET, + IMAGEATTR_NOOP_CLEAR, +}; + struct GpImageAttributes{ WrapMode wrap; ARGB outside_color; @@ -490,6 +496,7 @@ struct GpImageAttributes{ struct color_remap_table colorremaptables[ColorAdjustTypeCount]; BOOL gamma_enabled[ColorAdjustTypeCount]; REAL gamma[ColorAdjustTypeCount]; + enum imageattr_noop noop[ColorAdjustTypeCount]; };
struct GpFont{ diff --git a/dlls/gdiplus/graphics.c b/dlls/gdiplus/graphics.c index 0207385..06fb89e 100644 --- a/dlls/gdiplus/graphics.c +++ b/dlls/gdiplus/graphics.c @@ -676,6 +676,11 @@ PixelFormat apply_image_attributes(const GpImageAttributes *attributes, LPBYTE d UINT x, y; 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 || attributes->colorkeys[ColorAdjustTypeDefault].enabled) { diff --git a/dlls/gdiplus/imageattributes.c b/dlls/gdiplus/imageattributes.c index 2050706..ab197a4 100644 --- a/dlls/gdiplus/imageattributes.c +++ b/dlls/gdiplus/imageattributes.c @@ -218,14 +218,14 @@ GpStatus WINGDIPAPI GdipSetImageAttributesGamma(GpImageAttributes *imageAttr, GpStatus WINGDIPAPI GdipSetImageAttributesNoOp(GpImageAttributes *imageAttr, ColorAdjustType type, BOOL enableFlag) { - static int calls; - TRACE("(%p,%u,%i)\n", imageAttr, type, enableFlag);
- if(!(calls++)) - FIXME("not implemented\n"); + if (type >= ColorAdjustTypeCount) + return InvalidParameter;
- return NotImplemented; + imageAttr->noop[type] = enableFlag ? IMAGEATTR_NOOP_SET : IMAGEATTR_NOOP_CLEAR; + + return Ok; }
GpStatus WINGDIPAPI GdipSetImageAttributesOutputChannel(GpImageAttributes *imageAttr, @@ -332,6 +332,7 @@ GpStatus WINGDIPAPI GdipResetImageAttributes(GpImageAttributes *imageAttr, GdipSetImageAttributesColorKeys(imageAttr, type, FALSE, 0, 0); GdipSetImageAttributesRemapTable(imageAttr, type, FALSE, 0, NULL); GdipSetImageAttributesGamma(imageAttr, type, FALSE, 0.0); + imageAttr->noop[type] = IMAGEATTR_NOOP_UNDEFINED;
return Ok; } diff --git a/dlls/gdiplus/tests/image.c b/dlls/gdiplus/tests/image.c index 82afc74..0b444ef 100644 --- a/dlls/gdiplus/tests/image.c +++ b/dlls/gdiplus/tests/image.c @@ -2374,10 +2374,44 @@ static void test_colormatrix(void) expect(Ok, stat); 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); 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); expect(Ok, stat);
@@ -2385,6 +2419,101 @@ static void test_colormatrix(void) expect(Ok, stat); 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); GdipDisposeImage((GpImage*)bitmap1); GdipDisposeImage((GpImage*)bitmap2);