Wine-devel
Threads by month
- ----- 2026 -----
- March
- February
- January
- ----- 2025 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2024 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2023 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2022 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2021 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2020 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2019 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2018 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2017 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2016 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2015 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2014 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2013 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2012 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2011 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2010 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2009 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2008 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2007 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2006 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2005 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2004 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2003 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2002 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2001 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
November 2020
- 73 participants
- 650 discussions
24 Nov '20
Signed-off-by: Kevin Puetz <PuetzKevinA(a)JohnDeere.com>
Missed the signoff, and the subject should have been combase, not oleaut32
I’ll see if there are any other substantive comments before I resend a v2.
It’s kind of a nasty diff, but I couldn’t find a way to break it into a series where each step was functionally correct without introducing (and later fixing) a bunch of code duplication, which really didn’t make it more readable. The nested loop(s) were just fundamentally the wrong shape should seemingly just be one loop, which checks for alertable wakeup/handle completion/message/sleep inside. it's not too hard to read side-by-side if you use a tool like meld that can ignore leading whitespace and lets you add synchronization points that force it to line up the various almost-common hunks that were moved around.
1
0
[PATCH v2 1/2] winebrowser: Prefix an invalid URL with 'http://' before opening with a browser.
by Brendan Shanks 24 Nov '20
by Brendan Shanks 24 Nov '20
24 Nov '20
Fixes usage like 'winebrowser winehq.org' when xdg-open or macOS 'open' is used.
Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=50094
Signed-off-by: Brendan Shanks <bshanks(a)codeweavers.com>
---
v2: Split invalid URL handling into separate function.
programs/winebrowser/main.c | 27 +++++++++++++++++++++++++--
1 file changed, 25 insertions(+), 2 deletions(-)
diff --git a/programs/winebrowser/main.c b/programs/winebrowser/main.c
index 9cd6812d032..c70457e50b3 100644
--- a/programs/winebrowser/main.c
+++ b/programs/winebrowser/main.c
@@ -184,6 +184,29 @@ static int open_mailto_url( const WCHAR *url )
return launch_app( mailers, url );
}
+static int open_invalid_url( const WCHAR *url )
+{
+ static const WCHAR httpW[] =
+ {'h','t','t','p',':','/','/',0};
+
+ WCHAR *url_prefixed;
+ int ret;
+
+ url_prefixed = HeapAlloc( GetProcessHeap(), 0, (ARRAY_SIZE(httpW) + strlenW( url )) * sizeof(WCHAR) );
+ if (!url_prefixed)
+ {
+ WINE_ERR("Out of memory\n");
+ return 1;
+ }
+
+ strcpyW( url_prefixed, httpW );
+ strcatW( url_prefixed, url );
+
+ ret = open_http_url( url_prefixed );
+ HeapFree( GetProcessHeap(), 0, url_prefixed );
+ return ret;
+}
+
/*****************************************************************************
* DDE helper functions.
*/
@@ -448,8 +471,8 @@ int __cdecl wmain(int argc, WCHAR *argv[])
hres = CreateUri(url, Uri_CREATE_ALLOW_IMPLICIT_FILE_SCHEME|Uri_CREATE_FILE_USE_DOS_PATH, 0, &uri);
if(FAILED(hres)) {
- WINE_ERR("Failed to parse URL\n");
- ret = open_http_url(url);
+ WINE_ERR("Failed to parse URL %s, treating as HTTP\n", wine_dbgstr_w(url));
+ ret = open_invalid_url(url);
HeapFree(GetProcessHeap(), 0, ddeString);
return ret;
}
--
2.26.2
1
1
24 Nov '20
We have the following loop in test_CreateRestrictedToken which
can leave luid uninitialized:
for (i = 0; i < privs->PrivilegeCount; i++)
{
if (privs->Privileges[i].Attributes & SE_PRIVILEGE_ENABLED)
{
luid = privs->Privileges[i].Luid;
break;
}
}
So let's play it safely and initialize this upon declaration.
This is being diagnosed by clang 10.0.1, which is not the compiler
I ever use for production code, but that occasionally "sneaks" in.
Gerald
Signed-off-by: Gerald Pfeifer <gerald(a)pfeifer.com>
---
dlls/advapi32/tests/security.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/dlls/advapi32/tests/security.c b/dlls/advapi32/tests/security.c
index eaaa29866bb..020e69277e0 100644
--- a/dlls/advapi32/tests/security.c
+++ b/dlls/advapi32/tests/security.c
@@ -5195,7 +5195,7 @@ static void test_CreateRestrictedToken(void)
TOKEN_TYPE type;
BOOL is_member;
DWORD size;
- LUID luid;
+ LUID luid = { 0, 0 };
BOOL ret;
DWORD i;
--
2.28.0
1
0
Signed-off-by: Esme Povirk <esme(a)codeweavers.com>
---
dlls/windowscodecs/Makefile.in | 1 -
dlls/windowscodecs/encoder.c | 14 +-
dlls/windowscodecs/jpegformat.c | 920 -------------------------
dlls/windowscodecs/libjpeg.c | 313 +++++++++
dlls/windowscodecs/main.c | 28 +
dlls/windowscodecs/unix_lib.c | 3 +
dlls/windowscodecs/wincodecs_private.h | 7 +
7 files changed, 364 insertions(+), 922 deletions(-)
delete mode 100644 dlls/windowscodecs/jpegformat.c
diff --git a/dlls/windowscodecs/Makefile.in b/dlls/windowscodecs/Makefile.in
index d7f9336916b..2ab89eac84c 100644
--- a/dlls/windowscodecs/Makefile.in
+++ b/dlls/windowscodecs/Makefile.in
@@ -22,7 +22,6 @@ C_SRCS = \
icoformat.c \
imgfactory.c \
info.c \
- jpegformat.c \
libjpeg.c \
libpng.c \
libtiff.c \
diff --git a/dlls/windowscodecs/encoder.c b/dlls/windowscodecs/encoder.c
index bb673b13076..b17895a6c9c 100644
--- a/dlls/windowscodecs/encoder.c
+++ b/dlls/windowscodecs/encoder.c
@@ -38,12 +38,24 @@ static const WCHAR wszPngInterlaceOption[] = {'I','n','t','e','r','l','a','c','e
static const WCHAR wszPngFilterOption[] = {'F','i','l','t','e','r','O','p','t','i','o','n',0};
static const WCHAR wszTiffCompressionMethod[] = {'T','i','f','f','C','o','m','p','r','e','s','s','i','o','n','M','e','t','h','o','d',0};
static const WCHAR wszCompressionQuality[] = {'C','o','m','p','r','e','s','s','i','o','n','Q','u','a','l','i','t','y',0};
+static const WCHAR wszImageQuality[] = {'I','m','a','g','e','Q','u','a','l','i','t','y',0};
+static const WCHAR wszBitmapTransform[] = {'B','i','t','m','a','p','T','r','a','n','s','f','o','r','m',0};
+static const WCHAR wszLuminance[] = {'L','u','m','i','n','a','n','c','e',0};
+static const WCHAR wszChrominance[] = {'C','h','r','o','m','i','n','a','n','c','e',0};
+static const WCHAR wszJpegYCrCbSubsampling[] = {'J','p','e','g','Y','C','r','C','b','S','u','b','s','a','m','p','l','i','n','g',0};
+static const WCHAR wszSuppressApp0[] = {'S','u','p','p','r','e','s','s','A','p','p','0',0};
static const PROPBAG2 encoder_option_properties[ENCODER_OPTION_END] = {
{ PROPBAG2_TYPE_DATA, VT_BOOL, 0, 0, (LPOLESTR)wszPngInterlaceOption },
{ PROPBAG2_TYPE_DATA, VT_UI1, 0, 0, (LPOLESTR)wszPngFilterOption },
{ PROPBAG2_TYPE_DATA, VT_UI1, 0, 0, (LPOLESTR)wszTiffCompressionMethod },
- { PROPBAG2_TYPE_DATA, VT_R4, 0, 0, (LPOLESTR)wszCompressionQuality }
+ { PROPBAG2_TYPE_DATA, VT_R4, 0, 0, (LPOLESTR)wszCompressionQuality },
+ { PROPBAG2_TYPE_DATA, VT_R4, 0, 0, (LPOLESTR)wszImageQuality },
+ { PROPBAG2_TYPE_DATA, VT_UI1, 0, 0, (LPOLESTR)wszBitmapTransform },
+ { PROPBAG2_TYPE_DATA, VT_I4 | VT_ARRAY, 0, 0, (LPOLESTR)wszLuminance },
+ { PROPBAG2_TYPE_DATA, VT_I4 | VT_ARRAY, 0, 0, (LPOLESTR)wszChrominance },
+ { PROPBAG2_TYPE_DATA, VT_UI1, 0, 0, (LPOLESTR)wszJpegYCrCbSubsampling },
+ { PROPBAG2_TYPE_DATA, VT_BOOL, 0, 0, (LPOLESTR)wszSuppressApp0 }
};
typedef struct CommonEncoder {
diff --git a/dlls/windowscodecs/jpegformat.c b/dlls/windowscodecs/jpegformat.c
deleted file mode 100644
index 5be35a1ccb4..00000000000
--- a/dlls/windowscodecs/jpegformat.c
+++ /dev/null
@@ -1,920 +0,0 @@
-/*
- * Copyright 2009 Vincent Povirk for CodeWeavers
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
- */
-
-#include "config.h"
-#include "wine/port.h"
-
-#ifdef HAVE_UNISTD_H
-# include <unistd.h>
-#endif
-#include <stdarg.h>
-#include <stdio.h>
-#include <string.h>
-#include <setjmp.h>
-
-#ifdef SONAME_LIBJPEG
-/* This is a hack, so jpeglib.h does not redefine INT32 and the like*/
-#define XMD_H
-#define UINT8 JPEG_UINT8
-#define UINT16 JPEG_UINT16
-#define boolean jpeg_boolean
-#undef HAVE_STDLIB_H
-# include <jpeglib.h>
-#undef HAVE_STDLIB_H
-#define HAVE_STDLIB_H 1
-#undef UINT8
-#undef UINT16
-#undef boolean
-#endif
-
-#define COBJMACROS
-
-#include "windef.h"
-#include "winbase.h"
-#include "objbase.h"
-
-#include "wincodecs_private.h"
-
-#include "wine/heap.h"
-#include "wine/debug.h"
-
-WINE_DEFAULT_DEBUG_CHANNEL(wincodecs);
-
-#ifdef SONAME_LIBJPEG
-WINE_DECLARE_DEBUG_CHANNEL(jpeg);
-
-static void *libjpeg_handle;
-
-static const WCHAR wszImageQuality[] = {'I','m','a','g','e','Q','u','a','l','i','t','y',0};
-static const WCHAR wszBitmapTransform[] = {'B','i','t','m','a','p','T','r','a','n','s','f','o','r','m',0};
-static const WCHAR wszLuminance[] = {'L','u','m','i','n','a','n','c','e',0};
-static const WCHAR wszChrominance[] = {'C','h','r','o','m','i','n','a','n','c','e',0};
-static const WCHAR wszJpegYCrCbSubsampling[] = {'J','p','e','g','Y','C','r','C','b','S','u','b','s','a','m','p','l','i','n','g',0};
-static const WCHAR wszSuppressApp0[] = {'S','u','p','p','r','e','s','s','A','p','p','0',0};
-
-#define MAKE_FUNCPTR(f) static typeof(f) * p##f
-MAKE_FUNCPTR(jpeg_CreateCompress);
-MAKE_FUNCPTR(jpeg_CreateDecompress);
-MAKE_FUNCPTR(jpeg_destroy_compress);
-MAKE_FUNCPTR(jpeg_destroy_decompress);
-MAKE_FUNCPTR(jpeg_finish_compress);
-MAKE_FUNCPTR(jpeg_read_header);
-MAKE_FUNCPTR(jpeg_read_scanlines);
-MAKE_FUNCPTR(jpeg_resync_to_restart);
-MAKE_FUNCPTR(jpeg_set_defaults);
-MAKE_FUNCPTR(jpeg_start_compress);
-MAKE_FUNCPTR(jpeg_start_decompress);
-MAKE_FUNCPTR(jpeg_std_error);
-MAKE_FUNCPTR(jpeg_write_scanlines);
-#undef MAKE_FUNCPTR
-
-static void *load_libjpeg(void)
-{
- if((libjpeg_handle = dlopen(SONAME_LIBJPEG, RTLD_NOW)) != NULL) {
-
-#define LOAD_FUNCPTR(f) \
- if((p##f = dlsym(libjpeg_handle, #f)) == NULL) { \
- libjpeg_handle = NULL; \
- return NULL; \
- }
-
- LOAD_FUNCPTR(jpeg_CreateCompress);
- LOAD_FUNCPTR(jpeg_CreateDecompress);
- LOAD_FUNCPTR(jpeg_destroy_compress);
- LOAD_FUNCPTR(jpeg_destroy_decompress);
- LOAD_FUNCPTR(jpeg_finish_compress);
- LOAD_FUNCPTR(jpeg_read_header);
- LOAD_FUNCPTR(jpeg_read_scanlines);
- LOAD_FUNCPTR(jpeg_resync_to_restart);
- LOAD_FUNCPTR(jpeg_set_defaults);
- LOAD_FUNCPTR(jpeg_start_compress);
- LOAD_FUNCPTR(jpeg_start_decompress);
- LOAD_FUNCPTR(jpeg_std_error);
- LOAD_FUNCPTR(jpeg_write_scanlines);
-#undef LOAD_FUNCPTR
- }
- return libjpeg_handle;
-}
-
-static void error_exit_fn(j_common_ptr cinfo)
-{
- char message[JMSG_LENGTH_MAX];
- if (ERR_ON(jpeg))
- {
- cinfo->err->format_message(cinfo, message);
- ERR_(jpeg)("%s\n", message);
- }
- longjmp(*(jmp_buf*)cinfo->client_data, 1);
-}
-
-static void emit_message_fn(j_common_ptr cinfo, int msg_level)
-{
- char message[JMSG_LENGTH_MAX];
-
- if (msg_level < 0 && ERR_ON(jpeg))
- {
- cinfo->err->format_message(cinfo, message);
- ERR_(jpeg)("%s\n", message);
- }
- else if (msg_level == 0 && WARN_ON(jpeg))
- {
- cinfo->err->format_message(cinfo, message);
- WARN_(jpeg)("%s\n", message);
- }
- else if (msg_level > 0 && TRACE_ON(jpeg))
- {
- cinfo->err->format_message(cinfo, message);
- TRACE_(jpeg)("%s\n", message);
- }
-}
-
-typedef struct jpeg_compress_format {
- const WICPixelFormatGUID *guid;
- int bpp;
- int num_components;
- J_COLOR_SPACE color_space;
- int swap_rgb;
-} jpeg_compress_format;
-
-static const jpeg_compress_format compress_formats[] = {
- { &GUID_WICPixelFormat24bppBGR, 24, 3, JCS_RGB, 1 },
- { &GUID_WICPixelFormat32bppCMYK, 32, 4, JCS_CMYK },
- { &GUID_WICPixelFormat8bppGray, 8, 1, JCS_GRAYSCALE },
- { 0 }
-};
-
-typedef struct JpegEncoder {
- IWICBitmapEncoder IWICBitmapEncoder_iface;
- IWICBitmapFrameEncode IWICBitmapFrameEncode_iface;
- LONG ref;
- struct jpeg_compress_struct cinfo;
- struct jpeg_error_mgr jerr;
- struct jpeg_destination_mgr dest_mgr;
- BOOL initialized;
- int frame_count;
- BOOL frame_initialized;
- BOOL started_compress;
- int lines_written;
- BOOL frame_committed;
- BOOL committed;
- UINT width, height;
- double xres, yres;
- const jpeg_compress_format *format;
- IStream *stream;
- WICColor palette[256];
- UINT colors;
- CRITICAL_SECTION lock;
- BYTE dest_buffer[1024];
-} JpegEncoder;
-
-static inline JpegEncoder *impl_from_IWICBitmapEncoder(IWICBitmapEncoder *iface)
-{
- return CONTAINING_RECORD(iface, JpegEncoder, IWICBitmapEncoder_iface);
-}
-
-static inline JpegEncoder *impl_from_IWICBitmapFrameEncode(IWICBitmapFrameEncode *iface)
-{
- return CONTAINING_RECORD(iface, JpegEncoder, IWICBitmapFrameEncode_iface);
-}
-
-static inline JpegEncoder *encoder_from_compress(j_compress_ptr compress)
-{
- return CONTAINING_RECORD(compress, JpegEncoder, cinfo);
-}
-
-static void dest_mgr_init_destination(j_compress_ptr cinfo)
-{
- JpegEncoder *This = encoder_from_compress(cinfo);
-
- This->dest_mgr.next_output_byte = This->dest_buffer;
- This->dest_mgr.free_in_buffer = sizeof(This->dest_buffer);
-}
-
-static jpeg_boolean dest_mgr_empty_output_buffer(j_compress_ptr cinfo)
-{
- JpegEncoder *This = encoder_from_compress(cinfo);
- HRESULT hr;
- ULONG byteswritten;
-
- hr = IStream_Write(This->stream, This->dest_buffer,
- sizeof(This->dest_buffer), &byteswritten);
-
- if (hr != S_OK || byteswritten == 0)
- {
- ERR("Failed writing data, hr=%x\n", hr);
- return FALSE;
- }
-
- This->dest_mgr.next_output_byte = This->dest_buffer;
- This->dest_mgr.free_in_buffer = sizeof(This->dest_buffer);
- return TRUE;
-}
-
-static void dest_mgr_term_destination(j_compress_ptr cinfo)
-{
- JpegEncoder *This = encoder_from_compress(cinfo);
- ULONG byteswritten;
- HRESULT hr;
-
- if (This->dest_mgr.free_in_buffer != sizeof(This->dest_buffer))
- {
- hr = IStream_Write(This->stream, This->dest_buffer,
- sizeof(This->dest_buffer) - This->dest_mgr.free_in_buffer, &byteswritten);
-
- if (hr != S_OK || byteswritten == 0)
- ERR("Failed writing data, hr=%x\n", hr);
- }
-}
-
-static HRESULT WINAPI JpegEncoder_Frame_QueryInterface(IWICBitmapFrameEncode *iface, REFIID iid,
- void **ppv)
-{
- JpegEncoder *This = impl_from_IWICBitmapFrameEncode(iface);
- TRACE("(%p,%s,%p)\n", iface, debugstr_guid(iid), ppv);
-
- if (!ppv) return E_INVALIDARG;
-
- if (IsEqualIID(&IID_IUnknown, iid) ||
- IsEqualIID(&IID_IWICBitmapFrameEncode, iid))
- {
- *ppv = &This->IWICBitmapFrameEncode_iface;
- }
- else
- {
- *ppv = NULL;
- return E_NOINTERFACE;
- }
-
- IUnknown_AddRef((IUnknown*)*ppv);
- return S_OK;
-}
-
-static ULONG WINAPI JpegEncoder_Frame_AddRef(IWICBitmapFrameEncode *iface)
-{
- JpegEncoder *This = impl_from_IWICBitmapFrameEncode(iface);
- return IWICBitmapEncoder_AddRef(&This->IWICBitmapEncoder_iface);
-}
-
-static ULONG WINAPI JpegEncoder_Frame_Release(IWICBitmapFrameEncode *iface)
-{
- JpegEncoder *This = impl_from_IWICBitmapFrameEncode(iface);
- return IWICBitmapEncoder_Release(&This->IWICBitmapEncoder_iface);
-}
-
-static HRESULT WINAPI JpegEncoder_Frame_Initialize(IWICBitmapFrameEncode *iface,
- IPropertyBag2 *pIEncoderOptions)
-{
- JpegEncoder *This = impl_from_IWICBitmapFrameEncode(iface);
- TRACE("(%p,%p)\n", iface, pIEncoderOptions);
-
- EnterCriticalSection(&This->lock);
-
- if (This->frame_initialized)
- {
- LeaveCriticalSection(&This->lock);
- return WINCODEC_ERR_WRONGSTATE;
- }
-
- This->frame_initialized = TRUE;
-
- LeaveCriticalSection(&This->lock);
-
- return S_OK;
-}
-
-static HRESULT WINAPI JpegEncoder_Frame_SetSize(IWICBitmapFrameEncode *iface,
- UINT uiWidth, UINT uiHeight)
-{
- JpegEncoder *This = impl_from_IWICBitmapFrameEncode(iface);
- TRACE("(%p,%u,%u)\n", iface, uiWidth, uiHeight);
-
- EnterCriticalSection(&This->lock);
-
- if (!This->frame_initialized || This->started_compress)
- {
- LeaveCriticalSection(&This->lock);
- return WINCODEC_ERR_WRONGSTATE;
- }
-
- This->width = uiWidth;
- This->height = uiHeight;
-
- LeaveCriticalSection(&This->lock);
-
- return S_OK;
-}
-
-static HRESULT WINAPI JpegEncoder_Frame_SetResolution(IWICBitmapFrameEncode *iface,
- double dpiX, double dpiY)
-{
- JpegEncoder *This = impl_from_IWICBitmapFrameEncode(iface);
- TRACE("(%p,%0.2f,%0.2f)\n", iface, dpiX, dpiY);
-
- EnterCriticalSection(&This->lock);
-
- if (!This->frame_initialized || This->started_compress)
- {
- LeaveCriticalSection(&This->lock);
- return WINCODEC_ERR_WRONGSTATE;
- }
-
- This->xres = dpiX;
- This->yres = dpiY;
-
- LeaveCriticalSection(&This->lock);
-
- return S_OK;
-}
-
-static HRESULT WINAPI JpegEncoder_Frame_SetPixelFormat(IWICBitmapFrameEncode *iface,
- WICPixelFormatGUID *pPixelFormat)
-{
- JpegEncoder *This = impl_from_IWICBitmapFrameEncode(iface);
- int i;
- TRACE("(%p,%s)\n", iface, debugstr_guid(pPixelFormat));
-
- EnterCriticalSection(&This->lock);
-
- if (!This->frame_initialized || This->started_compress)
- {
- LeaveCriticalSection(&This->lock);
- return WINCODEC_ERR_WRONGSTATE;
- }
-
- for (i=0; compress_formats[i].guid; i++)
- {
- if (memcmp(compress_formats[i].guid, pPixelFormat, sizeof(GUID)) == 0)
- break;
- }
-
- if (!compress_formats[i].guid) i = 0;
-
- This->format = &compress_formats[i];
- memcpy(pPixelFormat, This->format->guid, sizeof(GUID));
-
- LeaveCriticalSection(&This->lock);
-
- return S_OK;
-}
-
-static HRESULT WINAPI JpegEncoder_Frame_SetColorContexts(IWICBitmapFrameEncode *iface,
- UINT cCount, IWICColorContext **ppIColorContext)
-{
- FIXME("(%p,%u,%p): stub\n", iface, cCount, ppIColorContext);
- return E_NOTIMPL;
-}
-
-static HRESULT WINAPI JpegEncoder_Frame_SetPalette(IWICBitmapFrameEncode *iface,
- IWICPalette *palette)
-{
- JpegEncoder *This = impl_from_IWICBitmapFrameEncode(iface);
- HRESULT hr;
-
- TRACE("(%p,%p)\n", iface, palette);
-
- if (!palette) return E_INVALIDARG;
-
- EnterCriticalSection(&This->lock);
-
- if (This->frame_initialized)
- hr = IWICPalette_GetColors(palette, 256, This->palette, &This->colors);
- else
- hr = WINCODEC_ERR_NOTINITIALIZED;
-
- LeaveCriticalSection(&This->lock);
- return hr;
-}
-
-static HRESULT WINAPI JpegEncoder_Frame_SetThumbnail(IWICBitmapFrameEncode *iface,
- IWICBitmapSource *pIThumbnail)
-{
- FIXME("(%p,%p): stub\n", iface, pIThumbnail);
- return WINCODEC_ERR_UNSUPPORTEDOPERATION;
-}
-
-static HRESULT WINAPI JpegEncoder_Frame_WritePixels(IWICBitmapFrameEncode *iface,
- UINT lineCount, UINT cbStride, UINT cbBufferSize, BYTE *pbPixels)
-{
- JpegEncoder *This = impl_from_IWICBitmapFrameEncode(iface);
- jmp_buf jmpbuf;
- BYTE *swapped_data = NULL, *current_row;
- UINT line;
- int row_size;
- TRACE("(%p,%u,%u,%u,%p)\n", iface, lineCount, cbStride, cbBufferSize, pbPixels);
-
- EnterCriticalSection(&This->lock);
-
- if (!This->frame_initialized || !This->width || !This->height || !This->format)
- {
- LeaveCriticalSection(&This->lock);
- return WINCODEC_ERR_WRONGSTATE;
- }
-
- if (lineCount == 0 || lineCount + This->lines_written > This->height)
- {
- LeaveCriticalSection(&This->lock);
- return E_INVALIDARG;
- }
-
- /* set up setjmp/longjmp error handling */
- if (setjmp(jmpbuf))
- {
- LeaveCriticalSection(&This->lock);
- HeapFree(GetProcessHeap(), 0, swapped_data);
- return E_FAIL;
- }
- This->cinfo.client_data = jmpbuf;
-
- if (!This->started_compress)
- {
- This->cinfo.image_width = This->width;
- This->cinfo.image_height = This->height;
- This->cinfo.input_components = This->format->num_components;
- This->cinfo.in_color_space = This->format->color_space;
-
- pjpeg_set_defaults(&This->cinfo);
-
- if (This->xres != 0.0 && This->yres != 0.0)
- {
- This->cinfo.density_unit = 1; /* dots per inch */
- This->cinfo.X_density = This->xres;
- This->cinfo.Y_density = This->yres;
- }
-
- pjpeg_start_compress(&This->cinfo, TRUE);
-
- This->started_compress = TRUE;
- }
-
- row_size = This->format->bpp / 8 * This->width;
-
- if (This->format->swap_rgb)
- {
- swapped_data = HeapAlloc(GetProcessHeap(), 0, row_size);
- if (!swapped_data)
- {
- LeaveCriticalSection(&This->lock);
- return E_OUTOFMEMORY;
- }
- }
-
- for (line=0; line < lineCount; line++)
- {
- if (This->format->swap_rgb)
- {
- UINT x;
-
- memcpy(swapped_data, pbPixels + (cbStride * line), row_size);
-
- for (x=0; x < This->width; x++)
- {
- BYTE b;
-
- b = swapped_data[x*3];
- swapped_data[x*3] = swapped_data[x*3+2];
- swapped_data[x*3+2] = b;
- }
-
- current_row = swapped_data;
- }
- else
- current_row = pbPixels + (cbStride * line);
-
- if (!pjpeg_write_scanlines(&This->cinfo, ¤t_row, 1))
- {
- ERR("failed writing scanlines\n");
- LeaveCriticalSection(&This->lock);
- HeapFree(GetProcessHeap(), 0, swapped_data);
- return E_FAIL;
- }
-
- This->lines_written++;
- }
-
- LeaveCriticalSection(&This->lock);
- HeapFree(GetProcessHeap(), 0, swapped_data);
-
- return S_OK;
-}
-
-static HRESULT WINAPI JpegEncoder_Frame_WriteSource(IWICBitmapFrameEncode *iface,
- IWICBitmapSource *pIBitmapSource, WICRect *prc)
-{
- JpegEncoder *This = impl_from_IWICBitmapFrameEncode(iface);
- HRESULT hr;
- TRACE("(%p,%p,%s)\n", iface, pIBitmapSource, debug_wic_rect(prc));
-
- if (!This->frame_initialized)
- return WINCODEC_ERR_WRONGSTATE;
-
- hr = configure_write_source(iface, pIBitmapSource, prc,
- This->format ? This->format->guid : NULL, This->width, This->height,
- This->xres, This->yres);
-
- if (SUCCEEDED(hr))
- {
- hr = write_source(iface, pIBitmapSource, prc,
- This->format->guid, This->format->bpp, FALSE,
- This->width, This->height);
- }
-
- return hr;
-}
-
-static HRESULT WINAPI JpegEncoder_Frame_Commit(IWICBitmapFrameEncode *iface)
-{
- JpegEncoder *This = impl_from_IWICBitmapFrameEncode(iface);
- jmp_buf jmpbuf;
- TRACE("(%p)\n", iface);
-
- EnterCriticalSection(&This->lock);
-
- if (!This->started_compress || This->lines_written != This->height || This->frame_committed)
- {
- LeaveCriticalSection(&This->lock);
- return WINCODEC_ERR_WRONGSTATE;
- }
-
- /* set up setjmp/longjmp error handling */
- if (setjmp(jmpbuf))
- {
- LeaveCriticalSection(&This->lock);
- return E_FAIL;
- }
- This->cinfo.client_data = jmpbuf;
-
- pjpeg_finish_compress(&This->cinfo);
-
- This->frame_committed = TRUE;
-
- LeaveCriticalSection(&This->lock);
-
- return S_OK;
-}
-
-static HRESULT WINAPI JpegEncoder_Frame_GetMetadataQueryWriter(IWICBitmapFrameEncode *iface,
- IWICMetadataQueryWriter **ppIMetadataQueryWriter)
-{
- FIXME("(%p, %p): stub\n", iface, ppIMetadataQueryWriter);
- return E_NOTIMPL;
-}
-
-static const IWICBitmapFrameEncodeVtbl JpegEncoder_FrameVtbl = {
- JpegEncoder_Frame_QueryInterface,
- JpegEncoder_Frame_AddRef,
- JpegEncoder_Frame_Release,
- JpegEncoder_Frame_Initialize,
- JpegEncoder_Frame_SetSize,
- JpegEncoder_Frame_SetResolution,
- JpegEncoder_Frame_SetPixelFormat,
- JpegEncoder_Frame_SetColorContexts,
- JpegEncoder_Frame_SetPalette,
- JpegEncoder_Frame_SetThumbnail,
- JpegEncoder_Frame_WritePixels,
- JpegEncoder_Frame_WriteSource,
- JpegEncoder_Frame_Commit,
- JpegEncoder_Frame_GetMetadataQueryWriter
-};
-
-static HRESULT WINAPI JpegEncoder_QueryInterface(IWICBitmapEncoder *iface, REFIID iid,
- void **ppv)
-{
- JpegEncoder *This = impl_from_IWICBitmapEncoder(iface);
- TRACE("(%p,%s,%p)\n", iface, debugstr_guid(iid), ppv);
-
- if (!ppv) return E_INVALIDARG;
-
- if (IsEqualIID(&IID_IUnknown, iid) ||
- IsEqualIID(&IID_IWICBitmapEncoder, iid))
- {
- *ppv = &This->IWICBitmapEncoder_iface;
- }
- else
- {
- *ppv = NULL;
- return E_NOINTERFACE;
- }
-
- IUnknown_AddRef((IUnknown*)*ppv);
- return S_OK;
-}
-
-static ULONG WINAPI JpegEncoder_AddRef(IWICBitmapEncoder *iface)
-{
- JpegEncoder *This = impl_from_IWICBitmapEncoder(iface);
- ULONG ref = InterlockedIncrement(&This->ref);
-
- TRACE("(%p) refcount=%u\n", iface, ref);
-
- return ref;
-}
-
-static ULONG WINAPI JpegEncoder_Release(IWICBitmapEncoder *iface)
-{
- JpegEncoder *This = impl_from_IWICBitmapEncoder(iface);
- ULONG ref = InterlockedDecrement(&This->ref);
-
- TRACE("(%p) refcount=%u\n", iface, ref);
-
- if (ref == 0)
- {
- This->lock.DebugInfo->Spare[0] = 0;
- DeleteCriticalSection(&This->lock);
- if (This->initialized) pjpeg_destroy_compress(&This->cinfo);
- if (This->stream) IStream_Release(This->stream);
- HeapFree(GetProcessHeap(), 0, This);
- }
-
- return ref;
-}
-
-static HRESULT WINAPI JpegEncoder_Initialize(IWICBitmapEncoder *iface,
- IStream *pIStream, WICBitmapEncoderCacheOption cacheOption)
-{
- JpegEncoder *This = impl_from_IWICBitmapEncoder(iface);
- jmp_buf jmpbuf;
-
- TRACE("(%p,%p,%u)\n", iface, pIStream, cacheOption);
-
- EnterCriticalSection(&This->lock);
-
- if (This->initialized)
- {
- LeaveCriticalSection(&This->lock);
- return WINCODEC_ERR_WRONGSTATE;
- }
-
- pjpeg_std_error(&This->jerr);
-
- This->jerr.error_exit = error_exit_fn;
- This->jerr.emit_message = emit_message_fn;
-
- This->cinfo.err = &This->jerr;
-
- This->cinfo.client_data = jmpbuf;
-
- if (setjmp(jmpbuf))
- {
- LeaveCriticalSection(&This->lock);
- return E_FAIL;
- }
-
- pjpeg_CreateCompress(&This->cinfo, JPEG_LIB_VERSION, sizeof(struct jpeg_compress_struct));
-
- This->stream = pIStream;
- IStream_AddRef(pIStream);
-
- This->dest_mgr.next_output_byte = This->dest_buffer;
- This->dest_mgr.free_in_buffer = sizeof(This->dest_buffer);
-
- This->dest_mgr.init_destination = dest_mgr_init_destination;
- This->dest_mgr.empty_output_buffer = dest_mgr_empty_output_buffer;
- This->dest_mgr.term_destination = dest_mgr_term_destination;
-
- This->cinfo.dest = &This->dest_mgr;
-
- This->initialized = TRUE;
-
- LeaveCriticalSection(&This->lock);
-
- return S_OK;
-}
-
-static HRESULT WINAPI JpegEncoder_GetContainerFormat(IWICBitmapEncoder *iface, GUID *format)
-{
- TRACE("(%p,%p)\n", iface, format);
-
- if (!format)
- return E_INVALIDARG;
-
- memcpy(format, &GUID_ContainerFormatJpeg, sizeof(*format));
- return S_OK;
-}
-
-static HRESULT WINAPI JpegEncoder_GetEncoderInfo(IWICBitmapEncoder *iface, IWICBitmapEncoderInfo **info)
-{
- IWICComponentInfo *comp_info;
- HRESULT hr;
-
- TRACE("%p,%p\n", iface, info);
-
- if (!info) return E_INVALIDARG;
-
- hr = CreateComponentInfo(&CLSID_WICJpegEncoder, &comp_info);
- if (hr == S_OK)
- {
- hr = IWICComponentInfo_QueryInterface(comp_info, &IID_IWICBitmapEncoderInfo, (void **)info);
- IWICComponentInfo_Release(comp_info);
- }
- return hr;
-}
-
-static HRESULT WINAPI JpegEncoder_SetColorContexts(IWICBitmapEncoder *iface,
- UINT cCount, IWICColorContext **ppIColorContext)
-{
- FIXME("(%p,%u,%p): stub\n", iface, cCount, ppIColorContext);
- return E_NOTIMPL;
-}
-
-static HRESULT WINAPI JpegEncoder_SetPalette(IWICBitmapEncoder *iface, IWICPalette *pIPalette)
-{
- JpegEncoder *This = impl_from_IWICBitmapEncoder(iface);
- HRESULT hr;
-
- TRACE("(%p,%p)\n", iface, pIPalette);
-
- EnterCriticalSection(&This->lock);
-
- hr = This->initialized ? WINCODEC_ERR_UNSUPPORTEDOPERATION : WINCODEC_ERR_NOTINITIALIZED;
-
- LeaveCriticalSection(&This->lock);
-
- return hr;
-}
-
-static HRESULT WINAPI JpegEncoder_SetThumbnail(IWICBitmapEncoder *iface, IWICBitmapSource *pIThumbnail)
-{
- TRACE("(%p,%p)\n", iface, pIThumbnail);
- return WINCODEC_ERR_UNSUPPORTEDOPERATION;
-}
-
-static HRESULT WINAPI JpegEncoder_SetPreview(IWICBitmapEncoder *iface, IWICBitmapSource *pIPreview)
-{
- TRACE("(%p,%p)\n", iface, pIPreview);
- return WINCODEC_ERR_UNSUPPORTEDOPERATION;
-}
-
-static HRESULT WINAPI JpegEncoder_CreateNewFrame(IWICBitmapEncoder *iface,
- IWICBitmapFrameEncode **ppIFrameEncode, IPropertyBag2 **ppIEncoderOptions)
-{
- JpegEncoder *This = impl_from_IWICBitmapEncoder(iface);
- HRESULT hr;
- static const PROPBAG2 opts[6] =
- {
- { PROPBAG2_TYPE_DATA, VT_R4, 0, 0, (LPOLESTR)wszImageQuality },
- { PROPBAG2_TYPE_DATA, VT_UI1, 0, 0, (LPOLESTR)wszBitmapTransform },
- { PROPBAG2_TYPE_DATA, VT_I4 | VT_ARRAY, 0, 0, (LPOLESTR)wszLuminance },
- { PROPBAG2_TYPE_DATA, VT_I4 | VT_ARRAY, 0, 0, (LPOLESTR)wszChrominance },
- { PROPBAG2_TYPE_DATA, VT_UI1, 0, 0, (LPOLESTR)wszJpegYCrCbSubsampling },
- { PROPBAG2_TYPE_DATA, VT_BOOL, 0, 0, (LPOLESTR)wszSuppressApp0 },
- };
-
- TRACE("(%p,%p,%p)\n", iface, ppIFrameEncode, ppIEncoderOptions);
-
- EnterCriticalSection(&This->lock);
-
- if (This->frame_count != 0)
- {
- LeaveCriticalSection(&This->lock);
- return WINCODEC_ERR_UNSUPPORTEDOPERATION;
- }
-
- if (!This->initialized)
- {
- LeaveCriticalSection(&This->lock);
- return WINCODEC_ERR_NOTINITIALIZED;
- }
-
- if (ppIEncoderOptions)
- {
- hr = CreatePropertyBag2(opts, ARRAY_SIZE(opts), ppIEncoderOptions);
- if (FAILED(hr))
- {
- LeaveCriticalSection(&This->lock);
- return hr;
- }
- }
-
- This->frame_count = 1;
-
- LeaveCriticalSection(&This->lock);
-
- IWICBitmapEncoder_AddRef(iface);
- *ppIFrameEncode = &This->IWICBitmapFrameEncode_iface;
-
- return S_OK;
-}
-
-static HRESULT WINAPI JpegEncoder_Commit(IWICBitmapEncoder *iface)
-{
- JpegEncoder *This = impl_from_IWICBitmapEncoder(iface);
- TRACE("(%p)\n", iface);
-
- EnterCriticalSection(&This->lock);
-
- if (!This->frame_committed || This->committed)
- {
- LeaveCriticalSection(&This->lock);
- return WINCODEC_ERR_WRONGSTATE;
- }
-
- This->committed = TRUE;
-
- LeaveCriticalSection(&This->lock);
-
- return S_OK;
-}
-
-static HRESULT WINAPI JpegEncoder_GetMetadataQueryWriter(IWICBitmapEncoder *iface,
- IWICMetadataQueryWriter **ppIMetadataQueryWriter)
-{
- FIXME("(%p,%p): stub\n", iface, ppIMetadataQueryWriter);
- return E_NOTIMPL;
-}
-
-static const IWICBitmapEncoderVtbl JpegEncoder_Vtbl = {
- JpegEncoder_QueryInterface,
- JpegEncoder_AddRef,
- JpegEncoder_Release,
- JpegEncoder_Initialize,
- JpegEncoder_GetContainerFormat,
- JpegEncoder_GetEncoderInfo,
- JpegEncoder_SetColorContexts,
- JpegEncoder_SetPalette,
- JpegEncoder_SetThumbnail,
- JpegEncoder_SetPreview,
- JpegEncoder_CreateNewFrame,
- JpegEncoder_Commit,
- JpegEncoder_GetMetadataQueryWriter
-};
-
-HRESULT JpegEncoder_CreateInstance(REFIID iid, void** ppv)
-{
- JpegEncoder *This;
- HRESULT ret;
-
- TRACE("(%s,%p)\n", debugstr_guid(iid), ppv);
-
- *ppv = NULL;
-
- if (!libjpeg_handle && !load_libjpeg())
- {
- ERR("Failed writing JPEG because unable to find %s\n",SONAME_LIBJPEG);
- return E_FAIL;
- }
-
- This = HeapAlloc(GetProcessHeap(), 0, sizeof(JpegEncoder));
- if (!This) return E_OUTOFMEMORY;
-
- This->IWICBitmapEncoder_iface.lpVtbl = &JpegEncoder_Vtbl;
- This->IWICBitmapFrameEncode_iface.lpVtbl = &JpegEncoder_FrameVtbl;
- This->ref = 1;
- This->initialized = FALSE;
- This->frame_count = 0;
- This->frame_initialized = FALSE;
- This->started_compress = FALSE;
- This->lines_written = 0;
- This->frame_committed = FALSE;
- This->committed = FALSE;
- This->width = This->height = 0;
- This->xres = This->yres = 0.0;
- This->format = NULL;
- This->stream = NULL;
- This->colors = 0;
- InitializeCriticalSection(&This->lock);
- This->lock.DebugInfo->Spare[0] = (DWORD_PTR)(__FILE__ ": JpegEncoder.lock");
-
- ret = IWICBitmapEncoder_QueryInterface(&This->IWICBitmapEncoder_iface, iid, ppv);
- IWICBitmapEncoder_Release(&This->IWICBitmapEncoder_iface);
-
- return ret;
-}
-
-#else /* !defined(SONAME_LIBJPEG) */
-
-HRESULT JpegEncoder_CreateInstance(REFIID iid, void** ppv)
-{
- ERR("Trying to save JPEG picture, but JPEG support is not compiled in.\n");
- return E_FAIL;
-}
-
-#endif
-
-HRESULT JpegDecoder_CreateInstance(REFIID iid, void** ppv)
-{
- HRESULT hr;
- struct decoder *decoder;
- struct decoder_info decoder_info;
-
- hr = get_unix_decoder(&CLSID_WICJpegDecoder, &decoder_info, &decoder);
-
- if (SUCCEEDED(hr))
- hr = CommonDecoder_CreateInstance(decoder, &decoder_info, iid, ppv);
-
- return hr;
-}
diff --git a/dlls/windowscodecs/libjpeg.c b/dlls/windowscodecs/libjpeg.c
index 58ca58e93b4..84e4df5e007 100644
--- a/dlls/windowscodecs/libjpeg.c
+++ b/dlls/windowscodecs/libjpeg.c
@@ -453,6 +453,313 @@ HRESULT CDECL jpeg_decoder_create(struct decoder_info *info, struct decoder **re
return S_OK;
}
+typedef struct jpeg_compress_format {
+ const WICPixelFormatGUID *guid;
+ int bpp;
+ int num_components;
+ J_COLOR_SPACE color_space;
+ int swap_rgb;
+} jpeg_compress_format;
+
+static const jpeg_compress_format compress_formats[] = {
+ { &GUID_WICPixelFormat24bppBGR, 24, 3, JCS_RGB, 1 },
+ { &GUID_WICPixelFormat32bppCMYK, 32, 4, JCS_CMYK },
+ { &GUID_WICPixelFormat8bppGray, 8, 1, JCS_GRAYSCALE },
+ { 0 }
+};
+
+struct jpeg_encoder
+{
+ struct encoder encoder;
+ IStream *stream;
+ BOOL cinfo_initialized;
+ struct jpeg_compress_struct cinfo;
+ struct jpeg_error_mgr jerr;
+ struct jpeg_destination_mgr dest_mgr;
+ struct encoder_frame encoder_frame;
+ const jpeg_compress_format *format;
+ BYTE dest_buffer[1024];
+};
+
+static inline struct jpeg_encoder *impl_from_encoder(struct encoder* iface)
+{
+ return CONTAINING_RECORD(iface, struct jpeg_encoder, encoder);
+}
+
+static inline struct jpeg_encoder *encoder_from_compress(j_compress_ptr compress)
+{
+ return CONTAINING_RECORD(compress, struct jpeg_encoder, cinfo);
+}
+
+static void dest_mgr_init_destination(j_compress_ptr cinfo)
+{
+ struct jpeg_encoder *This = encoder_from_compress(cinfo);
+
+ This->dest_mgr.next_output_byte = This->dest_buffer;
+ This->dest_mgr.free_in_buffer = sizeof(This->dest_buffer);
+}
+
+static jpeg_boolean dest_mgr_empty_output_buffer(j_compress_ptr cinfo)
+{
+ struct jpeg_encoder *This = encoder_from_compress(cinfo);
+ HRESULT hr;
+ ULONG byteswritten;
+
+ hr = stream_write(This->stream, This->dest_buffer,
+ sizeof(This->dest_buffer), &byteswritten);
+
+ if (hr != S_OK || byteswritten == 0)
+ {
+ ERR("Failed writing data, hr=%x\n", hr);
+ return FALSE;
+ }
+
+ This->dest_mgr.next_output_byte = This->dest_buffer;
+ This->dest_mgr.free_in_buffer = sizeof(This->dest_buffer);
+ return TRUE;
+}
+
+static void dest_mgr_term_destination(j_compress_ptr cinfo)
+{
+ struct jpeg_encoder *This = encoder_from_compress(cinfo);
+ ULONG byteswritten;
+ HRESULT hr;
+
+ if (This->dest_mgr.free_in_buffer != sizeof(This->dest_buffer))
+ {
+ hr = stream_write(This->stream, This->dest_buffer,
+ sizeof(This->dest_buffer) - This->dest_mgr.free_in_buffer, &byteswritten);
+
+ if (hr != S_OK || byteswritten == 0)
+ ERR("Failed writing data, hr=%x\n", hr);
+ }
+}
+
+HRESULT CDECL jpeg_encoder_initialize(struct encoder* iface, IStream *stream)
+{
+ struct jpeg_encoder *This = impl_from_encoder(iface);
+ jmp_buf jmpbuf;
+
+ pjpeg_std_error(&This->jerr);
+
+ This->jerr.error_exit = error_exit_fn;
+ This->jerr.emit_message = emit_message_fn;
+
+ This->cinfo.err = &This->jerr;
+
+ This->cinfo.client_data = jmpbuf;
+
+ if (setjmp(jmpbuf))
+ return E_FAIL;
+
+ pjpeg_CreateCompress(&This->cinfo, JPEG_LIB_VERSION, sizeof(struct jpeg_compress_struct));
+
+ This->stream = stream;
+
+ This->dest_mgr.next_output_byte = This->dest_buffer;
+ This->dest_mgr.free_in_buffer = sizeof(This->dest_buffer);
+
+ This->dest_mgr.init_destination = dest_mgr_init_destination;
+ This->dest_mgr.empty_output_buffer = dest_mgr_empty_output_buffer;
+ This->dest_mgr.term_destination = dest_mgr_term_destination;
+
+ This->cinfo.dest = &This->dest_mgr;
+
+ This->cinfo_initialized = TRUE;
+
+ return S_OK;
+}
+
+HRESULT CDECL jpeg_encoder_get_supported_format(struct encoder* iface, GUID *pixel_format,
+ DWORD *bpp, BOOL *indexed)
+{
+ int i;
+
+ for (i=0; compress_formats[i].guid; i++)
+ {
+ if (memcmp(compress_formats[i].guid, pixel_format, sizeof(GUID)) == 0)
+ break;
+ }
+
+ if (!compress_formats[i].guid) i = 0;
+
+ *pixel_format = *compress_formats[i].guid;
+ *bpp = compress_formats[i].bpp;
+ *indexed = FALSE;
+
+ return S_OK;
+}
+
+HRESULT CDECL jpeg_encoder_create_frame(struct encoder* iface, const struct encoder_frame *frame)
+{
+ struct jpeg_encoder *This = impl_from_encoder(iface);
+ jmp_buf jmpbuf;
+ int i;
+
+ This->encoder_frame = *frame;
+
+ if (setjmp(jmpbuf))
+ return E_FAIL;
+
+ This->cinfo.client_data = jmpbuf;
+
+ for (i=0; compress_formats[i].guid; i++)
+ {
+ if (memcmp(compress_formats[i].guid, &frame->pixel_format, sizeof(GUID)) == 0)
+ break;
+ }
+ This->format = &compress_formats[i];
+
+ This->cinfo.image_width = frame->width;
+ This->cinfo.image_height = frame->height;
+ This->cinfo.input_components = This->format->num_components;
+ This->cinfo.in_color_space = This->format->color_space;
+
+ pjpeg_set_defaults(&This->cinfo);
+
+ if (frame->dpix != 0.0 && frame->dpiy != 0.0)
+ {
+ This->cinfo.density_unit = 1; /* dots per inch */
+ This->cinfo.X_density = frame->dpix;
+ This->cinfo.Y_density = frame->dpiy;
+ }
+
+ pjpeg_start_compress(&This->cinfo, TRUE);
+
+ return S_OK;
+}
+
+HRESULT CDECL jpeg_encoder_write_lines(struct encoder* iface, BYTE *data,
+ DWORD line_count, DWORD stride)
+{
+ struct jpeg_encoder *This = impl_from_encoder(iface);
+ jmp_buf jmpbuf;
+ BYTE *swapped_data = NULL, *current_row;
+ UINT line;
+ int row_size;
+
+ if (setjmp(jmpbuf))
+ {
+ free(swapped_data);
+ return E_FAIL;
+ }
+
+ This->cinfo.client_data = jmpbuf;
+
+ row_size = This->format->bpp / 8 * This->encoder_frame.width;
+
+ if (This->format->swap_rgb)
+ {
+ swapped_data = malloc(row_size);
+ if (!swapped_data)
+ return E_OUTOFMEMORY;
+ }
+
+ for (line=0; line < line_count; line++)
+ {
+ if (This->format->swap_rgb)
+ {
+ UINT x;
+
+ memcpy(swapped_data, data + (stride * line), row_size);
+
+ for (x=0; x < This->encoder_frame.width; x++)
+ {
+ BYTE b;
+
+ b = swapped_data[x*3];
+ swapped_data[x*3] = swapped_data[x*3+2];
+ swapped_data[x*3+2] = b;
+ }
+
+ current_row = swapped_data;
+ }
+ else
+ current_row = data + (stride * line);
+
+ if (!pjpeg_write_scanlines(&This->cinfo, ¤t_row, 1))
+ {
+ ERR("failed writing scanlines\n");
+ free(swapped_data);
+ return E_FAIL;
+ }
+ }
+
+ free(swapped_data);
+
+ return S_OK;
+}
+
+HRESULT CDECL jpeg_encoder_commit_frame(struct encoder* iface)
+{
+ struct jpeg_encoder *This = impl_from_encoder(iface);
+ jmp_buf jmpbuf;
+
+ if (setjmp(jmpbuf))
+ return E_FAIL;
+
+ This->cinfo.client_data = jmpbuf;
+
+ pjpeg_finish_compress(&This->cinfo);
+
+ return S_OK;
+}
+
+HRESULT CDECL jpeg_encoder_commit_file(struct encoder* iface)
+{
+ return S_OK;
+}
+
+void CDECL jpeg_encoder_destroy(struct encoder* iface)
+{
+ struct jpeg_encoder *This = impl_from_encoder(iface);
+ if (This->cinfo_initialized)
+ pjpeg_destroy_compress(&This->cinfo);
+ RtlFreeHeap(GetProcessHeap(), 0, This);
+};
+
+static const struct encoder_funcs jpeg_encoder_vtable = {
+ jpeg_encoder_initialize,
+ jpeg_encoder_get_supported_format,
+ jpeg_encoder_create_frame,
+ jpeg_encoder_write_lines,
+ jpeg_encoder_commit_frame,
+ jpeg_encoder_commit_file,
+ jpeg_encoder_destroy
+};
+
+HRESULT CDECL jpeg_encoder_create(struct encoder_info *info, struct encoder **result)
+{
+ struct jpeg_encoder *This;
+
+ if (!load_libjpeg())
+ {
+ ERR("Failed writing JPEG because unable to find %s\n", SONAME_LIBJPEG);
+ return E_FAIL;
+ }
+
+ This = RtlAllocateHeap(GetProcessHeap(), 0, sizeof(struct jpeg_encoder));
+ if (!This) return E_OUTOFMEMORY;
+
+ This->encoder.vtable = &jpeg_encoder_vtable;
+ This->stream = NULL;
+ This->cinfo_initialized = FALSE;
+ *result = &This->encoder;
+
+ info->flags = 0;
+ info->container_format = GUID_ContainerFormatJpeg;
+ info->clsid = CLSID_WICJpegEncoder;
+ info->encoder_options[0] = ENCODER_OPTION_IMAGE_QUALITY;
+ info->encoder_options[1] = ENCODER_OPTION_BITMAP_TRANSFORM;
+ info->encoder_options[2] = ENCODER_OPTION_LUMINANCE;
+ info->encoder_options[3] = ENCODER_OPTION_CHROMINANCE;
+ info->encoder_options[4] = ENCODER_OPTION_YCRCB_SUBSAMPLING;
+ info->encoder_options[5] = ENCODER_OPTION_SUPPRESS_APP0;
+ info->encoder_options[6] = ENCODER_OPTION_END;
+
+ return S_OK;
+}
+
#else /* !defined(SONAME_LIBJPEG) */
HRESULT CDECL jpeg_decoder_create(struct decoder_info *info, struct decoder **result)
@@ -461,4 +768,10 @@ HRESULT CDECL jpeg_decoder_create(struct decoder_info *info, struct decoder **re
return E_FAIL;
}
+HRESULT CDECL jpeg_encoder_create(struct encoder_info *info, struct encoder **result)
+{
+ ERR("Trying to save JPEG picture, but JPEG support is not compiled in.\n");
+ return E_FAIL;
+}
+
#endif
diff --git a/dlls/windowscodecs/main.c b/dlls/windowscodecs/main.c
index bc12eb2fda1..b8ffb216186 100644
--- a/dlls/windowscodecs/main.c
+++ b/dlls/windowscodecs/main.c
@@ -279,3 +279,31 @@ HRESULT TiffEncoder_CreateInstance(REFIID iid, void** ppv)
return hr;
}
+
+HRESULT JpegDecoder_CreateInstance(REFIID iid, void** ppv)
+{
+ HRESULT hr;
+ struct decoder *decoder;
+ struct decoder_info decoder_info;
+
+ hr = get_unix_decoder(&CLSID_WICJpegDecoder, &decoder_info, &decoder);
+
+ if (SUCCEEDED(hr))
+ hr = CommonDecoder_CreateInstance(decoder, &decoder_info, iid, ppv);
+
+ return hr;
+}
+
+HRESULT JpegEncoder_CreateInstance(REFIID iid, void** ppv)
+{
+ HRESULT hr;
+ struct encoder *encoder;
+ struct encoder_info encoder_info;
+
+ hr = get_unix_encoder(&CLSID_WICJpegEncoder, &encoder_info, &encoder);
+
+ if (SUCCEEDED(hr))
+ hr = CommonEncoder_CreateInstance(encoder, &encoder_info, iid, ppv);
+
+ return hr;
+}
diff --git a/dlls/windowscodecs/unix_lib.c b/dlls/windowscodecs/unix_lib.c
index 7101880b93c..f94340fc971 100644
--- a/dlls/windowscodecs/unix_lib.c
+++ b/dlls/windowscodecs/unix_lib.c
@@ -89,6 +89,9 @@ HRESULT CDECL encoder_create(const CLSID *encoder_clsid, struct encoder_info *in
if (IsEqualGUID(encoder_clsid, &CLSID_WICTiffEncoder))
return tiff_encoder_create(info, result);
+ if (IsEqualGUID(encoder_clsid, &CLSID_WICJpegEncoder))
+ return jpeg_encoder_create(info, result);
+
return E_NOTIMPL;
}
diff --git a/dlls/windowscodecs/wincodecs_private.h b/dlls/windowscodecs/wincodecs_private.h
index ab0329b8bb3..3814edb32bb 100644
--- a/dlls/windowscodecs/wincodecs_private.h
+++ b/dlls/windowscodecs/wincodecs_private.h
@@ -343,6 +343,12 @@ enum encoder_option
ENCODER_OPTION_FILTER,
ENCODER_OPTION_COMPRESSION_METHOD,
ENCODER_OPTION_COMPRESSION_QUALITY,
+ ENCODER_OPTION_IMAGE_QUALITY,
+ ENCODER_OPTION_BITMAP_TRANSFORM,
+ ENCODER_OPTION_LUMINANCE,
+ ENCODER_OPTION_CHROMINANCE,
+ ENCODER_OPTION_YCRCB_SUBSAMPLING,
+ ENCODER_OPTION_SUPPRESS_APP0,
ENCODER_OPTION_END
};
@@ -400,6 +406,7 @@ HRESULT CDECL jpeg_decoder_create(struct decoder_info *info, struct decoder **re
HRESULT CDECL png_encoder_create(struct encoder_info *info, struct encoder **result);
HRESULT CDECL tiff_encoder_create(struct encoder_info *info, struct encoder **result);
+HRESULT CDECL jpeg_encoder_create(struct encoder_info *info, struct encoder **result);
struct unix_funcs
{
--
2.17.1
1
0
24 Nov '20
If there are no imports at all, winebuild will omit __wine_spec_imports,
so both VirtualAddress and Size will be 0. However, get_rva(module, 0)
does not point to a valid IMAGE_IMPORT_DESCRIPTOR.
Signed-off-by: Kevin Puetz <PuetzKevinA(a)JohnDeere.com>
---
My aarch64 builds would "work" on real hardware, but crash in wineboot
(or pretty much anything else non-trivial) if run in qemu-user 5.1.0.
The first crash would occur while loading gdi32.dll.so/gdi32.so.
wine 5.0.x worked, so it seems like there was enough hope to keep digging
and this seems to be the culprit.
I see desc->Name == 0xffff (actually reinterpreted bytes from the ELF header)
and on real aarch64 hardware the resulting bad pointer seems to avoid disaster,
(char*)get_rva(module,0xFFFF) == '\0'. I assume something just zero filled
betwen the ELF header and the __wine_spec_nt_header.
It does, however, hit the ERR trace with it's, printing:
"err:module:fixup_ntdll_imports module "/usr/lib/wine/gdi32.so" is importing "
(note empty %s)
In qemu-user, get_rva(module,0xFFFF) is unmapped so it just segfaults.
(probably just finer-grained tracking of sections and less zero-filling,
since qemu needs to move things around for the dynamic recompilation).
I fixed it to check DataDirectory[IMAGE_FILE_IMPORT_DIRECTORY].Size
before dereferencing the table, as map_so_dll does, so it doesn't access
a nonexistant imports section. This seems right, but I certainly won't
claim to understand all the machinery in here...
---
Patch below is mostly just indentation changing, diff -w looks like:
static NTSTATUS fixup_ntdll_imports( const char *name, HMODULE module )
{
const IMAGE_NT_HEADERS *nt;
- const IMAGE_IMPORT_DESCRIPTOR *descr;
+ const IMAGE_DATA_DIRECTORY *dir;
const IMAGE_THUNK_DATA *import_list;
IMAGE_THUNK_DATA *thunk_list;
nt = get_rva( module, ((IMAGE_DOS_HEADER *)module)->e_lfanew );
- descr = get_rva( module, nt->OptionalHeader.DataDirectory[IMAGE_FILE_IMPORT_DIRECTORY].VirtualAddress );
+
+ dir = &nt->OptionalHeader.DataDirectory[IMAGE_FILE_IMPORT_DIRECTORY];
+ if (dir->Size)
+ {
+ const IMAGE_IMPORT_DESCRIPTOR *descr= get_rva( module, dir->VirtualAddress );
+
for (; descr->Name && descr->FirstThunk; descr++)
{ ... }
+ }
return STATUS_SUCCESS;
}
diff --git a/dlls/ntdll/unix/loader.c b/dlls/ntdll/unix/loader.c
index c2b6ea603e3..5d81e26cc5b 100644
--- a/dlls/ntdll/unix/loader.c
+++ b/dlls/ntdll/unix/loader.c
@@ -809,43 +809,49 @@ static inline void *get_rva( void *module, ULONG_PTR addr )
static NTSTATUS fixup_ntdll_imports( const char *name, HMODULE module )
{
const IMAGE_NT_HEADERS *nt;
- const IMAGE_IMPORT_DESCRIPTOR *descr;
+ const IMAGE_DATA_DIRECTORY *dir;
const IMAGE_THUNK_DATA *import_list;
IMAGE_THUNK_DATA *thunk_list;
nt = get_rva( module, ((IMAGE_DOS_HEADER *)module)->e_lfanew );
- descr = get_rva( module, nt->OptionalHeader.DataDirectory[IMAGE_FILE_IMPORT_DIRECTORY].VirtualAddress );
- for (; descr->Name && descr->FirstThunk; descr++)
+
+ dir = &nt->OptionalHeader.DataDirectory[IMAGE_FILE_IMPORT_DIRECTORY];
+ if (dir->Size)
{
- thunk_list = get_rva( module, descr->FirstThunk );
+ const IMAGE_IMPORT_DESCRIPTOR *descr= get_rva( module, dir->VirtualAddress );
- /* ntdll must be the only import */
- if (strcmp( get_rva( module, descr->Name ), "ntdll.dll" ))
+ for (; descr->Name && descr->FirstThunk; descr++)
{
- ERR( "module %s is importing %s\n", debugstr_a(name), (char *)get_rva( module, descr->Name ));
- return STATUS_PROCEDURE_NOT_FOUND;
- }
- if (descr->u.OriginalFirstThunk)
- import_list = get_rva( module, descr->u.OriginalFirstThunk );
- else
- import_list = thunk_list;
+ thunk_list = get_rva( module, descr->FirstThunk );
- while (import_list->u1.Ordinal)
- {
- if (IMAGE_SNAP_BY_ORDINAL( import_list->u1.Ordinal ))
+ /* ntdll must be the only import */
+ if (strcmp( get_rva( module, descr->Name ), "ntdll.dll" ))
{
- int ordinal = IMAGE_ORDINAL( import_list->u1.Ordinal ) - ntdll_exports->Base;
- thunk_list->u1.Function = find_ordinal_export( ntdll_module, ntdll_exports, ordinal );
- if (!thunk_list->u1.Function) ERR( "%s: ntdll.%u not found\n", debugstr_a(name), ordinal );
+ ERR( "module %s is importing %s\n", debugstr_a(name), (char *)get_rva( module, descr->Name ));
+ return STATUS_PROCEDURE_NOT_FOUND;
}
- else /* import by name */
+ if (descr->u.OriginalFirstThunk)
+ import_list = get_rva( module, descr->u.OriginalFirstThunk );
+ else
+ import_list = thunk_list;
+
+ while (import_list->u1.Ordinal)
{
- IMAGE_IMPORT_BY_NAME *pe_name = get_rva( module, import_list->u1.AddressOfData );
- thunk_list->u1.Function = find_pe_export( ntdll_module, ntdll_exports, pe_name );
- if (!thunk_list->u1.Function) ERR( "%s: ntdll.%s not found\n", debugstr_a(name), pe_name->Name );
+ if (IMAGE_SNAP_BY_ORDINAL( import_list->u1.Ordinal ))
+ {
+ int ordinal = IMAGE_ORDINAL( import_list->u1.Ordinal ) - ntdll_exports->Base;
+ thunk_list->u1.Function = find_ordinal_export( ntdll_module, ntdll_exports, ordinal );
+ if (!thunk_list->u1.Function) ERR( "%s: ntdll.%u not found\n", debugstr_a(name), ordinal );
+ }
+ else /* import by name */
+ {
+ IMAGE_IMPORT_BY_NAME *pe_name = get_rva( module, import_list->u1.AddressOfData );
+ thunk_list->u1.Function = find_pe_export( ntdll_module, ntdll_exports, pe_name );
+ if (!thunk_list->u1.Function) ERR( "%s: ntdll.%s not found\n", debugstr_a(name), pe_name->Name );
+ }
+ import_list++;
+ thunk_list++;
}
- import_list++;
- thunk_list++;
}
}
return STATUS_SUCCESS;
2
2
24 Nov '20
Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=50037
Signed-off-by: Jacek Caban <jacek(a)codeweavers.com>
---
programs/conhost/conhost.c | 7 ++++++-
programs/conhost/conhost.h | 1 +
2 files changed, 7 insertions(+), 1 deletion(-)
1
0
[PATCH] mfreadwrite/reader: Implement GetServiceForStream() for stream objects.
by Nikolay Sivov 24 Nov '20
by Nikolay Sivov 24 Nov '20
24 Nov '20
Signed-off-by: Nikolay Sivov <nsivov(a)codeweavers.com>
---
dlls/mfreadwrite/reader.c | 52 ++++++++++++++++++++++++++++-----------
1 file changed, 38 insertions(+), 14 deletions(-)
diff --git a/dlls/mfreadwrite/reader.c b/dlls/mfreadwrite/reader.c
index 7aa8f65df7a..85aec9aaedc 100644
--- a/dlls/mfreadwrite/reader.c
+++ b/dlls/mfreadwrite/reader.c
@@ -1906,36 +1906,60 @@ static HRESULT WINAPI src_reader_GetServiceForStream(IMFSourceReader *iface, DWO
{
struct source_reader *reader = impl_from_IMFSourceReader(iface);
IUnknown *obj = NULL;
- HRESULT hr;
+ HRESULT hr = S_OK;
TRACE("%p, %#x, %s, %s, %p\n", iface, index, debugstr_guid(service), debugstr_guid(riid), object);
+ EnterCriticalSection(&reader->cs);
+
switch (index)
{
case MF_SOURCE_READER_MEDIASOURCE:
obj = (IUnknown *)reader->source;
break;
default:
- FIXME("Unsupported index %#x.\n", index);
- return E_NOTIMPL;
- }
+ if (index == MF_SOURCE_READER_FIRST_VIDEO_STREAM)
+ index = reader->first_video_stream_index;
+ else if (index == MF_SOURCE_READER_FIRST_AUDIO_STREAM)
+ index = reader->first_audio_stream_index;
- if (IsEqualGUID(service, &GUID_NULL))
- {
- hr = IUnknown_QueryInterface(obj, riid, object);
+ if (index >= reader->stream_count)
+ hr = MF_E_INVALIDSTREAMNUMBER;
+ else
+ {
+ obj = (IUnknown *)reader->streams[index].decoder;
+ if (!obj) hr = E_NOINTERFACE;
+ }
+ break;
}
- else
- {
- IMFGetService *gs;
- hr = IUnknown_QueryInterface(obj, &IID_IMFGetService, (void **)&gs);
- if (SUCCEEDED(hr))
+ if (obj)
+ IUnknown_AddRef(obj);
+
+ LeaveCriticalSection(&reader->cs);
+
+ if (obj)
+ {
+ if (IsEqualGUID(service, &GUID_NULL))
{
- hr = IMFGetService_GetService(gs, service, riid, object);
- IMFGetService_Release(gs);
+ hr = IUnknown_QueryInterface(obj, riid, object);
+ }
+ else
+ {
+ IMFGetService *gs;
+
+ hr = IUnknown_QueryInterface(obj, &IID_IMFGetService, (void **)&gs);
+ if (SUCCEEDED(hr))
+ {
+ hr = IMFGetService_GetService(gs, service, riid, object);
+ IMFGetService_Release(gs);
+ }
}
}
+ if (obj)
+ IUnknown_Release(obj);
+
return hr;
}
--
2.29.2
1
0
[PATCH 1/2] evr/presenter: Set frame size and aperture attributes for mixer output type.
by Nikolay Sivov 24 Nov '20
by Nikolay Sivov 24 Nov '20
24 Nov '20
Signed-off-by: Nikolay Sivov <nsivov(a)codeweavers.com>
---
dlls/evr/presenter.c | 36 ++++++++++--
dlls/evr/tests/evr.c | 132 +++++++++++++++++++++++++++++++++++++++++++
2 files changed, 163 insertions(+), 5 deletions(-)
diff --git a/dlls/evr/presenter.c b/dlls/evr/presenter.c
index f0733f6f060..5701eb17bd3 100644
--- a/dlls/evr/presenter.c
+++ b/dlls/evr/presenter.c
@@ -306,17 +306,43 @@ static HRESULT video_presenter_set_media_type(struct video_presenter *presenter,
static HRESULT video_presenter_invalidate_media_type(struct video_presenter *presenter)
{
- IMFMediaType *media_type;
+ IMFMediaType *media_type, *candidate_type;
unsigned int idx = 0;
+ UINT64 frame_size;
+ MFVideoArea aperture;
+ RECT rect;
HRESULT hr;
+ if (FAILED(hr = MFCreateMediaType(&media_type)))
+ return hr;
+
video_presenter_get_native_video_size(presenter);
- while (SUCCEEDED(hr = IMFTransform_GetOutputAvailableType(presenter->mixer, 0, idx++, &media_type)))
+ rect = presenter->dst_rect;
+ if (rect.left == 0 && rect.right == 0 && rect.bottom == 0 && rect.top == 0)
+ {
+ rect.right = presenter->native_size.cx;
+ rect.bottom = presenter->native_size.cy;
+ }
+
+ aperture.Area.cx = rect.right - rect.left;
+ aperture.Area.cy = rect.bottom - rect.top;
+ aperture.OffsetX.value = 0;
+ aperture.OffsetX.fract = 0;
+ aperture.OffsetY.value = 0;
+ aperture.OffsetY.fract = 0;
+ frame_size = (UINT64)aperture.Area.cx << 32 | aperture.Area.cy;
+
+ while (SUCCEEDED(hr = IMFTransform_GetOutputAvailableType(presenter->mixer, 0, idx++, &candidate_type)))
{
/* FIXME: check that d3d device supports this format */
- /* FIXME: potentially adjust frame size */
+ if (FAILED(hr = IMFMediaType_CopyAllItems(candidate_type, (IMFAttributes *)media_type)))
+ WARN("Failed to clone a media type, hr %#x.\n", hr);
+ IMFMediaType_Release(candidate_type);
+
+ IMFMediaType_SetUINT64(media_type, &MF_MT_FRAME_SIZE, frame_size);
+ IMFMediaType_SetBlob(media_type, &MF_MT_GEOMETRIC_APERTURE, (UINT8 *)&aperture, sizeof(aperture));
hr = IMFTransform_SetOutputType(presenter->mixer, 0, media_type, MFT_SET_TYPE_TEST_ONLY);
@@ -326,12 +352,12 @@ static HRESULT video_presenter_invalidate_media_type(struct video_presenter *pre
if (SUCCEEDED(hr))
hr = IMFTransform_SetOutputType(presenter->mixer, 0, media_type, 0);
- IMFMediaType_Release(media_type);
-
if (SUCCEEDED(hr))
break;
}
+ IMFMediaType_Release(media_type);
+
return hr;
}
diff --git a/dlls/evr/tests/evr.c b/dlls/evr/tests/evr.c
index 2740f2263f0..31434bde43a 100644
--- a/dlls/evr/tests/evr.c
+++ b/dlls/evr/tests/evr.c
@@ -2072,6 +2072,137 @@ todo_wine {
IMFVideoPresenter_Release(presenter);
}
+static void get_output_aperture(IMFTransform *mixer, SIZE *frame_size, MFVideoArea *aperture)
+{
+ IMFMediaType *media_type;
+ UINT64 size;
+ HRESULT hr;
+
+ memset(frame_size, 0xcc, sizeof(*frame_size));
+ memset(aperture, 0xcc, sizeof(*aperture));
+
+ hr = IMFTransform_GetOutputCurrentType(mixer, 0, &media_type);
+ ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
+
+ hr = IMFMediaType_GetUINT64(media_type, &MF_MT_FRAME_SIZE, &size);
+ ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
+
+ frame_size->cx = size >> 32;
+ frame_size->cy = size;
+
+ hr = IMFMediaType_GetBlob(media_type, &MF_MT_GEOMETRIC_APERTURE, (UINT8 *)aperture, sizeof(*aperture), NULL);
+ ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
+
+ IMFMediaType_Release(media_type);
+}
+
+static void test_presenter_media_type(void)
+{
+ IMFTopologyServiceLookupClient *lookup_client;
+ IMFVideoPresenter *presenter;
+ struct test_host host;
+ IMFMediaType *input_type;
+ IDirect3DDeviceManager9 *manager;
+ HRESULT hr;
+ IMFTransform *mixer;
+ IDirect3D9 *d3d;
+ IDirect3DDevice9 *device;
+ unsigned int token;
+ SIZE frame_size;
+ HWND window;
+ MFVideoArea aperture;
+ IMFVideoDisplayControl *display_control;
+ RECT dst;
+
+ window = create_window();
+ d3d = Direct3DCreate9(D3D_SDK_VERSION);
+ ok(!!d3d, "Failed to create a D3D object.\n");
+ if (!(device = create_device(d3d, window)))
+ {
+ skip("Failed to create a D3D device, skipping tests.\n");
+ goto done;
+ }
+
+ hr = DXVA2CreateDirect3DDeviceManager9(&token, &manager);
+ ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
+
+ hr = IDirect3DDeviceManager9_ResetDevice(manager, device, token);
+ ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
+
+ hr = MFCreateVideoPresenter(NULL, &IID_IDirect3DDevice9, &IID_IMFVideoPresenter, (void **)&presenter);
+ ok(hr == S_OK, "Failed to create default presenter, hr %#x.\n", hr);
+
+ hr = IMFVideoPresenter_QueryInterface(presenter, &IID_IMFVideoDisplayControl, (void **)&display_control);
+ ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
+
+ hr = MFCreateVideoMixer(NULL, &IID_IDirect3DDevice9, &IID_IMFTransform, (void **)&mixer);
+ ok(hr == S_OK, "Failed to create a mixer, hr %#x.\n", hr);
+
+ input_type = create_video_type(&MFVideoFormat_RGB32);
+
+ hr = IMFMediaType_SetUINT64(input_type, &MF_MT_FRAME_SIZE, (UINT64)100 << 32 | 50);
+ ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
+ hr = IMFMediaType_SetUINT32(input_type, &MF_MT_ALL_SAMPLES_INDEPENDENT, TRUE);
+ ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
+
+ hr = IMFTransform_ProcessMessage(mixer, MFT_MESSAGE_SET_D3D_MANAGER, (ULONG_PTR)manager);
+ ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
+
+ hr = IMFTransform_SetInputType(mixer, 0, input_type, 0);
+ ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
+
+ hr = IMFVideoPresenter_QueryInterface(presenter, &IID_IMFTopologyServiceLookupClient, (void **)&lookup_client);
+ ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
+
+ init_test_host(&host, mixer, presenter);
+
+ hr = IMFTopologyServiceLookupClient_InitServicePointers(lookup_client, &host.IMFTopologyServiceLookup_iface);
+ ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
+
+ hr = IMFVideoDisplayControl_SetVideoWindow(display_control, window);
+ ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
+
+ hr = IMFVideoPresenter_ProcessMessage(presenter, MFVP_MESSAGE_INVALIDATEMEDIATYPE, 0);
+ ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
+
+ get_output_aperture(mixer, &frame_size, &aperture);
+ ok(frame_size.cx == 100 && frame_size.cy == 50, "Unexpected frame size %u x %u.\n", frame_size.cx, frame_size.cy);
+ ok(aperture.Area.cx == 100 && aperture.Area.cy == 50, "Unexpected size %u x %u.\n", aperture.Area.cx, aperture.Area.cy);
+ ok(!aperture.OffsetX.value && !aperture.OffsetX.fract && !aperture.OffsetY.value && !aperture.OffsetY.fract,
+ "Unexpected offset %u x %u.\n", aperture.OffsetX.value, aperture.OffsetY.value);
+
+ SetRect(&dst, 1, 2, 200, 300);
+ hr = IMFVideoDisplayControl_SetVideoPosition(display_control, NULL, &dst);
+ ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
+
+ get_output_aperture(mixer, &frame_size, &aperture);
+todo_wine {
+ ok(frame_size.cx == 199 && frame_size.cy == 298, "Unexpected frame size %u x %u.\n", frame_size.cx, frame_size.cy);
+ ok(aperture.Area.cx == 199 && aperture.Area.cy == 298, "Unexpected size %u x %u.\n", aperture.Area.cx, aperture.Area.cy);
+}
+ ok(!aperture.OffsetX.value && !aperture.OffsetX.fract && !aperture.OffsetY.value && !aperture.OffsetY.fract,
+ "Unexpected offset %u x %u.\n", aperture.OffsetX.value, aperture.OffsetY.value);
+
+ hr = IMFVideoDisplayControl_SetAspectRatioMode(display_control, MFVideoARMode_None);
+ ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
+
+ get_output_aperture(mixer, &frame_size, &aperture);
+todo_wine {
+ ok(frame_size.cx == 199 && frame_size.cy == 298, "Unexpected frame size %u x %u.\n", frame_size.cx, frame_size.cy);
+ ok(aperture.Area.cx == 199 && aperture.Area.cy == 298, "Unexpected size %u x %u.\n", aperture.Area.cx, aperture.Area.cy);
+}
+ ok(!aperture.OffsetX.value && !aperture.OffsetX.fract && !aperture.OffsetY.value && !aperture.OffsetY.fract,
+ "Unexpected offset %u x %u.\n", aperture.OffsetX.value, aperture.OffsetY.value);
+
+ IMFVideoDisplayControl_Release(display_control);
+ IMFVideoPresenter_Release(presenter);
+ IMFTransform_Release(mixer);
+
+done:
+ IDirect3D9_Release(d3d);
+ DestroyWindow(window);
+}
+
static void test_mixer_output_rectangle(void)
{
IMFVideoMixerControl *mixer_control;
@@ -2574,6 +2705,7 @@ START_TEST(evr)
test_presenter_ar_mode();
test_presenter_video_window();
test_presenter_quality_control();
+ test_presenter_media_type();
test_mixer_output_rectangle();
test_mixer_zorder();
test_mixer_samples();
--
2.29.2
1
1
[PATCH] wininet: Use wide-char string literals in struct initialization.
by Michael Stefaniuc 24 Nov '20
by Michael Stefaniuc 24 Nov '20
24 Nov '20
Signed-off-by: Michael Stefaniuc <mstefani(a)winehq.org>
---
I know the months name to number is not in a struct but it fit in
visualy.
dlls/wininet/http.c | 249 ++++++++++++++++------------------------
dlls/wininet/internet.c | 10 +-
dlls/wininet/urlcache.c | 9 +-
3 files changed, 105 insertions(+), 163 deletions(-)
diff --git a/dlls/wininet/http.c b/dlls/wininet/http.c
index 97e6ffaabc1..8701e32067b 100644
--- a/dlls/wininet/http.c
+++ b/dlls/wininet/http.c
@@ -72,58 +72,16 @@ static const WCHAR szGET[] = { 'G','E','T', 0 };
static const WCHAR szHEAD[] = { 'H','E','A','D', 0 };
static const WCHAR szAccept[] = { 'A','c','c','e','p','t',0 };
-static const WCHAR szAccept_Charset[] = { 'A','c','c','e','p','t','-','C','h','a','r','s','e','t', 0 };
-static const WCHAR szAccept_Encoding[] = { 'A','c','c','e','p','t','-','E','n','c','o','d','i','n','g',0 };
-static const WCHAR szAccept_Language[] = { 'A','c','c','e','p','t','-','L','a','n','g','u','a','g','e',0 };
-static const WCHAR szAccept_Ranges[] = { 'A','c','c','e','p','t','-','R','a','n','g','e','s',0 };
-static const WCHAR szAge[] = { 'A','g','e',0 };
-static const WCHAR szAllow[] = { 'A','l','l','o','w',0 };
static const WCHAR szCache_Control[] = { 'C','a','c','h','e','-','C','o','n','t','r','o','l',0 };
static const WCHAR szConnection[] = { 'C','o','n','n','e','c','t','i','o','n',0 };
-static const WCHAR szContent_Base[] = { 'C','o','n','t','e','n','t','-','B','a','s','e',0 };
-static const WCHAR szContent_Disposition[] = { 'C','o','n','t','e','n','t','-','D','i','s','p','o','s','i','t','i','o','n',0 };
static const WCHAR szContent_Encoding[] = { 'C','o','n','t','e','n','t','-','E','n','c','o','d','i','n','g',0 };
-static const WCHAR szContent_ID[] = { 'C','o','n','t','e','n','t','-','I','D',0 };
-static const WCHAR szContent_Language[] = { 'C','o','n','t','e','n','t','-','L','a','n','g','u','a','g','e',0 };
static const WCHAR szContent_Length[] = { 'C','o','n','t','e','n','t','-','L','e','n','g','t','h',0 };
-static const WCHAR szContent_Location[] = { 'C','o','n','t','e','n','t','-','L','o','c','a','t','i','o','n',0 };
-static const WCHAR szContent_MD5[] = { 'C','o','n','t','e','n','t','-','M','D','5',0 };
-static const WCHAR szContent_Range[] = { 'C','o','n','t','e','n','t','-','R','a','n','g','e',0 };
-static const WCHAR szContent_Transfer_Encoding[] = { 'C','o','n','t','e','n','t','-','T','r','a','n','s','f','e','r','-','E','n','c','o','d','i','n','g',0 };
static const WCHAR szContent_Type[] = { 'C','o','n','t','e','n','t','-','T','y','p','e',0 };
-static const WCHAR szCookie[] = { 'C','o','o','k','i','e',0 };
-static const WCHAR szDate[] = { 'D','a','t','e',0 };
-static const WCHAR szFrom[] = { 'F','r','o','m',0 };
-static const WCHAR szETag[] = { 'E','T','a','g',0 };
-static const WCHAR szExpect[] = { 'E','x','p','e','c','t',0 };
static const WCHAR szExpires[] = { 'E','x','p','i','r','e','s',0 };
-static const WCHAR szIf_Match[] = { 'I','f','-','M','a','t','c','h',0 };
-static const WCHAR szIf_Modified_Since[] = { 'I','f','-','M','o','d','i','f','i','e','d','-','S','i','n','c','e',0 };
-static const WCHAR szIf_None_Match[] = { 'I','f','-','N','o','n','e','-','M','a','t','c','h',0 };
-static const WCHAR szIf_Range[] = { 'I','f','-','R','a','n','g','e',0 };
-static const WCHAR szIf_Unmodified_Since[] = { 'I','f','-','U','n','m','o','d','i','f','i','e','d','-','S','i','n','c','e',0 };
static const WCHAR szLast_Modified[] = { 'L','a','s','t','-','M','o','d','i','f','i','e','d',0 };
-static const WCHAR szLocation[] = { 'L','o','c','a','t','i','o','n',0 };
-static const WCHAR szMax_Forwards[] = { 'M','a','x','-','F','o','r','w','a','r','d','s',0 };
-static const WCHAR szMime_Version[] = { 'M','i','m','e','-','V','e','r','s','i','o','n',0 };
-static const WCHAR szPragma[] = { 'P','r','a','g','m','a',0 };
-static const WCHAR szProxy_Authenticate[] = { 'P','r','o','x','y','-','A','u','t','h','e','n','t','i','c','a','t','e',0 };
static const WCHAR szProxy_Connection[] = { 'P','r','o','x','y','-','C','o','n','n','e','c','t','i','o','n',0 };
-static const WCHAR szPublic[] = { 'P','u','b','l','i','c',0 };
-static const WCHAR szRange[] = { 'R','a','n','g','e',0 };
static const WCHAR szReferer[] = { 'R','e','f','e','r','e','r',0 };
-static const WCHAR szRetry_After[] = { 'R','e','t','r','y','-','A','f','t','e','r',0 };
-static const WCHAR szServer[] = { 'S','e','r','v','e','r',0 };
static const WCHAR szSet_Cookie[] = { 'S','e','t','-','C','o','o','k','i','e',0 };
-static const WCHAR szTransfer_Encoding[] = { 'T','r','a','n','s','f','e','r','-','E','n','c','o','d','i','n','g',0 };
-static const WCHAR szUnless_Modified_Since[] = { 'U','n','l','e','s','s','-','M','o','d','i','f','i','e','d','-','S','i','n','c','e',0 };
-static const WCHAR szUpgrade[] = { 'U','p','g','r','a','d','e',0 };
-static const WCHAR szURI[] = { 'U','R','I',0 };
-static const WCHAR szUser_Agent[] = { 'U','s','e','r','-','A','g','e','n','t',0 };
-static const WCHAR szVary[] = { 'V','a','r','y',0 };
-static const WCHAR szVia[] = { 'V','i','a',0 };
-static const WCHAR szWarning[] = { 'W','a','r','n','i','n','g',0 };
-static const WCHAR szWWW_Authenticate[] = { 'W','W','W','-','A','u','t','h','e','n','t','i','c','a','t','e',0 };
static const WCHAR emptyW[] = {0};
@@ -3588,77 +3546,77 @@ lend:
}
static const LPCWSTR header_lookup[] = {
- szMime_Version, /* HTTP_QUERY_MIME_VERSION = 0 */
- szContent_Type, /* HTTP_QUERY_CONTENT_TYPE = 1 */
- szContent_Transfer_Encoding,/* HTTP_QUERY_CONTENT_TRANSFER_ENCODING = 2 */
- szContent_ID, /* HTTP_QUERY_CONTENT_ID = 3 */
- NULL, /* HTTP_QUERY_CONTENT_DESCRIPTION = 4 */
- szContent_Length, /* HTTP_QUERY_CONTENT_LENGTH = 5 */
- szContent_Language, /* HTTP_QUERY_CONTENT_LANGUAGE = 6 */
- szAllow, /* HTTP_QUERY_ALLOW = 7 */
- szPublic, /* HTTP_QUERY_PUBLIC = 8 */
- szDate, /* HTTP_QUERY_DATE = 9 */
- szExpires, /* HTTP_QUERY_EXPIRES = 10 */
- szLast_Modified, /* HTTP_QUERY_LAST_MODIFIED = 11 */
- NULL, /* HTTP_QUERY_MESSAGE_ID = 12 */
- szURI, /* HTTP_QUERY_URI = 13 */
- szFrom, /* HTTP_QUERY_DERIVED_FROM = 14 */
- NULL, /* HTTP_QUERY_COST = 15 */
- NULL, /* HTTP_QUERY_LINK = 16 */
- szPragma, /* HTTP_QUERY_PRAGMA = 17 */
- NULL, /* HTTP_QUERY_VERSION = 18 */
- szStatus, /* HTTP_QUERY_STATUS_CODE = 19 */
- NULL, /* HTTP_QUERY_STATUS_TEXT = 20 */
- NULL, /* HTTP_QUERY_RAW_HEADERS = 21 */
- NULL, /* HTTP_QUERY_RAW_HEADERS_CRLF = 22 */
- szConnection, /* HTTP_QUERY_CONNECTION = 23 */
- szAccept, /* HTTP_QUERY_ACCEPT = 24 */
- szAccept_Charset, /* HTTP_QUERY_ACCEPT_CHARSET = 25 */
- szAccept_Encoding, /* HTTP_QUERY_ACCEPT_ENCODING = 26 */
- szAccept_Language, /* HTTP_QUERY_ACCEPT_LANGUAGE = 27 */
- szAuthorization, /* HTTP_QUERY_AUTHORIZATION = 28 */
- szContent_Encoding, /* HTTP_QUERY_CONTENT_ENCODING = 29 */
- NULL, /* HTTP_QUERY_FORWARDED = 30 */
- NULL, /* HTTP_QUERY_FROM = 31 */
- szIf_Modified_Since, /* HTTP_QUERY_IF_MODIFIED_SINCE = 32 */
- szLocation, /* HTTP_QUERY_LOCATION = 33 */
- NULL, /* HTTP_QUERY_ORIG_URI = 34 */
- szReferer, /* HTTP_QUERY_REFERER = 35 */
- szRetry_After, /* HTTP_QUERY_RETRY_AFTER = 36 */
- szServer, /* HTTP_QUERY_SERVER = 37 */
- NULL, /* HTTP_TITLE = 38 */
- szUser_Agent, /* HTTP_QUERY_USER_AGENT = 39 */
- szWWW_Authenticate, /* HTTP_QUERY_WWW_AUTHENTICATE = 40 */
- szProxy_Authenticate, /* HTTP_QUERY_PROXY_AUTHENTICATE = 41 */
- szAccept_Ranges, /* HTTP_QUERY_ACCEPT_RANGES = 42 */
- szSet_Cookie, /* HTTP_QUERY_SET_COOKIE = 43 */
- szCookie, /* HTTP_QUERY_COOKIE = 44 */
- NULL, /* HTTP_QUERY_REQUEST_METHOD = 45 */
- NULL, /* HTTP_QUERY_REFRESH = 46 */
- szContent_Disposition, /* HTTP_QUERY_CONTENT_DISPOSITION = 47 */
- szAge, /* HTTP_QUERY_AGE = 48 */
- szCache_Control, /* HTTP_QUERY_CACHE_CONTROL = 49 */
- szContent_Base, /* HTTP_QUERY_CONTENT_BASE = 50 */
- szContent_Location, /* HTTP_QUERY_CONTENT_LOCATION = 51 */
- szContent_MD5, /* HTTP_QUERY_CONTENT_MD5 = 52 */
- szContent_Range, /* HTTP_QUERY_CONTENT_RANGE = 53 */
- szETag, /* HTTP_QUERY_ETAG = 54 */
- hostW, /* HTTP_QUERY_HOST = 55 */
- szIf_Match, /* HTTP_QUERY_IF_MATCH = 56 */
- szIf_None_Match, /* HTTP_QUERY_IF_NONE_MATCH = 57 */
- szIf_Range, /* HTTP_QUERY_IF_RANGE = 58 */
- szIf_Unmodified_Since, /* HTTP_QUERY_IF_UNMODIFIED_SINCE = 59 */
- szMax_Forwards, /* HTTP_QUERY_MAX_FORWARDS = 60 */
- szProxy_Authorization, /* HTTP_QUERY_PROXY_AUTHORIZATION = 61 */
- szRange, /* HTTP_QUERY_RANGE = 62 */
- szTransfer_Encoding, /* HTTP_QUERY_TRANSFER_ENCODING = 63 */
- szUpgrade, /* HTTP_QUERY_UPGRADE = 64 */
- szVary, /* HTTP_QUERY_VARY = 65 */
- szVia, /* HTTP_QUERY_VIA = 66 */
- szWarning, /* HTTP_QUERY_WARNING = 67 */
- szExpect, /* HTTP_QUERY_EXPECT = 68 */
- szProxy_Connection, /* HTTP_QUERY_PROXY_CONNECTION = 69 */
- szUnless_Modified_Since, /* HTTP_QUERY_UNLESS_MODIFIED_SINCE = 70 */
+ L"Mime-Version", /* HTTP_QUERY_MIME_VERSION = 0 */
+ L"Content-Type", /* HTTP_QUERY_CONTENT_TYPE = 1 */
+ L"Content-Transfer-Encoding", /* HTTP_QUERY_CONTENT_TRANSFER_ENCODING = 2 */
+ L"Content-ID", /* HTTP_QUERY_CONTENT_ID = 3 */
+ NULL, /* HTTP_QUERY_CONTENT_DESCRIPTION = 4 */
+ L"Content-Length", /* HTTP_QUERY_CONTENT_LENGTH = 5 */
+ L"Content-Language", /* HTTP_QUERY_CONTENT_LANGUAGE = 6 */
+ L"Allow", /* HTTP_QUERY_ALLOW = 7 */
+ L"Public", /* HTTP_QUERY_PUBLIC = 8 */
+ L"Date", /* HTTP_QUERY_DATE = 9 */
+ L"Expires", /* HTTP_QUERY_EXPIRES = 10 */
+ L"Last-Modified", /* HTTP_QUERY_LAST_MODIFIED = 11 */
+ NULL, /* HTTP_QUERY_MESSAGE_ID = 12 */
+ L"URI", /* HTTP_QUERY_URI = 13 */
+ L"From", /* HTTP_QUERY_DERIVED_FROM = 14 */
+ NULL, /* HTTP_QUERY_COST = 15 */
+ NULL, /* HTTP_QUERY_LINK = 16 */
+ L"Pragma", /* HTTP_QUERY_PRAGMA = 17 */
+ NULL, /* HTTP_QUERY_VERSION = 18 */
+ L"Status", /* HTTP_QUERY_STATUS_CODE = 19 */
+ NULL, /* HTTP_QUERY_STATUS_TEXT = 20 */
+ NULL, /* HTTP_QUERY_RAW_HEADERS = 21 */
+ NULL, /* HTTP_QUERY_RAW_HEADERS_CRLF = 22 */
+ L"Connection", /* HTTP_QUERY_CONNECTION = 23 */
+ L"Accept", /* HTTP_QUERY_ACCEPT = 24 */
+ L"Accept-Charset", /* HTTP_QUERY_ACCEPT_CHARSET = 25 */
+ L"Accept-Encoding", /* HTTP_QUERY_ACCEPT_ENCODING = 26 */
+ L"Accept-Language", /* HTTP_QUERY_ACCEPT_LANGUAGE = 27 */
+ L"Authorization", /* HTTP_QUERY_AUTHORIZATION = 28 */
+ L"Content-Encoding", /* HTTP_QUERY_CONTENT_ENCODING = 29 */
+ NULL, /* HTTP_QUERY_FORWARDED = 30 */
+ NULL, /* HTTP_QUERY_FROM = 31 */
+ L"If-Modified-Since", /* HTTP_QUERY_IF_MODIFIED_SINCE = 32 */
+ L"Location", /* HTTP_QUERY_LOCATION = 33 */
+ NULL, /* HTTP_QUERY_ORIG_URI = 34 */
+ L"Referer", /* HTTP_QUERY_REFERER = 35 */
+ L"Retry-After", /* HTTP_QUERY_RETRY_AFTER = 36 */
+ L"Server", /* HTTP_QUERY_SERVER = 37 */
+ NULL, /* HTTP_TITLE = 38 */
+ L"User-Agent", /* HTTP_QUERY_USER_AGENT = 39 */
+ L"WWW-Authenticate", /* HTTP_QUERY_WWW_AUTHENTICATE = 40 */
+ L"Proxy-Authenticate", /* HTTP_QUERY_PROXY_AUTHENTICATE = 41 */
+ L"Accept-Ranges", /* HTTP_QUERY_ACCEPT_RANGES = 42 */
+ L"Set-Cookie", /* HTTP_QUERY_SET_COOKIE = 43 */
+ L"Cookie", /* HTTP_QUERY_COOKIE = 44 */
+ NULL, /* HTTP_QUERY_REQUEST_METHOD = 45 */
+ NULL, /* HTTP_QUERY_REFRESH = 46 */
+ L"Content-Disposition", /* HTTP_QUERY_CONTENT_DISPOSITION = 47 */
+ L"Age", /* HTTP_QUERY_AGE = 48 */
+ L"Cache-Control", /* HTTP_QUERY_CACHE_CONTROL = 49 */
+ L"Content-Base", /* HTTP_QUERY_CONTENT_BASE = 50 */
+ L"Content-Location", /* HTTP_QUERY_CONTENT_LOCATION = 51 */
+ L"Content-MD5", /* HTTP_QUERY_CONTENT_MD5 = 52 */
+ L"Content-Range", /* HTTP_QUERY_CONTENT_RANGE = 53 */
+ L"ETag", /* HTTP_QUERY_ETAG = 54 */
+ L"Host", /* HTTP_QUERY_HOST = 55 */
+ L"If-Match", /* HTTP_QUERY_IF_MATCH = 56 */
+ L"If-None-Match", /* HTTP_QUERY_IF_NONE_MATCH = 57 */
+ L"If-Range", /* HTTP_QUERY_IF_RANGE = 58 */
+ L"If-Unmodified-Since", /* HTTP_QUERY_IF_UNMODIFIED_SINCE = 59 */
+ L"Max-Forwards", /* HTTP_QUERY_MAX_FORWARDS = 60 */
+ L"Proxy-Authorization", /* HTTP_QUERY_PROXY_AUTHORIZATION = 61 */
+ L"Range", /* HTTP_QUERY_RANGE = 62 */
+ L"Transfer-Encoding", /* HTTP_QUERY_TRANSFER_ENCODING = 63 */
+ L"Upgrade", /* HTTP_QUERY_UPGRADE = 64 */
+ L"Vary", /* HTTP_QUERY_VARY = 65 */
+ L"Via", /* HTTP_QUERY_VIA = 66 */
+ L"Warning", /* HTTP_QUERY_WARNING = 67 */
+ L"Expect", /* HTTP_QUERY_EXPECT = 68 */
+ L"Proxy-Connection", /* HTTP_QUERY_PROXY_CONNECTION = 69 */
+ L"Unless-Modified-Since", /* HTTP_QUERY_UNLESS_MODIFIED_SINCE = 70 */
};
/***********************************************************************
@@ -4364,13 +4322,13 @@ static void HTTP_InsertCookies(http_request_t *request)
static WORD HTTP_ParseWkday(LPCWSTR day)
{
- static const WCHAR days[7][4] = {{ 's','u','n',0 },
- { 'm','o','n',0 },
- { 't','u','e',0 },
- { 'w','e','d',0 },
- { 't','h','u',0 },
- { 'f','r','i',0 },
- { 's','a','t',0 }};
+ static const WCHAR days[7][4] = {L"sun",
+ L"mon",
+ L"tue",
+ L"wed",
+ L"thu",
+ L"fri",
+ L"sat"};
unsigned int i;
for (i = 0; i < ARRAY_SIZE(days); i++)
if (!wcsicmp(day, days[i]))
@@ -4382,31 +4340,18 @@ static WORD HTTP_ParseWkday(LPCWSTR day)
static WORD HTTP_ParseMonth(LPCWSTR month)
{
- static const WCHAR jan[] = { 'j','a','n',0 };
- static const WCHAR feb[] = { 'f','e','b',0 };
- static const WCHAR mar[] = { 'm','a','r',0 };
- static const WCHAR apr[] = { 'a','p','r',0 };
- static const WCHAR may[] = { 'm','a','y',0 };
- static const WCHAR jun[] = { 'j','u','n',0 };
- static const WCHAR jul[] = { 'j','u','l',0 };
- static const WCHAR aug[] = { 'a','u','g',0 };
- static const WCHAR sep[] = { 's','e','p',0 };
- static const WCHAR oct[] = { 'o','c','t',0 };
- static const WCHAR nov[] = { 'n','o','v',0 };
- static const WCHAR dec[] = { 'd','e','c',0 };
-
- if (!wcsicmp(month, jan)) return 1;
- if (!wcsicmp(month, feb)) return 2;
- if (!wcsicmp(month, mar)) return 3;
- if (!wcsicmp(month, apr)) return 4;
- if (!wcsicmp(month, may)) return 5;
- if (!wcsicmp(month, jun)) return 6;
- if (!wcsicmp(month, jul)) return 7;
- if (!wcsicmp(month, aug)) return 8;
- if (!wcsicmp(month, sep)) return 9;
- if (!wcsicmp(month, oct)) return 10;
- if (!wcsicmp(month, nov)) return 11;
- if (!wcsicmp(month, dec)) return 12;
+ if (!wcsicmp(month, L"jan")) return 1;
+ if (!wcsicmp(month, L"feb")) return 2;
+ if (!wcsicmp(month, L"mar")) return 3;
+ if (!wcsicmp(month, L"apr")) return 4;
+ if (!wcsicmp(month, L"may")) return 5;
+ if (!wcsicmp(month, L"jun")) return 6;
+ if (!wcsicmp(month, L"jul")) return 7;
+ if (!wcsicmp(month, L"aug")) return 8;
+ if (!wcsicmp(month, L"sep")) return 9;
+ if (!wcsicmp(month, L"oct")) return 10;
+ if (!wcsicmp(month, L"nov")) return 11;
+ if (!wcsicmp(month, L"dec")) return 12;
/* Invalid */
return 0;
}
@@ -4624,13 +4569,13 @@ static BOOL HTTP_ParseRfc1123Date(LPCWSTR value, FILETIME *ft)
static WORD HTTP_ParseWeekday(LPCWSTR day)
{
- static const WCHAR days[7][10] = {{ 's','u','n','d','a','y',0 },
- { 'm','o','n','d','a','y',0 },
- { 't','u','e','s','d','a','y',0 },
- { 'w','e','d','n','e','s','d','a','y',0 },
- { 't','h','u','r','s','d','a','y',0 },
- { 'f','r','i','d','a','y',0 },
- { 's','a','t','u','r','d','a','y',0 }};
+ static const WCHAR days[7][10] = {L"sunday",
+ L"monday",
+ L"tuesday",
+ L"wednesday",
+ L"thursday",
+ L"friday",
+ L"saturday"};
unsigned int i;
for (i = 0; i < ARRAY_SIZE(days); i++)
if (!wcsicmp(day, days[i]))
diff --git a/dlls/wininet/internet.c b/dlls/wininet/internet.c
index 91bff2ece93..b26a1b912ee 100644
--- a/dlls/wininet/internet.c
+++ b/dlls/wininet/internet.c
@@ -3279,12 +3279,12 @@ BOOL WINAPI InternetSetOptionExW(HINTERNET hInternet, DWORD dwOption,
}
static const WCHAR WININET_wkday[7][4] =
- { { 'S','u','n', 0 }, { 'M','o','n', 0 }, { 'T','u','e', 0 }, { 'W','e','d', 0 },
- { 'T','h','u', 0 }, { 'F','r','i', 0 }, { 'S','a','t', 0 } };
+ { L"Sun", L"Mon", L"Tue", L"Wed",
+ L"Thu", L"Fri", L"Sat"};
static const WCHAR WININET_month[12][4] =
- { { 'J','a','n', 0 }, { 'F','e','b', 0 }, { 'M','a','r', 0 }, { 'A','p','r', 0 },
- { 'M','a','y', 0 }, { 'J','u','n', 0 }, { 'J','u','l', 0 }, { 'A','u','g', 0 },
- { 'S','e','p', 0 }, { 'O','c','t', 0 }, { 'N','o','v', 0 }, { 'D','e','c', 0 } };
+ { L"Jan", L"Feb", L"Mar", L"Apr",
+ L"May", L"Jun", L"Jul", L"Aug",
+ L"Sep", L"Oct", L"Nov", L"Dec"};
/***********************************************************************
* InternetTimeFromSystemTimeA (WININET.@)
diff --git a/dlls/wininet/urlcache.c b/dlls/wininet/urlcache.c
index 4a397b6b4de..cc12ef9e76e 100644
--- a/dlls/wininet/urlcache.c
+++ b/dlls/wininet/urlcache.c
@@ -748,9 +748,6 @@ static void cache_container_delete_container(cache_container *pContainer)
static void cache_containers_init(void)
{
- static const WCHAR UrlSuffix[] = {'C','o','n','t','e','n','t','.','I','E','5',0};
- static const WCHAR HistorySuffix[] = {'H','i','s','t','o','r','y','.','I','E','5',0};
- static const WCHAR CookieSuffix[] = {0};
static const struct
{
int nFolder; /* CSIDL_* constant */
@@ -759,9 +756,9 @@ static void cache_containers_init(void)
DWORD default_entry_type;
} DefaultContainerData[] =
{
- { CSIDL_INTERNET_CACHE, UrlSuffix, "", NORMAL_CACHE_ENTRY },
- { CSIDL_HISTORY, HistorySuffix, "Visited:", URLHISTORY_CACHE_ENTRY },
- { CSIDL_COOKIES, CookieSuffix, "Cookie:", COOKIE_CACHE_ENTRY },
+ { CSIDL_INTERNET_CACHE, L"Content.IE5", "", NORMAL_CACHE_ENTRY },
+ { CSIDL_HISTORY, L"History.IE5", "Visited:", URLHISTORY_CACHE_ENTRY },
+ { CSIDL_COOKIES, L"", "Cookie:", COOKIE_CACHE_ENTRY },
};
DWORD i;
--
2.26.2
2
1
[PATCH 2/2] mshtml: Use wide-char string literals for PRUnichar strings.
by Michael Stefaniuc 24 Nov '20
by Michael Stefaniuc 24 Nov '20
24 Nov '20
Signed-off-by: Michael Stefaniuc <mstefani(a)winehq.org>
---
dlls/mshtml/editor.c | 7 ++-----
dlls/mshtml/htmldoc.c | 4 +---
dlls/mshtml/htmlelemcol.c | 4 +---
dlls/mshtml/htmlform.c | 8 ++------
dlls/mshtml/htmlhead.c | 9 +++------
dlls/mshtml/htmlimg.c | 4 +---
dlls/mshtml/htmlselect.c | 4 +---
dlls/mshtml/nsevents.c | 21 ++++++++-------------
dlls/mshtml/nsservice.c | 8 +++-----
dlls/mshtml/olecmd.c | 14 ++++++--------
dlls/mshtml/pluginhost.c | 18 +++++-------------
dlls/mshtml/range.c | 7 ++-----
dlls/mshtml/script.c | 8 ++------
13 files changed, 37 insertions(+), 79 deletions(-)
diff --git a/dlls/mshtml/editor.c b/dlls/mshtml/editor.c
index 0a1b4879bde..28c4eceff8e 100644
--- a/dlls/mshtml/editor.c
+++ b/dlls/mshtml/editor.c
@@ -657,13 +657,10 @@ static HRESULT exec_italic(HTMLDocumentNode *doc, DWORD cmdexecopt, VARIANT *in,
static HRESULT query_justify(HTMLDocumentNode *doc, OLECMD *cmd)
{
- static const PRUnichar justifycenterW[] = {'j','u','s','t','i','f','y','c','e','n','t','e','r',0};
- static const PRUnichar justifyrightW[] = {'j','u','s','t','i','f','y','r','i','g','h','t',0};
-
switch(cmd->cmdID) {
case IDM_JUSTIFYCENTER:
TRACE("(%p) IDM_JUSTIFYCENTER\n", doc);
- cmd->cmdf = query_align_status(doc, justifycenterW);
+ cmd->cmdf = query_align_status(doc, L"justifycenter");
break;
case IDM_JUSTIFYLEFT:
TRACE("(%p) IDM_JUSTIFYLEFT\n", doc);
@@ -675,7 +672,7 @@ static HRESULT query_justify(HTMLDocumentNode *doc, OLECMD *cmd)
break;
case IDM_JUSTIFYRIGHT:
TRACE("(%p) IDM_JUSTIFYRIGHT\n", doc);
- cmd->cmdf = query_align_status(doc, justifyrightW);
+ cmd->cmdf = query_align_status(doc, L"justifyright");
break;
}
diff --git a/dlls/mshtml/htmldoc.c b/dlls/mshtml/htmldoc.c
index 767b46a7050..344079ba36e 100644
--- a/dlls/mshtml/htmldoc.c
+++ b/dlls/mshtml/htmldoc.c
@@ -5720,9 +5720,7 @@ HRESULT create_document_node(nsIDOMHTMLDocument *nsdoc, GeckoBrowser *browser, H
nsAString mode_str;
nsresult nsres;
- static const PRUnichar onW[] = {'o','n',0};
-
- nsAString_InitDepend(&mode_str, onW);
+ nsAString_InitDepend(&mode_str, L"on");
nsres = nsIDOMHTMLDocument_SetDesignMode(doc->nsdoc, &mode_str);
nsAString_Finish(&mode_str);
if(NS_FAILED(nsres))
diff --git a/dlls/mshtml/htmlelemcol.c b/dlls/mshtml/htmlelemcol.c
index 51cc90110f6..67bef804fbc 100644
--- a/dlls/mshtml/htmlelemcol.c
+++ b/dlls/mshtml/htmlelemcol.c
@@ -375,8 +375,6 @@ static BOOL is_elem_name(HTMLElement *elem, LPCWSTR name)
BOOL ret = FALSE;
nsresult nsres;
- static const PRUnichar nameW[] = {'n','a','m','e',0};
-
if(!elem->dom_element)
return FALSE;
@@ -388,7 +386,7 @@ static BOOL is_elem_name(HTMLElement *elem, LPCWSTR name)
return TRUE;
}
- nsres = get_elem_attr_value(elem->dom_element, nameW, &nsstr, &str);
+ nsres = get_elem_attr_value(elem->dom_element, L"name", &nsstr, &str);
if(NS_SUCCEEDED(nsres)) {
ret = !wcsicmp(str, name);
nsAString_Finish(&nsstr);
diff --git a/dlls/mshtml/htmlform.c b/dlls/mshtml/htmlform.c
index b4715298a1b..5906202f1c7 100644
--- a/dlls/mshtml/htmlform.c
+++ b/dlls/mshtml/htmlform.c
@@ -456,11 +456,9 @@ static HRESULT WINAPI HTMLFormElement_submit(IHTMLFormElement *iface)
if(NS_SUCCEEDED(nsres)) {
const PRUnichar *method;
- static const PRUnichar postW[] = {'p','o','s','t',0};
-
nsAString_GetData(&method_str, &method);
TRACE("method is %s\n", debugstr_w(method));
- is_post_submit = !wcsicmp(method, postW);
+ is_post_submit = !wcsicmp(method, L"post");
}
nsAString_Finish(&method_str);
@@ -661,8 +659,6 @@ static HRESULT HTMLFormElement_get_dispid(HTMLDOMNode *iface,
nsresult nsres;
HRESULT hres = DISP_E_UNKNOWNNAME;
- static const PRUnichar nameW[] = {'n','a','m','e',0};
-
TRACE("(%p)->(%s %x %p)\n", This, wine_dbgstr_w(name), grfdex, pid);
nsres = nsIDOMHTMLFormElement_GetElements(This->nsform, &elements);
@@ -731,7 +727,7 @@ static HRESULT HTMLFormElement_get_dispid(HTMLDOMNode *iface,
}
/* compare by name attr */
- nsres = get_elem_attr_value(elem, nameW, &name_str, &str);
+ nsres = get_elem_attr_value(elem, L"name", &name_str, &str);
nsIDOMElement_Release(elem);
if(NS_SUCCEEDED(nsres)) {
if(!wcsicmp(str, name)) {
diff --git a/dlls/mshtml/htmlhead.c b/dlls/mshtml/htmlhead.c
index 92eda92fbad..879eca424ae 100644
--- a/dlls/mshtml/htmlhead.c
+++ b/dlls/mshtml/htmlhead.c
@@ -448,11 +448,10 @@ static HRESULT WINAPI HTMLMetaElement_put_httpEquiv(IHTMLMetaElement *iface, BST
static HRESULT WINAPI HTMLMetaElement_get_httpEquiv(IHTMLMetaElement *iface, BSTR *p)
{
HTMLMetaElement *This = impl_from_IHTMLMetaElement(iface);
- static const PRUnichar httpEquivW[] = {'h','t','t','p','-','e','q','u','i','v',0};
TRACE("(%p)->(%p)\n", This, p);
- return elem_string_attr_getter(&This->element, httpEquivW, TRUE, p);
+ return elem_string_attr_getter(&This->element, L"http-equiv", TRUE, p);
}
static HRESULT WINAPI HTMLMetaElement_put_content(IHTMLMetaElement *iface, BSTR v)
@@ -465,11 +464,10 @@ static HRESULT WINAPI HTMLMetaElement_put_content(IHTMLMetaElement *iface, BSTR
static HRESULT WINAPI HTMLMetaElement_get_content(IHTMLMetaElement *iface, BSTR *p)
{
HTMLMetaElement *This = impl_from_IHTMLMetaElement(iface);
- static const PRUnichar contentW[] = {'c','o','n','t','e','n','t',0};
TRACE("(%p)->(%p)\n", This, p);
- return elem_string_attr_getter(&This->element, contentW, TRUE, p);
+ return elem_string_attr_getter(&This->element, L"content", TRUE, p);
}
static HRESULT WINAPI HTMLMetaElement_put_name(IHTMLMetaElement *iface, BSTR v)
@@ -482,11 +480,10 @@ static HRESULT WINAPI HTMLMetaElement_put_name(IHTMLMetaElement *iface, BSTR v)
static HRESULT WINAPI HTMLMetaElement_get_name(IHTMLMetaElement *iface, BSTR *p)
{
HTMLMetaElement *This = impl_from_IHTMLMetaElement(iface);
- static const PRUnichar nameW[] = {'n','a','m','e',0};
TRACE("(%p)->(%p)\n", This, p);
- return elem_string_attr_getter(&This->element, nameW, TRUE, p);
+ return elem_string_attr_getter(&This->element, L"name", TRUE, p);
}
static HRESULT WINAPI HTMLMetaElement_put_url(IHTMLMetaElement *iface, BSTR v)
diff --git a/dlls/mshtml/htmlimg.c b/dlls/mshtml/htmlimg.c
index 7dc32cd654d..aa4129e760e 100644
--- a/dlls/mshtml/htmlimg.c
+++ b/dlls/mshtml/htmlimg.c
@@ -876,8 +876,6 @@ static HRESULT WINAPI HTMLImageElementFactory_create(IHTMLImageElementFactory *i
LONG l;
HRESULT hres;
- static const PRUnichar imgW[] = {'I','M','G',0};
-
TRACE("(%p)->(%s %s %p)\n", This, debugstr_variant(&width),
debugstr_variant(&height), img_elem);
@@ -890,7 +888,7 @@ static HRESULT WINAPI HTMLImageElementFactory_create(IHTMLImageElementFactory *i
*img_elem = NULL;
- hres = create_nselem(doc, imgW, &nselem);
+ hres = create_nselem(doc, L"IMG", &nselem);
if(FAILED(hres))
return hres;
diff --git a/dlls/mshtml/htmlselect.c b/dlls/mshtml/htmlselect.c
index 739da9bf0ff..13a2f8b3f6a 100644
--- a/dlls/mshtml/htmlselect.c
+++ b/dlls/mshtml/htmlselect.c
@@ -538,8 +538,6 @@ static HRESULT WINAPI HTMLOptionElementFactory_create(IHTMLOptionElementFactory
HTMLDOMNode *node;
HRESULT hres;
- static const PRUnichar optionW[] = {'O','P','T','I','O','N',0};
-
TRACE("(%p)->(%s %s %s %s %p)\n", This, debugstr_variant(&text), debugstr_variant(&value),
debugstr_variant(&defaultselected), debugstr_variant(&selected), optelem);
@@ -550,7 +548,7 @@ static HRESULT WINAPI HTMLOptionElementFactory_create(IHTMLOptionElementFactory
*optelem = NULL;
- hres = create_nselem(This->window->doc, optionW, &nselem);
+ hres = create_nselem(This->window->doc, L"OPTION", &nselem);
if(FAILED(hres))
return hres;
diff --git a/dlls/mshtml/nsevents.c b/dlls/mshtml/nsevents.c
index f232a25ba33..21b59cf6e1d 100644
--- a/dlls/mshtml/nsevents.c
+++ b/dlls/mshtml/nsevents.c
@@ -38,11 +38,6 @@
WINE_DEFAULT_DEBUG_CHANNEL(mshtml);
-static const PRUnichar blurW[] = {'b','l','u','r',0};
-static const PRUnichar focusW[] = {'f','o','c','u','s',0};
-static const PRUnichar keypressW[] = {'k','e','y','p','r','e','s','s',0};
-static const PRUnichar loadW[] = {'l','o','a','d',0};
-
typedef struct {
nsIDOMEventListener nsIDOMEventListener_iface;
nsDocumentEventListener *This;
@@ -446,10 +441,10 @@ void release_nsevents(HTMLDocumentNode *doc)
if(!listener)
return;
- detach_nslistener(doc, blurW, &listener->blur_listener, TRUE);
- detach_nslistener(doc, focusW, &listener->focus_listener, TRUE);
- detach_nslistener(doc, keypressW, &listener->keypress_listener, FALSE);
- detach_nslistener(doc, loadW, &listener->load_listener, TRUE);
+ detach_nslistener(doc, L"blur", &listener->blur_listener, TRUE);
+ detach_nslistener(doc, L"focus", &listener->focus_listener, TRUE);
+ detach_nslistener(doc, L"keypress", &listener->keypress_listener, FALSE);
+ detach_nslistener(doc, L"load", &listener->load_listener, TRUE);
listener->doc = NULL;
release_listener(listener);
@@ -482,10 +477,10 @@ void init_nsevents(HTMLDocumentNode *doc)
if(!target)
return;
- init_event(target, blurW, &listener->blur_listener.nsIDOMEventListener_iface, TRUE);
- init_event(target, focusW, &listener->focus_listener.nsIDOMEventListener_iface, TRUE);
- init_event(target, keypressW, &listener->keypress_listener.nsIDOMEventListener_iface, FALSE);
- init_event(target, loadW, &listener->load_listener.nsIDOMEventListener_iface, TRUE);
+ init_event(target, L"blur", &listener->blur_listener.nsIDOMEventListener_iface, TRUE);
+ init_event(target, L"focus", &listener->focus_listener.nsIDOMEventListener_iface, TRUE);
+ init_event(target, L"keypress", &listener->keypress_listener.nsIDOMEventListener_iface, FALSE);
+ init_event(target, L"load", &listener->load_listener.nsIDOMEventListener_iface, TRUE);
nsIDOMEventTarget_Release(target);
}
diff --git a/dlls/mshtml/nsservice.c b/dlls/mshtml/nsservice.c
index 2eb838b2f54..55a65cfeae6 100644
--- a/dlls/mshtml/nsservice.c
+++ b/dlls/mshtml/nsservice.c
@@ -126,8 +126,6 @@ static nsresult NSAPI nsPromptService_ConfirmEx(nsIPromptService *iface,
const PRUnichar *aButton1Title, const PRUnichar *aButton2Title,
const PRUnichar *aCheckMsg, cpp_bool *aCheckState, LONG *_retval)
{
- static const PRUnichar wszContinue[] = {'C','o','n','t','i','n','u','e',0};
-
FIXME("(%p %s %s %08x %s %s %s %s %p %p) hack!\n", aParent, debugstr_w(aDialogTitle),
debugstr_w(aText), aButtonFlags, debugstr_w(aButton0Title),
debugstr_w(aButton1Title), debugstr_w(aButton2Title), debugstr_w(aCheckMsg),
@@ -138,11 +136,11 @@ static nsresult NSAPI nsPromptService_ConfirmEx(nsIPromptService *iface,
* This is really very very ugly hack!!!
*/
- if(aButton0Title && !memcmp(aButton0Title, wszContinue, sizeof(wszContinue)))
+ if(aButton0Title && !memcmp(aButton0Title, L"Continue", sizeof(L"Continue")))
*_retval = 0;
- else if(aButton1Title && !memcmp(aButton1Title, wszContinue, sizeof(wszContinue)))
+ else if(aButton1Title && !memcmp(aButton1Title, L"Continue", sizeof(L"Continue")))
*_retval = 1;
- else if(aButton2Title && !memcmp(aButton2Title, wszContinue, sizeof(wszContinue)))
+ else if(aButton2Title && !memcmp(aButton2Title, L"Continue", sizeof(L"Continue")))
*_retval = 2;
/* else
* let's hope that _retval is set to the default value */
diff --git a/dlls/mshtml/olecmd.c b/dlls/mshtml/olecmd.c
index a79f2d000ef..22d350bedd8 100644
--- a/dlls/mshtml/olecmd.c
+++ b/dlls/mshtml/olecmd.c
@@ -219,14 +219,12 @@ static void set_default_templates(nsIPrintSettings *settings)
{
WCHAR buf[64];
- static const PRUnichar empty[] = {0};
-
- nsIPrintSettings_SetHeaderStrLeft(settings, empty);
- nsIPrintSettings_SetHeaderStrRight(settings, empty);
- nsIPrintSettings_SetHeaderStrCenter(settings, empty);
- nsIPrintSettings_SetFooterStrLeft(settings, empty);
- nsIPrintSettings_SetFooterStrRight(settings, empty);
- nsIPrintSettings_SetFooterStrCenter(settings, empty);
+ nsIPrintSettings_SetHeaderStrLeft(settings, L"");
+ nsIPrintSettings_SetHeaderStrRight(settings, L"");
+ nsIPrintSettings_SetHeaderStrCenter(settings, L"");
+ nsIPrintSettings_SetFooterStrLeft(settings, L"");
+ nsIPrintSettings_SetFooterStrRight(settings, L"");
+ nsIPrintSettings_SetFooterStrCenter(settings, L"");
if(LoadStringW(get_shdoclc(), IDS_PRINT_HEADER_TEMPLATE, buf, ARRAY_SIZE(buf)))
set_print_template(settings, buf, TRUE);
diff --git a/dlls/mshtml/pluginhost.c b/dlls/mshtml/pluginhost.c
index b47d06f1d5b..d880cc89a9d 100644
--- a/dlls/mshtml/pluginhost.c
+++ b/dlls/mshtml/pluginhost.c
@@ -279,11 +279,7 @@ static HRESULT fill_props(nsIDOMElement *nselem, PropertyBag *prop_bag)
nsresult nsres;
HRESULT hres = S_OK;
- static const PRUnichar nameW[] = {'n','a','m','e',0};
- static const PRUnichar paramW[] = {'p','a','r','a','m',0};
- static const PRUnichar valueW[] = {'v','a','l','u','e',0};
-
- nsAString_InitDepend(&name_str, paramW);
+ nsAString_InitDepend(&name_str, L"param");
nsres = nsIDOMElement_GetElementsByTagName(nselem, &name_str, ¶ms);
nsAString_Finish(&name_str);
if(NS_FAILED(nsres))
@@ -307,9 +303,9 @@ static HRESULT fill_props(nsIDOMElement *nselem, PropertyBag *prop_bag)
break;
}
- nsres = get_elem_attr_value(param_elem, nameW, &name_str, &name);
+ nsres = get_elem_attr_value(param_elem, L"name", &name_str, &name);
if(NS_SUCCEEDED(nsres)) {
- nsres = get_elem_attr_value(param_elem, valueW, &value_str, &value);
+ nsres = get_elem_attr_value(param_elem, L"value", &value_str, &value);
if(NS_SUCCEEDED(nsres)) {
hres = add_prop(prop_bag, name, value);
nsAString_Finish(&value_str);
@@ -2297,9 +2293,7 @@ static BOOL get_elem_clsid(nsIDOMElement *elem, CLSID *clsid)
nsresult nsres;
BOOL ret = FALSE;
- static const PRUnichar classidW[] = {'c','l','a','s','s','i','d',0};
-
- nsres = get_elem_attr_value(elem, classidW, &val_str, &val);
+ nsres = get_elem_attr_value(elem, L"classid", &val_str, &val);
if(NS_SUCCEEDED(nsres)) {
if(*val)
ret = parse_classid(val, clsid);
@@ -2535,9 +2529,7 @@ static void check_codebase(HTMLInnerWindow *window, nsIDOMElement *nselem)
nsresult nsres;
HRESULT hres;
- static const PRUnichar codebaseW[] = {'c','o','d','e','b','a','s','e',0};
-
- nsres = get_elem_attr_value(nselem, codebaseW, &val_str, &val);
+ nsres = get_elem_attr_value(nselem, L"codebase", &val_str, &val);
if(NS_SUCCEEDED(nsres)) {
if(*val) {
hres = CoInternetCombineUrlEx(window->base.outer_window->uri, val, 0, &uri, 0);
diff --git a/dlls/mshtml/range.c b/dlls/mshtml/range.c
index 7db62f49a12..d38d64b4151 100644
--- a/dlls/mshtml/range.c
+++ b/dlls/mshtml/range.c
@@ -1674,9 +1674,6 @@ static HRESULT exec_indent(HTMLTxtRange *This, VARIANT *in, VARIANT *out)
nsIDOMDocumentFragment *fragment;
nsIDOMNode *tmp;
- static const PRUnichar blockquoteW[] = {'B','L','O','C','K','Q','U','O','T','E',0};
- static const PRUnichar pW[] = {'P',0};
-
TRACE("(%p)->(%p %p)\n", This, in, out);
if(!This->doc->nsdoc) {
@@ -1684,8 +1681,8 @@ static HRESULT exec_indent(HTMLTxtRange *This, VARIANT *in, VARIANT *out)
return E_NOTIMPL;
}
- create_nselem(This->doc, blockquoteW, &blockquote_elem);
- create_nselem(This->doc, pW, &p_elem);
+ create_nselem(This->doc, L"BLOCKQUOTE", &blockquote_elem);
+ create_nselem(This->doc, L"P", &p_elem);
nsIDOMRange_ExtractContents(This->nsrange, &fragment);
nsIDOMElement_AppendChild(p_elem, (nsIDOMNode*)fragment, &tmp);
diff --git a/dlls/mshtml/script.c b/dlls/mshtml/script.c
index 6f06d3b0919..bb097081c5e 100644
--- a/dlls/mshtml/script.c
+++ b/dlls/mshtml/script.c
@@ -1210,8 +1210,6 @@ static BOOL get_script_guid(HTMLInnerWindow *window, nsIDOMHTMLScriptElement *ns
BOOL ret = FALSE;
nsresult nsres;
- static const PRUnichar languageW[] = {'l','a','n','g','u','a','g','e',0};
-
nsAString_Init(&val_str, NULL);
nsres = nsIDOMHTMLScriptElement_GetType(nsscript, &val_str);
@@ -1231,7 +1229,7 @@ static BOOL get_script_guid(HTMLInnerWindow *window, nsIDOMHTMLScriptElement *ns
nsres = nsIDOMHTMLScriptElement_QueryInterface(nsscript, &IID_nsIDOMElement, (void**)&nselem);
assert(nsres == NS_OK);
- nsres = get_elem_attr_value(nselem, languageW, &val_str, &language);
+ nsres = get_elem_attr_value(nselem, L"language", &val_str, &language);
nsIDOMElement_Release(nselem);
if(NS_SUCCEEDED(nsres)) {
if(*language) {
@@ -1554,14 +1552,12 @@ void bind_event_scripts(HTMLDocumentNode *doc)
nsresult nsres;
HRESULT hres;
- static const PRUnichar selectorW[] = {'s','c','r','i','p','t','[','e','v','e','n','t',']',0};
-
TRACE("%p\n", doc);
if(!doc->nsdoc)
return;
- nsAString_InitDepend(&selector_str, selectorW);
+ nsAString_InitDepend(&selector_str, L"script[event]");
nsres = nsIDOMHTMLDocument_QuerySelectorAll(doc->nsdoc, &selector_str, &node_list);
nsAString_Finish(&selector_str);
if(NS_FAILED(nsres)) {
--
2.26.2
2
1