gfx/ipc/GfxMessageUtils.h

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/gfx/ipc/GfxMessageUtils.h	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,1085 @@
     1.4 +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
     1.5 +/* vim: set sw=2 ts=8 et tw=80 : */
     1.6 +/* This Source Code Form is subject to the terms of the Mozilla Public
     1.7 + * License, v. 2.0. If a copy of the MPL was not distributed with this
     1.8 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     1.9 +
    1.10 +#ifndef __GFXMESSAGEUTILS_H__
    1.11 +#define __GFXMESSAGEUTILS_H__
    1.12 +
    1.13 +#include "base/process_util.h"
    1.14 +#include "chrome/common/ipc_message_utils.h"
    1.15 +#include "ipc/IPCMessageUtils.h"
    1.16 +
    1.17 +#include <stdint.h>
    1.18 +
    1.19 +#include "gfx3DMatrix.h"
    1.20 +#include "gfxColor.h"
    1.21 +#include "mozilla/gfx/Matrix.h"
    1.22 +#include "GraphicsFilter.h"
    1.23 +#include "gfxPoint.h"
    1.24 +#include "gfxRect.h"
    1.25 +#include "nsRect.h"
    1.26 +#include "nsRegion.h"
    1.27 +#include "gfxTypes.h"
    1.28 +#include "mozilla/layers/LayersTypes.h"
    1.29 +#include "mozilla/layers/CompositorTypes.h"
    1.30 +#include "FrameMetrics.h"
    1.31 +#include "FilterSupport.h"
    1.32 +#include "mozilla/layers/GeckoContentController.h"
    1.33 +
    1.34 +#ifdef _MSC_VER
    1.35 +#pragma warning( disable : 4800 )
    1.36 +#endif
    1.37 +
    1.38 +namespace mozilla {
    1.39 +
    1.40 +typedef gfxImageFormat PixelFormat;
    1.41 +#if defined(MOZ_HAVE_CXX11_STRONG_ENUMS)
    1.42 +typedef ::GraphicsFilter GraphicsFilterType;
    1.43 +#else
    1.44 +// If we don't have support for enum classes, then we need to use the actual
    1.45 +// enum type here instead of the simulated enum class.
    1.46 +typedef GraphicsFilter::Enum GraphicsFilterType;
    1.47 +#endif
    1.48 +
    1.49 +} // namespace mozilla
    1.50 +
    1.51 +namespace IPC {
    1.52 +
    1.53 +template<>
    1.54 +struct ParamTraits<mozilla::gfx::Matrix>
    1.55 +{
    1.56 +  typedef mozilla::gfx::Matrix paramType;
    1.57 +
    1.58 +  static void Write(Message* aMsg, const paramType& aParam)
    1.59 +  {
    1.60 +    WriteParam(aMsg, aParam._11);
    1.61 +    WriteParam(aMsg, aParam._12);
    1.62 +    WriteParam(aMsg, aParam._21);
    1.63 +    WriteParam(aMsg, aParam._22);
    1.64 +    WriteParam(aMsg, aParam._31);
    1.65 +    WriteParam(aMsg, aParam._32);
    1.66 +  }
    1.67 +
    1.68 +  static bool Read(const Message* aMsg, void** aIter, paramType* aResult)
    1.69 +  {
    1.70 +    if (ReadParam(aMsg, aIter, &aResult->_11) &&
    1.71 +        ReadParam(aMsg, aIter, &aResult->_12) &&
    1.72 +        ReadParam(aMsg, aIter, &aResult->_21) &&
    1.73 +        ReadParam(aMsg, aIter, &aResult->_22) &&
    1.74 +        ReadParam(aMsg, aIter, &aResult->_31) &&
    1.75 +        ReadParam(aMsg, aIter, &aResult->_32))
    1.76 +      return true;
    1.77 +
    1.78 +    return false;
    1.79 +  }
    1.80 +
    1.81 +  static void Log(const paramType& aParam, std::wstring* aLog)
    1.82 +  {
    1.83 +    aLog->append(StringPrintf(L"[[%g %g] [%g %g] [%g %g]]", aParam._11, aParam._12, aParam._21, aParam._22,
    1.84 +                                                            aParam._31, aParam._32));
    1.85 +  }
    1.86 +};
    1.87 +
    1.88 +template<>
    1.89 +struct ParamTraits<mozilla::gfx::Matrix4x4>
    1.90 +{
    1.91 +  typedef mozilla::gfx::Matrix4x4 paramType;
    1.92 +
    1.93 +  static void Write(Message* msg, const paramType& param)
    1.94 +  {
    1.95 +#define Wr(_f)  WriteParam(msg, param. _f)
    1.96 +    Wr(_11); Wr(_12); Wr(_13); Wr(_14);
    1.97 +    Wr(_21); Wr(_22); Wr(_23); Wr(_24);
    1.98 +    Wr(_31); Wr(_32); Wr(_33); Wr(_34);
    1.99 +    Wr(_41); Wr(_42); Wr(_43); Wr(_44);
   1.100 +#undef Wr
   1.101 +  }
   1.102 +
   1.103 +  static bool Read(const Message* msg, void** iter, paramType* result)
   1.104 +  {
   1.105 +#define Rd(_f)  ReadParam(msg, iter, &result-> _f)
   1.106 +    return (Rd(_11) && Rd(_12) && Rd(_13) && Rd(_14) &&
   1.107 +            Rd(_21) && Rd(_22) && Rd(_23) && Rd(_24) &&
   1.108 +            Rd(_31) && Rd(_32) && Rd(_33) && Rd(_34) &&
   1.109 +            Rd(_41) && Rd(_42) && Rd(_43) && Rd(_44));
   1.110 +#undef Rd
   1.111 +  }
   1.112 +};
   1.113 +
   1.114 +template<>
   1.115 +struct ParamTraits<mozilla::gfx::Matrix5x4>
   1.116 +{
   1.117 +  typedef mozilla::gfx::Matrix5x4 paramType;
   1.118 +
   1.119 +  static void Write(Message* msg, const paramType& param)
   1.120 +  {
   1.121 +#define Wr(_f)  WriteParam(msg, param. _f)
   1.122 +    Wr(_11); Wr(_12); Wr(_13); Wr(_14);
   1.123 +    Wr(_21); Wr(_22); Wr(_23); Wr(_24);
   1.124 +    Wr(_31); Wr(_32); Wr(_33); Wr(_34);
   1.125 +    Wr(_41); Wr(_42); Wr(_43); Wr(_44);
   1.126 +    Wr(_51); Wr(_52); Wr(_53); Wr(_54);
   1.127 +#undef Wr
   1.128 +  }
   1.129 +
   1.130 +  static bool Read(const Message* msg, void** iter, paramType* result)
   1.131 +  {
   1.132 +#define Rd(_f)  ReadParam(msg, iter, &result-> _f)
   1.133 +    return (Rd(_11) && Rd(_12) && Rd(_13) && Rd(_14) &&
   1.134 +            Rd(_21) && Rd(_22) && Rd(_23) && Rd(_24) &&
   1.135 +            Rd(_31) && Rd(_32) && Rd(_33) && Rd(_34) &&
   1.136 +            Rd(_41) && Rd(_42) && Rd(_43) && Rd(_44) &&
   1.137 +            Rd(_51) && Rd(_52) && Rd(_53) && Rd(_54));
   1.138 +#undef Rd
   1.139 +  }
   1.140 +};
   1.141 +
   1.142 +template<>
   1.143 +struct ParamTraits<gfxPoint>
   1.144 +{
   1.145 +  typedef gfxPoint paramType;
   1.146 +
   1.147 +  static void Write(Message* aMsg, const paramType& aParam)
   1.148 +  {
   1.149 +    WriteParam(aMsg, aParam.x);
   1.150 +    WriteParam(aMsg, aParam.y);
   1.151 +  }
   1.152 +
   1.153 +  static bool Read(const Message* aMsg, void** aIter, paramType* aResult)
   1.154 +  {
   1.155 +    return (ReadParam(aMsg, aIter, &aResult->x) &&
   1.156 +            ReadParam(aMsg, aIter, &aResult->y));
   1.157 + }
   1.158 +};
   1.159 +
   1.160 +template<>
   1.161 +struct ParamTraits<gfxPoint3D>
   1.162 +{
   1.163 +  typedef gfxPoint3D paramType;
   1.164 +
   1.165 +  static void Write(Message* aMsg, const paramType& aParam)
   1.166 +  {
   1.167 +    WriteParam(aMsg, aParam.x);
   1.168 +    WriteParam(aMsg, aParam.y);
   1.169 +    WriteParam(aMsg, aParam.z);
   1.170 +  }
   1.171 +
   1.172 +  static bool Read(const Message* aMsg, void** aIter, paramType* aResult)
   1.173 +  {
   1.174 +    return (ReadParam(aMsg, aIter, &aResult->x) &&
   1.175 +            ReadParam(aMsg, aIter, &aResult->y) &&
   1.176 +            ReadParam(aMsg, aIter, &aResult->z));
   1.177 +  }
   1.178 +};
   1.179 +
   1.180 +template<>
   1.181 +struct ParamTraits<gfxSize>
   1.182 +{
   1.183 +  typedef gfxSize paramType;
   1.184 +
   1.185 +  static void Write(Message* aMsg, const paramType& aParam)
   1.186 +  {
   1.187 +    WriteParam(aMsg, aParam.width);
   1.188 +    WriteParam(aMsg, aParam.height);
   1.189 +  }
   1.190 +
   1.191 +  static bool Read(const Message* aMsg, void** aIter, paramType* aResult)
   1.192 +  {
   1.193 +    if (ReadParam(aMsg, aIter, &aResult->width) &&
   1.194 +        ReadParam(aMsg, aIter, &aResult->height))
   1.195 +      return true;
   1.196 +
   1.197 +    return false;
   1.198 +  }
   1.199 +};
   1.200 +
   1.201 +template<>
   1.202 +struct ParamTraits<gfxRect>
   1.203 +{
   1.204 +  typedef gfxRect paramType;
   1.205 +
   1.206 +  static void Write(Message* aMsg, const paramType& aParam)
   1.207 +  {
   1.208 +    WriteParam(aMsg, aParam.x);
   1.209 +    WriteParam(aMsg, aParam.y);
   1.210 +    WriteParam(aMsg, aParam.width);
   1.211 +    WriteParam(aMsg, aParam.height);
   1.212 +  }
   1.213 +
   1.214 +  static bool Read(const Message* aMsg, void** aIter, paramType* aResult)
   1.215 +  {
   1.216 +    return ReadParam(aMsg, aIter, &aResult->x) &&
   1.217 +           ReadParam(aMsg, aIter, &aResult->y) &&
   1.218 +           ReadParam(aMsg, aIter, &aResult->width) &&
   1.219 +           ReadParam(aMsg, aIter, &aResult->height);
   1.220 +  }
   1.221 +};
   1.222 +
   1.223 +template<>
   1.224 +struct ParamTraits<gfx3DMatrix>
   1.225 +{
   1.226 +  typedef gfx3DMatrix paramType;
   1.227 +
   1.228 +  static void Write(Message* msg, const paramType& param)
   1.229 +  {
   1.230 +#define Wr(_f)  WriteParam(msg, param. _f)
   1.231 +    Wr(_11); Wr(_12); Wr(_13); Wr(_14);
   1.232 +    Wr(_21); Wr(_22); Wr(_23); Wr(_24);
   1.233 +    Wr(_31); Wr(_32); Wr(_33); Wr(_34);
   1.234 +    Wr(_41); Wr(_42); Wr(_43); Wr(_44);
   1.235 +#undef Wr
   1.236 +  }
   1.237 +
   1.238 +  static bool Read(const Message* msg, void** iter, paramType* result)
   1.239 +  {
   1.240 +#define Rd(_f)  ReadParam(msg, iter, &result-> _f)
   1.241 +    return (Rd(_11) && Rd(_12) && Rd(_13) && Rd(_14) &&
   1.242 +            Rd(_21) && Rd(_22) && Rd(_23) && Rd(_24) &&
   1.243 +            Rd(_31) && Rd(_32) && Rd(_33) && Rd(_34) &&
   1.244 +            Rd(_41) && Rd(_42) && Rd(_43) && Rd(_44));
   1.245 +#undef Rd
   1.246 +  }
   1.247 +};
   1.248 +
   1.249 +template <>
   1.250 +struct ParamTraits<gfxContentType>
   1.251 +  : public ContiguousTypedEnumSerializer<
   1.252 +             gfxContentType,
   1.253 +             gfxContentType::COLOR,
   1.254 +             gfxContentType::SENTINEL>
   1.255 +{};
   1.256 +
   1.257 +template <>
   1.258 +struct ParamTraits<gfxSurfaceType>
   1.259 +  : public ContiguousTypedEnumSerializer<
   1.260 +             gfxSurfaceType,
   1.261 +             gfxSurfaceType::Image,
   1.262 +             gfxSurfaceType::Max>
   1.263 +{};
   1.264 +
   1.265 +template <>
   1.266 +struct ParamTraits<mozilla::GraphicsFilterType>
   1.267 +  : public ContiguousEnumSerializer<
   1.268 +             mozilla::GraphicsFilterType,
   1.269 +             GraphicsFilter::FILTER_FAST,
   1.270 +             GraphicsFilter::FILTER_SENTINEL>
   1.271 +{};
   1.272 +
   1.273 +template <>
   1.274 +struct ParamTraits<mozilla::layers::LayersBackend>
   1.275 +  : public ContiguousTypedEnumSerializer<
   1.276 +             mozilla::layers::LayersBackend,
   1.277 +             mozilla::layers::LayersBackend::LAYERS_NONE,
   1.278 +             mozilla::layers::LayersBackend::LAYERS_LAST>
   1.279 +{};
   1.280 +
   1.281 +template <>
   1.282 +struct ParamTraits<mozilla::layers::ScaleMode>
   1.283 +  : public ContiguousTypedEnumSerializer<
   1.284 +             mozilla::layers::ScaleMode,
   1.285 +             mozilla::layers::ScaleMode::SCALE_NONE,
   1.286 +             mozilla::layers::ScaleMode::SENTINEL>
   1.287 +{};
   1.288 +
   1.289 +template <>
   1.290 +struct ParamTraits<gfxImageFormat>
   1.291 +  : public ContiguousTypedEnumSerializer<
   1.292 +             gfxImageFormat,
   1.293 +             gfxImageFormat::ARGB32,
   1.294 +             gfxImageFormat::Unknown>
   1.295 +{};
   1.296 +
   1.297 +template <>
   1.298 +struct ParamTraits<mozilla::gfx::AttributeName>
   1.299 +  : public ContiguousEnumSerializer<
   1.300 +             mozilla::gfx::AttributeName,
   1.301 +             mozilla::gfx::eBlendBlendmode,
   1.302 +             mozilla::gfx::eLastAttributeName>
   1.303 +{};
   1.304 +
   1.305 +template <>
   1.306 +struct ParamTraits<mozilla::gfx::AttributeType>
   1.307 +  : public ContiguousTypedEnumSerializer<
   1.308 +             mozilla::gfx::AttributeType,
   1.309 +             mozilla::gfx::AttributeType::eBool,
   1.310 +             mozilla::gfx::AttributeType::Max>
   1.311 +{};
   1.312 +
   1.313 +template <>
   1.314 +struct ParamTraits<mozilla::gfx::PrimitiveType>
   1.315 +  : public ContiguousTypedEnumSerializer<
   1.316 +             mozilla::gfx::PrimitiveType,
   1.317 +             mozilla::gfx::PrimitiveType::Empty,
   1.318 +             mozilla::gfx::PrimitiveType::Max>
   1.319 +{};
   1.320 +
   1.321 +template <>
   1.322 +struct ParamTraits<mozilla::gfx::ColorSpace>
   1.323 +  : public ContiguousTypedEnumSerializer<
   1.324 +             mozilla::gfx::ColorSpace,
   1.325 +             mozilla::gfx::ColorSpace::SRGB,
   1.326 +             mozilla::gfx::ColorSpace::Max>
   1.327 +{};
   1.328 +
   1.329 +/*
   1.330 +template <>
   1.331 +struct ParamTraits<mozilla::PixelFormat>
   1.332 +  : public EnumSerializer<mozilla::PixelFormat,
   1.333 +                          gfxImageFormat::ARGB32,
   1.334 +                          gfxImageFormat::Unknown>
   1.335 +{};
   1.336 +*/
   1.337 +
   1.338 +template<>
   1.339 +struct ParamTraits<gfxRGBA>
   1.340 +{
   1.341 +  typedef gfxRGBA paramType;
   1.342 +
   1.343 +  static void Write(Message* msg, const paramType& param)
   1.344 +  {
   1.345 +    WriteParam(msg, param.r);
   1.346 +    WriteParam(msg, param.g);
   1.347 +    WriteParam(msg, param.b);
   1.348 +    WriteParam(msg, param.a);
   1.349 +  }
   1.350 +
   1.351 +  static bool Read(const Message* msg, void** iter, paramType* result)
   1.352 +  {
   1.353 +    return (ReadParam(msg, iter, &result->r) &&
   1.354 +            ReadParam(msg, iter, &result->g) &&
   1.355 +            ReadParam(msg, iter, &result->b) &&
   1.356 +            ReadParam(msg, iter, &result->a));
   1.357 +  }
   1.358 +};
   1.359 +
   1.360 +template<>
   1.361 +struct ParamTraits<mozilla::gfx::Color>
   1.362 +{
   1.363 +  typedef mozilla::gfx::Color paramType;
   1.364 +
   1.365 +  static void Write(Message* msg, const paramType& param)
   1.366 +  {
   1.367 +    WriteParam(msg, param.r);
   1.368 +    WriteParam(msg, param.g);
   1.369 +    WriteParam(msg, param.b);
   1.370 +    WriteParam(msg, param.a);
   1.371 +  }
   1.372 +
   1.373 +  static bool Read(const Message* msg, void** iter, paramType* result)
   1.374 +  {
   1.375 +    return (ReadParam(msg, iter, &result->r) &&
   1.376 +            ReadParam(msg, iter, &result->g) &&
   1.377 +            ReadParam(msg, iter, &result->b) &&
   1.378 +            ReadParam(msg, iter, &result->a));
   1.379 +  }
   1.380 +};
   1.381 +
   1.382 +template<>
   1.383 +struct ParamTraits<nsPoint>
   1.384 +{
   1.385 +  typedef nsPoint paramType;
   1.386 +
   1.387 +  static void Write(Message* msg, const paramType& param)
   1.388 +  {
   1.389 +    WriteParam(msg, param.x);
   1.390 +    WriteParam(msg, param.y);
   1.391 +  }
   1.392 +
   1.393 +  static bool Read(const Message* msg, void** iter, paramType* result)
   1.394 +  {
   1.395 +    return (ReadParam(msg, iter, &result->x) &&
   1.396 +            ReadParam(msg, iter, &result->y));
   1.397 +  }
   1.398 +};
   1.399 +
   1.400 +template<>
   1.401 +struct ParamTraits<nsIntPoint>
   1.402 +{
   1.403 +  typedef nsIntPoint paramType;
   1.404 +
   1.405 +  static void Write(Message* msg, const paramType& param)
   1.406 +  {
   1.407 +    WriteParam(msg, param.x);
   1.408 +    WriteParam(msg, param.y);
   1.409 +  }
   1.410 +
   1.411 +  static bool Read(const Message* msg, void** iter, paramType* result)
   1.412 +  {
   1.413 +    return (ReadParam(msg, iter, &result->x) &&
   1.414 +            ReadParam(msg, iter, &result->y));
   1.415 +  }
   1.416 +};
   1.417 +
   1.418 +template<>
   1.419 +struct ParamTraits<mozilla::gfx::IntSize>
   1.420 +{
   1.421 +  typedef mozilla::gfx::IntSize paramType;
   1.422 +
   1.423 +  static void Write(Message* msg, const paramType& param)
   1.424 +  {
   1.425 +    WriteParam(msg, param.width);
   1.426 +    WriteParam(msg, param.height);
   1.427 +  }
   1.428 +
   1.429 +  static bool Read(const Message* msg, void** iter, paramType* result)
   1.430 +  {
   1.431 +    return (ReadParam(msg, iter, &result->width) &&
   1.432 +            ReadParam(msg, iter, &result->height));
   1.433 +  }
   1.434 +};
   1.435 +
   1.436 +template<>
   1.437 +struct ParamTraits<nsIntRect>
   1.438 +{
   1.439 +  typedef nsIntRect paramType;
   1.440 +
   1.441 +  static void Write(Message* msg, const paramType& param)
   1.442 +  {
   1.443 +    WriteParam(msg, param.x);
   1.444 +    WriteParam(msg, param.y);
   1.445 +    WriteParam(msg, param.width);
   1.446 +    WriteParam(msg, param.height);
   1.447 +  }
   1.448 +
   1.449 +  static bool Read(const Message* msg, void** iter, paramType* result)
   1.450 +  {
   1.451 +    return (ReadParam(msg, iter, &result->x) &&
   1.452 +            ReadParam(msg, iter, &result->y) &&
   1.453 +            ReadParam(msg, iter, &result->width) &&
   1.454 +            ReadParam(msg, iter, &result->height));
   1.455 +  }
   1.456 +};
   1.457 +
   1.458 +template<typename Region, typename Rect, typename Iter>
   1.459 +struct RegionParamTraits
   1.460 +{
   1.461 +  typedef Region paramType;
   1.462 +
   1.463 +  static void Write(Message* msg, const paramType& param)
   1.464 +  {
   1.465 +    Iter it(param);
   1.466 +    while (const Rect* r = it.Next())
   1.467 +      WriteParam(msg, *r);
   1.468 +    // empty rects are sentinel values because nsRegions will never
   1.469 +    // contain them
   1.470 +    WriteParam(msg, Rect());
   1.471 +  }
   1.472 +
   1.473 +  static bool Read(const Message* msg, void** iter, paramType* result)
   1.474 +  {
   1.475 +    Rect rect;
   1.476 +    while (ReadParam(msg, iter, &rect)) {
   1.477 +      if (rect.IsEmpty())
   1.478 +        return true;
   1.479 +      result->Or(*result, rect);
   1.480 +    }
   1.481 +    return false;
   1.482 +  }
   1.483 +};
   1.484 +
   1.485 +template<>
   1.486 +struct ParamTraits<nsIntRegion>
   1.487 +  : RegionParamTraits<nsIntRegion, nsIntRect, nsIntRegionRectIterator>
   1.488 +{};
   1.489 +
   1.490 +template<>
   1.491 +struct ParamTraits<nsIntSize>
   1.492 +{
   1.493 +  typedef nsIntSize paramType;
   1.494 +
   1.495 +  static void Write(Message* msg, const paramType& param)
   1.496 +  {
   1.497 +    WriteParam(msg, param.width);
   1.498 +    WriteParam(msg, param.height);
   1.499 +  }
   1.500 +
   1.501 +  static bool Read(const Message* msg, void** iter, paramType* result)
   1.502 +  {
   1.503 +    return (ReadParam(msg, iter, &result->width) &&
   1.504 +            ReadParam(msg, iter, &result->height));
   1.505 +  }
   1.506 +};
   1.507 +
   1.508 +template<class T, class U>
   1.509 +struct ParamTraits< mozilla::gfx::ScaleFactor<T, U> >
   1.510 +{
   1.511 +  typedef mozilla::gfx::ScaleFactor<T, U> paramType;
   1.512 +
   1.513 +  static void Write(Message* msg, const paramType& param)
   1.514 +  {
   1.515 +    WriteParam(msg, param.scale);
   1.516 +  }
   1.517 +
   1.518 +  static bool Read(const Message* msg, void** iter, paramType* result)
   1.519 +  {
   1.520 +    return (ReadParam(msg, iter, &result->scale));
   1.521 +  }
   1.522 +};
   1.523 +
   1.524 +template<class T>
   1.525 +struct ParamTraits< mozilla::gfx::PointTyped<T> >
   1.526 +{
   1.527 +  typedef mozilla::gfx::PointTyped<T> paramType;
   1.528 +
   1.529 +  static void Write(Message* msg, const paramType& param)
   1.530 +  {
   1.531 +    WriteParam(msg, param.x);
   1.532 +    WriteParam(msg, param.y);
   1.533 +  }
   1.534 +
   1.535 +  static bool Read(const Message* msg, void** iter, paramType* result)
   1.536 +  {
   1.537 +    return (ReadParam(msg, iter, &result->x) &&
   1.538 +            ReadParam(msg, iter, &result->y));
   1.539 +  }
   1.540 +};
   1.541 +
   1.542 +template<class T>
   1.543 +struct ParamTraits< mozilla::gfx::Point3DTyped<T> >
   1.544 +{
   1.545 +  typedef mozilla::gfx::Point3DTyped<T> paramType;
   1.546 +
   1.547 +  static void Write(Message* msg, const paramType& param)
   1.548 +  {
   1.549 +    WriteParam(msg, param.x);
   1.550 +    WriteParam(msg, param.y);
   1.551 +    WriteParam(msg, param.z);
   1.552 +  }
   1.553 +
   1.554 +  static bool Read(const Message* msg, void** iter, paramType* result)
   1.555 +  {
   1.556 +    return (ReadParam(msg, iter, &result->x) &&
   1.557 +            ReadParam(msg, iter, &result->y) &&
   1.558 +            ReadParam(msg, iter, &result->z));
   1.559 +  }
   1.560 +};
   1.561 +
   1.562 +template<class T>
   1.563 +struct ParamTraits< mozilla::gfx::IntPointTyped<T> >
   1.564 +{
   1.565 +  typedef mozilla::gfx::IntPointTyped<T> paramType;
   1.566 +
   1.567 +  static void Write(Message* msg, const paramType& param)
   1.568 +  {
   1.569 +    WriteParam(msg, param.x);
   1.570 +    WriteParam(msg, param.y);
   1.571 +  }
   1.572 +
   1.573 +  static bool Read(const Message* msg, void** iter, paramType* result)
   1.574 +  {
   1.575 +    return (ReadParam(msg, iter, &result->x) &&
   1.576 +            ReadParam(msg, iter, &result->y));
   1.577 +  }
   1.578 +};
   1.579 +
   1.580 +template<class T>
   1.581 +struct ParamTraits< mozilla::gfx::SizeTyped<T> >
   1.582 +{
   1.583 +  typedef mozilla::gfx::SizeTyped<T> paramType;
   1.584 +
   1.585 +  static void Write(Message* msg, const paramType& param)
   1.586 +  {
   1.587 +    WriteParam(msg, param.width);
   1.588 +    WriteParam(msg, param.height);
   1.589 +  }
   1.590 +
   1.591 +  static bool Read(const Message* msg, void** iter, paramType* result)
   1.592 +  {
   1.593 +    return (ReadParam(msg, iter, &result->width) &&
   1.594 +            ReadParam(msg, iter, &result->height));
   1.595 +  }
   1.596 +};
   1.597 +
   1.598 +template<class T>
   1.599 +struct ParamTraits< mozilla::gfx::RectTyped<T> >
   1.600 +{
   1.601 +  typedef mozilla::gfx::RectTyped<T> paramType;
   1.602 +
   1.603 +  static void Write(Message* msg, const paramType& param)
   1.604 +  {
   1.605 +    WriteParam(msg, param.x);
   1.606 +    WriteParam(msg, param.y);
   1.607 +    WriteParam(msg, param.width);
   1.608 +    WriteParam(msg, param.height);
   1.609 +  }
   1.610 +
   1.611 +  static bool Read(const Message* msg, void** iter, paramType* result)
   1.612 +  {
   1.613 +    return (ReadParam(msg, iter, &result->x) &&
   1.614 +            ReadParam(msg, iter, &result->y) &&
   1.615 +            ReadParam(msg, iter, &result->width) &&
   1.616 +            ReadParam(msg, iter, &result->height));
   1.617 +  }
   1.618 +};
   1.619 +
   1.620 +template<class T>
   1.621 +struct ParamTraits< mozilla::gfx::IntRectTyped<T> >
   1.622 +{
   1.623 +  typedef mozilla::gfx::IntRectTyped<T> paramType;
   1.624 +
   1.625 +  static void Write(Message* msg, const paramType& param)
   1.626 +  {
   1.627 +    WriteParam(msg, param.x);
   1.628 +    WriteParam(msg, param.y);
   1.629 +    WriteParam(msg, param.width);
   1.630 +    WriteParam(msg, param.height);
   1.631 +  }
   1.632 +
   1.633 +  static bool Read(const Message* msg, void** iter, paramType* result)
   1.634 +  {
   1.635 +    return (ReadParam(msg, iter, &result->x) &&
   1.636 +            ReadParam(msg, iter, &result->y) &&
   1.637 +            ReadParam(msg, iter, &result->width) &&
   1.638 +            ReadParam(msg, iter, &result->height));
   1.639 +  }
   1.640 +};
   1.641 +
   1.642 +template<>
   1.643 +struct ParamTraits<mozilla::gfx::Margin>
   1.644 +{
   1.645 +  typedef mozilla::gfx::Margin paramType;
   1.646 +
   1.647 +  static void Write(Message* msg, const paramType& param)
   1.648 +  {
   1.649 +    WriteParam(msg, param.top);
   1.650 +    WriteParam(msg, param.right);
   1.651 +    WriteParam(msg, param.bottom);
   1.652 +    WriteParam(msg, param.left);
   1.653 +  }
   1.654 +
   1.655 +  static bool Read(const Message* msg, void** iter, paramType* result)
   1.656 +  {
   1.657 +    return (ReadParam(msg, iter, &result->top) &&
   1.658 +            ReadParam(msg, iter, &result->right) &&
   1.659 +            ReadParam(msg, iter, &result->bottom) &&
   1.660 +            ReadParam(msg, iter, &result->left));
   1.661 +  }
   1.662 +};
   1.663 +
   1.664 +template<class T>
   1.665 +struct ParamTraits< mozilla::gfx::MarginTyped<T> >
   1.666 +{
   1.667 +  typedef mozilla::gfx::MarginTyped<T> paramType;
   1.668 +
   1.669 +  static void Write(Message* msg, const paramType& param)
   1.670 +  {
   1.671 +    WriteParam(msg, param.top);
   1.672 +    WriteParam(msg, param.right);
   1.673 +    WriteParam(msg, param.bottom);
   1.674 +    WriteParam(msg, param.left);
   1.675 +  }
   1.676 +
   1.677 +  static bool Read(const Message* msg, void** iter, paramType* result)
   1.678 +  {
   1.679 +    return (ReadParam(msg, iter, &result->top) &&
   1.680 +            ReadParam(msg, iter, &result->right) &&
   1.681 +            ReadParam(msg, iter, &result->bottom) &&
   1.682 +            ReadParam(msg, iter, &result->left));
   1.683 +  }
   1.684 +};
   1.685 +
   1.686 +template<>
   1.687 +struct ParamTraits<nsRect>
   1.688 +{
   1.689 +  typedef nsRect paramType;
   1.690 +
   1.691 +  static void Write(Message* msg, const paramType& param)
   1.692 +  {
   1.693 +    WriteParam(msg, param.x);
   1.694 +    WriteParam(msg, param.y);
   1.695 +    WriteParam(msg, param.width);
   1.696 +    WriteParam(msg, param.height);
   1.697 +  }
   1.698 +
   1.699 +  static bool Read(const Message* msg, void** iter, paramType* result)
   1.700 +  {
   1.701 +    return (ReadParam(msg, iter, &result->x) &&
   1.702 +            ReadParam(msg, iter, &result->y) &&
   1.703 +            ReadParam(msg, iter, &result->width) &&
   1.704 +            ReadParam(msg, iter, &result->height));
   1.705 +  }
   1.706 +};
   1.707 +
   1.708 +template<>
   1.709 +struct ParamTraits<nsRegion>
   1.710 +  : RegionParamTraits<nsRegion, nsRect, nsRegionRectIterator>
   1.711 +{};
   1.712 +
   1.713 +template <>
   1.714 +struct ParamTraits<mozilla::layers::FrameMetrics>
   1.715 +{
   1.716 +  typedef mozilla::layers::FrameMetrics paramType;
   1.717 +
   1.718 +  static void Write(Message* aMsg, const paramType& aParam)
   1.719 +  {
   1.720 +    WriteParam(aMsg, aParam.mScrollableRect);
   1.721 +    WriteParam(aMsg, aParam.mViewport);
   1.722 +    WriteParam(aMsg, aParam.mScrollOffset);
   1.723 +    WriteParam(aMsg, aParam.mDisplayPort);
   1.724 +    WriteParam(aMsg, aParam.mDisplayPortMargins);
   1.725 +    WriteParam(aMsg, aParam.mUseDisplayPortMargins);
   1.726 +    WriteParam(aMsg, aParam.mCriticalDisplayPort);
   1.727 +    WriteParam(aMsg, aParam.mCompositionBounds);
   1.728 +    WriteParam(aMsg, aParam.mRootCompositionSize);
   1.729 +    WriteParam(aMsg, aParam.mScrollId);
   1.730 +    WriteParam(aMsg, aParam.mResolution);
   1.731 +    WriteParam(aMsg, aParam.mCumulativeResolution);
   1.732 +    WriteParam(aMsg, aParam.mZoom);
   1.733 +    WriteParam(aMsg, aParam.mDevPixelsPerCSSPixel);
   1.734 +    WriteParam(aMsg, aParam.mMayHaveTouchListeners);
   1.735 +    WriteParam(aMsg, aParam.mPresShellId);
   1.736 +    WriteParam(aMsg, aParam.mIsRoot);
   1.737 +    WriteParam(aMsg, aParam.mHasScrollgrab);
   1.738 +    WriteParam(aMsg, aParam.mUpdateScrollOffset);
   1.739 +    WriteParam(aMsg, aParam.mScrollGeneration);
   1.740 +    WriteParam(aMsg, aParam.mContentDescription);
   1.741 +    WriteParam(aMsg, aParam.mTransformScale);
   1.742 +  }
   1.743 +
   1.744 +  static bool Read(const Message* aMsg, void** aIter, paramType* aResult)
   1.745 +  {
   1.746 +    return (ReadParam(aMsg, aIter, &aResult->mScrollableRect) &&
   1.747 +            ReadParam(aMsg, aIter, &aResult->mViewport) &&
   1.748 +            ReadParam(aMsg, aIter, &aResult->mScrollOffset) &&
   1.749 +            ReadParam(aMsg, aIter, &aResult->mDisplayPort) &&
   1.750 +            ReadParam(aMsg, aIter, &aResult->mDisplayPortMargins) &&
   1.751 +            ReadParam(aMsg, aIter, &aResult->mUseDisplayPortMargins) &&
   1.752 +            ReadParam(aMsg, aIter, &aResult->mCriticalDisplayPort) &&
   1.753 +            ReadParam(aMsg, aIter, &aResult->mCompositionBounds) &&
   1.754 +            ReadParam(aMsg, aIter, &aResult->mRootCompositionSize) &&
   1.755 +            ReadParam(aMsg, aIter, &aResult->mScrollId) &&
   1.756 +            ReadParam(aMsg, aIter, &aResult->mResolution) &&
   1.757 +            ReadParam(aMsg, aIter, &aResult->mCumulativeResolution) &&
   1.758 +            ReadParam(aMsg, aIter, &aResult->mZoom) &&
   1.759 +            ReadParam(aMsg, aIter, &aResult->mDevPixelsPerCSSPixel) &&
   1.760 +            ReadParam(aMsg, aIter, &aResult->mMayHaveTouchListeners) &&
   1.761 +            ReadParam(aMsg, aIter, &aResult->mPresShellId) &&
   1.762 +            ReadParam(aMsg, aIter, &aResult->mIsRoot) &&
   1.763 +            ReadParam(aMsg, aIter, &aResult->mHasScrollgrab) &&
   1.764 +            ReadParam(aMsg, aIter, &aResult->mUpdateScrollOffset) &&
   1.765 +            ReadParam(aMsg, aIter, &aResult->mScrollGeneration) &&
   1.766 +            ReadParam(aMsg, aIter, &aResult->mContentDescription) &&
   1.767 +            ReadParam(aMsg, aIter, &aResult->mTransformScale));
   1.768 +  }
   1.769 +};
   1.770 +
   1.771 +template<>
   1.772 +struct ParamTraits<mozilla::layers::TextureFactoryIdentifier>
   1.773 +{
   1.774 +  typedef mozilla::layers::TextureFactoryIdentifier paramType;
   1.775 +
   1.776 +  static void Write(Message* aMsg, const paramType& aParam)
   1.777 +  {
   1.778 +    WriteParam(aMsg, aParam.mParentBackend);
   1.779 +    WriteParam(aMsg, aParam.mMaxTextureSize);
   1.780 +    WriteParam(aMsg, aParam.mSupportsTextureBlitting);
   1.781 +    WriteParam(aMsg, aParam.mSupportsPartialUploads);
   1.782 +  }
   1.783 +
   1.784 +  static bool Read(const Message* aMsg, void** aIter, paramType* aResult)
   1.785 +  {
   1.786 +    return ReadParam(aMsg, aIter, &aResult->mParentBackend) &&
   1.787 +           ReadParam(aMsg, aIter, &aResult->mMaxTextureSize) &&
   1.788 +           ReadParam(aMsg, aIter, &aResult->mSupportsTextureBlitting) &&
   1.789 +           ReadParam(aMsg, aIter, &aResult->mSupportsPartialUploads);
   1.790 +  }
   1.791 +};
   1.792 +
   1.793 +template<>
   1.794 +struct ParamTraits<mozilla::layers::TextureInfo>
   1.795 +{
   1.796 +  typedef mozilla::layers::TextureInfo paramType;
   1.797 +  
   1.798 +  static void Write(Message* aMsg, const paramType& aParam)
   1.799 +  {
   1.800 +    WriteParam(aMsg, aParam.mCompositableType);
   1.801 +    WriteParam(aMsg, aParam.mDeprecatedTextureHostFlags);
   1.802 +    WriteParam(aMsg, aParam.mTextureFlags);
   1.803 +  }
   1.804 +
   1.805 +  static bool Read(const Message* aMsg, void** aIter, paramType* aResult)
   1.806 +  {
   1.807 +    return ReadParam(aMsg, aIter, &aResult->mCompositableType) &&
   1.808 +           ReadParam(aMsg, aIter, &aResult->mDeprecatedTextureHostFlags) &&
   1.809 +           ReadParam(aMsg, aIter, &aResult->mTextureFlags);
   1.810 +  }
   1.811 +};
   1.812 +
   1.813 +template <>
   1.814 +struct ParamTraits<mozilla::layers::CompositableType>
   1.815 +  : public ContiguousEnumSerializer<
   1.816 +             mozilla::layers::CompositableType,
   1.817 +             mozilla::layers::BUFFER_UNKNOWN,
   1.818 +             mozilla::layers::BUFFER_COUNT>
   1.819 +{};
   1.820 +
   1.821 +template <>
   1.822 +struct ParamTraits<mozilla::gfx::SurfaceFormat>
   1.823 +  : public ContiguousTypedEnumSerializer<
   1.824 +             mozilla::gfx::SurfaceFormat,
   1.825 +             mozilla::gfx::SurfaceFormat::B8G8R8A8,
   1.826 +             mozilla::gfx::SurfaceFormat::UNKNOWN>
   1.827 +{};
   1.828 +
   1.829 +template <>
   1.830 +struct ParamTraits<mozilla::layers::ScrollableLayerGuid>
   1.831 +{
   1.832 +  typedef mozilla::layers::ScrollableLayerGuid paramType;
   1.833 +
   1.834 +  static void Write(Message* aMsg, const paramType& aParam)
   1.835 +  {
   1.836 +    WriteParam(aMsg, aParam.mLayersId);
   1.837 +    WriteParam(aMsg, aParam.mPresShellId);
   1.838 +    WriteParam(aMsg, aParam.mScrollId);
   1.839 +  }
   1.840 +
   1.841 +  static bool Read(const Message* aMsg, void** aIter, paramType* aResult)
   1.842 +  {
   1.843 +    return (ReadParam(aMsg, aIter, &aResult->mLayersId) &&
   1.844 +            ReadParam(aMsg, aIter, &aResult->mPresShellId) &&
   1.845 +            ReadParam(aMsg, aIter, &aResult->mScrollId));
   1.846 +  }
   1.847 +};
   1.848 +
   1.849 +template <>
   1.850 +struct ParamTraits<mozilla::layers::ZoomConstraints>
   1.851 +{
   1.852 +  typedef mozilla::layers::ZoomConstraints paramType;
   1.853 +
   1.854 +  static void Write(Message* aMsg, const paramType& aParam)
   1.855 +  {
   1.856 +    WriteParam(aMsg, aParam.mAllowZoom);
   1.857 +    WriteParam(aMsg, aParam.mAllowDoubleTapZoom);
   1.858 +    WriteParam(aMsg, aParam.mMinZoom);
   1.859 +    WriteParam(aMsg, aParam.mMaxZoom);
   1.860 +  }
   1.861 +
   1.862 +  static bool Read(const Message* aMsg, void** aIter, paramType* aResult)
   1.863 +  {
   1.864 +    return (ReadParam(aMsg, aIter, &aResult->mAllowZoom) &&
   1.865 +            ReadParam(aMsg, aIter, &aResult->mAllowDoubleTapZoom) &&
   1.866 +            ReadParam(aMsg, aIter, &aResult->mMinZoom) &&
   1.867 +            ReadParam(aMsg, aIter, &aResult->mMaxZoom));
   1.868 +  }
   1.869 +};
   1.870 +
   1.871 +template <>
   1.872 +struct ParamTraits<mozilla::layers::EventRegions>
   1.873 +{
   1.874 +  typedef mozilla::layers::EventRegions paramType;
   1.875 +
   1.876 +  static void Write(Message* aMsg, const paramType& aParam)
   1.877 +  {
   1.878 +    WriteParam(aMsg, aParam.mHitRegion);
   1.879 +    WriteParam(aMsg, aParam.mDispatchToContentHitRegion);
   1.880 +  }
   1.881 +
   1.882 +  static bool Read(const Message* aMsg, void** aIter, paramType* aResult)
   1.883 +  {
   1.884 +    return (ReadParam(aMsg, aIter, &aResult->mHitRegion) &&
   1.885 +            ReadParam(aMsg, aIter, &aResult->mDispatchToContentHitRegion));
   1.886 +  }
   1.887 +};
   1.888 +
   1.889 +struct MessageAndAttributeMap
   1.890 +{
   1.891 +  Message* msg;
   1.892 +  const mozilla::gfx::AttributeMap& map;
   1.893 +};
   1.894 +
   1.895 +static bool
   1.896 +WriteAttribute(mozilla::gfx::AttributeName aName,
   1.897 +               mozilla::gfx::AttributeType aType,
   1.898 +               void* aUserData)
   1.899 +{
   1.900 +  MessageAndAttributeMap* msgAndMap =
   1.901 +    static_cast<MessageAndAttributeMap*>(aUserData);
   1.902 +
   1.903 +  WriteParam(msgAndMap->msg, aType);
   1.904 +  WriteParam(msgAndMap->msg, aName);
   1.905 +
   1.906 +  switch (aType) {
   1.907 +
   1.908 +#define HANDLE_TYPE(typeName)                                          \
   1.909 +    case mozilla::gfx::AttributeType::e##typeName:                     \
   1.910 +      WriteParam(msgAndMap->msg, msgAndMap->map.Get##typeName(aName)); \
   1.911 +      break;
   1.912 +
   1.913 +    HANDLE_TYPE(Bool)
   1.914 +    HANDLE_TYPE(Uint)
   1.915 +    HANDLE_TYPE(Float)
   1.916 +    HANDLE_TYPE(Size)
   1.917 +    HANDLE_TYPE(IntSize)
   1.918 +    HANDLE_TYPE(IntPoint)
   1.919 +    HANDLE_TYPE(Matrix)
   1.920 +    HANDLE_TYPE(Matrix5x4)
   1.921 +    HANDLE_TYPE(Point3D)
   1.922 +    HANDLE_TYPE(Color)
   1.923 +    HANDLE_TYPE(AttributeMap)
   1.924 +    HANDLE_TYPE(Floats)
   1.925 +
   1.926 +#undef HANDLE_TYPE
   1.927 +
   1.928 +    default:
   1.929 +      MOZ_CRASH("unhandled attribute type");
   1.930 +  }
   1.931 +  return true;
   1.932 +}
   1.933 +
   1.934 +template <>
   1.935 +struct ParamTraits<mozilla::gfx::AttributeMap>
   1.936 +{
   1.937 +  typedef mozilla::gfx::AttributeMap paramType;
   1.938 +
   1.939 +  static void Write(Message* aMsg, const paramType& aParam)
   1.940 +  {
   1.941 +    WriteParam(aMsg, aParam.Count());
   1.942 +    MessageAndAttributeMap msgAndMap = { aMsg, aParam };
   1.943 +    aParam.EnumerateRead(WriteAttribute, &msgAndMap);
   1.944 +  }
   1.945 +
   1.946 +  static bool Read(const Message* aMsg, void** aIter, paramType* aResult)
   1.947 +  {
   1.948 +    uint32_t count;
   1.949 +    if (!ReadParam(aMsg, aIter, &count)) {
   1.950 +      return false;
   1.951 +    }
   1.952 +    for (uint32_t i = 0; i < count; i++) {
   1.953 +      mozilla::gfx::AttributeType type;
   1.954 +      if (!ReadParam(aMsg, aIter, &type)) {
   1.955 +        return false;
   1.956 +      }
   1.957 +      mozilla::gfx::AttributeName name;
   1.958 +      if (!ReadParam(aMsg, aIter, &name)) {
   1.959 +        return false;
   1.960 +      }
   1.961 +      switch (type) {
   1.962 +
   1.963 +#define HANDLE_TYPE(type, typeName)                                    \
   1.964 +        case mozilla::gfx::AttributeType::e##typeName:                 \
   1.965 +        {                                                              \
   1.966 +          type value;                                                  \
   1.967 +          if (!ReadParam(aMsg, aIter, &value)) {                       \
   1.968 +            return false;                                              \
   1.969 +          }                                                            \
   1.970 +          aResult->Set(name, value);                                   \
   1.971 +        }
   1.972 +
   1.973 +        HANDLE_TYPE(bool, Bool)
   1.974 +        HANDLE_TYPE(uint32_t, Uint)
   1.975 +        HANDLE_TYPE(float, Float)
   1.976 +        HANDLE_TYPE(mozilla::gfx::Size, Size)
   1.977 +        HANDLE_TYPE(mozilla::gfx::IntSize, IntSize)
   1.978 +        HANDLE_TYPE(mozilla::gfx::IntPoint, IntPoint)
   1.979 +        HANDLE_TYPE(mozilla::gfx::Matrix, Matrix)
   1.980 +        HANDLE_TYPE(mozilla::gfx::Matrix5x4, Matrix5x4)
   1.981 +        HANDLE_TYPE(mozilla::gfx::Point3D, Point3D)
   1.982 +        HANDLE_TYPE(mozilla::gfx::Color, Color)
   1.983 +        HANDLE_TYPE(mozilla::gfx::AttributeMap, AttributeMap)
   1.984 +
   1.985 +#undef HANDLE_TYPE
   1.986 +
   1.987 +        case mozilla::gfx::AttributeType::eFloats:
   1.988 +        {
   1.989 +          nsTArray<float> value;
   1.990 +          if (!ReadParam(aMsg, aIter, &value)) {
   1.991 +            return false;
   1.992 +          }
   1.993 +          aResult->Set(name, &value[0], value.Length());
   1.994 +          break;
   1.995 +        }
   1.996 +        default:
   1.997 +          MOZ_CRASH("unhandled attribute type");
   1.998 +      }
   1.999 +    }
  1.1000 +    return true;
  1.1001 +  }
  1.1002 +};
  1.1003 +
  1.1004 +template <>
  1.1005 +struct ParamTraits<mozilla::gfx::FilterPrimitiveDescription>
  1.1006 +{
  1.1007 +  typedef mozilla::gfx::FilterPrimitiveDescription paramType;
  1.1008 +
  1.1009 +  static void Write(Message* aMsg, const paramType& aParam)
  1.1010 +  {
  1.1011 +    WriteParam(aMsg, aParam.Type());
  1.1012 +    WriteParam(aMsg, aParam.PrimitiveSubregion());
  1.1013 +    WriteParam(aMsg, aParam.IsTainted());
  1.1014 +    WriteParam(aMsg, aParam.OutputColorSpace());
  1.1015 +    WriteParam(aMsg, aParam.NumberOfInputs());
  1.1016 +    for (size_t i = 0; i < aParam.NumberOfInputs(); i++) {
  1.1017 +      WriteParam(aMsg, aParam.InputPrimitiveIndex(i));
  1.1018 +      WriteParam(aMsg, aParam.InputColorSpace(i));
  1.1019 +    }
  1.1020 +    WriteParam(aMsg, aParam.Attributes());
  1.1021 +  }
  1.1022 +
  1.1023 +  static bool Read(const Message* aMsg, void** aIter, paramType* aResult)
  1.1024 +  {
  1.1025 +    mozilla::gfx::PrimitiveType type;
  1.1026 +    mozilla::gfx::IntRect primitiveSubregion;
  1.1027 +    bool isTainted = false;
  1.1028 +    mozilla::gfx::ColorSpace outputColorSpace;
  1.1029 +    size_t numberOfInputs = 0;
  1.1030 +    if (!ReadParam(aMsg, aIter, &type) ||
  1.1031 +        !ReadParam(aMsg, aIter, &primitiveSubregion) ||
  1.1032 +        !ReadParam(aMsg, aIter, &isTainted) ||
  1.1033 +        !ReadParam(aMsg, aIter, &outputColorSpace) ||
  1.1034 +        !ReadParam(aMsg, aIter, &numberOfInputs)) {
  1.1035 +      return false;
  1.1036 +    }
  1.1037 +
  1.1038 +    aResult->SetType(type);
  1.1039 +    aResult->SetPrimitiveSubregion(primitiveSubregion);
  1.1040 +    aResult->SetIsTainted(isTainted);
  1.1041 +    aResult->SetOutputColorSpace(outputColorSpace);
  1.1042 +
  1.1043 +    for (size_t i = 0; i < numberOfInputs; i++) {
  1.1044 +      int32_t inputPrimitiveIndex = 0;
  1.1045 +      mozilla::gfx::ColorSpace inputColorSpace;
  1.1046 +      if (!ReadParam(aMsg, aIter, &inputPrimitiveIndex) ||
  1.1047 +          !ReadParam(aMsg, aIter, &inputColorSpace)) {
  1.1048 +        return false;
  1.1049 +      }
  1.1050 +      aResult->SetInputPrimitive(i, inputPrimitiveIndex);
  1.1051 +      aResult->SetInputColorSpace(i, inputColorSpace);
  1.1052 +    }
  1.1053 +
  1.1054 +    return ReadParam(aMsg, aIter, &aResult->Attributes());
  1.1055 +  }
  1.1056 +};
  1.1057 +
  1.1058 +template <>
  1.1059 +struct ParamTraits<mozilla::gfx::FilterDescription>
  1.1060 +{
  1.1061 +  typedef mozilla::gfx::FilterDescription paramType;
  1.1062 +
  1.1063 +  static void Write(Message* aMsg, const paramType& aParam)
  1.1064 +  {
  1.1065 +    WriteParam(aMsg, aParam.mFilterSpaceBounds);
  1.1066 +    WriteParam(aMsg, aParam.mPrimitives);
  1.1067 +  }
  1.1068 +
  1.1069 +  static bool Read(const Message* aMsg, void** aIter, paramType* aResult)
  1.1070 +  {
  1.1071 +    return (ReadParam(aMsg, aIter, &aResult->mFilterSpaceBounds) &&
  1.1072 +            ReadParam(aMsg, aIter, &aResult->mPrimitives));
  1.1073 +  }
  1.1074 +};
  1.1075 +
  1.1076 +typedef mozilla::layers::GeckoContentController::APZStateChange APZStateChange;
  1.1077 +
  1.1078 +template <>
  1.1079 +struct ParamTraits<APZStateChange>
  1.1080 +  : public ContiguousTypedEnumSerializer<
  1.1081 +             APZStateChange,
  1.1082 +             APZStateChange::TransformBegin,
  1.1083 +             APZStateChange::APZStateChangeSentinel>
  1.1084 +{};
  1.1085 +
  1.1086 +} /* namespace IPC */
  1.1087 +
  1.1088 +#endif /* __GFXMESSAGEUTILS_H__ */

mercurial