summaryrefslogtreecommitdiff
path: root/Source/WebKit/blackberry/Api/WebOverlayOverride.cpp
blob: 1ba60368465f415369ed67febc1edd649bd66196 (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
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
/*
 * Copyright (C) 2012 Research In Motion Limited. All rights reserved.
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser 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
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
 */

#include "config.h"

#include "WebOverlayOverride.h"

#if USE(ACCELERATED_COMPOSITING)
#include "WebAnimation.h"
#include "WebAnimation_p.h"
#include "WebOverlay_p.h"

#include <BlackBerryPlatformMessageClient.h>
#include <BlackBerryPlatformString.h>
#include <wtf/CurrentTime.h>

namespace BlackBerry {
namespace WebKit {

using namespace WebCore;

WebOverlayOverride::WebOverlayOverride(WebOverlayPrivate* d)
    : d(d)
{
}

WebOverlayOverride::~WebOverlayOverride()
{
}

void WebOverlayOverride::setPosition(const Platform::FloatPoint& position)
{
    d->layerCompositingThread()->override()->setPosition(position);
    d->scheduleCompositingRun();
}

void WebOverlayOverride::setAnchorPoint(const Platform::FloatPoint& anchor)
{
    d->layerCompositingThread()->override()->setAnchorPoint(anchor);
    d->scheduleCompositingRun();
}

void WebOverlayOverride::setSize(const Platform::FloatSize& size)
{
    d->layerCompositingThread()->override()->setBounds(IntSize(size.width(), size.height()));
    d->scheduleCompositingRun();
}

void WebOverlayOverride::setTransform(const Platform::TransformationMatrix& transform)
{
    d->layerCompositingThread()->override()->setTransform(reinterpret_cast<const TransformationMatrix&>(transform));
    d->scheduleCompositingRun();
}

void WebOverlayOverride::setOpacity(float opacity)
{
    d->layerCompositingThread()->override()->setOpacity(opacity);
    d->scheduleCompositingRun();
}

void WebOverlayOverride::addAnimation(const WebAnimation& animation)
{
    LayerCompositingThread* layerCompositingThread = d->layerCompositingThread();
    LayerOverride* override = layerCompositingThread->override();

    IntSize boxSize = override->isBoundsSet() ? override->bounds() : layerCompositingThread->bounds();
    RefPtr<LayerAnimation> layerAnimation = LayerAnimation::create(animation.d->keyframes, boxSize, animation.d->animation.get(), animation.d->name, 0.0);
    layerAnimation->setStartTime(currentTime());

    override->addAnimation(layerAnimation);
    d->scheduleCompositingRun();
}

void WebOverlayOverride::removeAnimation(const BlackBerry::Platform::String& name)
{
    d->layerCompositingThread()->override()->removeAnimation(name);
    d->scheduleCompositingRun();
}

}
}
#else // USE(ACCELERATED_COMPOSITING)
namespace BlackBerry {
namespace WebKit {

WebOverlayOverride::WebOverlayOverride(WebOverlayPrivate*, bool)
{
}

WebOverlayOverride::~WebOverlayOverride()
{
}

void WebOverlayOverride::setPosition(const Platform::FloatPoint&)
{
}

void WebOverlayOverride::setAnchorPoint(const Platform::FloatPoint&)
{
}

void WebOverlayOverride::setSize(const Platform::FloatSize&)
{
}

void WebOverlayOverride::setTransform(const Platform::TransformationMatrix&)
{
}

void WebOverlayOverride::setOpacity(float)
{
}

void WebOverlayOverride::addAnimation(const WebAnimation&)
{
}

void WebOverlayOverride::removeAnimation(const BlackBerry::Platform::String&)
{
}

}
}
#endif // USE(ACCELERATED_COMPOSITING)