gfx/layers/ipc/ShadowLayerUtilsX11.h

branch
TOR_BUG_9701
changeset 8
97036ab72558
equal deleted inserted replaced
-1:000000000000 0:65e9acae819f
1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*-
2 * vim: sw=2 ts=8 et :
3 */
4 /* This Source Code Form is subject to the terms of the Mozilla Public
5 * License, v. 2.0. If a copy of the MPL was not distributed with this
6 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
7
8 #ifndef mozilla_layers_ShadowLayerUtilsX11_h
9 #define mozilla_layers_ShadowLayerUtilsX11_h
10
11 #include "ipc/IPCMessageUtils.h"
12 #include "mozilla/GfxMessageUtils.h"
13 #include "nsCOMPtr.h" // for already_AddRefed
14
15 #define MOZ_HAVE_SURFACEDESCRIPTORX11
16 #define MOZ_HAVE_PLATFORM_SPECIFIC_LAYER_BUFFERS
17
18 typedef unsigned long XID;
19 typedef XID Drawable;
20
21 class gfxXlibSurface;
22
23 namespace IPC {
24 class Message;
25 }
26
27 namespace mozilla {
28 namespace layers {
29
30 struct SurfaceDescriptorX11 {
31 SurfaceDescriptorX11()
32 { }
33
34 SurfaceDescriptorX11(gfxXlibSurface* aSurf);
35
36 SurfaceDescriptorX11(Drawable aDrawable, XID aFormatID,
37 const gfx::IntSize& aSize);
38
39 // Default copy ctor and operator= are OK
40
41 bool operator==(const SurfaceDescriptorX11& aOther) const {
42 // Define == as two descriptors having the same XID for now,
43 // ignoring size and render format. If the two indeed refer to
44 // the same valid XID, then size/format are "actually" the same
45 // anyway, regardless of the values of the fields in
46 // SurfaceDescriptorX11.
47 return mId == aOther.mId;
48 }
49
50 already_AddRefed<gfxXlibSurface> OpenForeign() const;
51
52 Drawable mId;
53 XID mFormat; // either a PictFormat or VisualID
54 gfx::IntSize mSize;
55 };
56
57 } // namespace layers
58 } // namespace mozilla
59
60 namespace IPC {
61
62 template <>
63 struct ParamTraits<mozilla::layers::SurfaceDescriptorX11> {
64 typedef mozilla::layers::SurfaceDescriptorX11 paramType;
65
66 static void Write(Message* aMsg, const paramType& aParam) {
67 WriteParam(aMsg, aParam.mId);
68 WriteParam(aMsg, aParam.mSize);
69 WriteParam(aMsg, aParam.mFormat);
70 }
71
72 static bool Read(const Message* aMsg, void** aIter, paramType* aResult) {
73 return (ReadParam(aMsg, aIter, &aResult->mId) &&
74 ReadParam(aMsg, aIter, &aResult->mSize) &&
75 ReadParam(aMsg, aIter, &aResult->mFormat));
76 }
77 };
78
79 } // namespace IPC
80
81 #endif // mozilla_layers_ShadowLayerUtilsX11_h

mercurial