~ubuntu-branches/ubuntu/raring/qtwebkit-source/raring-proposed

« back to all changes in this revision

Viewing changes to Source/WebCore/plugins/blackberry/NPCallbacksBlackBerry.cpp

  • Committer: Package Import Robot
  • Author(s): Jonathan Riddell
  • Date: 2013-02-18 14:24:18 UTC
  • Revision ID: package-import@ubuntu.com-20130218142418-eon0jmjg3nj438uy
Tags: upstream-2.3
ImportĀ upstreamĀ versionĀ 2.3

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * Copyright (C) 2011 Research In Motion Limited. All rights reserved.
 
3
 *
 
4
 * This library is free software; you can redistribute it and/or
 
5
 * modify it under the terms of the GNU Lesser General Public
 
6
 * License as published by the Free Software Foundation; either
 
7
 * version 2 of the License, or (at your option) any later version.
 
8
 *
 
9
 * This library is distributed in the hope that it will be useful,
 
10
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 
11
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 
12
 * Lesser General Public License for more details.
 
13
 *
 
14
 * You should have received a copy of the GNU Lesser General Public
 
15
 * License along with this library; if not, write to the Free Software
 
16
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
 
17
 */
 
18
 
 
19
#include "config.h"
 
20
#include "NPCallbacksBlackBerry.h"
 
21
 
 
22
#include "PluginViewPrivateBlackBerry.h"
 
23
 
 
24
#if USE(ACCELERATED_COMPOSITING)
 
25
#include "PluginLayerWebKitThread.h"
 
26
#endif
 
27
 
 
28
namespace WebCore {
 
29
 
 
30
PthreadMutexLocker::PthreadMutexLocker(pthread_mutex_t* mutex)
 
31
    : m_mutex(mutex)
 
32
{
 
33
    pthread_mutex_lock(m_mutex);
 
34
}
 
35
 
 
36
PthreadMutexLocker::~PthreadMutexLocker()
 
37
{
 
38
    pthread_mutex_unlock(m_mutex);
 
39
}
 
40
 
 
41
PthreadReadLocker::PthreadReadLocker(pthread_rwlock_t* rwlock)
 
42
    : m_rwlock(rwlock)
 
43
{
 
44
    pthread_rwlock_rdlock(m_rwlock);
 
45
}
 
46
 
 
47
PthreadReadLocker::~PthreadReadLocker()
 
48
{
 
49
    pthread_rwlock_unlock(m_rwlock);
 
50
}
 
51
 
 
52
PthreadWriteLocker::PthreadWriteLocker(pthread_rwlock_t* rwlock)
 
53
    : m_rwlock(rwlock)
 
54
{
 
55
    pthread_rwlock_wrlock(m_rwlock);
 
56
}
 
57
 
 
58
PthreadWriteLocker::~PthreadWriteLocker()
 
59
{
 
60
    pthread_rwlock_unlock(m_rwlock);
 
61
}
 
62
 
 
63
#if USE(ACCELERATED_COMPOSITING)
 
64
void npSetHolePunchHandler(void* holePunchData)
 
65
{
 
66
    OwnPtr<HolePunchData> data = adoptPtr(static_cast<HolePunchData*>(holePunchData));
 
67
    if (data->layer)
 
68
        data->layer->setHolePunchRect(IntRect(data->x, data->y, data->w, data->h));
 
69
}
 
70
#endif
 
71
 
 
72
// NPAPI callback functions
 
73
 
 
74
void setVisibleRects(NPP instance, const NPRect rects[], int32_t count)
 
75
{
 
76
    PluginView* view = static_cast<PluginView*>(instance->ndata);
 
77
    PluginViewPrivate* viewPrivate = view->getPrivate();
 
78
    viewPrivate->setVisibleRects(rects, count);
 
79
}
 
80
 
 
81
void clearVisibleRects(NPP instance)
 
82
{
 
83
    PluginView* view = static_cast<PluginView*>(instance->ndata);
 
84
    PluginViewPrivate* viewPrivate = view->getPrivate();
 
85
    viewPrivate->clearVisibleRects();
 
86
}
 
87
 
 
88
void showKeyboard(NPP instance, bool value)
 
89
{
 
90
    PluginView* view = static_cast<PluginView*>(instance->ndata);
 
91
    PluginViewPrivate* viewPrivate = view->getPrivate();
 
92
    viewPrivate->showKeyboard(value);
 
93
}
 
94
 
 
95
void requestFullScreen(NPP instance)
 
96
{
 
97
    PluginView* view = static_cast<PluginView*>(instance->ndata);
 
98
    PluginViewPrivate* viewPrivate = view->getPrivate();
 
99
    viewPrivate->requestFullScreen();
 
100
}
 
101
 
 
102
void exitFullScreen(NPP instance)
 
103
{
 
104
    PluginView* view = static_cast<PluginView*>(instance->ndata);
 
105
    PluginViewPrivate* viewPrivate = view->getPrivate();
 
106
    viewPrivate->exitFullScreen();
 
107
}
 
108
 
 
109
void requestCenterFitZoom(NPP instance)
 
110
{
 
111
    PluginView* view = static_cast<PluginView*>(instance->ndata);
 
112
    PluginViewPrivate* viewPrivate = view->getPrivate();
 
113
    viewPrivate->requestCenterFitZoom();
 
114
}
 
115
 
 
116
void lockOrientation(NPP instance, bool landscape)
 
117
{
 
118
    PluginView* view = static_cast<PluginView*>(instance->ndata);
 
119
    PluginViewPrivate* viewPrivate = view->getPrivate();
 
120
    viewPrivate->lockOrientation(landscape);
 
121
}
 
122
 
 
123
void unlockOrientation(NPP instance)
 
124
{
 
125
    PluginView* view = static_cast<PluginView*>(instance->ndata);
 
126
    PluginViewPrivate* viewPrivate = view->getPrivate();
 
127
    viewPrivate->unlockOrientation();
 
128
}
 
129
 
 
130
void preventIdle(NPP instance, bool preventIdle)
 
131
{
 
132
    PluginView* view = static_cast<PluginView*>(instance->ndata);
 
133
    PluginViewPrivate* viewPrivate = view->getPrivate();
 
134
    viewPrivate->preventIdle(preventIdle);
 
135
}
 
136
 
 
137
NPSurface lockBackBuffer(NPP instance)
 
138
{
 
139
    PluginView* view = static_cast<PluginView*>(instance->ndata);
 
140
    PluginViewPrivate* viewPrivate = view->getPrivate();
 
141
    return viewPrivate->lockBackBuffer();
 
142
}
 
143
 
 
144
void unlockBackBuffer(NPP instance)
 
145
{
 
146
    PluginView* view = static_cast<PluginView*>(instance->ndata);
 
147
    PluginViewPrivate* viewPrivate = view->getPrivate();
 
148
    viewPrivate->unlockBackBuffer();
 
149
}
 
150
 
 
151
NPSurface lockReadFrontBuffer(NPP instance)
 
152
{
 
153
    PluginView* view = static_cast<PluginView*>(instance->ndata);
 
154
    PluginViewPrivate* viewPrivate = view->getPrivate();
 
155
    return viewPrivate->lockReadFrontBuffer();
 
156
}
 
157
 
 
158
void unlockReadFrontBuffer(NPP instance)
 
159
{
 
160
    PluginView* view = static_cast<PluginView*>(instance->ndata);
 
161
    PluginViewPrivate* viewPrivate = view->getPrivate();
 
162
    viewPrivate->unlockReadFrontBuffer();
 
163
}
 
164
 
 
165
void swapBuffers(NPP instance)
 
166
{
 
167
    PluginView* view = static_cast<PluginView*>(instance->ndata);
 
168
    PluginViewPrivate* viewPrivate = view->getPrivate();
 
169
    viewPrivate->swapBuffers();
 
170
}
 
171
 
 
172
bool createBuffers(NPP instance, NPSurfaceFormat format, int width, int height)
 
173
{
 
174
    PluginView* view = static_cast<PluginView*>(instance->ndata);
 
175
    PluginViewPrivate* viewPrivate = view->getPrivate();
 
176
    return viewPrivate->createBuffers(format, width, height);
 
177
}
 
178
 
 
179
bool destroyBuffers(NPP instance)
 
180
{
 
181
    PluginView* view = static_cast<PluginView*>(instance->ndata);
 
182
    PluginViewPrivate* viewPrivate = view->getPrivate();
 
183
    return viewPrivate->destroyBuffers();
 
184
}
 
185
 
 
186
bool resizeBuffers(NPP instance, NPSurfaceFormat format, int width, int height)
 
187
{
 
188
    PluginView* view = static_cast<PluginView*>(instance->ndata);
 
189
    PluginViewPrivate* viewPrivate = view->getPrivate();
 
190
    return viewPrivate->resizeBuffers(format, width, height);
 
191
}
 
192
 
 
193
void setHolePunch(NPP instance, int x, int y, int width, int height)
 
194
{
 
195
    PluginView* view = static_cast<PluginView*>(instance->ndata);
 
196
    PluginViewPrivate* viewPrivate = view->getPrivate();
 
197
    viewPrivate->setHolePunch(x, y, width, height);
 
198
}
 
199
 
 
200
NPCallbacks s_NpCallbacks = {
 
201
    setVisibleRects,
 
202
    clearVisibleRects,
 
203
    showKeyboard,
 
204
    requestFullScreen,
 
205
    exitFullScreen,
 
206
    requestCenterFitZoom,
 
207
    lockOrientation,
 
208
    unlockOrientation,
 
209
    preventIdle,
 
210
    lockBackBuffer,
 
211
    unlockBackBuffer,
 
212
    lockReadFrontBuffer,
 
213
    unlockReadFrontBuffer,
 
214
    swapBuffers,
 
215
    createBuffers,
 
216
    destroyBuffers,
 
217
    resizeBuffers,
 
218
    setHolePunch
 
219
};
 
220
 
 
221
} // Namespace WebCore
 
222