Line data Source code
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/layers/LayersMessageUtils.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 0 : SurfaceDescriptorX11()
32 0 : { }
33 :
34 : explicit SurfaceDescriptorX11(gfxXlibSurface* aSurf, bool aForwardGLX = false);
35 :
36 : SurfaceDescriptorX11(Drawable aDrawable, XID aFormatID,
37 : const gfx::IntSize& aSize);
38 :
39 : // Default copy ctor and operator= are OK
40 :
41 0 : 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 0 : return mId == aOther.mId;
48 : }
49 :
50 : already_AddRefed<gfxXlibSurface> OpenForeign() const;
51 :
52 : MOZ_INIT_OUTSIDE_CTOR Drawable mId;
53 : MOZ_INIT_OUTSIDE_CTOR XID mFormat; // either a PictFormat or VisualID
54 : MOZ_INIT_OUTSIDE_CTOR gfx::IntSize mSize;
55 : MOZ_INIT_OUTSIDE_CTOR Drawable mGLXPixmap; // used to prevent multiple bindings to the same GLXPixmap in-process
56 : };
57 :
58 : } // namespace layers
59 : } // namespace mozilla
60 :
61 : namespace IPC {
62 :
63 : template <>
64 : struct ParamTraits<mozilla::layers::SurfaceDescriptorX11> {
65 : typedef mozilla::layers::SurfaceDescriptorX11 paramType;
66 :
67 0 : static void Write(Message* aMsg, const paramType& aParam) {
68 0 : WriteParam(aMsg, aParam.mId);
69 0 : WriteParam(aMsg, aParam.mSize);
70 0 : WriteParam(aMsg, aParam.mFormat);
71 0 : WriteParam(aMsg, aParam.mGLXPixmap);
72 0 : }
73 :
74 0 : static bool Read(const Message* aMsg, PickleIterator* aIter, paramType* aResult) {
75 0 : return (ReadParam(aMsg, aIter, &aResult->mId) &&
76 0 : ReadParam(aMsg, aIter, &aResult->mSize) &&
77 0 : ReadParam(aMsg, aIter, &aResult->mFormat) &&
78 0 : ReadParam(aMsg, aIter, &aResult->mGLXPixmap)
79 0 : );
80 : }
81 : };
82 :
83 : } // namespace IPC
84 :
85 : #endif // mozilla_layers_ShadowLayerUtilsX11_h
|