From 0ebf5bdf043a27fd3dfb7f92e0cb63d88954c44d Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Fri, 19 Apr 2024 03:47:29 +0200 Subject: Adding upstream version 115.8.0esr. Signed-off-by: Daniel Baumann --- gfx/layers/wr/WebRenderMessageUtils.h | 217 ++++++++++++++++++++++++++++++++++ 1 file changed, 217 insertions(+) create mode 100644 gfx/layers/wr/WebRenderMessageUtils.h (limited to 'gfx/layers/wr/WebRenderMessageUtils.h') diff --git a/gfx/layers/wr/WebRenderMessageUtils.h b/gfx/layers/wr/WebRenderMessageUtils.h new file mode 100644 index 0000000000..40edf6676d --- /dev/null +++ b/gfx/layers/wr/WebRenderMessageUtils.h @@ -0,0 +1,217 @@ +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* vim: set ts=8 sts=2 et sw=2 tw=80: */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +#ifndef GFX_WEBRENDERMESSAGEUTILS_H +#define GFX_WEBRENDERMESSAGEUTILS_H + +#include "chrome/common/ipc_message_utils.h" + +#include "ipc/EnumSerializer.h" +#include "ipc/IPCMessageUtils.h" +#include "mozilla/webrender/webrender_ffi.h" +#include "mozilla/webrender/WebRenderTypes.h" +#include "mozilla/dom/MediaIPCUtils.h" + +namespace IPC { + +template <> +struct ParamTraits { + typedef mozilla::wr::ByteBuffer paramType; + + static void Write(MessageWriter* aWriter, const paramType& aParam) { + WriteParam(aWriter, aParam.mLength); + aWriter->WriteBytes(aParam.mData, aParam.mLength); + } + + static bool Read(MessageReader* aReader, paramType* aResult) { + size_t length; + return ReadParam(aReader, &length) && aResult->Allocate(length) && + aReader->ReadBytesInto(aResult->mData, length); + } +}; + +template <> +struct ParamTraits { + typedef mozilla::wr::ImageDescriptor paramType; + + static void Write(MessageWriter* aWriter, const paramType& aParam) { + WriteParam(aWriter, aParam.format); + WriteParam(aWriter, aParam.width); + WriteParam(aWriter, aParam.height); + WriteParam(aWriter, aParam.stride); + WriteParam(aWriter, aParam.opacity); + } + + static bool Read(MessageReader* aReader, paramType* aResult) { + return ReadParam(aReader, &aResult->format) && + ReadParam(aReader, &aResult->width) && + ReadParam(aReader, &aResult->height) && + ReadParam(aReader, &aResult->stride) && + ReadParam(aReader, &aResult->opacity); + } +}; + +template <> +struct ParamTraits + : public ContiguousEnumSerializer< + mozilla::wr::GeckoDisplayListType::Tag, + mozilla::wr::GeckoDisplayListType::Tag::None, + mozilla::wr::GeckoDisplayListType::Tag::Sentinel> {}; + +template <> +struct ParamTraits { + typedef mozilla::wr::GeckoDisplayListType paramType; + + static void Write(MessageWriter* aWriter, const paramType& aParam) { + WriteParam(aWriter, aParam.tag); + switch (aParam.tag) { + case mozilla::wr::GeckoDisplayListType::Tag::None: + break; + case mozilla::wr::GeckoDisplayListType::Tag::Partial: + WriteParam(aWriter, aParam.partial._0); + break; + case mozilla::wr::GeckoDisplayListType::Tag::Full: + WriteParam(aWriter, aParam.full._0); + break; + default: + MOZ_RELEASE_ASSERT(false, "bad enum variant"); + } + } + + static bool Read(MessageReader* aReader, paramType* aResult) { + if (!ReadParam(aReader, &aResult->tag)) { + return false; + } + switch (aResult->tag) { + case mozilla::wr::GeckoDisplayListType::Tag::None: + return true; + case mozilla::wr::GeckoDisplayListType::Tag::Partial: + return ReadParam(aReader, &aResult->partial._0); + case mozilla::wr::GeckoDisplayListType::Tag::Full: + return ReadParam(aReader, &aResult->full._0); + default: + MOZ_RELEASE_ASSERT(false, "bad enum variant"); + } + } +}; + +template <> +struct ParamTraits { + typedef mozilla::wr::BuiltDisplayListDescriptor paramType; + + static void Write(MessageWriter* aWriter, const paramType& aParam) { + WriteParam(aWriter, aParam.gecko_display_list_type); + WriteParam(aWriter, aParam.builder_start_time); + WriteParam(aWriter, aParam.builder_finish_time); + WriteParam(aWriter, aParam.send_start_time); + WriteParam(aWriter, aParam.total_clip_nodes); + WriteParam(aWriter, aParam.total_spatial_nodes); + WriteParam(aWriter, aParam.cache_size); + } + + static bool Read(MessageReader* aReader, paramType* aResult) { + return ReadParam(aReader, &aResult->gecko_display_list_type) && + ReadParam(aReader, &aResult->builder_start_time) && + ReadParam(aReader, &aResult->builder_finish_time) && + ReadParam(aReader, &aResult->send_start_time) && + ReadParam(aReader, &aResult->total_clip_nodes) && + ReadParam(aReader, &aResult->total_spatial_nodes) && + ReadParam(aReader, &aResult->cache_size); + } +}; + +template <> +struct ParamTraits + : public PlainOldDataSerializer {}; + +template <> +struct ParamTraits + : public PlainOldDataSerializer {}; + +template <> +struct ParamTraits + : public PlainOldDataSerializer {}; + +template <> +struct ParamTraits + : public PlainOldDataSerializer {}; + +template <> +struct ParamTraits + : public PlainOldDataSerializer {}; + +template <> +struct ParamTraits + : public PlainOldDataSerializer {}; + +template <> +struct ParamTraits + : public PlainOldDataSerializer { +}; + +template <> +struct ParamTraits + : public PlainOldDataSerializer {}; + +template <> +struct ParamTraits + : public PlainOldDataSerializer {}; + +template <> +struct ParamTraits + : public ContiguousEnumSerializer {}; + +template <> +struct ParamTraits + : public PlainOldDataSerializer {}; + +template <> +struct ParamTraits + : public PlainOldDataSerializer {}; + +template <> +struct ParamTraits + : public PlainOldDataSerializer {}; + +template <> +struct ParamTraits + : public ContiguousEnumSerializer {}; + +template <> +struct ParamTraits + : public ContiguousEnumSerializer {}; + +template <> +struct ParamTraits + : public ContiguousEnumSerializer {}; + +template <> +struct ParamTraits + : public PlainOldDataSerializer {}; + +template <> +struct ParamTraits + : public PlainOldDataSerializer {}; + +template <> +struct ParamTraits + : public PlainOldDataSerializer {}; + +template <> +struct ParamTraits + : public PlainOldDataSerializer {}; + +} // namespace IPC + +#endif // GFX_WEBRENDERMESSAGEUTILS_H -- cgit v1.2.3