Author: jimtabor
Date: Wed May 14 21:15:10 2008
New Revision: 33522
URL:
http://svn.reactos.org/svn/reactos?rev=33522&view=rev
Log:
Implement Delete/CreateColorSpace and Get/SetColorSpace.
Added:
trunk/reactos/dll/win32/gdi32/objects/icm.c (with props)
Modified:
trunk/reactos/dll/win32/gdi32/gdi32.rbuild
trunk/reactos/dll/win32/gdi32/misc/stubs.c
trunk/reactos/dll/win32/gdi32/misc/stubsa.c
trunk/reactos/dll/win32/gdi32/misc/stubsw.c
trunk/reactos/include/psdk/wingdi.h
trunk/reactos/subsystems/win32/win32k/include/color.h
trunk/reactos/subsystems/win32/win32k/objects/gdiobj.c
trunk/reactos/subsystems/win32/win32k/objects/icm.c
Modified: trunk/reactos/dll/win32/gdi32/gdi32.rbuild
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/gdi32/gdi32.rbui…
==============================================================================
--- trunk/reactos/dll/win32/gdi32/gdi32.rbuild [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/gdi32/gdi32.rbuild [iso-8859-1] Wed May 14 21:15:10 2008
@@ -39,6 +39,7 @@
<file>eng.c</file>
<file>enhmfile.c</file>
<file>font.c</file>
+ <file>icm.c</file>
<file>linedda.c</file>
<file>metafile.c</file>
<file>painting.c</file>
Modified: trunk/reactos/dll/win32/gdi32/misc/stubs.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/gdi32/misc/stubs…
==============================================================================
--- trunk/reactos/dll/win32/gdi32/misc/stubs.c [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/gdi32/misc/stubs.c [iso-8859-1] Wed May 14 21:15:10 2008
@@ -636,34 +636,6 @@
return FALSE;
}
-
-/*
- * @unimplemented
- */
-HCOLORSPACE
-STDCALL
-GetColorSpace(HDC hDc)
-{
- UNIMPLEMENTED;
- SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
- return 0;
-}
-
-
-/*
- * @unimplemented
- */
-HCOLORSPACE
-STDCALL
-SetColorSpace(
- HDC a0,
- HCOLORSPACE a1
- )
-{
- UNIMPLEMENTED;
- SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
- return FALSE;
-}
/*
* @implemented
Modified: trunk/reactos/dll/win32/gdi32/misc/stubsa.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/gdi32/misc/stubs…
==============================================================================
--- trunk/reactos/dll/win32/gdi32/misc/stubsa.c [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/gdi32/misc/stubsa.c [iso-8859-1] Wed May 14 21:15:10 2008
@@ -82,21 +82,6 @@
UNIMPLEMENTED;
SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
return FALSE;
-}
-
-
-/*
- * @unimplemented
- */
-HCOLORSPACE
-STDCALL
-CreateColorSpaceA(
- LPLOGCOLORSPACEA a0
- )
-{
- UNIMPLEMENTED;
- SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
- return 0;
}
Modified: trunk/reactos/dll/win32/gdi32/misc/stubsw.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/gdi32/misc/stubs…
==============================================================================
--- trunk/reactos/dll/win32/gdi32/misc/stubsw.c [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/gdi32/misc/stubsw.c [iso-8859-1] Wed May 14 21:15:10 2008
@@ -46,20 +46,6 @@
UNIMPLEMENTED;
SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
return FALSE;
-}
-
-/*
- * @unimplemented
- */
-HCOLORSPACE
-STDCALL
-CreateColorSpaceW(
- LPLOGCOLORSPACEW a0
- )
-{
- UNIMPLEMENTED;
- SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
- return 0;
}
Added: trunk/reactos/dll/win32/gdi32/objects/icm.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/gdi32/objects/ic…
==============================================================================
--- trunk/reactos/dll/win32/gdi32/objects/icm.c (added)
+++ trunk/reactos/dll/win32/gdi32/objects/icm.c [iso-8859-1] Wed May 14 21:15:10 2008
@@ -1,0 +1,130 @@
+#include "precomp.h"
+
+#define NDEBUG
+#include <debug.h>
+
+
+HCOLORSPACE
+FASTCALL
+IntCreateColorSpaceW(
+ LPLOGCOLORSPACEW lplcpw,
+ BOOL Ascii
+ )
+{
+ LOGCOLORSPACEEXW lcpeexw;
+
+ if ((lplcpw->lcsSignature != LCS_SIGNATURE) ||
+ (lplcpw->lcsVersion != 0x400) ||
+ (lplcpw->lcsSize != sizeof(LOGCOLORSPACEW)))
+ {
+ SetLastError(ERROR_INVALID_COLORSPACE);
+ return NULL;
+ }
+ RtlCopyMemory(&lcpeexw.lcsColorSpace, lplcpw, sizeof(LOGCOLORSPACEW));
+
+ return NtGdiCreateColorSpace(&lcpeexw);
+}
+
+/*
+ * @implemented
+ */
+HCOLORSPACE
+STDCALL
+CreateColorSpaceW(
+ LPLOGCOLORSPACEW lplcpw
+ )
+{
+ return IntCreateColorSpaceW(lplcpw, FALSE);
+}
+
+
+/*
+ * @implemented
+ */
+HCOLORSPACE
+STDCALL
+CreateColorSpaceA(
+ LPLOGCOLORSPACEA lplcpa
+ )
+{
+ LOGCOLORSPACEW lcpw;
+
+ if ((lplcpa->lcsSignature != LCS_SIGNATURE) ||
+ (lplcpa->lcsVersion != 0x400) ||
+ (lplcpa->lcsSize != sizeof(LOGCOLORSPACEA)))
+ {
+ SetLastError(ERROR_INVALID_COLORSPACE);
+ return NULL;
+ }
+
+ lcpw.lcsSignature = lplcpa->lcsSignature;
+ lcpw.lcsVersion = lplcpa->lcsVersion;
+ lcpw.lcsSize = sizeof(LOGCOLORSPACEW);
+ lcpw.lcsCSType = lplcpa->lcsCSType;
+ lcpw.lcsIntent = lplcpa->lcsIntent;
+ lcpw.lcsEndpoints = lplcpa->lcsEndpoints;
+ lcpw.lcsGammaRed = lplcpa->lcsGammaRed;
+ lcpw.lcsGammaGreen = lplcpa->lcsGammaGreen;
+ lcpw.lcsGammaBlue = lplcpa->lcsGammaBlue;
+
+ RtlMultiByteToUnicodeN( lcpw.lcsFilename,
+ MAX_PATH,
+ NULL,
+ lplcpa->lcsFilename,
+ strlen(lplcpa->lcsFilename) + 1);
+
+ return IntCreateColorSpaceW(&lcpw, FALSE);
+}
+
+/*
+ * @implemented
+ */
+HCOLORSPACE
+STDCALL
+GetColorSpace(HDC hDC)
+{
+ PDC_ATTR pDc_Attr;
+
+ if (!GdiGetHandleUserData(hDC, GDI_OBJECT_TYPE_DC, (PVOID)&pDc_Attr))
+ {
+ SetLastError(ERROR_INVALID_HANDLE);
+ return NULL;
+ }
+ return pDc_Attr->hColorSpace;
+}
+
+
+/*
+ * @implemented
+ */
+HCOLORSPACE
+STDCALL
+SetColorSpace(
+ HDC hDC,
+ HCOLORSPACE hCS
+ )
+{
+ HCOLORSPACE rhCS = GetColorSpace(hDC);
+
+ if (GDI_HANDLE_GET_TYPE(hDC) == GDI_OBJECT_TYPE_DC)
+ {
+ if (NtGdiSetColorSpace(hDC, hCS)) return rhCS;
+ }
+#if 0
+ if (GDI_HANDLE_GET_TYPE(hDC) != GDI_OBJECT_TYPE_METADC)
+ {
+ PLDC pLDC = GdiGetLDC(hDC);
+ if ( !pLDC )
+ {
+ SetLastError(ERROR_INVALID_HANDLE);
+ return NULL;
+ }
+ if (pLDC->iType == LDC_EMFLDC)
+ {
+ return NULL;
+ }
+ }
+#endif
+ return NULL;
+}
+
Propchange: trunk/reactos/dll/win32/gdi32/objects/icm.c
------------------------------------------------------------------------------
svn:eol-style = native
Modified: trunk/reactos/include/psdk/wingdi.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/include/psdk/wingdi.h?rev=…
==============================================================================
--- trunk/reactos/include/psdk/wingdi.h [iso-8859-1] (original)
+++ trunk/reactos/include/psdk/wingdi.h [iso-8859-1] Wed May 14 21:15:10 2008
@@ -966,6 +966,10 @@
#define LCS_GM_BUSINESS 1
#define LCS_GM_GRAPHICS 2
#define LCS_GM_IMAGES 4
+#define LCS_GM_ABS_COLORIMETRIC 8
+#define LCS_SIGNATURE 0x50534F43 // 'PSOC'
+#define LCS_sRGB 'sRGB'
+#define LCS_WINDOWS_COLOR_SPACE 'Win '
#define RASTER_FONTTYPE 1
#define DEVICE_FONTTYPE 2
#define TRUETYPE_FONTTYPE 4
Modified: trunk/reactos/subsystems/win32/win32k/include/color.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/win32k/in…
==============================================================================
--- trunk/reactos/subsystems/win32/win32k/include/color.h [iso-8859-1] (original)
+++ trunk/reactos/subsystems/win32/win32k/include/color.h [iso-8859-1] Wed May 14 21:15:10
2008
@@ -10,10 +10,29 @@
#define NB_RESERVED_COLORS 20 /* number of fixed colors in system palette
*/
+typedef struct _COLORSPACE
+{
+ BASEOBJECT BaseObject;
+ LOGCOLORSPACEW lcsColorSpace;
+ DWORD dwFlags;
+} COLORSPACE, *PCOLORSPACE;
+
+
+#define COLORSPACEOBJ_AllocCS() ((PCOLORSPACE) GDIOBJ_AllocObj(GDIObjType_ICMLCS_TYPE))
+#define COLORSPACEOBJ_AllocCSWithHandle() ((PCOLORSPACE) GDIOBJ_AllocObjWithHandle
(GDI_OBJECT_TYPE_COLORSPACE))
+#define COLORSPACEOBJ_FreeCS(pCS) GDIOBJ_FreeObj((POBJ)pCS, GDIObjType_ICMLCS_TYPE)
+#define COLORSPACEOBJ_FreeCSByHandle(hCS) GDIOBJ_FreeObjByHandle((HGDIOBJ)hCS,
GDI_OBJECT_TYPE_COLORSPACE)
+#define COLORSPACEOBJ_LockCS(hCS) ((PCOLORSPACE)GDIOBJ_LockObj((HGDIOBJ)hCS,
GDI_OBJECT_TYPE_COLORSPACE))
+#define COLORSPACEOBJ_UnlockCS(pCS) GDIOBJ_UnlockObjByPtr((POBJ)pCS)
+
+extern HCOLORSPACE hStockColorSpace;
+
const PALETTEENTRY* FASTCALL COLOR_GetSystemPaletteTemplate (VOID);
COLORREF STDCALL COLOR_LookupNearestColor (PALETTEENTRY* palPalEntry, INT size, COLORREF
color);
INT STDCALL COLOR_PaletteLookupExactIndex (PALETTEENTRY* palPalEntry, INT size, COLORREF
col);
INT STDCALL COLOR_PaletteLookupPixel(PALETTEENTRY *palPalEntry, INT size, XLATEOBJ
*XlateObj, COLORREF col, BOOL skipReserved);
UINT FASTCALL IntGdiRealizePalette (HDC);
+HCOLORSPACE FASTCALL IntGdiCreateColorSpace(PLOGCOLORSPACEEXW);
+BOOL FASTCALL IntGdiDeleteColorSpace(HCOLORSPACE);
#endif /* _WIN32K_COLOR_H */
Modified: trunk/reactos/subsystems/win32/win32k/objects/gdiobj.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/win32k/ob…
==============================================================================
--- trunk/reactos/subsystems/win32/win32k/objects/gdiobj.c [iso-8859-1] (original)
+++ trunk/reactos/subsystems/win32/win32k/objects/gdiobj.c [iso-8859-1] Wed May 14
21:15:10 2008
@@ -59,7 +59,7 @@
{0, sizeof(DC), TAG_CLIENTOBJ, GDI_CleanupDummy}, /* 06 CLIENTOBJ:
METADC,... FIXME: don't use DC struct */
{0, 0, TAG_PATH, NULL}, /* 07 PATH, unused */
{1, sizeof(PALGDI), TAG_PALETTE, PALETTE_Cleanup}, /* 08 PAL */
- {0, 0, TAG_ICMLCS, NULL}, /* 09 ICMLCS, unused
*/
+ {1, sizeof(COLORSPACE), TAG_ICMLCS, GDI_CleanupDummy}, /* 09 ICMLCS, unused
*/
{1, sizeof(TEXTOBJ), TAG_LFONT, GDI_CleanupDummy}, /* 0a LFONT */
{0, 0, TAG_RFONT, NULL}, /* 0b RFONT, unused */
{0, 0, TAG_PFE, NULL}, /* 0c PFE, unused */
Modified: trunk/reactos/subsystems/win32/win32k/objects/icm.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/win32k/ob…
==============================================================================
--- trunk/reactos/subsystems/win32/win32k/objects/icm.c [iso-8859-1] (original)
+++ trunk/reactos/subsystems/win32/win32k/objects/icm.c [iso-8859-1] Wed May 14 21:15:10
2008
@@ -16,20 +16,75 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
-/* $Id$ */
#include <w32k.h>
#define NDEBUG
#include <debug.h>
+
+HCOLORSPACE hStockColorSpace = NULL;
+
+
+HCOLORSPACE
+FASTCALL
+IntGdiCreateColorSpace(
+ PLOGCOLORSPACEEXW pLogColorSpace)
+{
+ PCOLORSPACE pCS;
+ HCOLORSPACE hCS;
+
+ pCS = COLORSPACEOBJ_AllocCSWithHandle();
+ hCS = pCS->BaseObject.hHmgr;
+
+ pCS->lcsColorSpace = pLogColorSpace->lcsColorSpace;
+ pCS->dwFlags = pLogColorSpace->dwFlags;
+
+ COLORSPACEOBJ_UnlockCS(pCS);
+ return hCS;
+}
+
+BOOL
+FASTCALL
+IntGdiDeleteColorSpace(
+ HCOLORSPACE hColorSpace)
+{
+ BOOL Ret = FALSE;
+
+ if ( hColorSpace != hStockColorSpace )
+ {
+ Ret = COLORSPACEOBJ_FreeCSByHandle(hColorSpace);
+ if ( !Ret ) SetLastWin32Error(ERROR_INVALID_PARAMETER);
+ }
+ return Ret;
+}
HANDLE
APIENTRY
NtGdiCreateColorSpace(
IN PLOGCOLORSPACEEXW pLogColorSpace)
{
- UNIMPLEMENTED;
- return 0;
+ LOGCOLORSPACEEXW Safelcs;
+ NTSTATUS Status = STATUS_SUCCESS;
+
+ _SEH_TRY
+ {
+ ProbeForRead( pLogColorSpace,
+ sizeof(LOGCOLORSPACEEXW),
+ 1);
+ RtlCopyMemory(&Safelcs, pLogColorSpace, sizeof(LOGCOLORSPACEEXW));
+ }
+ _SEH_HANDLE
+ {
+ Status = _SEH_GetExceptionCode();
+ }
+ _SEH_END;
+
+ if (!NT_SUCCESS(Status))
+ {
+ SetLastNtError(Status);
+ return NULL;
+ }
+ return IntGdiCreateColorSpace(&Safelcs);
}
BOOL
@@ -37,8 +92,7 @@
NtGdiDeleteColorSpace(
IN HANDLE hColorSpace)
{
- UNIMPLEMENTED;
- return FALSE;
+ return IntGdiDeleteColorSpace(hColorSpace);
}
BOOL
@@ -136,8 +190,43 @@
NtGdiSetColorSpace(IN HDC hdc,
IN HCOLORSPACE hColorSpace)
{
- UNIMPLEMENTED;
- return 0;
+ PDC pDC;
+ PDC_ATTR pDc_Attr;
+ PCOLORSPACE pCS;
+
+ pDC = DC_LockDc(hdc);
+ if (!pDC)
+ {
+ SetLastWin32Error(ERROR_INVALID_HANDLE);
+ return FALSE;
+ }
+ pDc_Attr = pDC->pDc_Attr;
+ if(!pDc_Attr) pDc_Attr = &pDC->Dc_Attr;
+
+ if (pDc_Attr->hColorSpace == hColorSpace)
+ {
+ DC_UnlockDc(pDC);
+ return TRUE;
+ }
+
+ pCS = COLORSPACEOBJ_LockCS(hColorSpace);
+ if (!pCS)
+ {
+ SetLastWin32Error(ERROR_INVALID_HANDLE);
+ return FALSE;
+ }
+
+ if (pDC->DcLevel.pColorSpace)
+ {
+ GDIOBJ_ShareUnlockObjByPtr((POBJ) pDC->DcLevel.pColorSpace);
+ }
+
+ pDC->DcLevel.pColorSpace = pCS;
+ pDc_Attr->hColorSpace = hColorSpace;
+
+ COLORSPACEOBJ_UnlockCS(pCS);
+ DC_UnlockDc(pDC);
+ return TRUE;
}
BOOL