gfx/ipc/GfxMessageUtils.h

Fri, 16 Jan 2015 18:13:44 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Fri, 16 Jan 2015 18:13:44 +0100
branch
TOR_BUG_9701
changeset 14
925c144e1f1f
permissions
-rw-r--r--

Integrate suggestion from review to improve consistency with existing code.

michael@0 1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
michael@0 2 /* vim: set sw=2 ts=8 et tw=80 : */
michael@0 3 /* This Source Code Form is subject to the terms of the Mozilla Public
michael@0 4 * License, v. 2.0. If a copy of the MPL was not distributed with this
michael@0 5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
michael@0 6
michael@0 7 #ifndef __GFXMESSAGEUTILS_H__
michael@0 8 #define __GFXMESSAGEUTILS_H__
michael@0 9
michael@0 10 #include "base/process_util.h"
michael@0 11 #include "chrome/common/ipc_message_utils.h"
michael@0 12 #include "ipc/IPCMessageUtils.h"
michael@0 13
michael@0 14 #include <stdint.h>
michael@0 15
michael@0 16 #include "gfx3DMatrix.h"
michael@0 17 #include "gfxColor.h"
michael@0 18 #include "mozilla/gfx/Matrix.h"
michael@0 19 #include "GraphicsFilter.h"
michael@0 20 #include "gfxPoint.h"
michael@0 21 #include "gfxRect.h"
michael@0 22 #include "nsRect.h"
michael@0 23 #include "nsRegion.h"
michael@0 24 #include "gfxTypes.h"
michael@0 25 #include "mozilla/layers/LayersTypes.h"
michael@0 26 #include "mozilla/layers/CompositorTypes.h"
michael@0 27 #include "FrameMetrics.h"
michael@0 28 #include "FilterSupport.h"
michael@0 29 #include "mozilla/layers/GeckoContentController.h"
michael@0 30
michael@0 31 #ifdef _MSC_VER
michael@0 32 #pragma warning( disable : 4800 )
michael@0 33 #endif
michael@0 34
michael@0 35 namespace mozilla {
michael@0 36
michael@0 37 typedef gfxImageFormat PixelFormat;
michael@0 38 #if defined(MOZ_HAVE_CXX11_STRONG_ENUMS)
michael@0 39 typedef ::GraphicsFilter GraphicsFilterType;
michael@0 40 #else
michael@0 41 // If we don't have support for enum classes, then we need to use the actual
michael@0 42 // enum type here instead of the simulated enum class.
michael@0 43 typedef GraphicsFilter::Enum GraphicsFilterType;
michael@0 44 #endif
michael@0 45
michael@0 46 } // namespace mozilla
michael@0 47
michael@0 48 namespace IPC {
michael@0 49
michael@0 50 template<>
michael@0 51 struct ParamTraits<mozilla::gfx::Matrix>
michael@0 52 {
michael@0 53 typedef mozilla::gfx::Matrix paramType;
michael@0 54
michael@0 55 static void Write(Message* aMsg, const paramType& aParam)
michael@0 56 {
michael@0 57 WriteParam(aMsg, aParam._11);
michael@0 58 WriteParam(aMsg, aParam._12);
michael@0 59 WriteParam(aMsg, aParam._21);
michael@0 60 WriteParam(aMsg, aParam._22);
michael@0 61 WriteParam(aMsg, aParam._31);
michael@0 62 WriteParam(aMsg, aParam._32);
michael@0 63 }
michael@0 64
michael@0 65 static bool Read(const Message* aMsg, void** aIter, paramType* aResult)
michael@0 66 {
michael@0 67 if (ReadParam(aMsg, aIter, &aResult->_11) &&
michael@0 68 ReadParam(aMsg, aIter, &aResult->_12) &&
michael@0 69 ReadParam(aMsg, aIter, &aResult->_21) &&
michael@0 70 ReadParam(aMsg, aIter, &aResult->_22) &&
michael@0 71 ReadParam(aMsg, aIter, &aResult->_31) &&
michael@0 72 ReadParam(aMsg, aIter, &aResult->_32))
michael@0 73 return true;
michael@0 74
michael@0 75 return false;
michael@0 76 }
michael@0 77
michael@0 78 static void Log(const paramType& aParam, std::wstring* aLog)
michael@0 79 {
michael@0 80 aLog->append(StringPrintf(L"[[%g %g] [%g %g] [%g %g]]", aParam._11, aParam._12, aParam._21, aParam._22,
michael@0 81 aParam._31, aParam._32));
michael@0 82 }
michael@0 83 };
michael@0 84
michael@0 85 template<>
michael@0 86 struct ParamTraits<mozilla::gfx::Matrix4x4>
michael@0 87 {
michael@0 88 typedef mozilla::gfx::Matrix4x4 paramType;
michael@0 89
michael@0 90 static void Write(Message* msg, const paramType& param)
michael@0 91 {
michael@0 92 #define Wr(_f) WriteParam(msg, param. _f)
michael@0 93 Wr(_11); Wr(_12); Wr(_13); Wr(_14);
michael@0 94 Wr(_21); Wr(_22); Wr(_23); Wr(_24);
michael@0 95 Wr(_31); Wr(_32); Wr(_33); Wr(_34);
michael@0 96 Wr(_41); Wr(_42); Wr(_43); Wr(_44);
michael@0 97 #undef Wr
michael@0 98 }
michael@0 99
michael@0 100 static bool Read(const Message* msg, void** iter, paramType* result)
michael@0 101 {
michael@0 102 #define Rd(_f) ReadParam(msg, iter, &result-> _f)
michael@0 103 return (Rd(_11) && Rd(_12) && Rd(_13) && Rd(_14) &&
michael@0 104 Rd(_21) && Rd(_22) && Rd(_23) && Rd(_24) &&
michael@0 105 Rd(_31) && Rd(_32) && Rd(_33) && Rd(_34) &&
michael@0 106 Rd(_41) && Rd(_42) && Rd(_43) && Rd(_44));
michael@0 107 #undef Rd
michael@0 108 }
michael@0 109 };
michael@0 110
michael@0 111 template<>
michael@0 112 struct ParamTraits<mozilla::gfx::Matrix5x4>
michael@0 113 {
michael@0 114 typedef mozilla::gfx::Matrix5x4 paramType;
michael@0 115
michael@0 116 static void Write(Message* msg, const paramType& param)
michael@0 117 {
michael@0 118 #define Wr(_f) WriteParam(msg, param. _f)
michael@0 119 Wr(_11); Wr(_12); Wr(_13); Wr(_14);
michael@0 120 Wr(_21); Wr(_22); Wr(_23); Wr(_24);
michael@0 121 Wr(_31); Wr(_32); Wr(_33); Wr(_34);
michael@0 122 Wr(_41); Wr(_42); Wr(_43); Wr(_44);
michael@0 123 Wr(_51); Wr(_52); Wr(_53); Wr(_54);
michael@0 124 #undef Wr
michael@0 125 }
michael@0 126
michael@0 127 static bool Read(const Message* msg, void** iter, paramType* result)
michael@0 128 {
michael@0 129 #define Rd(_f) ReadParam(msg, iter, &result-> _f)
michael@0 130 return (Rd(_11) && Rd(_12) && Rd(_13) && Rd(_14) &&
michael@0 131 Rd(_21) && Rd(_22) && Rd(_23) && Rd(_24) &&
michael@0 132 Rd(_31) && Rd(_32) && Rd(_33) && Rd(_34) &&
michael@0 133 Rd(_41) && Rd(_42) && Rd(_43) && Rd(_44) &&
michael@0 134 Rd(_51) && Rd(_52) && Rd(_53) && Rd(_54));
michael@0 135 #undef Rd
michael@0 136 }
michael@0 137 };
michael@0 138
michael@0 139 template<>
michael@0 140 struct ParamTraits<gfxPoint>
michael@0 141 {
michael@0 142 typedef gfxPoint paramType;
michael@0 143
michael@0 144 static void Write(Message* aMsg, const paramType& aParam)
michael@0 145 {
michael@0 146 WriteParam(aMsg, aParam.x);
michael@0 147 WriteParam(aMsg, aParam.y);
michael@0 148 }
michael@0 149
michael@0 150 static bool Read(const Message* aMsg, void** aIter, paramType* aResult)
michael@0 151 {
michael@0 152 return (ReadParam(aMsg, aIter, &aResult->x) &&
michael@0 153 ReadParam(aMsg, aIter, &aResult->y));
michael@0 154 }
michael@0 155 };
michael@0 156
michael@0 157 template<>
michael@0 158 struct ParamTraits<gfxPoint3D>
michael@0 159 {
michael@0 160 typedef gfxPoint3D paramType;
michael@0 161
michael@0 162 static void Write(Message* aMsg, const paramType& aParam)
michael@0 163 {
michael@0 164 WriteParam(aMsg, aParam.x);
michael@0 165 WriteParam(aMsg, aParam.y);
michael@0 166 WriteParam(aMsg, aParam.z);
michael@0 167 }
michael@0 168
michael@0 169 static bool Read(const Message* aMsg, void** aIter, paramType* aResult)
michael@0 170 {
michael@0 171 return (ReadParam(aMsg, aIter, &aResult->x) &&
michael@0 172 ReadParam(aMsg, aIter, &aResult->y) &&
michael@0 173 ReadParam(aMsg, aIter, &aResult->z));
michael@0 174 }
michael@0 175 };
michael@0 176
michael@0 177 template<>
michael@0 178 struct ParamTraits<gfxSize>
michael@0 179 {
michael@0 180 typedef gfxSize paramType;
michael@0 181
michael@0 182 static void Write(Message* aMsg, const paramType& aParam)
michael@0 183 {
michael@0 184 WriteParam(aMsg, aParam.width);
michael@0 185 WriteParam(aMsg, aParam.height);
michael@0 186 }
michael@0 187
michael@0 188 static bool Read(const Message* aMsg, void** aIter, paramType* aResult)
michael@0 189 {
michael@0 190 if (ReadParam(aMsg, aIter, &aResult->width) &&
michael@0 191 ReadParam(aMsg, aIter, &aResult->height))
michael@0 192 return true;
michael@0 193
michael@0 194 return false;
michael@0 195 }
michael@0 196 };
michael@0 197
michael@0 198 template<>
michael@0 199 struct ParamTraits<gfxRect>
michael@0 200 {
michael@0 201 typedef gfxRect paramType;
michael@0 202
michael@0 203 static void Write(Message* aMsg, const paramType& aParam)
michael@0 204 {
michael@0 205 WriteParam(aMsg, aParam.x);
michael@0 206 WriteParam(aMsg, aParam.y);
michael@0 207 WriteParam(aMsg, aParam.width);
michael@0 208 WriteParam(aMsg, aParam.height);
michael@0 209 }
michael@0 210
michael@0 211 static bool Read(const Message* aMsg, void** aIter, paramType* aResult)
michael@0 212 {
michael@0 213 return ReadParam(aMsg, aIter, &aResult->x) &&
michael@0 214 ReadParam(aMsg, aIter, &aResult->y) &&
michael@0 215 ReadParam(aMsg, aIter, &aResult->width) &&
michael@0 216 ReadParam(aMsg, aIter, &aResult->height);
michael@0 217 }
michael@0 218 };
michael@0 219
michael@0 220 template<>
michael@0 221 struct ParamTraits<gfx3DMatrix>
michael@0 222 {
michael@0 223 typedef gfx3DMatrix paramType;
michael@0 224
michael@0 225 static void Write(Message* msg, const paramType& param)
michael@0 226 {
michael@0 227 #define Wr(_f) WriteParam(msg, param. _f)
michael@0 228 Wr(_11); Wr(_12); Wr(_13); Wr(_14);
michael@0 229 Wr(_21); Wr(_22); Wr(_23); Wr(_24);
michael@0 230 Wr(_31); Wr(_32); Wr(_33); Wr(_34);
michael@0 231 Wr(_41); Wr(_42); Wr(_43); Wr(_44);
michael@0 232 #undef Wr
michael@0 233 }
michael@0 234
michael@0 235 static bool Read(const Message* msg, void** iter, paramType* result)
michael@0 236 {
michael@0 237 #define Rd(_f) ReadParam(msg, iter, &result-> _f)
michael@0 238 return (Rd(_11) && Rd(_12) && Rd(_13) && Rd(_14) &&
michael@0 239 Rd(_21) && Rd(_22) && Rd(_23) && Rd(_24) &&
michael@0 240 Rd(_31) && Rd(_32) && Rd(_33) && Rd(_34) &&
michael@0 241 Rd(_41) && Rd(_42) && Rd(_43) && Rd(_44));
michael@0 242 #undef Rd
michael@0 243 }
michael@0 244 };
michael@0 245
michael@0 246 template <>
michael@0 247 struct ParamTraits<gfxContentType>
michael@0 248 : public ContiguousTypedEnumSerializer<
michael@0 249 gfxContentType,
michael@0 250 gfxContentType::COLOR,
michael@0 251 gfxContentType::SENTINEL>
michael@0 252 {};
michael@0 253
michael@0 254 template <>
michael@0 255 struct ParamTraits<gfxSurfaceType>
michael@0 256 : public ContiguousTypedEnumSerializer<
michael@0 257 gfxSurfaceType,
michael@0 258 gfxSurfaceType::Image,
michael@0 259 gfxSurfaceType::Max>
michael@0 260 {};
michael@0 261
michael@0 262 template <>
michael@0 263 struct ParamTraits<mozilla::GraphicsFilterType>
michael@0 264 : public ContiguousEnumSerializer<
michael@0 265 mozilla::GraphicsFilterType,
michael@0 266 GraphicsFilter::FILTER_FAST,
michael@0 267 GraphicsFilter::FILTER_SENTINEL>
michael@0 268 {};
michael@0 269
michael@0 270 template <>
michael@0 271 struct ParamTraits<mozilla::layers::LayersBackend>
michael@0 272 : public ContiguousTypedEnumSerializer<
michael@0 273 mozilla::layers::LayersBackend,
michael@0 274 mozilla::layers::LayersBackend::LAYERS_NONE,
michael@0 275 mozilla::layers::LayersBackend::LAYERS_LAST>
michael@0 276 {};
michael@0 277
michael@0 278 template <>
michael@0 279 struct ParamTraits<mozilla::layers::ScaleMode>
michael@0 280 : public ContiguousTypedEnumSerializer<
michael@0 281 mozilla::layers::ScaleMode,
michael@0 282 mozilla::layers::ScaleMode::SCALE_NONE,
michael@0 283 mozilla::layers::ScaleMode::SENTINEL>
michael@0 284 {};
michael@0 285
michael@0 286 template <>
michael@0 287 struct ParamTraits<gfxImageFormat>
michael@0 288 : public ContiguousTypedEnumSerializer<
michael@0 289 gfxImageFormat,
michael@0 290 gfxImageFormat::ARGB32,
michael@0 291 gfxImageFormat::Unknown>
michael@0 292 {};
michael@0 293
michael@0 294 template <>
michael@0 295 struct ParamTraits<mozilla::gfx::AttributeName>
michael@0 296 : public ContiguousEnumSerializer<
michael@0 297 mozilla::gfx::AttributeName,
michael@0 298 mozilla::gfx::eBlendBlendmode,
michael@0 299 mozilla::gfx::eLastAttributeName>
michael@0 300 {};
michael@0 301
michael@0 302 template <>
michael@0 303 struct ParamTraits<mozilla::gfx::AttributeType>
michael@0 304 : public ContiguousTypedEnumSerializer<
michael@0 305 mozilla::gfx::AttributeType,
michael@0 306 mozilla::gfx::AttributeType::eBool,
michael@0 307 mozilla::gfx::AttributeType::Max>
michael@0 308 {};
michael@0 309
michael@0 310 template <>
michael@0 311 struct ParamTraits<mozilla::gfx::PrimitiveType>
michael@0 312 : public ContiguousTypedEnumSerializer<
michael@0 313 mozilla::gfx::PrimitiveType,
michael@0 314 mozilla::gfx::PrimitiveType::Empty,
michael@0 315 mozilla::gfx::PrimitiveType::Max>
michael@0 316 {};
michael@0 317
michael@0 318 template <>
michael@0 319 struct ParamTraits<mozilla::gfx::ColorSpace>
michael@0 320 : public ContiguousTypedEnumSerializer<
michael@0 321 mozilla::gfx::ColorSpace,
michael@0 322 mozilla::gfx::ColorSpace::SRGB,
michael@0 323 mozilla::gfx::ColorSpace::Max>
michael@0 324 {};
michael@0 325
michael@0 326 /*
michael@0 327 template <>
michael@0 328 struct ParamTraits<mozilla::PixelFormat>
michael@0 329 : public EnumSerializer<mozilla::PixelFormat,
michael@0 330 gfxImageFormat::ARGB32,
michael@0 331 gfxImageFormat::Unknown>
michael@0 332 {};
michael@0 333 */
michael@0 334
michael@0 335 template<>
michael@0 336 struct ParamTraits<gfxRGBA>
michael@0 337 {
michael@0 338 typedef gfxRGBA paramType;
michael@0 339
michael@0 340 static void Write(Message* msg, const paramType& param)
michael@0 341 {
michael@0 342 WriteParam(msg, param.r);
michael@0 343 WriteParam(msg, param.g);
michael@0 344 WriteParam(msg, param.b);
michael@0 345 WriteParam(msg, param.a);
michael@0 346 }
michael@0 347
michael@0 348 static bool Read(const Message* msg, void** iter, paramType* result)
michael@0 349 {
michael@0 350 return (ReadParam(msg, iter, &result->r) &&
michael@0 351 ReadParam(msg, iter, &result->g) &&
michael@0 352 ReadParam(msg, iter, &result->b) &&
michael@0 353 ReadParam(msg, iter, &result->a));
michael@0 354 }
michael@0 355 };
michael@0 356
michael@0 357 template<>
michael@0 358 struct ParamTraits<mozilla::gfx::Color>
michael@0 359 {
michael@0 360 typedef mozilla::gfx::Color paramType;
michael@0 361
michael@0 362 static void Write(Message* msg, const paramType& param)
michael@0 363 {
michael@0 364 WriteParam(msg, param.r);
michael@0 365 WriteParam(msg, param.g);
michael@0 366 WriteParam(msg, param.b);
michael@0 367 WriteParam(msg, param.a);
michael@0 368 }
michael@0 369
michael@0 370 static bool Read(const Message* msg, void** iter, paramType* result)
michael@0 371 {
michael@0 372 return (ReadParam(msg, iter, &result->r) &&
michael@0 373 ReadParam(msg, iter, &result->g) &&
michael@0 374 ReadParam(msg, iter, &result->b) &&
michael@0 375 ReadParam(msg, iter, &result->a));
michael@0 376 }
michael@0 377 };
michael@0 378
michael@0 379 template<>
michael@0 380 struct ParamTraits<nsPoint>
michael@0 381 {
michael@0 382 typedef nsPoint paramType;
michael@0 383
michael@0 384 static void Write(Message* msg, const paramType& param)
michael@0 385 {
michael@0 386 WriteParam(msg, param.x);
michael@0 387 WriteParam(msg, param.y);
michael@0 388 }
michael@0 389
michael@0 390 static bool Read(const Message* msg, void** iter, paramType* result)
michael@0 391 {
michael@0 392 return (ReadParam(msg, iter, &result->x) &&
michael@0 393 ReadParam(msg, iter, &result->y));
michael@0 394 }
michael@0 395 };
michael@0 396
michael@0 397 template<>
michael@0 398 struct ParamTraits<nsIntPoint>
michael@0 399 {
michael@0 400 typedef nsIntPoint paramType;
michael@0 401
michael@0 402 static void Write(Message* msg, const paramType& param)
michael@0 403 {
michael@0 404 WriteParam(msg, param.x);
michael@0 405 WriteParam(msg, param.y);
michael@0 406 }
michael@0 407
michael@0 408 static bool Read(const Message* msg, void** iter, paramType* result)
michael@0 409 {
michael@0 410 return (ReadParam(msg, iter, &result->x) &&
michael@0 411 ReadParam(msg, iter, &result->y));
michael@0 412 }
michael@0 413 };
michael@0 414
michael@0 415 template<>
michael@0 416 struct ParamTraits<mozilla::gfx::IntSize>
michael@0 417 {
michael@0 418 typedef mozilla::gfx::IntSize paramType;
michael@0 419
michael@0 420 static void Write(Message* msg, const paramType& param)
michael@0 421 {
michael@0 422 WriteParam(msg, param.width);
michael@0 423 WriteParam(msg, param.height);
michael@0 424 }
michael@0 425
michael@0 426 static bool Read(const Message* msg, void** iter, paramType* result)
michael@0 427 {
michael@0 428 return (ReadParam(msg, iter, &result->width) &&
michael@0 429 ReadParam(msg, iter, &result->height));
michael@0 430 }
michael@0 431 };
michael@0 432
michael@0 433 template<>
michael@0 434 struct ParamTraits<nsIntRect>
michael@0 435 {
michael@0 436 typedef nsIntRect paramType;
michael@0 437
michael@0 438 static void Write(Message* msg, const paramType& param)
michael@0 439 {
michael@0 440 WriteParam(msg, param.x);
michael@0 441 WriteParam(msg, param.y);
michael@0 442 WriteParam(msg, param.width);
michael@0 443 WriteParam(msg, param.height);
michael@0 444 }
michael@0 445
michael@0 446 static bool Read(const Message* msg, void** iter, paramType* result)
michael@0 447 {
michael@0 448 return (ReadParam(msg, iter, &result->x) &&
michael@0 449 ReadParam(msg, iter, &result->y) &&
michael@0 450 ReadParam(msg, iter, &result->width) &&
michael@0 451 ReadParam(msg, iter, &result->height));
michael@0 452 }
michael@0 453 };
michael@0 454
michael@0 455 template<typename Region, typename Rect, typename Iter>
michael@0 456 struct RegionParamTraits
michael@0 457 {
michael@0 458 typedef Region paramType;
michael@0 459
michael@0 460 static void Write(Message* msg, const paramType& param)
michael@0 461 {
michael@0 462 Iter it(param);
michael@0 463 while (const Rect* r = it.Next())
michael@0 464 WriteParam(msg, *r);
michael@0 465 // empty rects are sentinel values because nsRegions will never
michael@0 466 // contain them
michael@0 467 WriteParam(msg, Rect());
michael@0 468 }
michael@0 469
michael@0 470 static bool Read(const Message* msg, void** iter, paramType* result)
michael@0 471 {
michael@0 472 Rect rect;
michael@0 473 while (ReadParam(msg, iter, &rect)) {
michael@0 474 if (rect.IsEmpty())
michael@0 475 return true;
michael@0 476 result->Or(*result, rect);
michael@0 477 }
michael@0 478 return false;
michael@0 479 }
michael@0 480 };
michael@0 481
michael@0 482 template<>
michael@0 483 struct ParamTraits<nsIntRegion>
michael@0 484 : RegionParamTraits<nsIntRegion, nsIntRect, nsIntRegionRectIterator>
michael@0 485 {};
michael@0 486
michael@0 487 template<>
michael@0 488 struct ParamTraits<nsIntSize>
michael@0 489 {
michael@0 490 typedef nsIntSize paramType;
michael@0 491
michael@0 492 static void Write(Message* msg, const paramType& param)
michael@0 493 {
michael@0 494 WriteParam(msg, param.width);
michael@0 495 WriteParam(msg, param.height);
michael@0 496 }
michael@0 497
michael@0 498 static bool Read(const Message* msg, void** iter, paramType* result)
michael@0 499 {
michael@0 500 return (ReadParam(msg, iter, &result->width) &&
michael@0 501 ReadParam(msg, iter, &result->height));
michael@0 502 }
michael@0 503 };
michael@0 504
michael@0 505 template<class T, class U>
michael@0 506 struct ParamTraits< mozilla::gfx::ScaleFactor<T, U> >
michael@0 507 {
michael@0 508 typedef mozilla::gfx::ScaleFactor<T, U> paramType;
michael@0 509
michael@0 510 static void Write(Message* msg, const paramType& param)
michael@0 511 {
michael@0 512 WriteParam(msg, param.scale);
michael@0 513 }
michael@0 514
michael@0 515 static bool Read(const Message* msg, void** iter, paramType* result)
michael@0 516 {
michael@0 517 return (ReadParam(msg, iter, &result->scale));
michael@0 518 }
michael@0 519 };
michael@0 520
michael@0 521 template<class T>
michael@0 522 struct ParamTraits< mozilla::gfx::PointTyped<T> >
michael@0 523 {
michael@0 524 typedef mozilla::gfx::PointTyped<T> paramType;
michael@0 525
michael@0 526 static void Write(Message* msg, const paramType& param)
michael@0 527 {
michael@0 528 WriteParam(msg, param.x);
michael@0 529 WriteParam(msg, param.y);
michael@0 530 }
michael@0 531
michael@0 532 static bool Read(const Message* msg, void** iter, paramType* result)
michael@0 533 {
michael@0 534 return (ReadParam(msg, iter, &result->x) &&
michael@0 535 ReadParam(msg, iter, &result->y));
michael@0 536 }
michael@0 537 };
michael@0 538
michael@0 539 template<class T>
michael@0 540 struct ParamTraits< mozilla::gfx::Point3DTyped<T> >
michael@0 541 {
michael@0 542 typedef mozilla::gfx::Point3DTyped<T> paramType;
michael@0 543
michael@0 544 static void Write(Message* msg, const paramType& param)
michael@0 545 {
michael@0 546 WriteParam(msg, param.x);
michael@0 547 WriteParam(msg, param.y);
michael@0 548 WriteParam(msg, param.z);
michael@0 549 }
michael@0 550
michael@0 551 static bool Read(const Message* msg, void** iter, paramType* result)
michael@0 552 {
michael@0 553 return (ReadParam(msg, iter, &result->x) &&
michael@0 554 ReadParam(msg, iter, &result->y) &&
michael@0 555 ReadParam(msg, iter, &result->z));
michael@0 556 }
michael@0 557 };
michael@0 558
michael@0 559 template<class T>
michael@0 560 struct ParamTraits< mozilla::gfx::IntPointTyped<T> >
michael@0 561 {
michael@0 562 typedef mozilla::gfx::IntPointTyped<T> paramType;
michael@0 563
michael@0 564 static void Write(Message* msg, const paramType& param)
michael@0 565 {
michael@0 566 WriteParam(msg, param.x);
michael@0 567 WriteParam(msg, param.y);
michael@0 568 }
michael@0 569
michael@0 570 static bool Read(const Message* msg, void** iter, paramType* result)
michael@0 571 {
michael@0 572 return (ReadParam(msg, iter, &result->x) &&
michael@0 573 ReadParam(msg, iter, &result->y));
michael@0 574 }
michael@0 575 };
michael@0 576
michael@0 577 template<class T>
michael@0 578 struct ParamTraits< mozilla::gfx::SizeTyped<T> >
michael@0 579 {
michael@0 580 typedef mozilla::gfx::SizeTyped<T> paramType;
michael@0 581
michael@0 582 static void Write(Message* msg, const paramType& param)
michael@0 583 {
michael@0 584 WriteParam(msg, param.width);
michael@0 585 WriteParam(msg, param.height);
michael@0 586 }
michael@0 587
michael@0 588 static bool Read(const Message* msg, void** iter, paramType* result)
michael@0 589 {
michael@0 590 return (ReadParam(msg, iter, &result->width) &&
michael@0 591 ReadParam(msg, iter, &result->height));
michael@0 592 }
michael@0 593 };
michael@0 594
michael@0 595 template<class T>
michael@0 596 struct ParamTraits< mozilla::gfx::RectTyped<T> >
michael@0 597 {
michael@0 598 typedef mozilla::gfx::RectTyped<T> paramType;
michael@0 599
michael@0 600 static void Write(Message* msg, const paramType& param)
michael@0 601 {
michael@0 602 WriteParam(msg, param.x);
michael@0 603 WriteParam(msg, param.y);
michael@0 604 WriteParam(msg, param.width);
michael@0 605 WriteParam(msg, param.height);
michael@0 606 }
michael@0 607
michael@0 608 static bool Read(const Message* msg, void** iter, paramType* result)
michael@0 609 {
michael@0 610 return (ReadParam(msg, iter, &result->x) &&
michael@0 611 ReadParam(msg, iter, &result->y) &&
michael@0 612 ReadParam(msg, iter, &result->width) &&
michael@0 613 ReadParam(msg, iter, &result->height));
michael@0 614 }
michael@0 615 };
michael@0 616
michael@0 617 template<class T>
michael@0 618 struct ParamTraits< mozilla::gfx::IntRectTyped<T> >
michael@0 619 {
michael@0 620 typedef mozilla::gfx::IntRectTyped<T> paramType;
michael@0 621
michael@0 622 static void Write(Message* msg, const paramType& param)
michael@0 623 {
michael@0 624 WriteParam(msg, param.x);
michael@0 625 WriteParam(msg, param.y);
michael@0 626 WriteParam(msg, param.width);
michael@0 627 WriteParam(msg, param.height);
michael@0 628 }
michael@0 629
michael@0 630 static bool Read(const Message* msg, void** iter, paramType* result)
michael@0 631 {
michael@0 632 return (ReadParam(msg, iter, &result->x) &&
michael@0 633 ReadParam(msg, iter, &result->y) &&
michael@0 634 ReadParam(msg, iter, &result->width) &&
michael@0 635 ReadParam(msg, iter, &result->height));
michael@0 636 }
michael@0 637 };
michael@0 638
michael@0 639 template<>
michael@0 640 struct ParamTraits<mozilla::gfx::Margin>
michael@0 641 {
michael@0 642 typedef mozilla::gfx::Margin paramType;
michael@0 643
michael@0 644 static void Write(Message* msg, const paramType& param)
michael@0 645 {
michael@0 646 WriteParam(msg, param.top);
michael@0 647 WriteParam(msg, param.right);
michael@0 648 WriteParam(msg, param.bottom);
michael@0 649 WriteParam(msg, param.left);
michael@0 650 }
michael@0 651
michael@0 652 static bool Read(const Message* msg, void** iter, paramType* result)
michael@0 653 {
michael@0 654 return (ReadParam(msg, iter, &result->top) &&
michael@0 655 ReadParam(msg, iter, &result->right) &&
michael@0 656 ReadParam(msg, iter, &result->bottom) &&
michael@0 657 ReadParam(msg, iter, &result->left));
michael@0 658 }
michael@0 659 };
michael@0 660
michael@0 661 template<class T>
michael@0 662 struct ParamTraits< mozilla::gfx::MarginTyped<T> >
michael@0 663 {
michael@0 664 typedef mozilla::gfx::MarginTyped<T> paramType;
michael@0 665
michael@0 666 static void Write(Message* msg, const paramType& param)
michael@0 667 {
michael@0 668 WriteParam(msg, param.top);
michael@0 669 WriteParam(msg, param.right);
michael@0 670 WriteParam(msg, param.bottom);
michael@0 671 WriteParam(msg, param.left);
michael@0 672 }
michael@0 673
michael@0 674 static bool Read(const Message* msg, void** iter, paramType* result)
michael@0 675 {
michael@0 676 return (ReadParam(msg, iter, &result->top) &&
michael@0 677 ReadParam(msg, iter, &result->right) &&
michael@0 678 ReadParam(msg, iter, &result->bottom) &&
michael@0 679 ReadParam(msg, iter, &result->left));
michael@0 680 }
michael@0 681 };
michael@0 682
michael@0 683 template<>
michael@0 684 struct ParamTraits<nsRect>
michael@0 685 {
michael@0 686 typedef nsRect paramType;
michael@0 687
michael@0 688 static void Write(Message* msg, const paramType& param)
michael@0 689 {
michael@0 690 WriteParam(msg, param.x);
michael@0 691 WriteParam(msg, param.y);
michael@0 692 WriteParam(msg, param.width);
michael@0 693 WriteParam(msg, param.height);
michael@0 694 }
michael@0 695
michael@0 696 static bool Read(const Message* msg, void** iter, paramType* result)
michael@0 697 {
michael@0 698 return (ReadParam(msg, iter, &result->x) &&
michael@0 699 ReadParam(msg, iter, &result->y) &&
michael@0 700 ReadParam(msg, iter, &result->width) &&
michael@0 701 ReadParam(msg, iter, &result->height));
michael@0 702 }
michael@0 703 };
michael@0 704
michael@0 705 template<>
michael@0 706 struct ParamTraits<nsRegion>
michael@0 707 : RegionParamTraits<nsRegion, nsRect, nsRegionRectIterator>
michael@0 708 {};
michael@0 709
michael@0 710 template <>
michael@0 711 struct ParamTraits<mozilla::layers::FrameMetrics>
michael@0 712 {
michael@0 713 typedef mozilla::layers::FrameMetrics paramType;
michael@0 714
michael@0 715 static void Write(Message* aMsg, const paramType& aParam)
michael@0 716 {
michael@0 717 WriteParam(aMsg, aParam.mScrollableRect);
michael@0 718 WriteParam(aMsg, aParam.mViewport);
michael@0 719 WriteParam(aMsg, aParam.mScrollOffset);
michael@0 720 WriteParam(aMsg, aParam.mDisplayPort);
michael@0 721 WriteParam(aMsg, aParam.mDisplayPortMargins);
michael@0 722 WriteParam(aMsg, aParam.mUseDisplayPortMargins);
michael@0 723 WriteParam(aMsg, aParam.mCriticalDisplayPort);
michael@0 724 WriteParam(aMsg, aParam.mCompositionBounds);
michael@0 725 WriteParam(aMsg, aParam.mRootCompositionSize);
michael@0 726 WriteParam(aMsg, aParam.mScrollId);
michael@0 727 WriteParam(aMsg, aParam.mResolution);
michael@0 728 WriteParam(aMsg, aParam.mCumulativeResolution);
michael@0 729 WriteParam(aMsg, aParam.mZoom);
michael@0 730 WriteParam(aMsg, aParam.mDevPixelsPerCSSPixel);
michael@0 731 WriteParam(aMsg, aParam.mMayHaveTouchListeners);
michael@0 732 WriteParam(aMsg, aParam.mPresShellId);
michael@0 733 WriteParam(aMsg, aParam.mIsRoot);
michael@0 734 WriteParam(aMsg, aParam.mHasScrollgrab);
michael@0 735 WriteParam(aMsg, aParam.mUpdateScrollOffset);
michael@0 736 WriteParam(aMsg, aParam.mScrollGeneration);
michael@0 737 WriteParam(aMsg, aParam.mContentDescription);
michael@0 738 WriteParam(aMsg, aParam.mTransformScale);
michael@0 739 }
michael@0 740
michael@0 741 static bool Read(const Message* aMsg, void** aIter, paramType* aResult)
michael@0 742 {
michael@0 743 return (ReadParam(aMsg, aIter, &aResult->mScrollableRect) &&
michael@0 744 ReadParam(aMsg, aIter, &aResult->mViewport) &&
michael@0 745 ReadParam(aMsg, aIter, &aResult->mScrollOffset) &&
michael@0 746 ReadParam(aMsg, aIter, &aResult->mDisplayPort) &&
michael@0 747 ReadParam(aMsg, aIter, &aResult->mDisplayPortMargins) &&
michael@0 748 ReadParam(aMsg, aIter, &aResult->mUseDisplayPortMargins) &&
michael@0 749 ReadParam(aMsg, aIter, &aResult->mCriticalDisplayPort) &&
michael@0 750 ReadParam(aMsg, aIter, &aResult->mCompositionBounds) &&
michael@0 751 ReadParam(aMsg, aIter, &aResult->mRootCompositionSize) &&
michael@0 752 ReadParam(aMsg, aIter, &aResult->mScrollId) &&
michael@0 753 ReadParam(aMsg, aIter, &aResult->mResolution) &&
michael@0 754 ReadParam(aMsg, aIter, &aResult->mCumulativeResolution) &&
michael@0 755 ReadParam(aMsg, aIter, &aResult->mZoom) &&
michael@0 756 ReadParam(aMsg, aIter, &aResult->mDevPixelsPerCSSPixel) &&
michael@0 757 ReadParam(aMsg, aIter, &aResult->mMayHaveTouchListeners) &&
michael@0 758 ReadParam(aMsg, aIter, &aResult->mPresShellId) &&
michael@0 759 ReadParam(aMsg, aIter, &aResult->mIsRoot) &&
michael@0 760 ReadParam(aMsg, aIter, &aResult->mHasScrollgrab) &&
michael@0 761 ReadParam(aMsg, aIter, &aResult->mUpdateScrollOffset) &&
michael@0 762 ReadParam(aMsg, aIter, &aResult->mScrollGeneration) &&
michael@0 763 ReadParam(aMsg, aIter, &aResult->mContentDescription) &&
michael@0 764 ReadParam(aMsg, aIter, &aResult->mTransformScale));
michael@0 765 }
michael@0 766 };
michael@0 767
michael@0 768 template<>
michael@0 769 struct ParamTraits<mozilla::layers::TextureFactoryIdentifier>
michael@0 770 {
michael@0 771 typedef mozilla::layers::TextureFactoryIdentifier paramType;
michael@0 772
michael@0 773 static void Write(Message* aMsg, const paramType& aParam)
michael@0 774 {
michael@0 775 WriteParam(aMsg, aParam.mParentBackend);
michael@0 776 WriteParam(aMsg, aParam.mMaxTextureSize);
michael@0 777 WriteParam(aMsg, aParam.mSupportsTextureBlitting);
michael@0 778 WriteParam(aMsg, aParam.mSupportsPartialUploads);
michael@0 779 }
michael@0 780
michael@0 781 static bool Read(const Message* aMsg, void** aIter, paramType* aResult)
michael@0 782 {
michael@0 783 return ReadParam(aMsg, aIter, &aResult->mParentBackend) &&
michael@0 784 ReadParam(aMsg, aIter, &aResult->mMaxTextureSize) &&
michael@0 785 ReadParam(aMsg, aIter, &aResult->mSupportsTextureBlitting) &&
michael@0 786 ReadParam(aMsg, aIter, &aResult->mSupportsPartialUploads);
michael@0 787 }
michael@0 788 };
michael@0 789
michael@0 790 template<>
michael@0 791 struct ParamTraits<mozilla::layers::TextureInfo>
michael@0 792 {
michael@0 793 typedef mozilla::layers::TextureInfo paramType;
michael@0 794
michael@0 795 static void Write(Message* aMsg, const paramType& aParam)
michael@0 796 {
michael@0 797 WriteParam(aMsg, aParam.mCompositableType);
michael@0 798 WriteParam(aMsg, aParam.mDeprecatedTextureHostFlags);
michael@0 799 WriteParam(aMsg, aParam.mTextureFlags);
michael@0 800 }
michael@0 801
michael@0 802 static bool Read(const Message* aMsg, void** aIter, paramType* aResult)
michael@0 803 {
michael@0 804 return ReadParam(aMsg, aIter, &aResult->mCompositableType) &&
michael@0 805 ReadParam(aMsg, aIter, &aResult->mDeprecatedTextureHostFlags) &&
michael@0 806 ReadParam(aMsg, aIter, &aResult->mTextureFlags);
michael@0 807 }
michael@0 808 };
michael@0 809
michael@0 810 template <>
michael@0 811 struct ParamTraits<mozilla::layers::CompositableType>
michael@0 812 : public ContiguousEnumSerializer<
michael@0 813 mozilla::layers::CompositableType,
michael@0 814 mozilla::layers::BUFFER_UNKNOWN,
michael@0 815 mozilla::layers::BUFFER_COUNT>
michael@0 816 {};
michael@0 817
michael@0 818 template <>
michael@0 819 struct ParamTraits<mozilla::gfx::SurfaceFormat>
michael@0 820 : public ContiguousTypedEnumSerializer<
michael@0 821 mozilla::gfx::SurfaceFormat,
michael@0 822 mozilla::gfx::SurfaceFormat::B8G8R8A8,
michael@0 823 mozilla::gfx::SurfaceFormat::UNKNOWN>
michael@0 824 {};
michael@0 825
michael@0 826 template <>
michael@0 827 struct ParamTraits<mozilla::layers::ScrollableLayerGuid>
michael@0 828 {
michael@0 829 typedef mozilla::layers::ScrollableLayerGuid paramType;
michael@0 830
michael@0 831 static void Write(Message* aMsg, const paramType& aParam)
michael@0 832 {
michael@0 833 WriteParam(aMsg, aParam.mLayersId);
michael@0 834 WriteParam(aMsg, aParam.mPresShellId);
michael@0 835 WriteParam(aMsg, aParam.mScrollId);
michael@0 836 }
michael@0 837
michael@0 838 static bool Read(const Message* aMsg, void** aIter, paramType* aResult)
michael@0 839 {
michael@0 840 return (ReadParam(aMsg, aIter, &aResult->mLayersId) &&
michael@0 841 ReadParam(aMsg, aIter, &aResult->mPresShellId) &&
michael@0 842 ReadParam(aMsg, aIter, &aResult->mScrollId));
michael@0 843 }
michael@0 844 };
michael@0 845
michael@0 846 template <>
michael@0 847 struct ParamTraits<mozilla::layers::ZoomConstraints>
michael@0 848 {
michael@0 849 typedef mozilla::layers::ZoomConstraints paramType;
michael@0 850
michael@0 851 static void Write(Message* aMsg, const paramType& aParam)
michael@0 852 {
michael@0 853 WriteParam(aMsg, aParam.mAllowZoom);
michael@0 854 WriteParam(aMsg, aParam.mAllowDoubleTapZoom);
michael@0 855 WriteParam(aMsg, aParam.mMinZoom);
michael@0 856 WriteParam(aMsg, aParam.mMaxZoom);
michael@0 857 }
michael@0 858
michael@0 859 static bool Read(const Message* aMsg, void** aIter, paramType* aResult)
michael@0 860 {
michael@0 861 return (ReadParam(aMsg, aIter, &aResult->mAllowZoom) &&
michael@0 862 ReadParam(aMsg, aIter, &aResult->mAllowDoubleTapZoom) &&
michael@0 863 ReadParam(aMsg, aIter, &aResult->mMinZoom) &&
michael@0 864 ReadParam(aMsg, aIter, &aResult->mMaxZoom));
michael@0 865 }
michael@0 866 };
michael@0 867
michael@0 868 template <>
michael@0 869 struct ParamTraits<mozilla::layers::EventRegions>
michael@0 870 {
michael@0 871 typedef mozilla::layers::EventRegions paramType;
michael@0 872
michael@0 873 static void Write(Message* aMsg, const paramType& aParam)
michael@0 874 {
michael@0 875 WriteParam(aMsg, aParam.mHitRegion);
michael@0 876 WriteParam(aMsg, aParam.mDispatchToContentHitRegion);
michael@0 877 }
michael@0 878
michael@0 879 static bool Read(const Message* aMsg, void** aIter, paramType* aResult)
michael@0 880 {
michael@0 881 return (ReadParam(aMsg, aIter, &aResult->mHitRegion) &&
michael@0 882 ReadParam(aMsg, aIter, &aResult->mDispatchToContentHitRegion));
michael@0 883 }
michael@0 884 };
michael@0 885
michael@0 886 struct MessageAndAttributeMap
michael@0 887 {
michael@0 888 Message* msg;
michael@0 889 const mozilla::gfx::AttributeMap& map;
michael@0 890 };
michael@0 891
michael@0 892 static bool
michael@0 893 WriteAttribute(mozilla::gfx::AttributeName aName,
michael@0 894 mozilla::gfx::AttributeType aType,
michael@0 895 void* aUserData)
michael@0 896 {
michael@0 897 MessageAndAttributeMap* msgAndMap =
michael@0 898 static_cast<MessageAndAttributeMap*>(aUserData);
michael@0 899
michael@0 900 WriteParam(msgAndMap->msg, aType);
michael@0 901 WriteParam(msgAndMap->msg, aName);
michael@0 902
michael@0 903 switch (aType) {
michael@0 904
michael@0 905 #define HANDLE_TYPE(typeName) \
michael@0 906 case mozilla::gfx::AttributeType::e##typeName: \
michael@0 907 WriteParam(msgAndMap->msg, msgAndMap->map.Get##typeName(aName)); \
michael@0 908 break;
michael@0 909
michael@0 910 HANDLE_TYPE(Bool)
michael@0 911 HANDLE_TYPE(Uint)
michael@0 912 HANDLE_TYPE(Float)
michael@0 913 HANDLE_TYPE(Size)
michael@0 914 HANDLE_TYPE(IntSize)
michael@0 915 HANDLE_TYPE(IntPoint)
michael@0 916 HANDLE_TYPE(Matrix)
michael@0 917 HANDLE_TYPE(Matrix5x4)
michael@0 918 HANDLE_TYPE(Point3D)
michael@0 919 HANDLE_TYPE(Color)
michael@0 920 HANDLE_TYPE(AttributeMap)
michael@0 921 HANDLE_TYPE(Floats)
michael@0 922
michael@0 923 #undef HANDLE_TYPE
michael@0 924
michael@0 925 default:
michael@0 926 MOZ_CRASH("unhandled attribute type");
michael@0 927 }
michael@0 928 return true;
michael@0 929 }
michael@0 930
michael@0 931 template <>
michael@0 932 struct ParamTraits<mozilla::gfx::AttributeMap>
michael@0 933 {
michael@0 934 typedef mozilla::gfx::AttributeMap paramType;
michael@0 935
michael@0 936 static void Write(Message* aMsg, const paramType& aParam)
michael@0 937 {
michael@0 938 WriteParam(aMsg, aParam.Count());
michael@0 939 MessageAndAttributeMap msgAndMap = { aMsg, aParam };
michael@0 940 aParam.EnumerateRead(WriteAttribute, &msgAndMap);
michael@0 941 }
michael@0 942
michael@0 943 static bool Read(const Message* aMsg, void** aIter, paramType* aResult)
michael@0 944 {
michael@0 945 uint32_t count;
michael@0 946 if (!ReadParam(aMsg, aIter, &count)) {
michael@0 947 return false;
michael@0 948 }
michael@0 949 for (uint32_t i = 0; i < count; i++) {
michael@0 950 mozilla::gfx::AttributeType type;
michael@0 951 if (!ReadParam(aMsg, aIter, &type)) {
michael@0 952 return false;
michael@0 953 }
michael@0 954 mozilla::gfx::AttributeName name;
michael@0 955 if (!ReadParam(aMsg, aIter, &name)) {
michael@0 956 return false;
michael@0 957 }
michael@0 958 switch (type) {
michael@0 959
michael@0 960 #define HANDLE_TYPE(type, typeName) \
michael@0 961 case mozilla::gfx::AttributeType::e##typeName: \
michael@0 962 { \
michael@0 963 type value; \
michael@0 964 if (!ReadParam(aMsg, aIter, &value)) { \
michael@0 965 return false; \
michael@0 966 } \
michael@0 967 aResult->Set(name, value); \
michael@0 968 }
michael@0 969
michael@0 970 HANDLE_TYPE(bool, Bool)
michael@0 971 HANDLE_TYPE(uint32_t, Uint)
michael@0 972 HANDLE_TYPE(float, Float)
michael@0 973 HANDLE_TYPE(mozilla::gfx::Size, Size)
michael@0 974 HANDLE_TYPE(mozilla::gfx::IntSize, IntSize)
michael@0 975 HANDLE_TYPE(mozilla::gfx::IntPoint, IntPoint)
michael@0 976 HANDLE_TYPE(mozilla::gfx::Matrix, Matrix)
michael@0 977 HANDLE_TYPE(mozilla::gfx::Matrix5x4, Matrix5x4)
michael@0 978 HANDLE_TYPE(mozilla::gfx::Point3D, Point3D)
michael@0 979 HANDLE_TYPE(mozilla::gfx::Color, Color)
michael@0 980 HANDLE_TYPE(mozilla::gfx::AttributeMap, AttributeMap)
michael@0 981
michael@0 982 #undef HANDLE_TYPE
michael@0 983
michael@0 984 case mozilla::gfx::AttributeType::eFloats:
michael@0 985 {
michael@0 986 nsTArray<float> value;
michael@0 987 if (!ReadParam(aMsg, aIter, &value)) {
michael@0 988 return false;
michael@0 989 }
michael@0 990 aResult->Set(name, &value[0], value.Length());
michael@0 991 break;
michael@0 992 }
michael@0 993 default:
michael@0 994 MOZ_CRASH("unhandled attribute type");
michael@0 995 }
michael@0 996 }
michael@0 997 return true;
michael@0 998 }
michael@0 999 };
michael@0 1000
michael@0 1001 template <>
michael@0 1002 struct ParamTraits<mozilla::gfx::FilterPrimitiveDescription>
michael@0 1003 {
michael@0 1004 typedef mozilla::gfx::FilterPrimitiveDescription paramType;
michael@0 1005
michael@0 1006 static void Write(Message* aMsg, const paramType& aParam)
michael@0 1007 {
michael@0 1008 WriteParam(aMsg, aParam.Type());
michael@0 1009 WriteParam(aMsg, aParam.PrimitiveSubregion());
michael@0 1010 WriteParam(aMsg, aParam.IsTainted());
michael@0 1011 WriteParam(aMsg, aParam.OutputColorSpace());
michael@0 1012 WriteParam(aMsg, aParam.NumberOfInputs());
michael@0 1013 for (size_t i = 0; i < aParam.NumberOfInputs(); i++) {
michael@0 1014 WriteParam(aMsg, aParam.InputPrimitiveIndex(i));
michael@0 1015 WriteParam(aMsg, aParam.InputColorSpace(i));
michael@0 1016 }
michael@0 1017 WriteParam(aMsg, aParam.Attributes());
michael@0 1018 }
michael@0 1019
michael@0 1020 static bool Read(const Message* aMsg, void** aIter, paramType* aResult)
michael@0 1021 {
michael@0 1022 mozilla::gfx::PrimitiveType type;
michael@0 1023 mozilla::gfx::IntRect primitiveSubregion;
michael@0 1024 bool isTainted = false;
michael@0 1025 mozilla::gfx::ColorSpace outputColorSpace;
michael@0 1026 size_t numberOfInputs = 0;
michael@0 1027 if (!ReadParam(aMsg, aIter, &type) ||
michael@0 1028 !ReadParam(aMsg, aIter, &primitiveSubregion) ||
michael@0 1029 !ReadParam(aMsg, aIter, &isTainted) ||
michael@0 1030 !ReadParam(aMsg, aIter, &outputColorSpace) ||
michael@0 1031 !ReadParam(aMsg, aIter, &numberOfInputs)) {
michael@0 1032 return false;
michael@0 1033 }
michael@0 1034
michael@0 1035 aResult->SetType(type);
michael@0 1036 aResult->SetPrimitiveSubregion(primitiveSubregion);
michael@0 1037 aResult->SetIsTainted(isTainted);
michael@0 1038 aResult->SetOutputColorSpace(outputColorSpace);
michael@0 1039
michael@0 1040 for (size_t i = 0; i < numberOfInputs; i++) {
michael@0 1041 int32_t inputPrimitiveIndex = 0;
michael@0 1042 mozilla::gfx::ColorSpace inputColorSpace;
michael@0 1043 if (!ReadParam(aMsg, aIter, &inputPrimitiveIndex) ||
michael@0 1044 !ReadParam(aMsg, aIter, &inputColorSpace)) {
michael@0 1045 return false;
michael@0 1046 }
michael@0 1047 aResult->SetInputPrimitive(i, inputPrimitiveIndex);
michael@0 1048 aResult->SetInputColorSpace(i, inputColorSpace);
michael@0 1049 }
michael@0 1050
michael@0 1051 return ReadParam(aMsg, aIter, &aResult->Attributes());
michael@0 1052 }
michael@0 1053 };
michael@0 1054
michael@0 1055 template <>
michael@0 1056 struct ParamTraits<mozilla::gfx::FilterDescription>
michael@0 1057 {
michael@0 1058 typedef mozilla::gfx::FilterDescription paramType;
michael@0 1059
michael@0 1060 static void Write(Message* aMsg, const paramType& aParam)
michael@0 1061 {
michael@0 1062 WriteParam(aMsg, aParam.mFilterSpaceBounds);
michael@0 1063 WriteParam(aMsg, aParam.mPrimitives);
michael@0 1064 }
michael@0 1065
michael@0 1066 static bool Read(const Message* aMsg, void** aIter, paramType* aResult)
michael@0 1067 {
michael@0 1068 return (ReadParam(aMsg, aIter, &aResult->mFilterSpaceBounds) &&
michael@0 1069 ReadParam(aMsg, aIter, &aResult->mPrimitives));
michael@0 1070 }
michael@0 1071 };
michael@0 1072
michael@0 1073 typedef mozilla::layers::GeckoContentController::APZStateChange APZStateChange;
michael@0 1074
michael@0 1075 template <>
michael@0 1076 struct ParamTraits<APZStateChange>
michael@0 1077 : public ContiguousTypedEnumSerializer<
michael@0 1078 APZStateChange,
michael@0 1079 APZStateChange::TransformBegin,
michael@0 1080 APZStateChange::APZStateChangeSentinel>
michael@0 1081 {};
michael@0 1082
michael@0 1083 } /* namespace IPC */
michael@0 1084
michael@0 1085 #endif /* __GFXMESSAGEUTILS_H__ */

mercurial