IDWriteGlyphRunAnalysis supports gray-scale antialiasing only when
created via IDWriteFactory2 (and newer), introduced in Windows 8.1
Fallback to using DIrect2D on A8 targets when IDWriteFactory2 is
not available.
This partially reverts commit ba4d5fbd5 from MR !343 which asked for
hidden symbols everywhere. cairo-fdr and cairo-trace explicitly try to
interpose existing symbols. Changing them to hidden symbols breaks these
tools.
See: https://gitlab.freedesktop.org/cairo/cairo/-/issues/882#note_2759005
Signed-off-by: Uli Schlachter <psychon@znc.in>
...by checking for IUnknown.
This makes GeometryRecorder::QueryInterface compliant with the
rules of COM.
QueryInterface for IUnknown has a special meaning in COM: it's
used to check whether two interface pointers refer to the same
object.
STDMETHOD / IFACEMETHOD macros already add __declspec(nothrow), but
noexcept is better. From MSDN [1]:
We recommend that all new code use the noexcept operator rather than
__declspec(nothrow).
This attribute tells the compiler that the declared function and the
functions it calls never throw an exception. However, it does not
enforce the directive. In other words, it never causes std::terminate
to be invoked, unlike noexcept, or in std:c++17 mode (Visual Studio
2017 version 15.5 and later), throw().
See also [2]:
Non-throwing functions are permitted to call potentially-throwing
functions. Whenever an exception is thrown and the search for a handler
encounters the outermost block of a non-throwing function, the function
std::terminate is called:
extern void f(); // potentially-throwing
void g() noexcept {
f(); // valid, even if f throws
throw 42; // valid, effectively a call to std::terminate
}
References:
[1] https://learn.microsoft.com/en-us/cpp/cpp/nothrow-cpp?view=msvc-170
[2] https://en.cppreference.com/w/cpp/language/noexcept_spec
IFACEMETHOD already adds the __override / __allowed(on_function) SAL
annotation (only on Windows SDK, not mingw-w64), which is understood
by some code analysis tools [1]. Since we're compiling in C++11 mode,
we can add the override specifier, so that the compiler is informed
as well.
[1] https://devblogs.microsoft.com/oldnewthing/20200911-00/?p=104205
Fixes the following warnings on CLang:
../cairo/src/win32/cairo-dwrite-font.cpp:869:27: warning: exception specification
of overriding function is more lax than base version [-Wmicrosoft-exception-spec]
869 | IFACEMETHODIMP_(void) SetFillMode(D2D1_FILL_MODE fillMode)
| ^
D:/msys64/clang64/include/d2d1.h:1491:22: note: overridden virtual function is here
1491 | STDMETHOD_(void, SetFillMode)(D2D1_FILL_MODE fillMode) PURE;
|
COM objects are usually implemented like that:
1. The class is defined with only method declarations. For that,
one should use IFACEMETHOD macros.
2. Then methods are implemented (defined), outside of the class
definition. For that, one should use the IFACEMETHODIMP macros
If one really wants to provide inline method definitions (that is,
inside the class definition), then IFACEMETHOD macros should be used
(and not IFACEMETHODIMP, though it's a definition / implementation).
...to _cairo_win32_print_api_error, since it should not be used
with most GDI functions. Also move the function definition to
cairo-win32-system.c and change argument signature.
Most GDI functions do not set the last error, so GetLastError() returns
unrelated error codes. There are some exceptions, however, like BitBlt
and CreateDIBSection.
Whether a GDI function sets the last error is stated in the reference
documentation on MSDN.
Bit-shifting a signed integer (which is what 1 is here) left is
undefined behavior – you can see it when compiling with
`-fsanitize=undefined`. Explicitly declaring 1 as unsigned fixes this.
...and make the code use that instead of the original IDWriteFontFace
in the font face subclass. We do that because to apply a few settings
(font variations) a new IDWriteFontFace must be created out of the
original one.
For now the IDWriteFontFace in the scaled font is a copy of the one in
the font face. In the next commit we'll add code to create a different
object.
DWRITE_GLYPH_IMAGE_FORMATS is now defined by dcommon.h
In file included from C:/msys64/ucrt64/include/minwindef.h:163,
from C:/msys64/ucrt64/include/windef.h:9,
from C:/msys64/ucrt64/include/windows.h:69,
from ..\src/cairo-mutex-impl-private.h:182,
from ..\src/cairo-mutex-type-private.h:45,
from ..\src/cairo-scaled-font-private.h:45,
from ..\src/cairoint.h:415,
from ../src/win32/cairo-dwrite-font.cpp:37:
../src/win32/dw-extra.h:26:1: error: redefinition of 'DWRITE_GLYPH_IMAGE_FORMATS operator|(DWRITE_GLYPH_IMAGE_FORMATS, DWRITE_GLYPH_IMAGE_FORMATS)'
26 | DEFINE_ENUM_FLAG_OPERATORS(DWRITE_GLYPH_IMAGE_FORMATS);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~
C:/msys64/ucrt64/include/dcommon.h:67:1: note: 'DWRITE_GLYPH_IMAGE_FORMATS operator|(DWRITE_GLYPH_IMAGE_FORMATS, DWRITE_GLYPH_IMAGE_FORMATS)' previously defined here
67 | DEFINE_ENUM_FLAG_OPERATORS(DWRITE_GLYPH_IMAGE_FORMATS)
| ^~~~~~~~~~~~~~~~~~~~~~~~~~
Adds include of <termios.h> if system has it, in order to fix:
../perf/cairo-perf-print.c: In function ‘report_print’:
../perf/cairo-perf-print.c:62:28: error: storage size of ‘ws’ isn’t known
62 | struct winsize ws;
| ^~
../perf/cairo-perf-print.c:64:26: error: ‘TIOCGWINSZ’ undeclared
(first use in this function)
64 | if(ioctl(fd, TIOCGWINSZ, &ws) == 0 ) {
| ^~~~~~~~~~
Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
Adds include of <sys/wait.h> if system has it, in order to fix:
../test/pdf-structure.c: In function ‘check_pdf’:
../test/pdf-structure.c:551:21: error: implicit declaration of function
‘WIFEXITED’ [-Wimplicit-function-declaration]
551 | WIFEXITED (ret) ? WEXITSTATUS (ret) : -1);
| ^~~~~~~~~
../test/pdf-structure.c:551:39: error: implicit declaration of function
‘WEXITSTATUS’ [-Wimplicit-function-declaration]
551 | WIFEXITED (ret) ? WEXITSTATUS (ret) : -1);
| ^~~~~~~~~~~
Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
In file included from ../src/cairo-colr-glyph-render.c:37:
../src/cairo-ft-private.h:87:30: error: unknown type name 'FT_Color'
87 | FT_Color *palette,
| ^~~~~~~~
Fixes https://gitlab.freedesktop.org/cairo/cairo/-/issues/792
Signed-off-by: Thomas Devoogdt <thomas@devoogdt.com>
GitLab pages for cairo appear in
https://cairo.pages.freedesktop.org/cairo/ but there is nothing there
right now, so it gives a 404. Only
https://cairo.pages.freedesktop.org/cairo/coverage works so far.
So, add public/index.html as a minimal landing page. My intention is
to link other things from there - an HTMLized report of the test
suite, a development guide, things like that.
lzo2's pkg-config file has always specified "Cflags: -I${includedir}/lzo".
Including <lzo/lzo2a.h> happens to work if ${includedir} is already on the
header search path, e.g. it's /usr/include. However, if lzo2 is in an
unusual location and we're depending on pkg-config to tell us where it is,
we'll end up looking for ${includedir}/lzo/lzo/lzo2a.h and failing the
build:
util/cairo-script/cairo-script-file.c:45:10: fatal error: 'lzo/lzo2a.h' file not found
Fix the include paths.