michael@0: /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- michael@0: * vim: sw=2 ts=8 et : michael@0: */ michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: #ifndef IPC_ShadowLayerUtils_h michael@0: #define IPC_ShadowLayerUtils_h michael@0: michael@0: #include "ipc/IPCMessageUtils.h" michael@0: #include "GLContextTypes.h" michael@0: #include "SurfaceTypes.h" michael@0: #include "mozilla/WidgetUtils.h" michael@0: michael@0: #if defined(MOZ_ENABLE_D3D10_LAYER) michael@0: # include "mozilla/layers/ShadowLayerUtilsD3D10.h" michael@0: #endif michael@0: michael@0: #if defined(XP_MACOSX) michael@0: #define MOZ_HAVE_PLATFORM_SPECIFIC_LAYER_BUFFERS michael@0: #endif michael@0: michael@0: #if defined(MOZ_X11) michael@0: # include "mozilla/layers/ShadowLayerUtilsX11.h" michael@0: #else michael@0: namespace mozilla { namespace layers { michael@0: struct SurfaceDescriptorX11 { michael@0: bool operator==(const SurfaceDescriptorX11&) const { return false; } michael@0: }; michael@0: } } michael@0: #endif michael@0: michael@0: #if defined(MOZ_WIDGET_GONK) michael@0: # include "mozilla/layers/ShadowLayerUtilsGralloc.h" michael@0: #else michael@0: namespace mozilla { namespace layers { michael@0: struct MagicGrallocBufferHandle { michael@0: bool operator==(const MagicGrallocBufferHandle&) const { return false; } michael@0: }; michael@0: } } michael@0: #endif michael@0: michael@0: namespace IPC { michael@0: michael@0: #if !defined(MOZ_HAVE_SURFACEDESCRIPTORX11) michael@0: template <> michael@0: struct ParamTraits { michael@0: typedef mozilla::layers::SurfaceDescriptorX11 paramType; michael@0: static void Write(Message*, const paramType&) {} michael@0: static bool Read(const Message*, void**, paramType*) { return false; } michael@0: }; michael@0: #endif // !defined(MOZ_HAVE_XSURFACEDESCRIPTORX11) michael@0: michael@0: template<> michael@0: struct ParamTraits michael@0: { michael@0: typedef mozilla::gl::SharedTextureShareType paramType; michael@0: michael@0: static void Write(Message* msg, const paramType& param) michael@0: { michael@0: static_assert(sizeof(paramType) <= sizeof(int32_t), michael@0: "TextureShareType assumes to be int32_t"); michael@0: WriteParam(msg, int32_t(param)); michael@0: } michael@0: michael@0: static bool Read(const Message* msg, void** iter, paramType* result) michael@0: { michael@0: int32_t type; michael@0: if (!ReadParam(msg, iter, &type)) michael@0: return false; michael@0: michael@0: *result = paramType(type); michael@0: return true; michael@0: } michael@0: }; michael@0: michael@0: #if !defined(MOZ_HAVE_SURFACEDESCRIPTORGRALLOC) michael@0: template <> michael@0: struct ParamTraits { michael@0: typedef mozilla::layers::MagicGrallocBufferHandle paramType; michael@0: static void Write(Message*, const paramType&) {} michael@0: static bool Read(const Message*, void**, paramType*) { return false; } michael@0: }; michael@0: #endif // !defined(MOZ_HAVE_XSURFACEDESCRIPTORGRALLOC) michael@0: michael@0: template <> michael@0: struct ParamTraits michael@0: : public ContiguousEnumSerializer< michael@0: mozilla::ScreenRotation, michael@0: mozilla::ROTATION_0, michael@0: mozilla::ROTATION_COUNT> michael@0: {}; michael@0: michael@0: } // namespace IPC michael@0: michael@0: #endif // IPC_ShadowLayerUtils_h