From 5bfbf126a7900ba7037ed04b78c937aa7ceb3c90 Mon Sep 17 00:00:00 2001 From: Jeff Muizelaar Date: Fri, 26 Jul 2013 15:28:31 -0400 Subject: [PATCH] Bug 898525. Separate out Gfx helpers into GfxMessageUtils.h. r=bent This helps us include less. --HG-- extra : rebase_source : bb9ca934a9dade9ef21cecfee7ae8e860f9c60c1 --- content/events/src/nsDOMNotifyPaintEvent.cpp | 1 + dom/bluetooth/ipc/BluetoothParent.h | 1 + dom/ipc/PContent.ipdl | 2 + dom/ipc/PDocumentRenderer.ipdl | 2 + gfx/ipc/GfxMessageUtils.h | 663 +++++++++++++++++++ gfx/ipc/moz.build | 4 + gfx/layers/Layers.h | 1 + gfx/layers/YCbCrImageDataSerializer.cpp | 1 + gfx/layers/YCbCrImageDataSerializer.h | 3 +- gfx/layers/d3d11/TextureD3D11.h | 1 + gfx/layers/d3d9/TextureD3D9.h | 1 + gfx/layers/ipc/LayerTransaction.ipdlh | 1 + gfx/layers/ipc/PCompositor.ipdl | 1 + gfx/layers/ipc/PImageBridge.ipdl | 1 + gfx/layers/ipc/PLayerTransaction.ipdl | 1 + gfx/layers/ipc/ShadowLayerUtilsX11.h | 1 + ipc/glue/AsyncChannel.h | 1 + ipc/glue/IPCMessageUtils.h | 634 ------------------ widget/nsGUIEventIPC.h | 1 + 19 files changed, 686 insertions(+), 635 deletions(-) create mode 100644 gfx/ipc/GfxMessageUtils.h diff --git a/content/events/src/nsDOMNotifyPaintEvent.cpp b/content/events/src/nsDOMNotifyPaintEvent.cpp index 36c7e0373a23..64d74ae72dc7 100644 --- a/content/events/src/nsDOMNotifyPaintEvent.cpp +++ b/content/events/src/nsDOMNotifyPaintEvent.cpp @@ -5,6 +5,7 @@ #include "base/basictypes.h" #include "ipc/IPCMessageUtils.h" +#include "mozilla/GfxMessageUtils.h" #include "nsDOMNotifyPaintEvent.h" #include "nsContentUtils.h" #include "nsClientRect.h" diff --git a/dom/bluetooth/ipc/BluetoothParent.h b/dom/bluetooth/ipc/BluetoothParent.h index cbf56d2f1ce2..6601303a9bd2 100644 --- a/dom/bluetooth/ipc/BluetoothParent.h +++ b/dom/bluetooth/ipc/BluetoothParent.h @@ -16,6 +16,7 @@ #include "mozilla/Observer.h" #include "nsAutoPtr.h" #include "nsTArray.h" +#include "nsThreadUtils.h" template class nsRevocableEventPtr; diff --git a/dom/ipc/PContent.ipdl b/dom/ipc/PContent.ipdl index 1e3ba3e1ce3b..d856baa55d1c 100644 --- a/dom/ipc/PContent.ipdl +++ b/dom/ipc/PContent.ipdl @@ -30,10 +30,12 @@ include URIParams; include "mozilla/chrome/RegistryMessageUtils.h"; include "mozilla/dom/PermissionMessageUtils.h"; include "mozilla/dom/TabMessageUtils.h"; +include "mozilla/dom/Element.h"; include "mozilla/HalTypes.h"; include "mozilla/layout/RenderFrameUtils.h"; include "mozilla/net/NeckoMessageUtils.h"; include "nsGeoPositionIPCSerialiser.h"; +include "gfxPoint.h"; using GeoPosition; using PrefTuple; diff --git a/dom/ipc/PDocumentRenderer.ipdl b/dom/ipc/PDocumentRenderer.ipdl index 7e20add80502..4851cf967f4b 100644 --- a/dom/ipc/PDocumentRenderer.ipdl +++ b/dom/ipc/PDocumentRenderer.ipdl @@ -5,6 +5,8 @@ include protocol PBrowser; +include "mozilla/GfxMessageUtils.h"; + using nsIntSize; namespace mozilla { diff --git a/gfx/ipc/GfxMessageUtils.h b/gfx/ipc/GfxMessageUtils.h new file mode 100644 index 000000000000..b64b129fb874 --- /dev/null +++ b/gfx/ipc/GfxMessageUtils.h @@ -0,0 +1,663 @@ +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* vim: set sw=2 ts=8 et 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 __GFXMESSAGEUTILS_H__ +#define __GFXMESSAGEUTILS_H__ + +#include "base/process_util.h" +#include "chrome/common/ipc_message_utils.h" +//#include "ipc/IPCMessageUtils.h" + +#include "mozilla/Util.h" +#include "mozilla/gfx/2D.h" +#include + +#include "gfx3DMatrix.h" +#include "gfxColor.h" +#include "gfxMatrix.h" +#include "gfxPattern.h" +#include "gfxPoint.h" +#include "gfxRect.h" +#include "nsRect.h" +#include "nsRegion.h" +#include "gfxASurface.h" +#include "mozilla/layers/LayersTypes.h" +#include "mozilla/layers/CompositorTypes.h" +#include "FrameMetrics.h" +#include "ImageLayers.h" + +#ifdef _MSC_VER +#pragma warning( disable : 4800 ) +#endif + +namespace mozilla { + +typedef gfxASurface::gfxContentType gfxContentType; +typedef gfxASurface::gfxImageFormat PixelFormat; +typedef gfxASurface::gfxSurfaceType gfxSurfaceType; +typedef gfxPattern::GraphicsFilter GraphicsFilterType; +typedef layers::LayersBackend LayersBackend; +typedef layers::ImageLayer::ScaleMode ScaleMode; + +} // namespace mozilla + +namespace IPC { + +template<> +struct ParamTraits +{ + typedef gfxMatrix paramType; + + static void Write(Message* aMsg, const paramType& aParam) + { + WriteParam(aMsg, aParam.xx); + WriteParam(aMsg, aParam.xy); + WriteParam(aMsg, aParam.yx); + WriteParam(aMsg, aParam.yy); + WriteParam(aMsg, aParam.x0); + WriteParam(aMsg, aParam.y0); + } + + static bool Read(const Message* aMsg, void** aIter, paramType* aResult) + { + if (ReadParam(aMsg, aIter, &aResult->xx) && + ReadParam(aMsg, aIter, &aResult->xy) && + ReadParam(aMsg, aIter, &aResult->yx) && + ReadParam(aMsg, aIter, &aResult->yy) && + ReadParam(aMsg, aIter, &aResult->x0) && + ReadParam(aMsg, aIter, &aResult->y0)) + return true; + + return false; + } + + static void Log(const paramType& aParam, std::wstring* aLog) + { + aLog->append(StringPrintf(L"[[%g %g] [%g %g] [%g %g]]", aParam.xx, aParam.xy, aParam.yx, aParam.yy, + aParam.x0, aParam.y0)); + } +}; + +template<> +struct ParamTraits +{ + typedef gfxPoint paramType; + + static void Write(Message* aMsg, const paramType& aParam) + { + WriteParam(aMsg, aParam.x); + WriteParam(aMsg, aParam.y); + } + + static bool Read(const Message* aMsg, void** aIter, paramType* aResult) + { + return (ReadParam(aMsg, aIter, &aResult->x) && + ReadParam(aMsg, aIter, &aResult->y)); + } +}; + +template<> +struct ParamTraits +{ + typedef gfxPoint3D paramType; + + static void Write(Message* aMsg, const paramType& aParam) + { + WriteParam(aMsg, aParam.x); + WriteParam(aMsg, aParam.y); + WriteParam(aMsg, aParam.z); + } + + static bool Read(const Message* aMsg, void** aIter, paramType* aResult) + { + return (ReadParam(aMsg, aIter, &aResult->x) && + ReadParam(aMsg, aIter, &aResult->y) && + ReadParam(aMsg, aIter, &aResult->z)); + } +}; + +template<> +struct ParamTraits +{ + typedef gfxSize paramType; + + static void Write(Message* aMsg, const paramType& aParam) + { + WriteParam(aMsg, aParam.width); + WriteParam(aMsg, aParam.height); + } + + static bool Read(const Message* aMsg, void** aIter, paramType* aResult) + { + if (ReadParam(aMsg, aIter, &aResult->width) && + ReadParam(aMsg, aIter, &aResult->height)) + return true; + + return false; + } +}; + +template<> +struct ParamTraits +{ + typedef gfxRect paramType; + + static void Write(Message* aMsg, const paramType& aParam) + { + WriteParam(aMsg, aParam.x); + WriteParam(aMsg, aParam.y); + WriteParam(aMsg, aParam.width); + WriteParam(aMsg, aParam.height); + } + + static bool Read(const Message* aMsg, void** aIter, paramType* aResult) + { + return ReadParam(aMsg, aIter, &aResult->x) && + ReadParam(aMsg, aIter, &aResult->y) && + ReadParam(aMsg, aIter, &aResult->width) && + ReadParam(aMsg, aIter, &aResult->height); + } +}; + +template<> +struct ParamTraits +{ + typedef gfx3DMatrix paramType; + + static void Write(Message* msg, const paramType& param) + { +#define Wr(_f) WriteParam(msg, param. _f) + Wr(_11); Wr(_12); Wr(_13); Wr(_14); + Wr(_21); Wr(_22); Wr(_23); Wr(_24); + Wr(_31); Wr(_32); Wr(_33); Wr(_34); + Wr(_41); Wr(_42); Wr(_43); Wr(_44); +#undef Wr + } + + static bool Read(const Message* msg, void** iter, paramType* result) + { +#define Rd(_f) ReadParam(msg, iter, &result-> _f) + return (Rd(_11) && Rd(_12) && Rd(_13) && Rd(_14) && + Rd(_21) && Rd(_22) && Rd(_23) && Rd(_24) && + Rd(_31) && Rd(_32) && Rd(_33) && Rd(_34) && + Rd(_41) && Rd(_42) && Rd(_43) && Rd(_44)); +#undef Rd + } +}; + +template <> +struct ParamTraits + : public EnumSerializer +{}; + +template <> +struct ParamTraits + : public EnumSerializer +{}; + +template <> +struct ParamTraits + : public EnumSerializer +{}; + +template <> +struct ParamTraits + : public EnumSerializer +{}; + +template <> +struct ParamTraits + : public EnumSerializer +{}; + +template <> +struct ParamTraits + : public EnumSerializer +{}; + + +template<> +struct ParamTraits +{ + typedef gfxRGBA paramType; + + static void Write(Message* msg, const paramType& param) + { + WriteParam(msg, param.r); + WriteParam(msg, param.g); + WriteParam(msg, param.b); + WriteParam(msg, param.a); + } + + static bool Read(const Message* msg, void** iter, paramType* result) + { + return (ReadParam(msg, iter, &result->r) && + ReadParam(msg, iter, &result->g) && + ReadParam(msg, iter, &result->b) && + ReadParam(msg, iter, &result->a)); + } +}; + +template<> +struct ParamTraits +{ + typedef nsPoint paramType; + + static void Write(Message* msg, const paramType& param) + { + WriteParam(msg, param.x); + WriteParam(msg, param.y); + } + + static bool Read(const Message* msg, void** iter, paramType* result) + { + return (ReadParam(msg, iter, &result->x) && + ReadParam(msg, iter, &result->y)); + } +}; + +template<> +struct ParamTraits +{ + typedef nsIntPoint paramType; + + static void Write(Message* msg, const paramType& param) + { + WriteParam(msg, param.x); + WriteParam(msg, param.y); + } + + static bool Read(const Message* msg, void** iter, paramType* result) + { + return (ReadParam(msg, iter, &result->x) && + ReadParam(msg, iter, &result->y)); + } +}; + +template<> +struct ParamTraits +{ + typedef mozilla::gfx::IntSize paramType; + + static void Write(Message* msg, const paramType& param) + { + WriteParam(msg, param.width); + WriteParam(msg, param.height); + } + + static bool Read(const Message* msg, void** iter, paramType* result) + { + return (ReadParam(msg, iter, &result->width) && + ReadParam(msg, iter, &result->height)); + } +}; + +template<> +struct ParamTraits +{ + typedef nsIntRect paramType; + + static void Write(Message* msg, const paramType& param) + { + WriteParam(msg, param.x); + WriteParam(msg, param.y); + WriteParam(msg, param.width); + WriteParam(msg, param.height); + } + + static bool Read(const Message* msg, void** iter, paramType* result) + { + return (ReadParam(msg, iter, &result->x) && + ReadParam(msg, iter, &result->y) && + ReadParam(msg, iter, &result->width) && + ReadParam(msg, iter, &result->height)); + } +}; + +template +struct RegionParamTraits +{ + typedef Region paramType; + + static void Write(Message* msg, const paramType& param) + { + Iter it(param); + while (const Rect* r = it.Next()) + WriteParam(msg, *r); + // empty rects are sentinel values because nsRegions will never + // contain them + WriteParam(msg, Rect()); + } + + static bool Read(const Message* msg, void** iter, paramType* result) + { + Rect rect; + while (ReadParam(msg, iter, &rect)) { + if (rect.IsEmpty()) + return true; + result->Or(*result, rect); + } + return false; + } +}; + +template<> +struct ParamTraits + : RegionParamTraits +{}; + +template<> +struct ParamTraits +{ + typedef nsIntSize paramType; + + static void Write(Message* msg, const paramType& param) + { + WriteParam(msg, param.width); + WriteParam(msg, param.height); + } + + static bool Read(const Message* msg, void** iter, paramType* result) + { + return (ReadParam(msg, iter, &result->width) && + ReadParam(msg, iter, &result->height)); + } +}; + +template +struct ParamTraits< mozilla::gfx::ScaleFactor > +{ + typedef mozilla::gfx::ScaleFactor paramType; + + static void Write(Message* msg, const paramType& param) + { + WriteParam(msg, param.scale); + } + + static bool Read(const Message* msg, void** iter, paramType* result) + { + return (ReadParam(msg, iter, &result->scale)); + } +}; + +template +struct ParamTraits< mozilla::gfx::PointTyped > +{ + typedef mozilla::gfx::PointTyped paramType; + + static void Write(Message* msg, const paramType& param) + { + WriteParam(msg, param.x); + WriteParam(msg, param.y); + } + + static bool Read(const Message* msg, void** iter, paramType* result) + { + return (ReadParam(msg, iter, &result->x) && + ReadParam(msg, iter, &result->y)); + } +}; + +template +struct ParamTraits< mozilla::gfx::IntPointTyped > +{ + typedef mozilla::gfx::IntPointTyped paramType; + + static void Write(Message* msg, const paramType& param) + { + WriteParam(msg, param.x); + WriteParam(msg, param.y); + } + + static bool Read(const Message* msg, void** iter, paramType* result) + { + return (ReadParam(msg, iter, &result->x) && + ReadParam(msg, iter, &result->y)); + } +}; + +template<> +struct ParamTraits +{ + typedef mozilla::gfx::Size paramType; + + static void Write(Message* msg, const paramType& param) + { + WriteParam(msg, param.width); + WriteParam(msg, param.height); + } + + static bool Read(const Message* msg, void** iter, paramType* result) + { + return (ReadParam(msg, iter, &result->width) && + ReadParam(msg, iter, &result->height)); + } +}; + +template +struct ParamTraits< mozilla::gfx::RectTyped > +{ + typedef mozilla::gfx::RectTyped paramType; + + static void Write(Message* msg, const paramType& param) + { + WriteParam(msg, param.x); + WriteParam(msg, param.y); + WriteParam(msg, param.width); + WriteParam(msg, param.height); + } + + static bool Read(const Message* msg, void** iter, paramType* result) + { + return (ReadParam(msg, iter, &result->x) && + ReadParam(msg, iter, &result->y) && + ReadParam(msg, iter, &result->width) && + ReadParam(msg, iter, &result->height)); + } +}; + +template +struct ParamTraits< mozilla::gfx::IntRectTyped > +{ + typedef mozilla::gfx::IntRectTyped paramType; + + static void Write(Message* msg, const paramType& param) + { + WriteParam(msg, param.x); + WriteParam(msg, param.y); + WriteParam(msg, param.width); + WriteParam(msg, param.height); + } + + static bool Read(const Message* msg, void** iter, paramType* result) + { + return (ReadParam(msg, iter, &result->x) && + ReadParam(msg, iter, &result->y) && + ReadParam(msg, iter, &result->width) && + ReadParam(msg, iter, &result->height)); + } +}; + +template<> +struct ParamTraits +{ + typedef mozilla::gfx::Margin paramType; + + static void Write(Message* msg, const paramType& param) + { + WriteParam(msg, param.top); + WriteParam(msg, param.right); + WriteParam(msg, param.bottom); + WriteParam(msg, param.left); + } + + static bool Read(const Message* msg, void** iter, paramType* result) + { + return (ReadParam(msg, iter, &result->top) && + ReadParam(msg, iter, &result->right) && + ReadParam(msg, iter, &result->bottom) && + ReadParam(msg, iter, &result->left)); + } +}; + +template +struct ParamTraits< mozilla::gfx::MarginTyped > +{ + typedef mozilla::gfx::MarginTyped paramType; + + static void Write(Message* msg, const paramType& param) + { + WriteParam(msg, param.top); + WriteParam(msg, param.right); + WriteParam(msg, param.bottom); + WriteParam(msg, param.left); + } + + static bool Read(const Message* msg, void** iter, paramType* result) + { + return (ReadParam(msg, iter, &result->top) && + ReadParam(msg, iter, &result->right) && + ReadParam(msg, iter, &result->bottom) && + ReadParam(msg, iter, &result->left)); + } +}; + +template<> +struct ParamTraits +{ + typedef nsRect paramType; + + static void Write(Message* msg, const paramType& param) + { + WriteParam(msg, param.x); + WriteParam(msg, param.y); + WriteParam(msg, param.width); + WriteParam(msg, param.height); + } + + static bool Read(const Message* msg, void** iter, paramType* result) + { + return (ReadParam(msg, iter, &result->x) && + ReadParam(msg, iter, &result->y) && + ReadParam(msg, iter, &result->width) && + ReadParam(msg, iter, &result->height)); + } +}; + +template<> +struct ParamTraits + : RegionParamTraits +{}; + +template <> +struct ParamTraits +{ + typedef mozilla::layers::FrameMetrics paramType; + + static void Write(Message* aMsg, const paramType& aParam) + { + WriteParam(aMsg, aParam.mScrollableRect); + WriteParam(aMsg, aParam.mViewport); + WriteParam(aMsg, aParam.mScrollOffset); + WriteParam(aMsg, aParam.mDisplayPort); + WriteParam(aMsg, aParam.mCriticalDisplayPort); + WriteParam(aMsg, aParam.mCompositionBounds); + WriteParam(aMsg, aParam.mScrollId); + WriteParam(aMsg, aParam.mResolution); + WriteParam(aMsg, aParam.mZoom); + WriteParam(aMsg, aParam.mDevPixelsPerCSSPixel); + WriteParam(aMsg, aParam.mMayHaveTouchListeners); + WriteParam(aMsg, aParam.mPresShellId); + } + + static bool Read(const Message* aMsg, void** aIter, paramType* aResult) + { + return (ReadParam(aMsg, aIter, &aResult->mScrollableRect) && + ReadParam(aMsg, aIter, &aResult->mViewport) && + ReadParam(aMsg, aIter, &aResult->mScrollOffset) && + ReadParam(aMsg, aIter, &aResult->mDisplayPort) && + ReadParam(aMsg, aIter, &aResult->mCriticalDisplayPort) && + ReadParam(aMsg, aIter, &aResult->mCompositionBounds) && + ReadParam(aMsg, aIter, &aResult->mScrollId) && + ReadParam(aMsg, aIter, &aResult->mResolution) && + ReadParam(aMsg, aIter, &aResult->mZoom) && + ReadParam(aMsg, aIter, &aResult->mDevPixelsPerCSSPixel) && + ReadParam(aMsg, aIter, &aResult->mMayHaveTouchListeners) && + ReadParam(aMsg, aIter, &aResult->mPresShellId)); + } +}; + +template<> +struct ParamTraits +{ + typedef mozilla::layers::TextureFactoryIdentifier paramType; + + static void Write(Message* aMsg, const paramType& aParam) + { + WriteParam(aMsg, aParam.mParentBackend); + WriteParam(aMsg, aParam.mMaxTextureSize); + WriteParam(aMsg, aParam.mSupportsTextureBlitting); + WriteParam(aMsg, aParam.mSupportsPartialUploads); + } + + static bool Read(const Message* aMsg, void** aIter, paramType* aResult) + { + return ReadParam(aMsg, aIter, &aResult->mParentBackend) && + ReadParam(aMsg, aIter, &aResult->mMaxTextureSize) && + ReadParam(aMsg, aIter, &aResult->mSupportsTextureBlitting) && + ReadParam(aMsg, aIter, &aResult->mSupportsPartialUploads); + } +}; + +template<> +struct ParamTraits +{ + typedef mozilla::layers::TextureInfo paramType; + + static void Write(Message* aMsg, const paramType& aParam) + { + WriteParam(aMsg, aParam.mCompositableType); + WriteParam(aMsg, aParam.mDeprecatedTextureHostFlags); + WriteParam(aMsg, aParam.mTextureFlags); + } + + static bool Read(const Message* aMsg, void** aIter, paramType* aResult) + { + return ReadParam(aMsg, aIter, &aResult->mCompositableType) && + ReadParam(aMsg, aIter, &aResult->mDeprecatedTextureHostFlags) && + ReadParam(aMsg, aIter, &aResult->mTextureFlags); + } +}; + +template <> +struct ParamTraits + : public EnumSerializer +{}; + +template <> +struct ParamTraits + : public EnumSerializer +{}; + +} /* namespace IPC */ + +#endif /* __GFXMESSAGEUTILS_H__ */ diff --git a/gfx/ipc/moz.build b/gfx/ipc/moz.build index 2d5ed2ac4486..999b459bc1de 100644 --- a/gfx/ipc/moz.build +++ b/gfx/ipc/moz.build @@ -6,6 +6,10 @@ MODULE = 'gfxipc' +EXPORTS.mozilla += [ + 'GfxMessageUtils.h' +] + EXPORTS.mozilla.gfx += [ 'SharedDIB.h', ] diff --git a/gfx/layers/Layers.h b/gfx/layers/Layers.h index 58f9d9266b82..64b7f1423442 100644 --- a/gfx/layers/Layers.h +++ b/gfx/layers/Layers.h @@ -25,6 +25,7 @@ #include "FrameMetrics.h" #include "mozilla/gfx/2D.h" #include "mozilla/TimeStamp.h" +//#include "mozilla/CanonicalRegion.h" class gfxContext; class nsPaintEvent; diff --git a/gfx/layers/YCbCrImageDataSerializer.cpp b/gfx/layers/YCbCrImageDataSerializer.cpp index a97956da09e5..21cc56403290 100644 --- a/gfx/layers/YCbCrImageDataSerializer.cpp +++ b/gfx/layers/YCbCrImageDataSerializer.cpp @@ -4,6 +4,7 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ #include "mozilla/layers/YCbCrImageDataSerializer.h" +#include "ImageTypes.h" #include "yuv_convert.h" #include "mozilla/gfx/2D.h" #include "gfx2DGlue.h" diff --git a/gfx/layers/YCbCrImageDataSerializer.h b/gfx/layers/YCbCrImageDataSerializer.h index cb48a9dda03e..ae32676c1e47 100644 --- a/gfx/layers/YCbCrImageDataSerializer.h +++ b/gfx/layers/YCbCrImageDataSerializer.h @@ -7,7 +7,8 @@ #define MOZILLA_LAYERS_BLOBYCBCRSURFACE_H #include "mozilla/DebugOnly.h" - +#include "mozilla/RefPtr.h" +#include "ImageTypes.h" #include "base/basictypes.h" #include "Shmem.h" #include "gfxPoint.h" diff --git a/gfx/layers/d3d11/TextureD3D11.h b/gfx/layers/d3d11/TextureD3D11.h index f99bfb14f422..6667e78c6d99 100644 --- a/gfx/layers/d3d11/TextureD3D11.h +++ b/gfx/layers/d3d11/TextureD3D11.h @@ -10,6 +10,7 @@ #include "mozilla/layers/TextureClient.h" #include "mozilla/layers/TextureHost.h" #include "gfxWindowsPlatform.h" +#include "mozilla/GfxMessageUtils.h" #include #include diff --git a/gfx/layers/d3d9/TextureD3D9.h b/gfx/layers/d3d9/TextureD3D9.h index 0c66d867c1c3..718bad3fbb96 100644 --- a/gfx/layers/d3d9/TextureD3D9.h +++ b/gfx/layers/d3d9/TextureD3D9.h @@ -9,6 +9,7 @@ #include "mozilla/layers/Compositor.h" #include "mozilla/layers/TextureClient.h" #include "mozilla/layers/TextureHost.h" +#include "mozilla/GfxMessageUtils.h" #include "gfxWindowsPlatform.h" #include "d3d9.h" #include diff --git a/gfx/layers/ipc/LayerTransaction.ipdlh b/gfx/layers/ipc/LayerTransaction.ipdlh index c7ebf3193733..a007abc80fab 100644 --- a/gfx/layers/ipc/LayerTransaction.ipdlh +++ b/gfx/layers/ipc/LayerTransaction.ipdlh @@ -17,6 +17,7 @@ include "mozilla/TimeStamp.h"; include "mozilla/dom/ScreenOrientation.h"; include "nsCSSProperty.h"; include "gfxipc/ShadowLayerUtils.h"; +include "mozilla/GfxMessageUtils.h"; include "ImageLayers.h"; include "mozilla/layers/CompositorTypes.h"; diff --git a/gfx/layers/ipc/PCompositor.ipdl b/gfx/layers/ipc/PCompositor.ipdl index e14762e55ef1..925e6f0d15cc 100644 --- a/gfx/layers/ipc/PCompositor.ipdl +++ b/gfx/layers/ipc/PCompositor.ipdl @@ -9,6 +9,7 @@ include LayersSurfaces; include protocol PGrallocBuffer; include protocol PLayerTransaction; include "mozilla/layers/CompositorTypes.h"; +include "mozilla/GfxMessageUtils.h"; using mozilla::null_t; using mozilla::layers::TextureFactoryIdentifier; diff --git a/gfx/layers/ipc/PImageBridge.ipdl b/gfx/layers/ipc/PImageBridge.ipdl index e1bf4b090daa..daa7c1db1e88 100644 --- a/gfx/layers/ipc/PImageBridge.ipdl +++ b/gfx/layers/ipc/PImageBridge.ipdl @@ -9,6 +9,7 @@ include protocol PGrallocBuffer; include protocol PCompositable; include "mozilla/layers/CompositorTypes.h"; +include "mozilla/GfxMessageUtils.h"; using ImageHandle; using mozilla::layers::TextureInfo; diff --git a/gfx/layers/ipc/PLayerTransaction.ipdl b/gfx/layers/ipc/PLayerTransaction.ipdl index 38ef5fadd82b..e663593b7b92 100644 --- a/gfx/layers/ipc/PLayerTransaction.ipdl +++ b/gfx/layers/ipc/PLayerTransaction.ipdl @@ -18,6 +18,7 @@ include "mozilla/TimeStamp.h"; include "mozilla/dom/ScreenOrientation.h"; include "nsCSSProperty.h"; include "gfxipc/ShadowLayerUtils.h"; +include "mozilla/GfxMessageUtils.h"; using mozilla::layers::TextureInfo; diff --git a/gfx/layers/ipc/ShadowLayerUtilsX11.h b/gfx/layers/ipc/ShadowLayerUtilsX11.h index 9773967cb983..dbf8ad975d1c 100644 --- a/gfx/layers/ipc/ShadowLayerUtilsX11.h +++ b/gfx/layers/ipc/ShadowLayerUtilsX11.h @@ -12,6 +12,7 @@ #include #include "ipc/IPCMessageUtils.h" +#include "mozilla/GfxMessageUtils.h" #define MOZ_HAVE_SURFACEDESCRIPTORX11 #define MOZ_HAVE_PLATFORM_SPECIFIC_LAYER_BUFFERS diff --git a/ipc/glue/AsyncChannel.h b/ipc/glue/AsyncChannel.h index f3c00004ef70..07b923b0c456 100644 --- a/ipc/glue/AsyncChannel.h +++ b/ipc/glue/AsyncChannel.h @@ -14,6 +14,7 @@ #include "mozilla/WeakPtr.h" #include "mozilla/Monitor.h" #include "mozilla/ipc/Transport.h" +#include "nsAutoPtr.h" //----------------------------------------------------------------------------- diff --git a/ipc/glue/IPCMessageUtils.h b/ipc/glue/IPCMessageUtils.h index 6cd172c65413..bbc1fb661160 100644 --- a/ipc/glue/IPCMessageUtils.h +++ b/ipc/glue/IPCMessageUtils.h @@ -15,8 +15,6 @@ #include "mozilla/TimeStamp_windows.h" #endif #include "mozilla/Util.h" -#include "mozilla/gfx/2D.h" -#include "mozilla/gfx/Point.h" #include @@ -24,21 +22,8 @@ #include "nsMemory.h" #include "nsStringGlue.h" #include "nsTArray.h" -#include "gfx3DMatrix.h" -#include "gfxColor.h" -#include "gfxMatrix.h" -#include "gfxPattern.h" -#include "gfxPoint.h" -#include "gfxRect.h" -#include "nsRect.h" -#include "nsRegion.h" -#include "gfxASurface.h" #include "jsapi.h" -#include "mozilla/layers/LayersTypes.h" -#include "mozilla/layers/CompositorTypes.h" -#include "FrameMetrics.h" #include "nsCSSProperty.h" -#include "ImageLayers.h" #ifdef _MSC_VER #pragma warning( disable : 4800 ) @@ -55,13 +40,6 @@ namespace base { struct FileDescriptor { }; } namespace mozilla { -typedef gfxASurface::gfxContentType gfxContentType; -typedef gfxASurface::gfxImageFormat PixelFormat; -typedef gfxASurface::gfxSurfaceType gfxSurfaceType; -typedef gfxPattern::GraphicsFilter GraphicsFilterType; -typedef layers::LayersBackend LayersBackend; -typedef layers::ImageLayer::ScaleMode ScaleMode; - // This is a cross-platform approximation to HANDLE, which we expect // to be typedef'd to void* or thereabouts. typedef uintptr_t WindowsHandle; @@ -447,190 +425,6 @@ struct ParamTraits } }; -template<> -struct ParamTraits -{ - typedef gfxMatrix paramType; - - static void Write(Message* aMsg, const paramType& aParam) - { - WriteParam(aMsg, aParam.xx); - WriteParam(aMsg, aParam.xy); - WriteParam(aMsg, aParam.yx); - WriteParam(aMsg, aParam.yy); - WriteParam(aMsg, aParam.x0); - WriteParam(aMsg, aParam.y0); - } - - static bool Read(const Message* aMsg, void** aIter, paramType* aResult) - { - if (ReadParam(aMsg, aIter, &aResult->xx) && - ReadParam(aMsg, aIter, &aResult->xy) && - ReadParam(aMsg, aIter, &aResult->yx) && - ReadParam(aMsg, aIter, &aResult->yy) && - ReadParam(aMsg, aIter, &aResult->x0) && - ReadParam(aMsg, aIter, &aResult->y0)) - return true; - - return false; - } - - static void Log(const paramType& aParam, std::wstring* aLog) - { - aLog->append(StringPrintf(L"[[%g %g] [%g %g] [%g %g]]", aParam.xx, aParam.xy, aParam.yx, aParam.yy, - aParam.x0, aParam.y0)); - } -}; - -template<> -struct ParamTraits -{ - typedef gfxPoint paramType; - - static void Write(Message* aMsg, const paramType& aParam) - { - WriteParam(aMsg, aParam.x); - WriteParam(aMsg, aParam.y); - } - - static bool Read(const Message* aMsg, void** aIter, paramType* aResult) - { - return (ReadParam(aMsg, aIter, &aResult->x) && - ReadParam(aMsg, aIter, &aResult->y)); - } -}; - -template<> -struct ParamTraits -{ - typedef gfxPoint3D paramType; - - static void Write(Message* aMsg, const paramType& aParam) - { - WriteParam(aMsg, aParam.x); - WriteParam(aMsg, aParam.y); - WriteParam(aMsg, aParam.z); - } - - static bool Read(const Message* aMsg, void** aIter, paramType* aResult) - { - return (ReadParam(aMsg, aIter, &aResult->x) && - ReadParam(aMsg, aIter, &aResult->y) && - ReadParam(aMsg, aIter, &aResult->z)); - } -}; - -template<> -struct ParamTraits -{ - typedef gfxSize paramType; - - static void Write(Message* aMsg, const paramType& aParam) - { - WriteParam(aMsg, aParam.width); - WriteParam(aMsg, aParam.height); - } - - static bool Read(const Message* aMsg, void** aIter, paramType* aResult) - { - if (ReadParam(aMsg, aIter, &aResult->width) && - ReadParam(aMsg, aIter, &aResult->height)) - return true; - - return false; - } -}; - -template<> -struct ParamTraits -{ - typedef gfxRect paramType; - - static void Write(Message* aMsg, const paramType& aParam) - { - WriteParam(aMsg, aParam.x); - WriteParam(aMsg, aParam.y); - WriteParam(aMsg, aParam.width); - WriteParam(aMsg, aParam.height); - } - - static bool Read(const Message* aMsg, void** aIter, paramType* aResult) - { - return ReadParam(aMsg, aIter, &aResult->x) && - ReadParam(aMsg, aIter, &aResult->y) && - ReadParam(aMsg, aIter, &aResult->width) && - ReadParam(aMsg, aIter, &aResult->height); - } -}; - -template<> -struct ParamTraits -{ - typedef gfx3DMatrix paramType; - - static void Write(Message* msg, const paramType& param) - { -#define Wr(_f) WriteParam(msg, param. _f) - Wr(_11); Wr(_12); Wr(_13); Wr(_14); - Wr(_21); Wr(_22); Wr(_23); Wr(_24); - Wr(_31); Wr(_32); Wr(_33); Wr(_34); - Wr(_41); Wr(_42); Wr(_43); Wr(_44); -#undef Wr - } - - static bool Read(const Message* msg, void** iter, paramType* result) - { -#define Rd(_f) ReadParam(msg, iter, &result-> _f) - return (Rd(_11) && Rd(_12) && Rd(_13) && Rd(_14) && - Rd(_21) && Rd(_22) && Rd(_23) && Rd(_24) && - Rd(_31) && Rd(_32) && Rd(_33) && Rd(_34) && - Rd(_41) && Rd(_42) && Rd(_43) && Rd(_44)); -#undef Rd - } -}; - -template <> -struct ParamTraits - : public EnumSerializer -{}; - -template <> -struct ParamTraits - : public EnumSerializer -{}; - -template <> -struct ParamTraits - : public EnumSerializer -{}; - -template <> -struct ParamTraits - : public EnumSerializer -{}; - -template <> -struct ParamTraits - : public EnumSerializer -{}; - -template <> -struct ParamTraits - : public EnumSerializer -{}; - template <> struct ParamTraits : public EnumSerializer eCSSProperty_COUNT> {}; - -template<> -struct ParamTraits -{ - typedef gfxRGBA paramType; - - static void Write(Message* msg, const paramType& param) - { - WriteParam(msg, param.r); - WriteParam(msg, param.g); - WriteParam(msg, param.b); - WriteParam(msg, param.a); - } - - static bool Read(const Message* msg, void** iter, paramType* result) - { - return (ReadParam(msg, iter, &result->r) && - ReadParam(msg, iter, &result->g) && - ReadParam(msg, iter, &result->b) && - ReadParam(msg, iter, &result->a)); - } -}; - template<> struct ParamTraits { @@ -687,317 +458,6 @@ struct ParamTraits } }; -template<> -struct ParamTraits -{ - typedef nsPoint paramType; - - static void Write(Message* msg, const paramType& param) - { - WriteParam(msg, param.x); - WriteParam(msg, param.y); - } - - static bool Read(const Message* msg, void** iter, paramType* result) - { - return (ReadParam(msg, iter, &result->x) && - ReadParam(msg, iter, &result->y)); - } -}; - -template<> -struct ParamTraits -{ - typedef nsIntPoint paramType; - - static void Write(Message* msg, const paramType& param) - { - WriteParam(msg, param.x); - WriteParam(msg, param.y); - } - - static bool Read(const Message* msg, void** iter, paramType* result) - { - return (ReadParam(msg, iter, &result->x) && - ReadParam(msg, iter, &result->y)); - } -}; - -template<> -struct ParamTraits -{ - typedef mozilla::gfx::IntSize paramType; - - static void Write(Message* msg, const paramType& param) - { - WriteParam(msg, param.width); - WriteParam(msg, param.height); - } - - static bool Read(const Message* msg, void** iter, paramType* result) - { - return (ReadParam(msg, iter, &result->width) && - ReadParam(msg, iter, &result->height)); - } -}; - -template<> -struct ParamTraits -{ - typedef nsIntRect paramType; - - static void Write(Message* msg, const paramType& param) - { - WriteParam(msg, param.x); - WriteParam(msg, param.y); - WriteParam(msg, param.width); - WriteParam(msg, param.height); - } - - static bool Read(const Message* msg, void** iter, paramType* result) - { - return (ReadParam(msg, iter, &result->x) && - ReadParam(msg, iter, &result->y) && - ReadParam(msg, iter, &result->width) && - ReadParam(msg, iter, &result->height)); - } -}; - -template -struct RegionParamTraits -{ - typedef Region paramType; - - static void Write(Message* msg, const paramType& param) - { - Iter it(param); - while (const Rect* r = it.Next()) - WriteParam(msg, *r); - // empty rects are sentinel values because nsRegions will never - // contain them - WriteParam(msg, Rect()); - } - - static bool Read(const Message* msg, void** iter, paramType* result) - { - Rect rect; - while (ReadParam(msg, iter, &rect)) { - if (rect.IsEmpty()) - return true; - result->Or(*result, rect); - } - return false; - } -}; - -template<> -struct ParamTraits - : RegionParamTraits -{}; - -template<> -struct ParamTraits -{ - typedef nsIntSize paramType; - - static void Write(Message* msg, const paramType& param) - { - WriteParam(msg, param.width); - WriteParam(msg, param.height); - } - - static bool Read(const Message* msg, void** iter, paramType* result) - { - return (ReadParam(msg, iter, &result->width) && - ReadParam(msg, iter, &result->height)); - } -}; - -template -struct ParamTraits< mozilla::gfx::ScaleFactor > -{ - typedef mozilla::gfx::ScaleFactor paramType; - - static void Write(Message* msg, const paramType& param) - { - WriteParam(msg, param.scale); - } - - static bool Read(const Message* msg, void** iter, paramType* result) - { - return (ReadParam(msg, iter, &result->scale)); - } -}; - -template -struct ParamTraits< mozilla::gfx::PointTyped > -{ - typedef mozilla::gfx::PointTyped paramType; - - static void Write(Message* msg, const paramType& param) - { - WriteParam(msg, param.x); - WriteParam(msg, param.y); - } - - static bool Read(const Message* msg, void** iter, paramType* result) - { - return (ReadParam(msg, iter, &result->x) && - ReadParam(msg, iter, &result->y)); - } -}; - -template -struct ParamTraits< mozilla::gfx::IntPointTyped > -{ - typedef mozilla::gfx::IntPointTyped paramType; - - static void Write(Message* msg, const paramType& param) - { - WriteParam(msg, param.x); - WriteParam(msg, param.y); - } - - static bool Read(const Message* msg, void** iter, paramType* result) - { - return (ReadParam(msg, iter, &result->x) && - ReadParam(msg, iter, &result->y)); - } -}; - -template<> -struct ParamTraits -{ - typedef mozilla::gfx::Size paramType; - - static void Write(Message* msg, const paramType& param) - { - WriteParam(msg, param.width); - WriteParam(msg, param.height); - } - - static bool Read(const Message* msg, void** iter, paramType* result) - { - return (ReadParam(msg, iter, &result->width) && - ReadParam(msg, iter, &result->height)); - } -}; - -template -struct ParamTraits< mozilla::gfx::RectTyped > -{ - typedef mozilla::gfx::RectTyped paramType; - - static void Write(Message* msg, const paramType& param) - { - WriteParam(msg, param.x); - WriteParam(msg, param.y); - WriteParam(msg, param.width); - WriteParam(msg, param.height); - } - - static bool Read(const Message* msg, void** iter, paramType* result) - { - return (ReadParam(msg, iter, &result->x) && - ReadParam(msg, iter, &result->y) && - ReadParam(msg, iter, &result->width) && - ReadParam(msg, iter, &result->height)); - } -}; - -template -struct ParamTraits< mozilla::gfx::IntRectTyped > -{ - typedef mozilla::gfx::IntRectTyped paramType; - - static void Write(Message* msg, const paramType& param) - { - WriteParam(msg, param.x); - WriteParam(msg, param.y); - WriteParam(msg, param.width); - WriteParam(msg, param.height); - } - - static bool Read(const Message* msg, void** iter, paramType* result) - { - return (ReadParam(msg, iter, &result->x) && - ReadParam(msg, iter, &result->y) && - ReadParam(msg, iter, &result->width) && - ReadParam(msg, iter, &result->height)); - } -}; - -template<> -struct ParamTraits -{ - typedef mozilla::gfx::Margin paramType; - - static void Write(Message* msg, const paramType& param) - { - WriteParam(msg, param.top); - WriteParam(msg, param.right); - WriteParam(msg, param.bottom); - WriteParam(msg, param.left); - } - - static bool Read(const Message* msg, void** iter, paramType* result) - { - return (ReadParam(msg, iter, &result->top) && - ReadParam(msg, iter, &result->right) && - ReadParam(msg, iter, &result->bottom) && - ReadParam(msg, iter, &result->left)); - } -}; - -template -struct ParamTraits< mozilla::gfx::MarginTyped > -{ - typedef mozilla::gfx::MarginTyped paramType; - - static void Write(Message* msg, const paramType& param) - { - WriteParam(msg, param.top); - WriteParam(msg, param.right); - WriteParam(msg, param.bottom); - WriteParam(msg, param.left); - } - - static bool Read(const Message* msg, void** iter, paramType* result) - { - return (ReadParam(msg, iter, &result->top) && - ReadParam(msg, iter, &result->right) && - ReadParam(msg, iter, &result->bottom) && - ReadParam(msg, iter, &result->left)); - } -}; - -template<> -struct ParamTraits -{ - typedef nsRect paramType; - - static void Write(Message* msg, const paramType& param) - { - WriteParam(msg, param.x); - WriteParam(msg, param.y); - WriteParam(msg, param.width); - WriteParam(msg, param.height); - } - - static bool Read(const Message* msg, void** iter, paramType* result) - { - return (ReadParam(msg, iter, &result->x) && - ReadParam(msg, iter, &result->y) && - ReadParam(msg, iter, &result->width) && - ReadParam(msg, iter, &result->height)); - } -}; - -template<> -struct ParamTraits - : RegionParamTraits -{}; - template<> struct ParamTraits { @@ -1133,100 +593,6 @@ struct ParamTraits } }; -template <> -struct ParamTraits -{ - typedef mozilla::layers::FrameMetrics paramType; - - static void Write(Message* aMsg, const paramType& aParam) - { - WriteParam(aMsg, aParam.mScrollableRect); - WriteParam(aMsg, aParam.mViewport); - WriteParam(aMsg, aParam.mScrollOffset); - WriteParam(aMsg, aParam.mDisplayPort); - WriteParam(aMsg, aParam.mCriticalDisplayPort); - WriteParam(aMsg, aParam.mCompositionBounds); - WriteParam(aMsg, aParam.mScrollId); - WriteParam(aMsg, aParam.mResolution); - WriteParam(aMsg, aParam.mZoom); - WriteParam(aMsg, aParam.mDevPixelsPerCSSPixel); - WriteParam(aMsg, aParam.mMayHaveTouchListeners); - WriteParam(aMsg, aParam.mPresShellId); - } - - static bool Read(const Message* aMsg, void** aIter, paramType* aResult) - { - return (ReadParam(aMsg, aIter, &aResult->mScrollableRect) && - ReadParam(aMsg, aIter, &aResult->mViewport) && - ReadParam(aMsg, aIter, &aResult->mScrollOffset) && - ReadParam(aMsg, aIter, &aResult->mDisplayPort) && - ReadParam(aMsg, aIter, &aResult->mCriticalDisplayPort) && - ReadParam(aMsg, aIter, &aResult->mCompositionBounds) && - ReadParam(aMsg, aIter, &aResult->mScrollId) && - ReadParam(aMsg, aIter, &aResult->mResolution) && - ReadParam(aMsg, aIter, &aResult->mZoom) && - ReadParam(aMsg, aIter, &aResult->mDevPixelsPerCSSPixel) && - ReadParam(aMsg, aIter, &aResult->mMayHaveTouchListeners) && - ReadParam(aMsg, aIter, &aResult->mPresShellId)); - } -}; - -template<> -struct ParamTraits -{ - typedef mozilla::layers::TextureFactoryIdentifier paramType; - - static void Write(Message* aMsg, const paramType& aParam) - { - WriteParam(aMsg, aParam.mParentBackend); - WriteParam(aMsg, aParam.mMaxTextureSize); - WriteParam(aMsg, aParam.mSupportsTextureBlitting); - WriteParam(aMsg, aParam.mSupportsPartialUploads); - } - - static bool Read(const Message* aMsg, void** aIter, paramType* aResult) - { - return ReadParam(aMsg, aIter, &aResult->mParentBackend) && - ReadParam(aMsg, aIter, &aResult->mMaxTextureSize) && - ReadParam(aMsg, aIter, &aResult->mSupportsTextureBlitting) && - ReadParam(aMsg, aIter, &aResult->mSupportsPartialUploads); - } -}; - -template<> -struct ParamTraits -{ - typedef mozilla::layers::TextureInfo paramType; - - static void Write(Message* aMsg, const paramType& aParam) - { - WriteParam(aMsg, aParam.mCompositableType); - WriteParam(aMsg, aParam.mDeprecatedTextureHostFlags); - WriteParam(aMsg, aParam.mTextureFlags); - } - - static bool Read(const Message* aMsg, void** aIter, paramType* aResult) - { - return ReadParam(aMsg, aIter, &aResult->mCompositableType) && - ReadParam(aMsg, aIter, &aResult->mDeprecatedTextureHostFlags) && - ReadParam(aMsg, aIter, &aResult->mTextureFlags); - } -}; - -template <> -struct ParamTraits - : public EnumSerializer -{}; - -template <> -struct ParamTraits - : public EnumSerializer -{}; - } /* namespace IPC */ #endif /* __IPC_GLUE_IPCMESSAGEUTILS_H__ */ diff --git a/widget/nsGUIEventIPC.h b/widget/nsGUIEventIPC.h index 70d4ae9094c5..f97304840d2a 100644 --- a/widget/nsGUIEventIPC.h +++ b/widget/nsGUIEventIPC.h @@ -7,6 +7,7 @@ #define nsGUIEventIPC_h__ #include "ipc/IPCMessageUtils.h" +#include "mozilla/GfxMessageUtils.h" #include "mozilla/dom/Touch.h" #include "nsGUIEvent.h"