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#ifndef LayerMessage_h 20#define LayerMessage_h 21 22#include <BlackBerryPlatformExecutableMessage.h> 23#include <BlackBerryPlatformMessage.h> 24#include <BlackBerryPlatformMessageClient.h> 25 26typedef BlackBerry::Platform::Message PlatformMessage; 27 28namespace WebCore { 29 30inline bool isCompositingThread() 31{ 32 return BlackBerry::Platform::userInterfaceThreadMessageClient()->isCurrentThread(); 33} 34 35inline pthread_t compositingThread() 36{ 37 return BlackBerry::Platform::userInterfaceThreadMessageClient()->threadIdentifier(); 38} 39 40inline bool isWebKitThread() 41{ 42 return BlackBerry::Platform::webKitThreadMessageClient()->isCurrentThread(); 43} 44 45inline pthread_t webKitThread() 46{ 47 return BlackBerry::Platform::webKitThreadMessageClient()->threadIdentifier(); 48} 49 50inline void dispatchCompositingMessage(PlatformMessage* msg) 51{ 52 BlackBerry::Platform::userInterfaceThreadMessageClient()->dispatchMessage(msg); 53} 54 55inline void dispatchSyncCompositingMessage(PlatformMessage* msg) 56{ 57 BlackBerry::Platform::userInterfaceThreadMessageClient()->dispatchSyncMessage(msg); 58} 59 60enum PlatformMessagePriority { PlatformMessagePriorityLow = -1, PlatformMessagePriorityNormal = 0, PlatformMessagePriorityHigh = 1 }; 61 62inline void dispatchWebKitMessage(PlatformMessage* msg, PlatformMessagePriority priority = PlatformMessagePriorityNormal) 63{ 64 if (priority != PlatformMessagePriorityNormal) 65 msg->setPriority(BlackBerry::Platform::webKitThreadMessageClient()->threadPriority() + priority); 66 BlackBerry::Platform::webKitThreadMessageClient()->dispatchMessage(msg); 67} 68 69} // namespace WebCore 70 71#endif // LayerMessage_h 72