12to11/Imakefile
hujianwei 1ce5081dfa Major refactoring of the frame clock code
This is in preparation for a migration to the Present extension
on systems that do not support frame synchronization.

* 12to11.man: Remove option that is no longer useful.
* Imakefile (SRCS, OBJS): Add `sync_source.c.'.
* compositor.h (enum _RenderMode): New enum.
(struct _RenderFuncs): Add some new functions.
(enum _FrameMode): Remove ModeNotifyDisablePresent.

* frame_clock.c (struct _FrameClockCallback): Add draw time to
frame callback.
(struct _FrameClock): Rearrange for alignment and remove many
unused members.
(BumpFrame): New function.
(FreezeForValue): Remove code that is no longer useful, as
clock->frozen no longer exists.
(StartFrame, EndFrame): Remove clock "freezing" logic.  Only
`need_configure' remains.
(RunFrameCallbacks, NoteFakeFrame): Add frame drawn time.
(XLFrameClockAfterFrame): Adjust for new type of callback.
(XLFrameClockFreeze): Remove function.
(XLFrameClockFrameInProgress): Remove test for
`frozen_until_end_frame'.
(XLFrameClockHandleFrameEvent): Improve code in accordance with
above changes.
(XLFrameClockUnfreeze, XLFrameClockNeedConfigure): Remove
functions.
(XLFrameClockIsFrozen): Remove function.
(XLFrameClockSetFreezeCallback): Accept new callback
`fast_forward_callback'.
(XLFrameClockGetFrameTime): Remove unused function.

* icon_surface.c (struct _IconSurface, ReleaseBacking)
(ReleaseBuffer, RunFrameCallbacks, AfterFrame, Commit)
(SubsurfaceUpdate, XLGetIconSurface)
(XLHandleOneXEventForIconSurfaces): Switch the icon surface to
the sync helper abstraction, and allow asynch buffer release
from inside.

* picture_renderer.c (struct _PictureTarget): New field
`next_msc' and `render_mode'.
(SwapBackBuffers): Respect the render mode.
(InitSynchronizedPresentation): Delete function.
(InitAdditionalModifiers): Remove incorrect comment.
(InitRenderFuncs): Stop initializing obsolete option.
(SetRenderMode): New function.
(PresentToWindow): Respect the render mode.
(NotifyMsc): New function.
(picture_render_funcs): Add notify_msc.
(HandlePresentCompleteNotify): Call completion callback with the
fraame counter.

* renderer.c (RenderSetRenderMode):
(RenderNotifyMsc): New functions.

* subcompositor.c (struct _Subcompositor)
(SubcompositorSetNoteFrameCallback): Add msc and ust to note
frame callback.
(PresentCompletedCallback, RenderCompletedCallback): Call with
msc and ust.
(BeginFrame): When presentation is being synchronized and there
is no existing presentation callback, ask for an event to be
sent on the next frame.
(EndFrame): Do not clear the presentation callbacks, as the
update might not touch anything.

* test.c (NoteFrame): Update prototype.
* xdg_popup.c (InternalReposition): Stop "freezing" the frame
clock.

* xdg_surface.c (struct _XdgRole): Replace the frame clock with
the sync helper abstraction.
(RunFrameCallbacks): Run with the frame time.
(RunFrameCallbacksConditionally): Save the pending frame time.
(UpdateFrameRefreshPrediction): Delete function.
(XLHandleXEventForXdgSurfaces): Give events to the sync helper
instead.
(Unfreeze, IsRoleMapped, CheckFrame): Remove functions.
(Commit, SubsurfaceUpdate): Update using the sync helper
instead, only if not pending ack commit.
(MaybeRunLateFrame, AfterFrame): Delete functions.
(NoteConfigure, NoteBounds): Update for the sync helper.
(WriteRedirectProperty): Always require redirection for now.
Disabling redirection requires sorting out some Present problems
on the X server side.
(WasFrameQueued, NoteFrame): Delete functions.
(HandleFreeze): Delete function.
(HandleResize, CheckFastForward, HandleFrameCallback): New
functions.
(XLGetXdgSurface): Use the sync helper for most things.
(XLXdgRoleSendConfigure, XLXdgRoleReconstrain)
(XLXdgRoleGetFrameClock): Delete function.
(XLXdgRoleNoteRejectedConfigure): Clean up for using the sync
clock instead.
2022-11-22 10:57:50 +00:00

140 lines
6.7 KiB
Text

#include "12to11.conf"
#ifndef HasPosixThreads
#error "Posix threads are required"
#endif
SYS_LIBRARIES = MathLibrary ThreadsLibraries
DEPLIBS = $(DEPXLIB) $(DEPEXTENSIONLIB) $(DEPXRANDRLIB) $(DEPXRENDERLIB) $(DEPXFIXESLIB) $(DEPXILIB) $(DEPXKBFILELIB)
LOCAL_LIBRARIES = $(XLIB) $(EXTENSIONLIB) $(XCBLIB) $(XCB) $(XCB_SHM) $(XRANDRLIB) $(PIXMAN) $(XRENDERLIB) $(XILIB) $(XKBFILELIB) $(XFIXESLIB) $(XCB_DRI3) $(XCB_SHAPE) $(WAYLAND_SERVER) $(XCB_RANDR) $(DRM) $(XPRESENTLIB) $(XSHMFENCELIB)
INCLUDES := $(DRMINCLUDES) $(PIXMANINCLUDES)
#ifdef BuildTests
# define IHaveSubdirs
# define PassCDebugFlags 'CDEBUGFLAGS=$(CDEBUGFLAGS)'
SUBDIRS = tests
MakeSubdirs($(SUBDIRS))
DependSubdirs($(SUBDIRS))
#endif
SRCS = 12to11.c run.c alloc.c fns.c output.c compositor.c surface.c region.c shm.c atoms.c subcompositor.c positioner.c xdg_wm.c xdg_surface.c xdg_toplevel.c frame_clock.c xerror.c ewmh.c timer.c subsurface.c seat.c data_device.c xdg_popup.c dmabuf.c buffer.c select.c xdata.c xsettings.c dnd.c icon_surface.c primary_selection.c renderer.c picture_renderer.c explicit_synchronization.c transform.c wp_viewporter.c decoration.c text_input.c single_pixel_buffer.c drm_lease.c pointer_constraints.c time.c relative_pointer.c keyboard_shortcuts_inhibit.c idle_inhibit.c process.c fence_ring.c pointer_gestures.c test.c buffer_release.c xdg_activation.c tearing_control.c sync_source.c
OBJS = 12to11.o run.o alloc.o fns.o output.o compositor.o surface.o region.o shm.o atoms.o subcompositor.o positioner.o xdg_wm.o xdg_surface.o xdg_toplevel.o frame_clock.o xerror.o ewmh.o timer.o subsurface.o seat.o data_device.o xdg_popup.o dmabuf.o buffer.o select.o xdata.o xsettings.o dnd.o icon_surface.o primary_selection.o renderer.o picture_renderer.o explicit_synchronization.o transform.o wp_viewporter.o decoration.o text_input.o single_pixel_buffer.o drm_lease.o pointer_constraints.o time.o relative_pointer.o keyboard_shortcuts_inhibit.o idle_inhibit.o process.o fence_ring.o pointer_gestures.o test.o buffer_release.o xdg_activation.o tearing_control.o sync_source.o
GENHEADERS = transfer_atoms.h drm_modifiers.h
HEADER = $(GENHEADERS) compositor.h
#if defined LinuxArchitecture || defined GNUArchitecture
EXTRA_DEFINES := -DPortFile=\"port_gnu.h\" -D_GNU_SOURCE -U_BSD_SOURCE -U_SVID_SOURCE
DEPEND_DEFINES := -DPortFile=\"port_gnu.h\"
#else
# error "The protocol translator was not ported to your system"
#endif
#ifdef HaveEglSupport
EGL_SRCS = egl.c
EGL_OBJS = egl.o
LOCAL_LIBRARIES ::= $(LOCAL_LIBRARIES) $(EGL) $(GLES)
SRCS ::= $(SRCS) $(EGL_SRCS)
OBJS ::= $(OBJS) $(EGL_OBJS)
DEFINES ::= $(DEFINES) -DHaveEglSupport
shaders.h: shaders.txt shaders.awk
awk -f shaders.awk shaders.txt > $@
depend:: shaders.h
$(EGL_OBJS): shaders.h
cleandir::
$(RM) shaders.h
#endif
OPTIMIZE = -O0
#if GccMajorVersion >= 10
ANALYZE = -fanalyzer
#endif
#if GccMajorVersion >= 7
CDEBUGFLAGS := -fno-common -Wall -Warith-conversion -Wdate-time -Wdisabled-optimization -Wdouble-promotion -Wduplicated-cond -Wextra -Wformat-signedness -Winit-self -Winvalid-pch -Wlogical-op -Wmissing-declarations -Wmissing-include-dirs -Wmissing-prototypes -Wnested-externs -Wnull-dereference -Wold-style-definition -Wopenmp-simd -Wpacked -Wpointer-arith -Wstrict-prototypes -Wsuggest-attribute=format -Wsuggest-attribute=noreturn -Wsuggest-final-methods -Wsuggest-final-types -Wuninitialized -Wunknown-pragmas -Wunused-macros -Wvariadic-macros -Wvector-operation-performance -Wwrite-strings -Warray-bounds=2 -Wattribute-alias=2 -Wformat=2 -Wformat-truncation=2 -Wimplicit-fallthrough=5 -Wshift-overflow=2 -Wuse-after-free=3 -Wvla-larger-than=4031 -Wredundant-decls -Wno-missing-field-initializers -Wno-override-init -Wno-sign-compare -Wno-type-limits -Wno-unused-parameter -Wno-format-nonliteral -g3 $(OPTIMIZE) $(ANALYZE)
#endif
short_types.txt: media_types.txt
XCOMM Remove all data types starting with application/vnd.
XCOMM no program really uses them in clipboard data, and they
XCOMM waste a lot of space on disk.
sed '/application\/vnd/d' media_types.txt > $@
transfer_atoms.h: short_types.txt mime0.awk mime1.awk mime2.awk mime3.awk \
mime4.awk
awk -f mime0.awk short_types.txt > $@
awk -f mime1.awk short_types.txt >> $@
awk -f mime2.awk short_types.txt >> $@
awk -f mime3.awk short_types.txt >> $@
awk -f mime4.awk short_types.txt >> $@
drm_modifiers.h: modifiers.awk $(DRMFOURCCH)
awk -f modifiers.awk $(DRMFOURCCH) > $@
/* Now, define generated files. */
#define ScannerTarget(name) @@\
name.h: name.xml @@\
$(WAYLAND_SCANNER) server-header $< $@ @@\
@@\
name.c: name.xml name.h @@\
$(WAYLAND_SCANNER) private-code $< $@ @@\
@@\
GENHEADERS := $(GENHEADERS) name.h @@\
OBJS := $(OBJS) name.o @@\
SRCS := $(SRCS) name.c @@\
GENSRCS := $(GENSRCS) name.c @@\
ScannerTarget(linux-dmabuf-unstable-v1)
ScannerTarget(xdg-shell)
ScannerTarget(primary-selection-unstable-v1)
ScannerTarget(linux-explicit-synchronization-unstable-v1)
ScannerTarget(viewporter)
ScannerTarget(xdg-decoration-unstable-v1)
ScannerTarget(text-input-unstable-v3)
ScannerTarget(single-pixel-buffer-v1)
ScannerTarget(drm-lease-v1)
ScannerTarget(pointer-constraints-unstable-v1)
ScannerTarget(relative-pointer-unstable-v1)
ScannerTarget(keyboard-shortcuts-inhibit-unstable-v1)
ScannerTarget(idle-inhibit-unstable-v1)
ScannerTarget(pointer-gestures-unstable-v1)
ScannerTarget(12to11-test)
ScannerTarget(xdg-activation-v1)
ScannerTarget(tearing-control-v1)
/* Make seat.o depend on test_seat.c, as it includes that. Both files
are rather special. */
seat.o: test_seat.c
/* Make OBJS depend on scanner headers, and depend on both them and
SRCS. */
$(OBJS): $(GENHEADERS)
/* depend somehow does not depend on SRCS, even though some of OBJS
are generated. */
depend:: $(GENHEADERS) $(SRCS)
cleandir::
$(RM) $(GENHEADERS) $(GENSRCS) short_types.txt 12to11.tar.gz
ComplexProgramTarget(12to11)
.PHONY: dist
dist: 12to11.tar.gz
DIST_FILES = Imakefile $(SRCS) media_types.txt shaders.txt *.awk *.xml 12to11.man README libraries.def *.h
/* Include files generated by wayland-scanner, so the target does not
need to have it installed. */
12to11.tar.gz: $(DIST_FILES)
rm -rf 12to11.tar.gz
tar -cvf 12to11.tar $(DIST_FILES)
gzip 12to11.tar
$(RM) 12to11.tar