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 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222
|
/*
* Copyright (C) 2011 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 "NPCallbacksBlackBerry.h"
#include "PluginViewPrivateBlackBerry.h"
#if USE(ACCELERATED_COMPOSITING)
#include "PluginLayerWebKitThread.h"
#endif
namespace WebCore {
PthreadMutexLocker::PthreadMutexLocker(pthread_mutex_t* mutex)
: m_mutex(mutex)
{
pthread_mutex_lock(m_mutex);
}
PthreadMutexLocker::~PthreadMutexLocker()
{
pthread_mutex_unlock(m_mutex);
}
PthreadReadLocker::PthreadReadLocker(pthread_rwlock_t* rwlock)
: m_rwlock(rwlock)
{
pthread_rwlock_rdlock(m_rwlock);
}
PthreadReadLocker::~PthreadReadLocker()
{
pthread_rwlock_unlock(m_rwlock);
}
PthreadWriteLocker::PthreadWriteLocker(pthread_rwlock_t* rwlock)
: m_rwlock(rwlock)
{
pthread_rwlock_wrlock(m_rwlock);
}
PthreadWriteLocker::~PthreadWriteLocker()
{
pthread_rwlock_unlock(m_rwlock);
}
#if USE(ACCELERATED_COMPOSITING)
void npSetHolePunchHandler(void* holePunchData)
{
OwnPtr<HolePunchData> data = adoptPtr(static_cast<HolePunchData*>(holePunchData));
if (data->layer)
static_cast<PluginLayerWebKitThread*>(data->layer.get())->setHolePunchRect(IntRect(data->x, data->y, data->w, data->h));
}
#endif
// NPAPI callback functions
void setVisibleRects(NPP instance, const NPRect rects[], int32_t count)
{
PluginView* view = static_cast<PluginView*>(instance->ndata);
PluginViewPrivate* viewPrivate = view->getPrivate();
viewPrivate->setVisibleRects(rects, count);
}
void clearVisibleRects(NPP instance)
{
PluginView* view = static_cast<PluginView*>(instance->ndata);
PluginViewPrivate* viewPrivate = view->getPrivate();
viewPrivate->clearVisibleRects();
}
void showKeyboard(NPP instance, bool value)
{
PluginView* view = static_cast<PluginView*>(instance->ndata);
PluginViewPrivate* viewPrivate = view->getPrivate();
viewPrivate->showKeyboard(value);
}
void requestFullScreen(NPP instance)
{
PluginView* view = static_cast<PluginView*>(instance->ndata);
PluginViewPrivate* viewPrivate = view->getPrivate();
viewPrivate->requestFullScreen();
}
void exitFullScreen(NPP instance)
{
PluginView* view = static_cast<PluginView*>(instance->ndata);
PluginViewPrivate* viewPrivate = view->getPrivate();
viewPrivate->exitFullScreen();
}
void requestCenterFitZoom(NPP instance)
{
PluginView* view = static_cast<PluginView*>(instance->ndata);
PluginViewPrivate* viewPrivate = view->getPrivate();
viewPrivate->requestCenterFitZoom();
}
void lockOrientation(NPP instance, bool landscape)
{
PluginView* view = static_cast<PluginView*>(instance->ndata);
PluginViewPrivate* viewPrivate = view->getPrivate();
viewPrivate->lockOrientation(landscape);
}
void unlockOrientation(NPP instance)
{
PluginView* view = static_cast<PluginView*>(instance->ndata);
PluginViewPrivate* viewPrivate = view->getPrivate();
viewPrivate->unlockOrientation();
}
void preventIdle(NPP instance, bool preventIdle)
{
PluginView* view = static_cast<PluginView*>(instance->ndata);
PluginViewPrivate* viewPrivate = view->getPrivate();
viewPrivate->preventIdle(preventIdle);
}
NPSurface lockBackBuffer(NPP instance)
{
PluginView* view = static_cast<PluginView*>(instance->ndata);
PluginViewPrivate* viewPrivate = view->getPrivate();
return viewPrivate->lockBackBuffer();
}
void unlockBackBuffer(NPP instance)
{
PluginView* view = static_cast<PluginView*>(instance->ndata);
PluginViewPrivate* viewPrivate = view->getPrivate();
viewPrivate->unlockBackBuffer();
}
NPSurface lockReadFrontBuffer(NPP instance)
{
PluginView* view = static_cast<PluginView*>(instance->ndata);
PluginViewPrivate* viewPrivate = view->getPrivate();
return viewPrivate->lockReadFrontBuffer();
}
void unlockReadFrontBuffer(NPP instance)
{
PluginView* view = static_cast<PluginView*>(instance->ndata);
PluginViewPrivate* viewPrivate = view->getPrivate();
viewPrivate->unlockReadFrontBuffer();
}
void swapBuffers(NPP instance)
{
PluginView* view = static_cast<PluginView*>(instance->ndata);
PluginViewPrivate* viewPrivate = view->getPrivate();
viewPrivate->swapBuffers();
}
bool createBuffers(NPP instance, NPSurfaceFormat format, int width, int height)
{
PluginView* view = static_cast<PluginView*>(instance->ndata);
PluginViewPrivate* viewPrivate = view->getPrivate();
return viewPrivate->createBuffers(format, width, height);
}
bool destroyBuffers(NPP instance)
{
PluginView* view = static_cast<PluginView*>(instance->ndata);
PluginViewPrivate* viewPrivate = view->getPrivate();
return viewPrivate->destroyBuffers();
}
bool resizeBuffers(NPP instance, NPSurfaceFormat format, int width, int height)
{
PluginView* view = static_cast<PluginView*>(instance->ndata);
PluginViewPrivate* viewPrivate = view->getPrivate();
return viewPrivate->resizeBuffers(format, width, height);
}
void setHolePunch(NPP instance, int x, int y, int width, int height)
{
PluginView* view = static_cast<PluginView*>(instance->ndata);
PluginViewPrivate* viewPrivate = view->getPrivate();
viewPrivate->setHolePunch(x, y, width, height);
}
NPCallbacks s_NpCallbacks = {
setVisibleRects,
clearVisibleRects,
showKeyboard,
requestFullScreen,
exitFullScreen,
requestCenterFitZoom,
lockOrientation,
unlockOrientation,
preventIdle,
lockBackBuffer,
unlockBackBuffer,
lockReadFrontBuffer,
unlockReadFrontBuffer,
swapBuffers,
createBuffers,
destroyBuffers,
resizeBuffers,
setHolePunch
};
} // Namespace WebCore
|