LCOV - code coverage report
Current view: top level - gfx/layers/wr - WebRenderMessageUtils.h (source / functions) Hit Total Coverage
Test: output.info Lines: 5 48 10.4 %
Date: 2017-07-14 16:53:18 Functions: 2 14 14.3 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
       2             :  * This Source Code Form is subject to the terms of the Mozilla Public
       3             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       4             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
       5             : 
       6             : #ifndef GFX_WEBRENDERMESSAGEUTILS_H
       7             : #define GFX_WEBRENDERMESSAGEUTILS_H
       8             : 
       9             : #include "chrome/common/ipc_message_utils.h"
      10             : 
      11             : #include "mozilla/webrender/webrender_ffi.h"
      12             : #include "mozilla/webrender/WebRenderTypes.h"
      13             : 
      14             : namespace IPC {
      15             : 
      16             : template<>
      17             : struct ParamTraits<mozilla::wr::ByteBuffer>
      18             : {
      19             :   typedef mozilla::wr::ByteBuffer paramType;
      20             : 
      21             :   static void
      22           0 :   Write(Message* aMsg, const paramType& aParam)
      23             :   {
      24           0 :     WriteParam(aMsg, aParam.mLength);
      25           0 :     aMsg->WriteBytes(aParam.mData, aParam.mLength);
      26           0 :   }
      27             : 
      28             :   static bool
      29           0 :   Read(const Message* aMsg, PickleIterator* aIter, paramType* aResult)
      30             :   {
      31             :     size_t length;
      32           0 :     return ReadParam(aMsg, aIter, &length)
      33           0 :         && aResult->Allocate(length)
      34           0 :         && aMsg->ReadBytesInto(aIter, aResult->mData, length);
      35             :   }
      36             : };
      37             : 
      38             : template<>
      39             : struct ParamTraits<mozilla::wr::ImageKey>
      40             : {
      41             :   static void
      42           0 :   Write(Message* aMsg, const mozilla::wr::ImageKey& aParam)
      43             :   {
      44           0 :     WriteParam(aMsg, aParam.mNamespace);
      45           0 :     WriteParam(aMsg, aParam.mHandle);
      46           0 :   }
      47             : 
      48             :   static bool
      49           0 :   Read(const Message* aMsg, PickleIterator* aIter, mozilla::wr::ImageKey* aResult)
      50             :   {
      51           0 :     return ReadParam(aMsg, aIter, &aResult->mNamespace)
      52           0 :         && ReadParam(aMsg, aIter, &aResult->mHandle);
      53             :   }
      54             : };
      55             : 
      56             : template<>
      57             : struct ParamTraits<mozilla::wr::FontKey>
      58             : {
      59             :   static void
      60           0 :   Write(Message* aMsg, const mozilla::wr::FontKey& aParam)
      61             :   {
      62           0 :     WriteParam(aMsg, aParam.mNamespace);
      63           0 :     WriteParam(aMsg, aParam.mHandle);
      64           0 :   }
      65             : 
      66             :   static bool
      67           0 :   Read(const Message* aMsg, PickleIterator* aIter, mozilla::wr::FontKey* aResult)
      68             :   {
      69           0 :     return ReadParam(aMsg, aIter, &aResult->mNamespace)
      70           0 :         && ReadParam(aMsg, aIter, &aResult->mHandle);
      71             :   }
      72             : };
      73             : 
      74             : template<>
      75             : struct ParamTraits<mozilla::wr::ExternalImageId>
      76             : {
      77             :   static void
      78           9 :   Write(Message* aMsg, const mozilla::wr::ExternalImageId& aParam)
      79             :   {
      80           9 :     WriteParam(aMsg, aParam.mHandle);
      81           9 :   }
      82             : 
      83             :   static bool
      84           9 :   Read(const Message* aMsg, PickleIterator* aIter, mozilla::wr::ExternalImageId* aResult)
      85             :   {
      86           9 :     return ReadParam(aMsg, aIter, &aResult->mHandle);
      87             :   }
      88             : };
      89             : 
      90             : template<>
      91             : struct ParamTraits<mozilla::wr::PipelineId>
      92             : {
      93             :   static void
      94           0 :   Write(Message* aMsg, const mozilla::wr::PipelineId& aParam)
      95             :   {
      96           0 :     WriteParam(aMsg, aParam.mNamespace);
      97           0 :     WriteParam(aMsg, aParam.mHandle);
      98           0 :   }
      99             : 
     100             :   static bool
     101           0 :   Read(const Message* aMsg, PickleIterator* aIter, mozilla::wr::PipelineId* aResult)
     102             :   {
     103           0 :     return ReadParam(aMsg, aIter, &aResult->mNamespace)
     104           0 :         && ReadParam(aMsg, aIter, &aResult->mHandle);
     105             :   }
     106             : };
     107             : 
     108             : template<>
     109             : struct ParamTraits<WrImageFormat>
     110             :   : public ContiguousEnumSerializer<
     111             :         WrImageFormat,
     112             :         WrImageFormat::Invalid,
     113             :         WrImageFormat::Sentinel>
     114             : {
     115             : };
     116             : 
     117             : template<>
     118             : struct ParamTraits<WrSize>
     119             : {
     120             :   static void
     121           0 :   Write(Message* aMsg, const WrSize& aParam)
     122             :   {
     123           0 :     WriteParam(aMsg, aParam.width);
     124           0 :     WriteParam(aMsg, aParam.height);
     125           0 :   }
     126             : 
     127             :   static bool
     128           0 :   Read(const Message* aMsg, PickleIterator* aIter, WrSize* aResult)
     129             :   {
     130           0 :     return ReadParam(aMsg, aIter, &aResult->width)
     131           0 :         && ReadParam(aMsg, aIter, &aResult->height);
     132             :   }
     133             : };
     134             : 
     135             : template<>
     136             : struct ParamTraits<WrRect>
     137             : {
     138             :   static void
     139             :   Write(Message* aMsg, const WrRect& aParam)
     140             :   {
     141             :     WriteParam(aMsg, aParam.x);
     142             :     WriteParam(aMsg, aParam.y);
     143             :     WriteParam(aMsg, aParam.width);
     144             :     WriteParam(aMsg, aParam.height);
     145             :   }
     146             : 
     147             :   static bool
     148             :   Read(const Message* aMsg, PickleIterator* aIter, WrRect* aResult)
     149             :   {
     150             :     return ReadParam(aMsg, aIter, &aResult->x)
     151             :         && ReadParam(aMsg, aIter, &aResult->y)
     152             :         && ReadParam(aMsg, aIter, &aResult->width)
     153             :         && ReadParam(aMsg, aIter, &aResult->height);
     154             :   }
     155             : };
     156             : 
     157             : template<>
     158             : struct ParamTraits<WrPoint>
     159             : {
     160             :   static void
     161             :   Write(Message* aMsg, const WrPoint& aParam)
     162             :   {
     163             :     WriteParam(aMsg, aParam.x);
     164             :     WriteParam(aMsg, aParam.y);
     165             :   }
     166             : 
     167             :   static bool
     168             :   Read(const Message* aMsg, PickleIterator* aIter, WrPoint* aResult)
     169             :   {
     170             :     return ReadParam(aMsg, aIter, &aResult->x) &&
     171             :            ReadParam(aMsg, aIter, &aResult->y);
     172             :   }
     173             : };
     174             : 
     175             : template<>
     176             : struct ParamTraits<WrImageMask>
     177             : {
     178             :   static void
     179             :   Write(Message* aMsg, const WrImageMask& aParam)
     180             :   {
     181             :     WriteParam(aMsg, aParam.image);
     182             :     WriteParam(aMsg, aParam.rect);
     183             :     WriteParam(aMsg, aParam.repeat);
     184             :   }
     185             : 
     186             :   static bool
     187             :   Read(const Message* aMsg, PickleIterator* aIter, WrImageMask* aResult)
     188             :   {
     189             :     return ReadParam(aMsg, aIter, &aResult->image)
     190             :         && ReadParam(aMsg, aIter, &aResult->rect)
     191             :         && ReadParam(aMsg, aIter, &aResult->repeat);
     192             :   }
     193             : };
     194             : 
     195             : template<>
     196             : struct ParamTraits<WrImageRendering>
     197             :   : public ContiguousEnumSerializer<
     198             :         WrImageRendering,
     199             :         WrImageRendering::Auto,
     200             :         WrImageRendering::Sentinel>
     201             : {
     202             : };
     203             : 
     204             : template<>
     205             : struct ParamTraits<WrMixBlendMode>
     206             :   : public ContiguousEnumSerializer<
     207             :         WrMixBlendMode,
     208             :         WrMixBlendMode::Normal,
     209             :         WrMixBlendMode::Sentinel>
     210             : {
     211             : };
     212             : 
     213             : template<>
     214             : struct ParamTraits<WrBuiltDisplayListDescriptor>
     215             : {
     216             :   static void
     217           0 :   Write(Message* aMsg, const WrBuiltDisplayListDescriptor& aParam)
     218             :   {
     219           0 :     WriteParam(aMsg, aParam.builder_start_time);
     220           0 :     WriteParam(aMsg, aParam.builder_finish_time);
     221           0 :   }
     222             : 
     223             :   static bool
     224           0 :   Read(const Message* aMsg, PickleIterator* aIter, WrBuiltDisplayListDescriptor* aResult)
     225             :   {
     226           0 :     return ReadParam(aMsg, aIter, &aResult->builder_start_time)
     227           0 :         && ReadParam(aMsg, aIter, &aResult->builder_finish_time);
     228             :   }
     229             : };
     230             : 
     231             : } // namespace IPC
     232             : 
     233             : #endif // GFX_WEBRENDERMESSAGEUTILS_H

Generated by: LCOV version 1.13