From e156e69112511469096a7c467642e32ba06c8bd7 Mon Sep 17 00:00:00 2001 From: Andri Yngvason Date: Sun, 6 Oct 2019 15:27:56 +0000 Subject: [PATCH] Add protocol build --- .gitignore | 1 + Makefile | 17 +- common.mk | 2 +- protocols/Makefile | 25 +++ protocols/wlr-export-dmabuf-unstable-v1.xml | 203 ++++++++++++++++++++ 5 files changed, 245 insertions(+), 3 deletions(-) create mode 100644 protocols/Makefile create mode 100644 protocols/wlr-export-dmabuf-unstable-v1.xml diff --git a/.gitignore b/.gitignore index 5c82818..a464b96 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ build-* *.swp +protocols/build diff --git a/Makefile b/Makefile index 170393e..5ae0eb7 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,4 @@ -DEPENDENCIES := libuv egl glesv2 +DEPENDENCIES := libuv egl glesv2 wayland-client EXEC := wayvnc @@ -8,15 +8,28 @@ SOURCES := \ include common.mk +PROTOCOLS := \ + $(BUILD_DIR)/proto-wlr-export-dmabuf-unstable-v1.o \ + VERSION=0.0.0 ifndef DONT_STRIP INSTALL_STRIP := -s --strip-program=$(STRIP) endif +protocols/build/%.c: + make -C protocols + $(BUILD_DIR)/%.o: src/%.c | $(BUILD_DIR) ; $(CC_OBJ) -$(BUILD_DIR)/$(EXEC): $(OBJECTS) | $(BUILD_DIR) ; $(LINK_EXE) +$(BUILD_DIR)/proto-%.o: protocols/build/%.c | $(BUILD_DIR) ; $(CC_OBJ) +$(BUILD_DIR)/$(EXEC): $(OBJECTS) $(PROTOCOLS) | $(BUILD_DIR) ; $(LINK_EXE) .PHONY: install install: $(EXEC) install $(INSTALL_STRIP) -Dt $(DESTDIR)$(PREFIX)/bin $(BUILD_DIR)/$(EXEC) + +.PHONY: proto_clean +proto_clean: + make -C protocols clean + +clean: proto_clean diff --git a/common.mk b/common.mk index 5023e9c..93d1365 100644 --- a/common.mk +++ b/common.mk @@ -27,7 +27,7 @@ endif CFLAGS ?= -g -O3 $(ARCH_CFLAGS) -flto -DNDEBUG LDFLAGS ?= -flto -CFLAGS += -std=gnu11 -D_GNU_SOURCE -Iinclude +CFLAGS += -std=gnu11 -D_GNU_SOURCE -Iinclude -Iprotocols/build CC_OBJ = $(CC) -c $(CFLAGS) $< -o $@ -MMD -MP -MF $(@:.o=.deps) LINK_EXE = $(CC) $^ $(LDFLAGS) -o $@ diff --git a/protocols/Makefile b/protocols/Makefile new file mode 100644 index 0000000..2f1cbfe --- /dev/null +++ b/protocols/Makefile @@ -0,0 +1,25 @@ +WAYLAND_SCANNER ?= wayland-scanner + +PROTOCOLS := \ + wlr-export-dmabuf-unstable-v1.xml \ + +SOURCES := $(PROTOCOLS:%.xml=build/%.c) +HEADERS := $(PROTOCOLS:%.xml=build/%.h) + +all: $(SOURCES) $(HEADERS) + +build: + mkdir -p build + +build/%.c: %.xml | build + $(WAYLAND_SCANNER) private-code $< $@ + +build/%.h: %.xml | build + $(WAYLAND_SCANNER) client-header $< $@ + +.PHONY: clean +clean: + rm -rf build + +.SUFFIXES: +.SECONDARY: diff --git a/protocols/wlr-export-dmabuf-unstable-v1.xml b/protocols/wlr-export-dmabuf-unstable-v1.xml new file mode 100644 index 0000000..751f7ef --- /dev/null +++ b/protocols/wlr-export-dmabuf-unstable-v1.xml @@ -0,0 +1,203 @@ + + + + Copyright © 2018 Rostislav Pehlivanov + + Permission is hereby granted, free of charge, to any person obtaining a + copy of this software and associated documentation files (the "Software"), + to deal in the Software without restriction, including without limitation + the rights to use, copy, modify, merge, publish, distribute, sublicense, + and/or sell copies of the Software, and to permit persons to whom the + Software is furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice (including the next + paragraph) shall be included in all copies or substantial portions of the + Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + DEALINGS IN THE SOFTWARE. + + + + An interface to capture surfaces in an efficient way by exporting DMA-BUFs. + + Warning! The protocol described in this file is experimental and + backward incompatible changes may be made. Backward compatible changes + may be added together with the corresponding interface version bump. + Backward incompatible changes are done by bumping the version number in + the protocol and interface names and resetting the interface version. + Once the protocol is to be declared stable, the 'z' prefix and the + version number in the protocol and interface names are removed and the + interface version number is reset. + + + + + This object is a manager with which to start capturing from sources. + + + + + Capture the next frame of a an entire output. + + + + + + + + + All objects created by the manager will still remain valid, until their + appropriate destroy request has been called. + + + + + + + This object represents a single DMA-BUF frame. + + If the capture is successful, the compositor will first send a "frame" + event, followed by one or several "object". When the frame is available + for readout, the "ready" event is sent. + + If the capture failed, the "cancel" event is sent. This can happen anytime + before the "ready" event. + + Once either a "ready" or a "cancel" event is received, the client should + destroy the frame. Once an "object" event is received, the client is + responsible for closing the associated file descriptor. + + All frames are read-only and may not be written into or altered. + + + + + Special flags that should be respected by the client. + + + + + + + Main event supplying the client with information about the frame. If the + capture didn't fail, this event is always emitted first before any other + events. + + This event is followed by a number of "object" as specified by the + "num_objects" argument. + + + + + + + + + + + + + + + + Event which serves to supply the client with the file descriptors + containing the data for each object. + + After receiving this event, the client must always close the file + descriptor as soon as they're done with it and even if the frame fails. + + + + + + + + + + + + This event is sent as soon as the frame is presented, indicating it is + available for reading. This event includes the time at which + presentation happened at. + + The timestamp is expressed as tv_sec_hi, tv_sec_lo, tv_nsec triples, + each component being an unsigned 32-bit value. Whole seconds are in + tv_sec which is a 64-bit value combined from tv_sec_hi and tv_sec_lo, + and the additional fractional part in tv_nsec as nanoseconds. Hence, + for valid timestamps tv_nsec must be in [0, 999999999]. The seconds part + may have an arbitrary offset at start. + + After receiving this event, the client should destroy this object. + + + + + + + + + Indicates reason for cancelling the frame. + + + + + + + + + If the capture failed or if the frame is no longer valid after the + "frame" event has been emitted, this event will be used to inform the + client to scrap the frame. + + If the failure is temporary, the client may capture again the same + source. If the failure is permanent, any further attempts to capture the + same source will fail again. + + After receiving this event, the client should destroy this object. + + + + + + + Unreferences the frame. This request must be called as soon as its no + longer used. + + It can be called at any time by the client. The client will still have + to close any FDs it has been given. + + + +