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 mozilla_layers_ShadowLayerUtilsX11_h michael@0: #define mozilla_layers_ShadowLayerUtilsX11_h michael@0: michael@0: #include "ipc/IPCMessageUtils.h" michael@0: #include "mozilla/GfxMessageUtils.h" michael@0: #include "nsCOMPtr.h" // for already_AddRefed michael@0: michael@0: #define MOZ_HAVE_SURFACEDESCRIPTORX11 michael@0: #define MOZ_HAVE_PLATFORM_SPECIFIC_LAYER_BUFFERS michael@0: michael@0: typedef unsigned long XID; michael@0: typedef XID Drawable; michael@0: michael@0: class gfxXlibSurface; michael@0: michael@0: namespace IPC { michael@0: class Message; michael@0: } michael@0: michael@0: namespace mozilla { michael@0: namespace layers { michael@0: michael@0: struct SurfaceDescriptorX11 { michael@0: SurfaceDescriptorX11() michael@0: { } michael@0: michael@0: SurfaceDescriptorX11(gfxXlibSurface* aSurf); michael@0: michael@0: SurfaceDescriptorX11(Drawable aDrawable, XID aFormatID, michael@0: const gfx::IntSize& aSize); michael@0: michael@0: // Default copy ctor and operator= are OK michael@0: michael@0: bool operator==(const SurfaceDescriptorX11& aOther) const { michael@0: // Define == as two descriptors having the same XID for now, michael@0: // ignoring size and render format. If the two indeed refer to michael@0: // the same valid XID, then size/format are "actually" the same michael@0: // anyway, regardless of the values of the fields in michael@0: // SurfaceDescriptorX11. michael@0: return mId == aOther.mId; michael@0: } michael@0: michael@0: already_AddRefed OpenForeign() const; michael@0: michael@0: Drawable mId; michael@0: XID mFormat; // either a PictFormat or VisualID michael@0: gfx::IntSize mSize; michael@0: }; michael@0: michael@0: } // namespace layers michael@0: } // namespace mozilla michael@0: michael@0: namespace IPC { michael@0: michael@0: template <> michael@0: struct ParamTraits { michael@0: typedef mozilla::layers::SurfaceDescriptorX11 paramType; michael@0: michael@0: static void Write(Message* aMsg, const paramType& aParam) { michael@0: WriteParam(aMsg, aParam.mId); michael@0: WriteParam(aMsg, aParam.mSize); michael@0: WriteParam(aMsg, aParam.mFormat); michael@0: } michael@0: michael@0: static bool Read(const Message* aMsg, void** aIter, paramType* aResult) { michael@0: return (ReadParam(aMsg, aIter, &aResult->mId) && michael@0: ReadParam(aMsg, aIter, &aResult->mSize) && michael@0: ReadParam(aMsg, aIter, &aResult->mFormat)); michael@0: } michael@0: }; michael@0: michael@0: } // namespace IPC michael@0: michael@0: #endif // mozilla_layers_ShadowLayerUtilsX11_h