Author: akhaldi
Date: Fri Dec 18 10:32:42 2015
New Revision: 70391
URL:
http://svn.reactos.org/svn/reactos?rev=70391&view=rev
Log:
[0.4.0] * Merge the styled lines and pen implementation fixes by Timo Kreuzer in revisions
70387 and 70388. CORE-9984
Modified:
branches/ros-branch-0_4_0/ (props changed)
branches/ros-branch-0_4_0/reactos/ (props changed)
branches/ros-branch-0_4_0/reactos/win32ss/gdi/eng/lineto.c
branches/ros-branch-0_4_0/reactos/win32ss/gdi/ntgdi/brush.cpp
branches/ros-branch-0_4_0/reactos/win32ss/gdi/ntgdi/brush.h
branches/ros-branch-0_4_0/reactos/win32ss/gdi/ntgdi/pen.c
Propchange: branches/ros-branch-0_4_0/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Fri Dec 18 10:32:42 2015
@@ -1 +1 @@
-/trunk:70000-70321,70323-70324,70328-70337,70347,70349,70354-70358,70360,70363,70369,70373,70375-70378,70381,70384
+/trunk:70000-70321,70323-70324,70328-70337,70347,70349,70354-70358,70360,70363,70369,70373,70375-70378,70381,70384,70387-70388
Propchange: branches/ros-branch-0_4_0/reactos/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Fri Dec 18 10:32:42 2015
@@ -20,4 +20,4 @@
/branches/usb-bringup:51335,51337,51341-51343,51348,51350,51353,51355,51365-51369,51372,51384-54388,54396-54398,54736-54737,54752-54754,54756-54760,54762,54764-54765,54767-54768,54772,54774-54777,54781,54787,54790-54792,54797-54798,54806,54808,54834-54838,54843,54850,54852,54856,54858-54859
/branches/usb-bringup-trunk:55019-55543,55548-55554,55556-55567
/branches/wlan-bringup:54809-54998
-/trunk/reactos:70000-70321,70323-70324,70328-70337,70347,70349,70354-70358,70360,70363,70369,70373,70375-70378,70381,70384
+/trunk/reactos:70000-70321,70323-70324,70328-70337,70347,70349,70354-70358,70360,70363,70369,70373,70375-70378,70381,70384,70387-70388
Modified: branches/ros-branch-0_4_0/reactos/win32ss/gdi/eng/lineto.c
URL:
http://svn.reactos.org/svn/reactos/branches/ros-branch-0_4_0/reactos/win32s…
==============================================================================
--- branches/ros-branch-0_4_0/reactos/win32ss/gdi/eng/lineto.c [iso-8859-1] (original)
+++ branches/ros-branch-0_4_0/reactos/win32ss/gdi/eng/lineto.c [iso-8859-1] Fri Dec 18
10:32:42 2015
@@ -28,6 +28,63 @@
}
}
+LONG
+HandleStyles(
+ BRUSHOBJ *pbo,
+ POINTL* Translate,
+ LONG x,
+ LONG y,
+ LONG deltax,
+ LONG deltay,
+ LONG dx,
+ LONG dy,
+ PULONG piStyle)
+{
+ PEBRUSHOBJ pebo = (PEBRUSHOBJ)pbo;
+ PULONG pulStyles = pebo->pbrush->pStyle;
+ ULONG iStyle, cStyles = pebo->pbrush->dwStyleCount;
+ LONG diStyle, offStyle, lStyleMax;
+
+ if (cStyles > 0)
+ {
+ if (deltax > deltay)
+ {
+ offStyle = (- Translate->x) % pebo->pbrush->ulStyleSize;
+ diStyle = dx;
+ lStyleMax = x;
+ }
+ else
+ {
+ offStyle = (- Translate->y) % pebo->pbrush->ulStyleSize;
+ diStyle = dy;
+ lStyleMax = y;
+ }
+
+ /* Now loop until we have found the style index */
+ for (iStyle = 0; offStyle >= pulStyles[iStyle]; iStyle++)
+ {
+ offStyle -= pulStyles[iStyle];
+ }
+
+ if (diStyle > 0)
+ {
+ lStyleMax += pulStyles[iStyle] - offStyle;
+ }
+ else
+ {
+ lStyleMax -= offStyle + 1;
+ }
+ }
+ else
+ {
+ iStyle = 0;
+ lStyleMax = MAX_COORD;
+ }
+
+ *piStyle = iStyle;
+ return lStyleMax;
+}
+
/*
* Draw a line from top-left to bottom-right
*/
@@ -43,6 +100,12 @@
RECT_ENUM RectEnum;
ULONG Pixel = pbo->iSolidColor;
LONG delta;
+ PEBRUSHOBJ pebo = (PEBRUSHOBJ)pbo;
+ PULONG pulStyles = pebo->pbrush->pStyle;
+ ULONG iStyle, cStyles = pebo->pbrush->dwStyleCount;
+ LONG lStyleMax;
+
+ lStyleMax = HandleStyles(pbo, Translate, x, y, deltax, deltay, 1, 1, &iStyle);
CLIPOBJ_cEnumStart(Clip, FALSE, CT_RECTANGLES, CD_RIGHTDOWN, 0);
EnumMore = CLIPOBJ_bEnum(Clip, (ULONG) sizeof(RectEnum), (PVOID) &RectEnum);
@@ -72,7 +135,7 @@
}
if (ClipRect < RectEnum.arcl + RectEnum.c) /* If there's no current clip
rect we're done */
{
- if (ClipRect->left <= x && ClipRect->top <= y)
+ if ((ClipRect->left <= x && ClipRect->top <= y)
&& ((iStyle & 1) == 0))
{
DibFunctionsForBitmapFormat[OutputObj->iBitmapFormat].DIB_PutPixel(
OutputObj, x, y, Pixel);
@@ -80,6 +143,11 @@
if (deltax < deltay)
{
y++;
+ if (y == lStyleMax)
+ {
+ iStyle = (iStyle + 1) % cStyles;
+ lStyleMax = y + pulStyles[iStyle];
+ }
error = error + deltax;
if (deltay <= error)
{
@@ -90,6 +158,11 @@
else
{
x++;
+ if (x == lStyleMax)
+ {
+ iStyle = (iStyle + 1) % cStyles;
+ lStyleMax = x + pulStyles[iStyle];
+ }
error = error + deltay;
if (deltax <= error)
{
@@ -114,6 +187,12 @@
RECT_ENUM RectEnum;
ULONG Pixel = pbo->iSolidColor;
LONG delta;
+ PEBRUSHOBJ pebo = (PEBRUSHOBJ)pbo;
+ PULONG pulStyles = pebo->pbrush->pStyle;
+ ULONG iStyle, cStyles = pebo->pbrush->dwStyleCount;
+ LONG lStyleMax;
+
+ lStyleMax = HandleStyles(pbo, Translate, x, y, deltax, deltay, 1, -1, &iStyle);
CLIPOBJ_cEnumStart(Clip, FALSE, CT_RECTANGLES, CD_RIGHTUP, 0);
EnumMore = CLIPOBJ_bEnum(Clip, (ULONG) sizeof(RectEnum), (PVOID) &RectEnum);
@@ -142,7 +221,7 @@
}
if (ClipRect < RectEnum.arcl + RectEnum.c)
{
- if (ClipRect->left <= x && y < ClipRect->bottom)
+ if ((ClipRect->left <= x && y < ClipRect->bottom)
&& ((iStyle & 1) == 0))
{
DibFunctionsForBitmapFormat[OutputObj->iBitmapFormat].DIB_PutPixel(
OutputObj, x, y, Pixel);
@@ -150,6 +229,11 @@
if (deltax < deltay)
{
y--;
+ if (y == lStyleMax)
+ {
+ iStyle = (iStyle - 1) % cStyles;
+ lStyleMax = y - pulStyles[iStyle];
+ }
error = error + deltax;
if (deltay <= error)
{
@@ -160,6 +244,11 @@
else
{
x++;
+ if (x == lStyleMax)
+ {
+ iStyle = (iStyle + 1) % cStyles;
+ lStyleMax = x + pulStyles[iStyle];
+ }
error = error + deltay;
if (deltax <= error)
{
@@ -184,6 +273,12 @@
RECT_ENUM RectEnum;
ULONG Pixel = pbo->iSolidColor;
LONG delta;
+ PEBRUSHOBJ pebo = (PEBRUSHOBJ)pbo;
+ PULONG pulStyles = pebo->pbrush->pStyle;
+ ULONG iStyle, cStyles = pebo->pbrush->dwStyleCount;
+ LONG lStyleMax;
+
+ lStyleMax = HandleStyles(pbo, Translate, x, y, deltax, deltay, -1, 1, &iStyle);
CLIPOBJ_cEnumStart(Clip, FALSE, CT_RECTANGLES, CD_LEFTDOWN, 0);
EnumMore = CLIPOBJ_bEnum(Clip, (ULONG) sizeof(RectEnum), (PVOID) &RectEnum);
@@ -212,7 +307,7 @@
}
if (ClipRect < RectEnum.arcl + RectEnum.c)
{
- if (x < ClipRect->right && ClipRect->top <= y)
+ if ((x < ClipRect->right && ClipRect->top <= y)
&& ((iStyle & 1) == 0))
{
DibFunctionsForBitmapFormat[OutputObj->iBitmapFormat].DIB_PutPixel(
OutputObj, x, y, Pixel);
@@ -220,6 +315,11 @@
if (deltax < deltay)
{
y++;
+ if (y == lStyleMax)
+ {
+ iStyle = (iStyle + 1) % cStyles;
+ lStyleMax = y + pulStyles[iStyle];
+ }
error = error + deltax;
if (deltay <= error)
{
@@ -230,6 +330,11 @@
else
{
x--;
+ if (x == lStyleMax)
+ {
+ iStyle = (iStyle - 1) % cStyles;
+ lStyleMax = x - pulStyles[iStyle];
+ }
error = error + deltay;
if (deltax <= error)
{
@@ -254,6 +359,12 @@
RECT_ENUM RectEnum;
ULONG Pixel = pbo->iSolidColor;
LONG delta;
+ PEBRUSHOBJ pebo = (PEBRUSHOBJ)pbo;
+ PULONG pulStyles = pebo->pbrush->pStyle;
+ ULONG iStyle, cStyles = pebo->pbrush->dwStyleCount;
+ LONG lStyleMax;
+
+ lStyleMax = HandleStyles(pbo, Translate, x, y, deltax, deltay, -1, -1, &iStyle);
CLIPOBJ_cEnumStart(Clip, FALSE, CT_RECTANGLES, CD_LEFTUP, 0);
EnumMore = CLIPOBJ_bEnum(Clip, (ULONG) sizeof(RectEnum), (PVOID) &RectEnum);
@@ -282,7 +393,7 @@
}
if (ClipRect < RectEnum.arcl + RectEnum.c)
{
- if (x < ClipRect->right && y < ClipRect->bottom)
+ if ((x < ClipRect->right && y < ClipRect->bottom)
&& ((iStyle & 1) == 0))
{
DibFunctionsForBitmapFormat[OutputObj->iBitmapFormat].DIB_PutPixel(
OutputObj, x, y, Pixel);
@@ -290,6 +401,11 @@
if (deltax < deltay)
{
y--;
+ if (y == lStyleMax)
+ {
+ iStyle = (iStyle - 1) % cStyles;
+ lStyleMax = y - pulStyles[iStyle];
+ }
error = error + deltax;
if (deltay <= error)
{
@@ -300,6 +416,11 @@
else
{
x--;
+ if (x == lStyleMax)
+ {
+ iStyle = (iStyle - 1) % cStyles;
+ lStyleMax = x - pulStyles[iStyle];
+ }
error = error + deltay;
if (deltax <= error)
{
@@ -337,6 +458,8 @@
RECT_ENUM RectEnum;
BOOL EnumMore;
CLIPOBJ *pcoPriv = NULL;
+ PEBRUSHOBJ pebo = (PEBRUSHOBJ)pbo;
+ ULONG cStyles = pebo->pbrush->dwStyleCount;
if (x1 < x2)
{
@@ -413,7 +536,7 @@
vy = y1;
}
- if (y1 == y2)
+ if ((y1 == y2) && (cStyles == 0))
{
CLIPOBJ_cEnumStart(Clip, FALSE, CT_RECTANGLES, CD_RIGHTDOWN, 0);
do
@@ -437,7 +560,7 @@
}
while (EnumMore);
}
- else if (x1 == x2)
+ else if ((x1 == x2) && (cStyles == 0))
{
CLIPOBJ_cEnumStart(Clip, FALSE, CT_RECTANGLES, CD_RIGHTDOWN, 0);
do
Modified: branches/ros-branch-0_4_0/reactos/win32ss/gdi/ntgdi/brush.cpp
URL:
http://svn.reactos.org/svn/reactos/branches/ros-branch-0_4_0/reactos/win32s…
==============================================================================
--- branches/ros-branch-0_4_0/reactos/win32ss/gdi/ntgdi/brush.cpp [iso-8859-1] (original)
+++ branches/ros-branch-0_4_0/reactos/win32ss/gdi/ntgdi/brush.cpp [iso-8859-1] Fri Dec 18
10:32:42 2015
@@ -45,6 +45,11 @@
this->ulSurfTime = 0;
this->pvRBrush = NULL;
this->hdev = NULL;
+
+ /* FIXME: should be done only in PEN constructor,
+ but our destructor needs it! */
+ this->dwStyleCount = 0;
+ this->pStyle = NULL;
}
BRUSH::~BRUSH(
@@ -62,6 +67,12 @@
{
GreSetBitmapOwner(this->hbmPattern, BASEOBJECT::OWNER::POWNED);
GreDeleteObject(this->hbmPattern);
+ }
+
+ /* Delete styles */
+ if ((this->pStyle != NULL) && !(this->flAttrs &
BR_IS_DEFAULTSTYLE))
+ {
+ ExFreePoolWithTag(this->pStyle, GDITAG_PENSTYLE);
}
}
Modified: branches/ros-branch-0_4_0/reactos/win32ss/gdi/ntgdi/brush.h
URL:
http://svn.reactos.org/svn/reactos/branches/ros-branch-0_4_0/reactos/win32s…
==============================================================================
--- branches/ros-branch-0_4_0/reactos/win32ss/gdi/ntgdi/brush.h [iso-8859-1] (original)
+++ branches/ros-branch-0_4_0/reactos/win32ss/gdi/ntgdi/brush.h [iso-8859-1] Fri Dec 18
10:32:42 2015
@@ -43,7 +43,8 @@
INT iBrushStyle; // 0x070
//PREGION prgn; // 0x074
//DWORD unk078; // 0x078
- DWORD unk07c; // 0x07c
+ //DWORD unk07c; // 0x07c
+ ULONG ulStyleSize;
LIST_ENTRY ListHead; // 0x080
} BRUSHBODY;
Modified: branches/ros-branch-0_4_0/reactos/win32ss/gdi/ntgdi/pen.c
URL:
http://svn.reactos.org/svn/reactos/branches/ros-branch-0_4_0/reactos/win32s…
==============================================================================
--- branches/ros-branch-0_4_0/reactos/win32ss/gdi/ntgdi/pen.c [iso-8859-1] (original)
+++ branches/ros-branch-0_4_0/reactos/win32ss/gdi/ntgdi/pen.c [iso-8859-1] Fri Dec 18
10:32:42 2015
@@ -86,11 +86,12 @@
{
HPEN hPen;
PBRUSH pbrushPen;
- static const BYTE PatternAlternate[] = {0x55, 0x55, 0x55, 0};
- static const BYTE PatternDash[] = {0xFF, 0xFF, 0xC0, 0};
- static const BYTE PatternDot[] = {0xE3, 0x8E, 0x38, 0};
- static const BYTE PatternDashDot[] = {0xFF, 0x81, 0xC0, 0};
- static const BYTE PatternDashDotDot[] = {0xFF, 0x8E, 0x38, 0};
+ static ULONG aulStyleAlternate[] = { 1, 1 };
+ static ULONG aulStyleDash[] = { 6, 2 };
+ static ULONG aulStyleDot[] = { 1, 1 };
+ static ULONG aulStyleDashDot[] = { 3, 2, 1, 2 };
+ static ULONG aulStyleDashDotDot[] = { 3, 1, 1, 1, 1, 1 };
+ ULONG i;
dwWidth = abs(dwWidth);
@@ -127,8 +128,9 @@
pbrushPen->iBrushStyle = ulBrushStyle;
// FIXME: Copy the bitmap first ?
pbrushPen->hbmClient = (HANDLE)ulClientHatch;
- pbrushPen->dwStyleCount = dwStyleCount;
- pbrushPen->pStyle = pStyle;
+ pbrushPen->dwStyleCount = 0;
+ pbrushPen->pStyle = NULL;
+ pbrushPen->ulStyleSize = 0;
pbrushPen->flAttrs = bOldStylePen ? BR_IS_OLDSTYLEPEN : BR_IS_PEN;
@@ -150,28 +152,33 @@
break;
case PS_ALTERNATE:
- pbrushPen->flAttrs |= BR_IS_BITMAP;
- pbrushPen->hbmPattern = GreCreateBitmap(24, 1, 1, 1,
(LPBYTE)PatternAlternate);
+ pbrushPen->flAttrs |= BR_IS_SOLID | BR_IS_DEFAULTSTYLE;
+ pbrushPen->pStyle = aulStyleAlternate;
+ pbrushPen->dwStyleCount = _countof(aulStyleAlternate);
break;
case PS_DOT:
- pbrushPen->flAttrs |= BR_IS_BITMAP;
- pbrushPen->hbmPattern = GreCreateBitmap(24, 1, 1, 1, (LPBYTE)PatternDot);
+ pbrushPen->flAttrs |= BR_IS_SOLID | BR_IS_DEFAULTSTYLE;
+ pbrushPen->pStyle = aulStyleDot;
+ pbrushPen->dwStyleCount = _countof(aulStyleDot);
break;
case PS_DASH:
- pbrushPen->flAttrs |= BR_IS_BITMAP;
- pbrushPen->hbmPattern = GreCreateBitmap(24, 1, 1, 1, (LPBYTE)PatternDash);
+ pbrushPen->flAttrs |= BR_IS_SOLID | BR_IS_DEFAULTSTYLE;
+ pbrushPen->pStyle = aulStyleDash;
+ pbrushPen->dwStyleCount = _countof(aulStyleDash);
break;
case PS_DASHDOT:
- pbrushPen->flAttrs |= BR_IS_BITMAP;
- pbrushPen->hbmPattern = GreCreateBitmap(24, 1, 1, 1, (LPBYTE)PatternDashDot);
+ pbrushPen->flAttrs |= BR_IS_SOLID | BR_IS_DEFAULTSTYLE;
+ pbrushPen->pStyle = aulStyleDashDot;
+ pbrushPen->dwStyleCount = _countof(aulStyleDashDot);
break;
case PS_DASHDOTDOT:
- pbrushPen->flAttrs |= BR_IS_BITMAP;
- pbrushPen->hbmPattern = GreCreateBitmap(24, 1, 1, 1,
(LPBYTE)PatternDashDotDot);
+ pbrushPen->flAttrs |= BR_IS_SOLID | BR_IS_DEFAULTSTYLE;
+ pbrushPen->pStyle = aulStyleDashDotDot;
+ pbrushPen->dwStyleCount = _countof(aulStyleDashDotDot);
break;
case PS_INSIDEFRAME:
@@ -179,14 +186,6 @@
break;
case PS_USERSTYLE:
- if ((dwPenStyle & PS_TYPE_MASK) == PS_COSMETIC)
- {
- /* FIXME: PS_USERSTYLE workaround */
- DPRINT1("PS_COSMETIC | PS_USERSTYLE not handled\n");
- pbrushPen->flAttrs |= BR_IS_SOLID;
- break;
- }
- else
{
UINT i;
BOOL has_neg = FALSE, all_zero = TRUE;
@@ -203,13 +202,25 @@
}
}
/* FIXME: What style here? */
- pbrushPen->flAttrs |= 0;
+ pbrushPen->flAttrs |= BR_IS_SOLID;
+ pbrushPen->dwStyleCount = dwStyleCount;
+ pbrushPen->pStyle = pStyle;
break;
default:
DPRINT1("IntGdiExtCreatePen unknown penstyle %x\n", dwPenStyle);
goto ExitCleanup;
}
+
+ if (pbrushPen->pStyle != NULL)
+ {
+ for (i = 0; i < pbrushPen->dwStyleCount; i++)
+ {
+ pbrushPen->ulStyleSize += pbrushPen->pStyle[i];
+ }
+ }
+
+ NT_ASSERT((pbrushPen->dwStyleCount == 0) || (pbrushPen->pStyle != NULL));
PEN_UnlockPen(pbrushPen);
return hPen;
@@ -278,8 +289,9 @@
}
else
{
- // FIXME: Can we trust in dwStyleCount being <= 16?
- cbRetCount = sizeof(EXTLOGPEN) - sizeof(DWORD) + pbrushPen->dwStyleCount *
sizeof(DWORD);
+ DWORD dwStyleCount = (pbrushPen->flAttrs & BR_IS_DEFAULTSTYLE) ?
+ 0 : pbrushPen->dwStyleCount;
+ cbRetCount = sizeof(EXTLOGPEN) - sizeof(DWORD) + dwStyleCount * sizeof(DWORD);
if (pBuffer)
{
ULONG i;
@@ -291,8 +303,8 @@
pExtLogPen->elpBrushStyle = pbrushPen->iBrushStyle;
pExtLogPen->elpColor = pbrushPen->BrushAttr.lbColor;
pExtLogPen->elpHatch = (ULONG_PTR)pbrushPen->hbmClient;
- pExtLogPen->elpNumEntries = pbrushPen->dwStyleCount;
- for (i = 0; i < pExtLogPen->elpNumEntries; i++)
+ pExtLogPen->elpNumEntries = dwStyleCount;
+ for (i = 0; i < dwStyleCount; i++)
{
pExtLogPen->elpStyleEntry[i] = pbrushPen->pStyle[i];
}
@@ -358,6 +370,39 @@
return 0;
}
+ if (((dwPenStyle & PS_TYPE_MASK) == PS_COSMETIC) &&
+ (ulBrushStyle != BS_SOLID))
+ {
+ EngSetLastError(ERROR_INVALID_PARAMETER);
+ return 0;
+ }
+
+ if (((dwPenStyle & PS_STYLE_MASK) == PS_NULL) ||
+ (ulBrushStyle == BS_NULL))
+ {
+ return StockObjects[NULL_PEN];
+ }
+
+
+ if ((ulBrushStyle == BS_PATTERN) ||
+ (ulBrushStyle == BS_DIBPATTERN) ||
+ (ulBrushStyle == BS_DIBPATTERNPT))
+ {
+ ulColor = 0;
+ }
+ else if ((ulBrushStyle != BS_SOLID) &&
+ (ulBrushStyle != BS_HATCHED))
+ {
+ EngSetLastError(ERROR_INVALID_PARAMETER);
+ return 0;
+ }
+
+ if ((dwPenStyle & PS_STYLE_MASK) != PS_USERSTYLE)
+ {
+ dwStyleCount = 0;
+ pUnsafeStyle = NULL;
+ }
+
if (dwStyleCount > 0)
{
if (pUnsafeStyle == NULL)
@@ -378,8 +423,8 @@
{
ProbeForRead(pUnsafeStyle, dwStyleCount * sizeof(DWORD), 1);
RtlCopyMemory(pSafeStyle,
- pUnsafeStyle,
- dwStyleCount * sizeof(DWORD));
+ pUnsafeStyle,
+ dwStyleCount * sizeof(DWORD));
}
_SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
{