Files
palemoon27/gfx/ipc/GfxMessageUtils.h
T
roytam1 729a46113b import changes from `dev' branch of rmottola/Arctic-Fox:
- Bug 1159056. Don't store a value in CSS pixels in a variable with type nscoord in ScrollFrameHelper::SetCoordAttribute. r=dholbert (432f06158)
- Bug 1138442 - Disable reftests on Mulet in parity with B2G/B2G Desktop. r=ahal (8b5c55da7)
- Don't clip in ComputeFrameMetrics if the scrollframe won't be layerized. (bug 1148582 part 2, r=tn) (088b6ef29)
- Bug 1157579 - Make sure the visual scroll port size includes the area of scrollbars when used in TryLayout. r=tn (c35244374)
- Bug 1139306: Fix margin sides for right-to-left scrollbars depending on the actual position of the scrollbar as determined by layout.scrollbar.side, r=tn (34328312d)
- Fix some full zoom FrameMetrics changes not propagating to APZ. (bug 1147648, r=botond) (91f009ac4)
- Bug 1159405 - Fix "Found a non-root APZ with no handoff parent". r=botond (09b0ddf07)
- Bug 1161040 - Don't set a scrollparent on the root content document in the child process that points to itself. r=tn (d0dfbffb0)
- Bug 1161040 - Add some assertions to guard against infinite loops in the handoff chains. r=botond (e6bae82e8)
- Bug 1153539 patch 1 - Improve comments for nsLayoutUtils::ComputeSuitableScaleForAnimation. r=roc (1b2bc00cd)
- Bug 1153539 patch 2 - Compute scale for rasterizing off-main-thread transform animations based on ratio to display size in addition to maximum and minimum scale. r=roc (97d632d0f)
- Bug 1160250 - Extract a helper method from the triplicated comp-bounds function to determine if we need to deflate the scrollbars. r=botond,tn (8d79c845f)
- Bug 1160250 - Extract a helper function from the triplicated composition-bounds-updating code. r=botond,tn (5b3f71329)
- Bug 1160250 - Collapse the code from CalculateRootCompositionSize into UpdateCompositionBounds. r=botond,tn (db0f081d6)
- Bug 1160250 - Put in a missing transfomToAncestor scaling factor. r=botond,tn (14837aa3a)
- Bug 1160250 - Fix up the rect being used for the composition size calculation. r=tn (0ba58021f)
- Bug 1139575 - Reset velocity on axes when going from a pan to a pinch. r=botond (2e03d04ab)
- Bug 1136971 - Draw layer borders correctly in the presence of multi-FrameMetrics. r=kats (e72f5b171)
- Bug 1148871 - Only apply checkerboarding background color to opaque layers. r=botond (20e070b84)
- Bug 1157327 - Don't cull out container layers, because their prepared data might be null and cause crashes. r=nical (3d06c925f)
- Bug 1157327 follow-up to add a comment. r=me and DONTBUILD (4cd74c0a1)
- Bug 1160566 - Make FrameMetrics.mCompositionBounds private and add a getter/setter for it. r=botond (277dd9afd)
- Bug 1160566 - Change some return values to be reference-to-const. r=botond (2ce17b63f)
- Bug 1158933 - Prevent scrollbars from jumping while zoomed in the B2G browser. r=botond (eca8aae7d)
- Bug 1158933 - Replace the compositedHeight/scrollableHeight (and width) term with the adjusted scrollThumbRatio. r=botond (236af4c4a)
- Bug 1156401 - Fix painting when building fennec with apzc. r=kats, r=botond (be18764b9)
- Bug 1159305 - patch 1 - Provide logical accessors for nsStylePosition and nsStyleSides fields. r=dbaron (7a90c519d)
- Bug 1159305 - patch 2 - Clean up layout code by using the new accessors. r=smontagu (926eb7dd5)
- Bug 1164406 - Expose scrollbar-area deflation in nsLayoutUtils. r=kats (42e5e8784)
- Bug 1139895 - Add fuzz for 1062792-1.html. r=tn (e38d0ac73)
- Bug 1139893 - Disable reftest bugs/1062108-1.html on mulet. r=jfkthame (930590d73)
- Move the APZ scroll frame clip onto FrameMetrics. (bug 1148582 part 3, r=mstange,tn) (c8e05f8d7)
- Fix PostprocessRetainedLayers to not test occlusion with asynchronous clips. (bug 1148582 part 5, r=tn) (cc71cafe2)
- Bug 1146626 - Refresh the reftest snapshot after adjusting the async scroll offsets. r=roc (1f041955d)
- Bug 1160642. Add reftest-async-zoom to apply an async zoom before taking snapshot. r=dbaron (1e8e54d8d)
- Bug 1160285 - Add a staticruntime version of mfbt and link some stuff against it. r=glandium (c733c49c7)
- Bug 786520 - Install things to $(DIST)/branding from moz.build instead of manual rules in Makefile.ins. r=mshal (42d38eb26)
- Bug 1155776 - move USE_EXTENSION_MANIFEST to moz.build; r=mshal (a87ecc2ca)
- Bug 1155816 - part 0 - remove NO_JS_MANIFEST from testing/mochitest/Makefile.in; r=mshal (af90a362c)
- Bug 1155816 - part 1 - move NO_JS_MANIFEST to moz.build; r=mshal (3a55e99a0)
- Bug 978591 - Remove per-directory uses of MOZ_CHROME_FILE_FORMAT. r=glandium (5084d62b5)
- Bug 991983 - Set GARBAGE for GeneratedSources in the recursivemake backend. r=gps (b8ae57c14)
- Bug 991983 - Emit absolute paths for UnifiedSources. r=gps (4100640d0)
- Bug 991983 - Emit absolute paths for other sources. r=gps (f30ddd773)
- Bug 991983 - Remove commented code in gyp_reader.py. r=gps (0685eca6a)
- Bug 1167474 - Remove ELFHACK_BUILD hack. r=mshal (b9d56c0b2)
- Bug 1097804 - Part 1 - Create a library containing nsISocketTransportService and nsIDNS that can be used to support standalone WebRTC. r=mcmanus (d2f83eb1c)
- Bug 1097804 - Part 2 - Added xpcomrt build of library containing unicode util functions. r=gps (fa9306f34)
- Bug 1162852 - Remove EXTRA_COMPILE_FLAGS. r=gps (340312bc6)
- Bug 1162852 - Remove EXTRA_ASSEMBLER_FLAGS. r=gps (f124c902c)
- Bug 1162852 - Remove the VARIABLES method of GypContext now it is doing nothing. r=gps (b6c1c0246)
- accidental commit (a1bbb1ada)
- Bug 991983 - Define SOURCES as SourcePath. r=gps (678065bce)
- Bug 991983 - Use objdir-relative SOURCES instead of GENERATED_SOURCES. r=gps (b54db0304)
- Bug 991983 - Make TEST_HARNESS_FILES use the *Path classes instead of a separate set of methods to resolve paths. r=gps (025fe1ca9)
- Bug 991983 - Add a deprecation hint for GENERATED_SOURCES. r=gps (67c75f4ab)
- Bug 1172800 - Fixup after bug 991983. r=gps (ce6e8c7a3)
- Bug 1164218 - Allow running individual mochitests and reftests in chaos mode. r=roc,froydnj (f2ec1d9d8)
- Bug 1154231 - Part 1. Use LRU to manage remote layers. r=mattwoodrow (1fe47e64f)
- Bug 1128037 - Minimalist support for wildcards in jar manifests. r=gps (1b07a6ffc)
- Bug 1162569 - default engine files should be in the omni.ja file, r=markh,glandium. (b07e54881)
- Bug 1157279. Escaping CSS identifiers should use lowercase letters for hex digits, not uppercase ones. r=dbaron (6f220936e)
2020-12-07 11:03:05 +08:00

1121 lines
32 KiB
C++

/* -*- 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 <stdint.h>
#include "gfxColor.h"
#include "mozilla/gfx/Matrix.h"
#include "GraphicsFilter.h"
#include "gfxPoint.h"
#include "gfxRect.h"
#include "nsRect.h"
#include "nsRegion.h"
#include "gfxTypes.h"
#include "mozilla/layers/LayersTypes.h"
#include "mozilla/layers/CompositorTypes.h"
#include "FrameMetrics.h"
#include "FilterSupport.h"
#include "mozilla/layers/GeckoContentController.h"
#ifdef _MSC_VER
#pragma warning( disable : 4800 )
#endif
namespace mozilla {
typedef gfxImageFormat PixelFormat;
typedef ::GraphicsFilter GraphicsFilterType;
} // namespace mozilla
namespace IPC {
template<>
struct ParamTraits<mozilla::gfx::Matrix>
{
typedef mozilla::gfx::Matrix paramType;
static void Write(Message* aMsg, const paramType& aParam)
{
WriteParam(aMsg, aParam._11);
WriteParam(aMsg, aParam._12);
WriteParam(aMsg, aParam._21);
WriteParam(aMsg, aParam._22);
WriteParam(aMsg, aParam._31);
WriteParam(aMsg, aParam._32);
}
static bool Read(const Message* aMsg, void** aIter, paramType* aResult)
{
if (ReadParam(aMsg, aIter, &aResult->_11) &&
ReadParam(aMsg, aIter, &aResult->_12) &&
ReadParam(aMsg, aIter, &aResult->_21) &&
ReadParam(aMsg, aIter, &aResult->_22) &&
ReadParam(aMsg, aIter, &aResult->_31) &&
ReadParam(aMsg, aIter, &aResult->_32))
return true;
return false;
}
static void Log(const paramType& aParam, std::wstring* aLog)
{
aLog->append(StringPrintf(L"[[%g %g] [%g %g] [%g %g]]", aParam._11, aParam._12, aParam._21, aParam._22,
aParam._31, aParam._32));
}
};
template<>
struct ParamTraits<mozilla::gfx::Matrix4x4>
{
typedef mozilla::gfx::Matrix4x4 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<mozilla::gfx::Matrix5x4>
{
typedef mozilla::gfx::Matrix5x4 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);
Wr(_51); Wr(_52); Wr(_53); Wr(_54);
#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) &&
Rd(_51) && Rd(_52) && Rd(_53) && Rd(_54));
#undef Rd
}
};
template<>
struct ParamTraits<gfxPoint>
{
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<gfxSize>
{
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<gfxRect>
{
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<gfxContentType>
: public ContiguousEnumSerializer<
gfxContentType,
gfxContentType::COLOR,
gfxContentType::SENTINEL>
{};
template <>
struct ParamTraits<gfxSurfaceType>
: public ContiguousEnumSerializer<
gfxSurfaceType,
gfxSurfaceType::Image,
gfxSurfaceType::Max>
{};
template <>
struct ParamTraits<mozilla::GraphicsFilterType>
: public ContiguousEnumSerializer<
mozilla::GraphicsFilterType,
GraphicsFilter::FILTER_FAST,
GraphicsFilter::FILTER_SENTINEL>
{};
template <>
struct ParamTraits<mozilla::layers::LayersBackend>
: public ContiguousEnumSerializer<
mozilla::layers::LayersBackend,
mozilla::layers::LayersBackend::LAYERS_NONE,
mozilla::layers::LayersBackend::LAYERS_LAST>
{};
template <>
struct ParamTraits<mozilla::layers::ScaleMode>
: public ContiguousEnumSerializer<
mozilla::layers::ScaleMode,
mozilla::layers::ScaleMode::SCALE_NONE,
mozilla::layers::ScaleMode::SENTINEL>
{};
template <>
struct ParamTraits<gfxImageFormat>
: public ContiguousEnumSerializer<
gfxImageFormat,
gfxImageFormat::ARGB32,
gfxImageFormat::Unknown>
{};
template <>
struct ParamTraits<mozilla::gfx::AttributeName>
: public ContiguousEnumSerializer<
mozilla::gfx::AttributeName,
mozilla::gfx::eBlendBlendmode,
mozilla::gfx::eLastAttributeName>
{};
template <>
struct ParamTraits<mozilla::gfx::AttributeType>
: public ContiguousEnumSerializer<
mozilla::gfx::AttributeType,
mozilla::gfx::AttributeType::eBool,
mozilla::gfx::AttributeType::Max>
{};
template <>
struct ParamTraits<mozilla::gfx::PrimitiveType>
: public ContiguousEnumSerializer<
mozilla::gfx::PrimitiveType,
mozilla::gfx::PrimitiveType::Empty,
mozilla::gfx::PrimitiveType::Max>
{};
template <>
struct ParamTraits<mozilla::gfx::ColorSpace>
: public ContiguousEnumSerializer<
mozilla::gfx::ColorSpace,
mozilla::gfx::ColorSpace::SRGB,
mozilla::gfx::ColorSpace::Max>
{};
template <>
struct ParamTraits<mozilla::layers::TextureFlags>
: public BitFlagsEnumSerializer<
mozilla::layers::TextureFlags,
mozilla::layers::TextureFlags::ALL_BITS>
{};
template <>
struct ParamTraits<mozilla::layers::DiagnosticTypes>
: public BitFlagsEnumSerializer<
mozilla::layers::DiagnosticTypes,
mozilla::layers::DiagnosticTypes::ALL_BITS>
{};
/*
template <>
struct ParamTraits<mozilla::PixelFormat>
: public EnumSerializer<mozilla::PixelFormat,
gfxImageFormat::ARGB32,
gfxImageFormat::Unknown>
{};
*/
template<>
struct ParamTraits<gfxRGBA>
{
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<mozilla::gfx::Color>
{
typedef mozilla::gfx::Color 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<nsPoint>
{
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<nsIntPoint>
{
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<typename T>
struct ParamTraits<mozilla::gfx::IntSizeTyped<T> >
{
typedef mozilla::gfx::IntSizeTyped<T> 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<typename Region, typename Rect, typename Iter>
struct RegionParamTraits
{
typedef Region paramType;
static void Write(Message* msg, const paramType& param)
{
Iter it(param);
while (const Rect* r = it.Next()) {
MOZ_ASSERT(!r->IsEmpty());
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<nsIntRegion>
: RegionParamTraits<nsIntRegion, mozilla::gfx::IntRect, nsIntRegionRectIterator>
{};
template<>
struct ParamTraits<nsIntSize>
{
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<class T>
struct ParamTraits< mozilla::gfx::CoordTyped<T> >
{
typedef mozilla::gfx::CoordTyped<T> paramType;
static void Write(Message* msg, const paramType& param)
{
WriteParam(msg, param.value);
}
static bool Read(const Message* msg, void** iter, paramType* result)
{
return (ReadParam(msg, iter, &result->value));
}
};
template<class T>
struct ParamTraits< mozilla::gfx::IntCoordTyped<T> >
{
typedef mozilla::gfx::IntCoordTyped<T> paramType;
static void Write(Message* msg, const paramType& param)
{
WriteParam(msg, param.value);
}
static bool Read(const Message* msg, void** iter, paramType* result)
{
return (ReadParam(msg, iter, &result->value));
}
};
template<class T, class U>
struct ParamTraits< mozilla::gfx::ScaleFactor<T, U> >
{
typedef mozilla::gfx::ScaleFactor<T, U> 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<class T, class U>
struct ParamTraits< mozilla::gfx::ScaleFactors2D<T, U> >
{
typedef mozilla::gfx::ScaleFactors2D<T, U> paramType;
static void Write(Message* msg, const paramType& param)
{
WriteParam(msg, param.xScale);
WriteParam(msg, param.yScale);
}
static bool Read(const Message* msg, void** iter, paramType* result)
{
return (ReadParam(msg, iter, &result->xScale) &&
ReadParam(msg, iter, &result->yScale));
}
};
template<class T>
struct ParamTraits< mozilla::gfx::PointTyped<T> >
{
typedef mozilla::gfx::PointTyped<T> 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<class T>
struct ParamTraits< mozilla::gfx::Point3DTyped<T> >
{
typedef mozilla::gfx::Point3DTyped<T> paramType;
static void Write(Message* msg, const paramType& param)
{
WriteParam(msg, param.x);
WriteParam(msg, param.y);
WriteParam(msg, param.z);
}
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->z));
}
};
template<class T>
struct ParamTraits< mozilla::gfx::IntPointTyped<T> >
{
typedef mozilla::gfx::IntPointTyped<T> 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<class T>
struct ParamTraits< mozilla::gfx::SizeTyped<T> >
{
typedef mozilla::gfx::SizeTyped<T> 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<class T>
struct ParamTraits< mozilla::gfx::RectTyped<T> >
{
typedef mozilla::gfx::RectTyped<T> 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<class T>
struct ParamTraits< mozilla::gfx::IntRectTyped<T> >
{
typedef mozilla::gfx::IntRectTyped<T> 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::Margin>
{
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<class T>
struct ParamTraits< mozilla::gfx::MarginTyped<T> >
{
typedef mozilla::gfx::MarginTyped<T> 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<nsRect>
{
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<nsRegion>
: RegionParamTraits<nsRegion, nsRect, nsRegionRectIterator>
{};
template <>
struct ParamTraits<mozilla::layers::FrameMetrics>
{
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.mDisplayPortMargins);
WriteParam(aMsg, aParam.mUseDisplayPortMargins);
WriteParam(aMsg, aParam.mCriticalDisplayPort);
WriteParam(aMsg, aParam.mCompositionBounds);
WriteParam(aMsg, aParam.mRootCompositionSize);
WriteParam(aMsg, aParam.mScrollId);
WriteParam(aMsg, aParam.mScrollParentId);
WriteParam(aMsg, aParam.mPresShellResolution);
WriteParam(aMsg, aParam.mCumulativeResolution);
WriteParam(aMsg, aParam.mZoom);
WriteParam(aMsg, aParam.mDevPixelsPerCSSPixel);
WriteParam(aMsg, aParam.mPresShellId);
WriteParam(aMsg, aParam.mIsRoot);
WriteParam(aMsg, aParam.mHasScrollgrab);
WriteParam(aMsg, aParam.mUpdateScrollOffset);
WriteParam(aMsg, aParam.mScrollGeneration);
WriteParam(aMsg, aParam.mExtraResolution);
WriteParam(aMsg, aParam.mBackgroundColor);
WriteParam(aMsg, aParam.mDoSmoothScroll);
WriteParam(aMsg, aParam.mSmoothScrollOffset);
WriteParam(aMsg, aParam.GetLineScrollAmount());
WriteParam(aMsg, aParam.GetPageScrollAmount());
WriteParam(aMsg, aParam.AllowVerticalScrollWithWheel());
WriteParam(aMsg, aParam.mClipRect);
WriteParam(aMsg, aParam.GetContentDescription());
}
static bool ReadContentDescription(const Message* aMsg, void** aIter, paramType* aResult)
{
nsCString str;
if (!ReadParam(aMsg, aIter, &str)) {
return false;
}
aResult->SetContentDescription(str);
return true;
}
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->mDisplayPortMargins) &&
ReadParam(aMsg, aIter, &aResult->mUseDisplayPortMargins) &&
ReadParam(aMsg, aIter, &aResult->mCriticalDisplayPort) &&
ReadParam(aMsg, aIter, &aResult->mCompositionBounds) &&
ReadParam(aMsg, aIter, &aResult->mRootCompositionSize) &&
ReadParam(aMsg, aIter, &aResult->mScrollId) &&
ReadParam(aMsg, aIter, &aResult->mScrollParentId) &&
ReadParam(aMsg, aIter, &aResult->mPresShellResolution) &&
ReadParam(aMsg, aIter, &aResult->mCumulativeResolution) &&
ReadParam(aMsg, aIter, &aResult->mZoom) &&
ReadParam(aMsg, aIter, &aResult->mDevPixelsPerCSSPixel) &&
ReadParam(aMsg, aIter, &aResult->mPresShellId) &&
ReadParam(aMsg, aIter, &aResult->mIsRoot) &&
ReadParam(aMsg, aIter, &aResult->mHasScrollgrab) &&
ReadParam(aMsg, aIter, &aResult->mUpdateScrollOffset) &&
ReadParam(aMsg, aIter, &aResult->mScrollGeneration) &&
ReadParam(aMsg, aIter, &aResult->mExtraResolution) &&
ReadParam(aMsg, aIter, &aResult->mBackgroundColor) &&
ReadParam(aMsg, aIter, &aResult->mDoSmoothScroll) &&
ReadParam(aMsg, aIter, &aResult->mSmoothScrollOffset) &&
ReadParam(aMsg, aIter, &aResult->mLineScrollAmount) &&
ReadParam(aMsg, aIter, &aResult->mPageScrollAmount) &&
ReadParam(aMsg, aIter, &aResult->mAllowVerticalScrollWithWheel) &&
ReadParam(aMsg, aIter, &aResult->mClipRect) &&
ReadContentDescription(aMsg, aIter, aResult));
}
};
template<>
struct ParamTraits<mozilla::layers::TextureFactoryIdentifier>
{
typedef mozilla::layers::TextureFactoryIdentifier paramType;
static void Write(Message* aMsg, const paramType& aParam)
{
WriteParam(aMsg, aParam.mParentBackend);
WriteParam(aMsg, aParam.mSupportedBlendModes.serialize());
WriteParam(aMsg, aParam.mMaxTextureSize);
WriteParam(aMsg, aParam.mSupportsTextureBlitting);
WriteParam(aMsg, aParam.mSupportsPartialUploads);
WriteParam(aMsg, aParam.mSyncHandle);
}
static bool Read(const Message* aMsg, void** aIter, paramType* aResult)
{
uint32_t supportedBlendModes = 0;
bool result = ReadParam(aMsg, aIter, &aResult->mParentBackend) &&
ReadParam(aMsg, aIter, &supportedBlendModes) &&
ReadParam(aMsg, aIter, &aResult->mMaxTextureSize) &&
ReadParam(aMsg, aIter, &aResult->mSupportsTextureBlitting) &&
ReadParam(aMsg, aIter, &aResult->mSupportsPartialUploads) &&
ReadParam(aMsg, aIter, &aResult->mSyncHandle);
aResult->mSupportedBlendModes.deserialize(supportedBlendModes);
return result;
}
};
template<>
struct ParamTraits<mozilla::layers::TextureInfo>
{
typedef mozilla::layers::TextureInfo paramType;
static void Write(Message* aMsg, const paramType& aParam)
{
WriteParam(aMsg, aParam.mCompositableType);
WriteParam(aMsg, aParam.mTextureFlags);
}
static bool Read(const Message* aMsg, void** aIter, paramType* aResult)
{
return ReadParam(aMsg, aIter, &aResult->mCompositableType) &&
ReadParam(aMsg, aIter, &aResult->mTextureFlags);
}
};
template <>
struct ParamTraits<mozilla::layers::CompositableType>
: public ContiguousEnumSerializer<
mozilla::layers::CompositableType,
mozilla::layers::CompositableType::UNKNOWN,
mozilla::layers::CompositableType::COUNT>
{};
template <>
struct ParamTraits<mozilla::gfx::SurfaceFormat>
: public ContiguousEnumSerializer<
mozilla::gfx::SurfaceFormat,
mozilla::gfx::SurfaceFormat::B8G8R8A8,
mozilla::gfx::SurfaceFormat::UNKNOWN>
{};
template <>
struct ParamTraits<mozilla::layers::ScrollableLayerGuid>
{
typedef mozilla::layers::ScrollableLayerGuid paramType;
static void Write(Message* aMsg, const paramType& aParam)
{
WriteParam(aMsg, aParam.mLayersId);
WriteParam(aMsg, aParam.mPresShellId);
WriteParam(aMsg, aParam.mScrollId);
}
static bool Read(const Message* aMsg, void** aIter, paramType* aResult)
{
return (ReadParam(aMsg, aIter, &aResult->mLayersId) &&
ReadParam(aMsg, aIter, &aResult->mPresShellId) &&
ReadParam(aMsg, aIter, &aResult->mScrollId));
}
};
template <>
struct ParamTraits<mozilla::layers::ZoomConstraints>
{
typedef mozilla::layers::ZoomConstraints paramType;
static void Write(Message* aMsg, const paramType& aParam)
{
WriteParam(aMsg, aParam.mAllowZoom);
WriteParam(aMsg, aParam.mAllowDoubleTapZoom);
WriteParam(aMsg, aParam.mMinZoom);
WriteParam(aMsg, aParam.mMaxZoom);
}
static bool Read(const Message* aMsg, void** aIter, paramType* aResult)
{
return (ReadParam(aMsg, aIter, &aResult->mAllowZoom) &&
ReadParam(aMsg, aIter, &aResult->mAllowDoubleTapZoom) &&
ReadParam(aMsg, aIter, &aResult->mMinZoom) &&
ReadParam(aMsg, aIter, &aResult->mMaxZoom));
}
};
template <>
struct ParamTraits<mozilla::layers::EventRegions>
{
typedef mozilla::layers::EventRegions paramType;
static void Write(Message* aMsg, const paramType& aParam)
{
WriteParam(aMsg, aParam.mHitRegion);
WriteParam(aMsg, aParam.mDispatchToContentHitRegion);
WriteParam(aMsg, aParam.mNoActionRegion);
WriteParam(aMsg, aParam.mHorizontalPanRegion);
WriteParam(aMsg, aParam.mVerticalPanRegion);
}
static bool Read(const Message* aMsg, void** aIter, paramType* aResult)
{
return (ReadParam(aMsg, aIter, &aResult->mHitRegion) &&
ReadParam(aMsg, aIter, &aResult->mDispatchToContentHitRegion) &&
ReadParam(aMsg, aIter, &aResult->mNoActionRegion) &&
ReadParam(aMsg, aIter, &aResult->mHorizontalPanRegion) &&
ReadParam(aMsg, aIter, &aResult->mVerticalPanRegion));
}
};
struct MessageAndAttributeMap
{
Message* msg;
const mozilla::gfx::AttributeMap& map;
};
static bool
WriteAttribute(mozilla::gfx::AttributeName aName,
mozilla::gfx::AttributeType aType,
void* aUserData)
{
MessageAndAttributeMap* msgAndMap =
static_cast<MessageAndAttributeMap*>(aUserData);
WriteParam(msgAndMap->msg, aType);
WriteParam(msgAndMap->msg, aName);
switch (aType) {
#define HANDLE_TYPE(typeName) \
case mozilla::gfx::AttributeType::e##typeName: \
WriteParam(msgAndMap->msg, msgAndMap->map.Get##typeName(aName)); \
break;
HANDLE_TYPE(Bool)
HANDLE_TYPE(Uint)
HANDLE_TYPE(Float)
HANDLE_TYPE(Size)
HANDLE_TYPE(IntSize)
HANDLE_TYPE(IntPoint)
HANDLE_TYPE(Matrix)
HANDLE_TYPE(Matrix5x4)
HANDLE_TYPE(Point3D)
HANDLE_TYPE(Color)
HANDLE_TYPE(AttributeMap)
HANDLE_TYPE(Floats)
#undef HANDLE_TYPE
default:
MOZ_CRASH("unhandled attribute type");
}
return true;
}
template <>
struct ParamTraits<mozilla::gfx::AttributeMap>
{
typedef mozilla::gfx::AttributeMap paramType;
static void Write(Message* aMsg, const paramType& aParam)
{
WriteParam(aMsg, aParam.Count());
MessageAndAttributeMap msgAndMap = { aMsg, aParam };
aParam.EnumerateRead(WriteAttribute, &msgAndMap);
}
static bool Read(const Message* aMsg, void** aIter, paramType* aResult)
{
uint32_t count;
if (!ReadParam(aMsg, aIter, &count)) {
return false;
}
for (uint32_t i = 0; i < count; i++) {
mozilla::gfx::AttributeType type;
if (!ReadParam(aMsg, aIter, &type)) {
return false;
}
mozilla::gfx::AttributeName name;
if (!ReadParam(aMsg, aIter, &name)) {
return false;
}
switch (type) {
#define HANDLE_TYPE(type, typeName) \
case mozilla::gfx::AttributeType::e##typeName: \
{ \
type value; \
if (!ReadParam(aMsg, aIter, &value)) { \
return false; \
} \
aResult->Set(name, value); \
}
HANDLE_TYPE(bool, Bool)
HANDLE_TYPE(uint32_t, Uint)
HANDLE_TYPE(float, Float)
HANDLE_TYPE(mozilla::gfx::Size, Size)
HANDLE_TYPE(mozilla::gfx::IntSize, IntSize)
HANDLE_TYPE(mozilla::gfx::IntPoint, IntPoint)
HANDLE_TYPE(mozilla::gfx::Matrix, Matrix)
HANDLE_TYPE(mozilla::gfx::Matrix5x4, Matrix5x4)
HANDLE_TYPE(mozilla::gfx::Point3D, Point3D)
HANDLE_TYPE(mozilla::gfx::Color, Color)
HANDLE_TYPE(mozilla::gfx::AttributeMap, AttributeMap)
#undef HANDLE_TYPE
case mozilla::gfx::AttributeType::eFloats:
{
nsTArray<float> value;
if (!ReadParam(aMsg, aIter, &value)) {
return false;
}
aResult->Set(name, &value[0], value.Length());
break;
}
default:
MOZ_CRASH("unhandled attribute type");
}
}
return true;
}
};
template <>
struct ParamTraits<mozilla::gfx::FilterPrimitiveDescription>
{
typedef mozilla::gfx::FilterPrimitiveDescription paramType;
static void Write(Message* aMsg, const paramType& aParam)
{
WriteParam(aMsg, aParam.Type());
WriteParam(aMsg, aParam.PrimitiveSubregion());
WriteParam(aMsg, aParam.FilterSpaceBounds());
WriteParam(aMsg, aParam.IsTainted());
WriteParam(aMsg, aParam.OutputColorSpace());
WriteParam(aMsg, aParam.NumberOfInputs());
for (size_t i = 0; i < aParam.NumberOfInputs(); i++) {
WriteParam(aMsg, aParam.InputPrimitiveIndex(i));
WriteParam(aMsg, aParam.InputColorSpace(i));
}
WriteParam(aMsg, aParam.Attributes());
}
static bool Read(const Message* aMsg, void** aIter, paramType* aResult)
{
mozilla::gfx::PrimitiveType type;
mozilla::gfx::IntRect primitiveSubregion;
mozilla::gfx::IntRect filterSpaceBounds;
bool isTainted = false;
mozilla::gfx::ColorSpace outputColorSpace;
size_t numberOfInputs = 0;
if (!ReadParam(aMsg, aIter, &type) ||
!ReadParam(aMsg, aIter, &primitiveSubregion) ||
!ReadParam(aMsg, aIter, &filterSpaceBounds) ||
!ReadParam(aMsg, aIter, &isTainted) ||
!ReadParam(aMsg, aIter, &outputColorSpace) ||
!ReadParam(aMsg, aIter, &numberOfInputs)) {
return false;
}
aResult->SetType(type);
aResult->SetPrimitiveSubregion(primitiveSubregion);
aResult->SetFilterSpaceBounds(filterSpaceBounds);
aResult->SetIsTainted(isTainted);
aResult->SetOutputColorSpace(outputColorSpace);
for (size_t i = 0; i < numberOfInputs; i++) {
int32_t inputPrimitiveIndex = 0;
mozilla::gfx::ColorSpace inputColorSpace;
if (!ReadParam(aMsg, aIter, &inputPrimitiveIndex) ||
!ReadParam(aMsg, aIter, &inputColorSpace)) {
return false;
}
aResult->SetInputPrimitive(i, inputPrimitiveIndex);
aResult->SetInputColorSpace(i, inputColorSpace);
}
return ReadParam(aMsg, aIter, &aResult->Attributes());
}
};
template <>
struct ParamTraits<mozilla::gfx::FilterDescription>
{
typedef mozilla::gfx::FilterDescription paramType;
static void Write(Message* aMsg, const paramType& aParam)
{
WriteParam(aMsg, aParam.mPrimitives);
}
static bool Read(const Message* aMsg, void** aIter, paramType* aResult)
{
return (ReadParam(aMsg, aIter, &aResult->mPrimitives));
}
};
typedef mozilla::layers::GeckoContentController::APZStateChange APZStateChange;
template <>
struct ParamTraits<APZStateChange>
: public ContiguousEnumSerializer<
APZStateChange,
APZStateChange::TransformBegin,
APZStateChange::APZStateChangeSentinel>
{};
template<>
struct ParamTraits<mozilla::layers::EventRegionsOverride>
: public BitFlagsEnumSerializer<
mozilla::layers::EventRegionsOverride,
mozilla::layers::EventRegionsOverride::ALL_BITS>
{};
} /* namespace IPC */
#endif /* __GFXMESSAGEUTILS_H__ */