gdiplus: implement GdipSetLineLinearBlend
Vincent Povirk
madewokherd+8cd9 at gmail.com
Sat Jul 11 11:51:43 CDT 2009
--
Vincent Povirk
-------------- next part --------------
From 57530f0bdbca247e7b02b03ddc9668c5b3926a35 Mon Sep 17 00:00:00 2001
From: Vincent Povirk <madewokherd at gmail.com>
Date: Sat, 11 Jul 2009 11:49:44 -0500
Subject: [PATCH] gdiplus: implement GdipSetLineLinearBlend
---
dlls/gdiplus/brush.c | 29 ++++++++++++++++--
dlls/gdiplus/tests/brush.c | 66 ++++++++++++++++++++++++++++++++++++++++++++
include/gdiplusflat.h | 1 +
3 files changed, 92 insertions(+), 4 deletions(-)
diff --git a/dlls/gdiplus/brush.c b/dlls/gdiplus/brush.c
index 824ece0..bb19e43 100644
--- a/dlls/gdiplus/brush.c
+++ b/dlls/gdiplus/brush.c
@@ -1531,12 +1531,33 @@ GpStatus WINGDIPAPI GdipRotateTextureTransform(GpTexture* brush, REAL angle,
GpStatus WINGDIPAPI GdipSetLineLinearBlend(GpLineGradient *brush, REAL focus,
REAL scale)
{
- static int calls;
+ REAL factors[3];
+ REAL positions[3];
+ int num_points = 0;
- if(!(calls++))
- FIXME("not implemented\n");
+ TRACE("(%p,%.2f,%.2f)\n", brush, focus, scale);
- return NotImplemented;
+ if (!brush) return InvalidParameter;
+
+ if (focus != 0.0)
+ {
+ factors[num_points] = 0.0;
+ positions[num_points] = 0.0;
+ num_points++;
+ }
+
+ factors[num_points] = scale;
+ positions[num_points] = focus;
+ num_points++;
+
+ if (focus != 1.0)
+ {
+ factors[num_points] = 0.0;
+ positions[num_points] = 1.0;
+ num_points++;
+ }
+
+ return GdipSetLineBlend(brush, factors, positions, num_points);
}
GpStatus WINGDIPAPI GdipSetLinePresetBlend(GpLineGradient *brush,
diff --git a/dlls/gdiplus/tests/brush.c b/dlls/gdiplus/tests/brush.c
index b6fbe30..7993d60 100644
--- a/dlls/gdiplus/tests/brush.c
+++ b/dlls/gdiplus/tests/brush.c
@@ -493,6 +493,71 @@ static void test_lineblend(void)
expect(Ok, status);
}
+static void test_linelinearblend(void)
+{
+ GpLineGradient *brush;
+ GpStatus status;
+ GpPointF pt1, pt2;
+ INT count=10;
+ REAL res_factors[3] = {0.3f};
+ REAL res_positions[3] = {0.3f};
+
+ status = GdipSetLineLinearBlend(NULL, 0.6, 0.8);
+ expect(InvalidParameter, status);
+
+ pt1.X = pt1.Y = 1.0;
+ pt2.X = pt2.Y = 100.0;
+ status = GdipCreateLineBrush(&pt1, &pt2, 0, 0, WrapModeTile, &brush);
+ expect(Ok, status);
+
+
+ status = GdipSetLineLinearBlend(brush, 0.6, 0.8);
+ expect(Ok, status);
+
+ status = GdipGetLineBlendCount(brush, &count);
+ expect(Ok, status);
+ expect(3, count);
+
+ status = GdipGetLineBlend(brush, res_factors, res_positions, 3);
+ expect(Ok, status);
+ expectf(0.0, res_factors[0]);
+ expectf(0.0, res_positions[0]);
+ expectf(0.8, res_factors[1]);
+ expectf(0.6, res_positions[1]);
+ expectf(0.0, res_factors[2]);
+ expectf(1.0, res_positions[2]);
+
+
+ status = GdipSetLineLinearBlend(brush, 0.0, 0.8);
+ expect(Ok, status);
+
+ status = GdipGetLineBlendCount(brush, &count);
+ expect(Ok, status);
+ expect(2, count);
+
+ status = GdipGetLineBlend(brush, res_factors, res_positions, 3);
+ expect(Ok, status);
+ expectf(0.8, res_factors[0]);
+ expectf(0.0, res_positions[0]);
+ expectf(0.0, res_factors[1]);
+ expectf(1.0, res_positions[1]);
+
+
+ status = GdipSetLineLinearBlend(brush, 1.0, 0.8);
+ expect(Ok, status);
+
+ status = GdipGetLineBlendCount(brush, &count);
+ expect(Ok, status);
+ expect(2, count);
+
+ status = GdipGetLineBlend(brush, res_factors, res_positions, 3);
+ expect(Ok, status);
+ expectf(0.0, res_factors[0]);
+ expectf(0.0, res_positions[0]);
+ expectf(0.8, res_factors[1]);
+ expectf(1.0, res_positions[1]);
+}
+
START_TEST(brush)
{
struct GdiplusStartupInput gdiplusStartupInput;
@@ -515,6 +580,7 @@ START_TEST(brush)
test_texturewrap();
test_gradientgetrect();
test_lineblend();
+ test_linelinearblend();
GdiplusShutdown(gdiplusToken);
}
diff --git a/include/gdiplusflat.h b/include/gdiplusflat.h
index 0c1e54f..2ee24bd 100644
--- a/include/gdiplusflat.h
+++ b/include/gdiplusflat.h
@@ -409,6 +409,7 @@ GpStatus WINGDIPAPI GdipGetLineBlendCount(GpLineGradient*,INT*);
GpStatus WINGDIPAPI GdipSetLineColors(GpLineGradient*,ARGB,ARGB);
GpStatus WINGDIPAPI GdipSetLineGammaCorrection(GpLineGradient*,BOOL);
GpStatus WINGDIPAPI GdipSetLineSigmaBlend(GpLineGradient*,REAL,REAL);
+GpStatus WINGDIPAPI GdipSetLineLinearBlend(GpLineGradient*,REAL,REAL);
GpStatus WINGDIPAPI GdipSetLineWrapMode(GpLineGradient*,GpWrapMode);
/* Matrix */
--
1.6.3.3
More information about the wine-patches
mailing list