summaryrefslogtreecommitdiff
path: root/Source/WebKit2/Shared/WebLayerTreeInfo.cpp
blob: 164f3c0dbdcfbc9d9895c425f180f97bf288879d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
/*
 Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies)

 This library is free software; you can redistribute it and/or
 modify it under the terms of the GNU Library General Public
 License as published by the Free Software Foundation; either
 version 2 of the License, or (at your option) any later version.

 This library is distributed in the hope that it will be useful,
 but WITHOUT ANY WARRANTY; without even the implied warranty of
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 Library General Public License for more details.

 You should have received a copy of the GNU Library General Public License
 along with this library; see the file COPYING.LIB.  If not, write to
 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
 Boston, MA 02110-1301, USA.
 */

#include "config.h"

#if USE(ACCELERATED_COMPOSITING)

#include "WebLayerTreeInfo.h"

#include "Arguments.h"
#include "SharedMemory.h"
#include "WebCoreArgumentCoders.h"

using namespace CoreIPC;

namespace WebKit {

void WebLayerInfo::encode(CoreIPC::ArgumentEncoder* encoder) const
{
    // We have to divide it to several lines, because CoreIPC::In/Out takes a maximum of 10 arguments.
    encoder->encode(CoreIPC::In(id, name, parent, children, flags, replica, mask, imageBackingStoreID));
    encoder->encode(CoreIPC::In(pos, size, transform, opacity, anchorPoint, childrenTransform, contentsRect, animations));
}

bool WebLayerInfo::decode(CoreIPC::ArgumentDecoder* decoder, WebLayerInfo& info)
{
    // We have to divide it to several lines, because CoreIPC::In/Out takes a maximum of 10 arguments.
    if (!decoder->decode(CoreIPC::Out(info.id, info.name, info.parent, info.children, info.flags, info.replica, info.mask, info.imageBackingStoreID)))
        return false;
    if (!decoder->decode(CoreIPC::Out(info.pos, info.size, info.transform, info.opacity, info.anchorPoint, info.childrenTransform, info.contentsRect, info.animations)))
        return false;

    return true;
}

void WebLayerTreeInfo::encode(CoreIPC::ArgumentEncoder* encoder) const
{
    encoder->encode(CoreIPC::In(layers, rootLayerID, deletedLayerIDs, contentScale));
}

bool WebLayerTreeInfo::decode(CoreIPC::ArgumentDecoder* decoder, WebLayerTreeInfo& info)
{
    return decoder->decode(CoreIPC::Out(info.layers, info.rootLayerID, info.deletedLayerIDs, info.contentScale));
}

void WebLayerUpdateInfo::encode(CoreIPC::ArgumentEncoder* encoder) const
{
    encoder->encode(CoreIPC::In(layerID, rect, bitmapHandle));
}

bool WebLayerUpdateInfo::decode(CoreIPC::ArgumentDecoder* decoder, WebLayerUpdateInfo& info)
{
    return decoder->decode(CoreIPC::Out(info.layerID, info.rect, info.bitmapHandle));
}

void WebLayerAnimation::encode(CoreIPC::ArgumentEncoder* encoder) const
{
    encoder->encodeEnum(operation);
    encoder->encode(keyframeList);
    encoder->encode(CoreIPC::In(name, startTime, boxSize));

    if (operation == WebLayerAnimation::AddAnimation)
        encoder->encode(animation);
}

bool WebLayerAnimation::decode(CoreIPC::ArgumentDecoder* decoder, WebLayerAnimation& info)
{
    if (!decoder->decodeEnum(info.operation))
        return false;
    if (!decoder->decode(info.keyframeList))
        return false;
    if (!decoder->decode(CoreIPC::Out(info.name, info.startTime, info.boxSize)))
        return false;

    if (info.operation == WebLayerAnimation::AddAnimation)
        if (!decoder->decode(info.animation))
            return false;

    return true;
}

}
#endif