1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/dom/plugins/ipc/PluginInstanceChild.h Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,623 @@ 1.4 +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- 1.5 + * vim: sw=4 ts=4 et : 1.6 + * This Source Code Form is subject to the terms of the Mozilla Public 1.7 + * License, v. 2.0. If a copy of the MPL was not distributed with this 1.8 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 1.9 + 1.10 +#ifndef dom_plugins_PluginInstanceChild_h 1.11 +#define dom_plugins_PluginInstanceChild_h 1 1.12 + 1.13 +#include "mozilla/plugins/PPluginInstanceChild.h" 1.14 +#include "mozilla/plugins/PluginScriptableObjectChild.h" 1.15 +#include "mozilla/plugins/StreamNotifyChild.h" 1.16 +#include "mozilla/plugins/PPluginSurfaceChild.h" 1.17 +#include "mozilla/ipc/CrossProcessMutex.h" 1.18 +#include "nsClassHashtable.h" 1.19 +#if defined(OS_WIN) 1.20 +#include "mozilla/gfx/SharedDIBWin.h" 1.21 +#elif defined(MOZ_WIDGET_COCOA) 1.22 +#include "PluginUtilsOSX.h" 1.23 +#include "mozilla/gfx/QuartzSupport.h" 1.24 +#include "base/timer.h" 1.25 + 1.26 +#endif 1.27 + 1.28 +#include "npfunctions.h" 1.29 +#include "nsAutoPtr.h" 1.30 +#include "nsTArray.h" 1.31 +#include "ChildAsyncCall.h" 1.32 +#include "ChildTimer.h" 1.33 +#include "nsRect.h" 1.34 +#include "nsTHashtable.h" 1.35 +#include "mozilla/PaintTracker.h" 1.36 + 1.37 +#include <map> 1.38 + 1.39 +#if (MOZ_WIDGET_GTK == 2) 1.40 +#include "gtk2xtbin.h" 1.41 +#endif 1.42 + 1.43 +class gfxASurface; 1.44 + 1.45 +namespace mozilla { 1.46 + 1.47 +namespace layers { 1.48 +struct RemoteImageData; 1.49 +} 1.50 + 1.51 +namespace plugins { 1.52 + 1.53 +class PBrowserStreamChild; 1.54 +class BrowserStreamChild; 1.55 +class StreamNotifyChild; 1.56 + 1.57 +class PluginInstanceChild : public PPluginInstanceChild 1.58 +{ 1.59 + friend class BrowserStreamChild; 1.60 + friend class PluginStreamChild; 1.61 + friend class StreamNotifyChild; 1.62 + 1.63 +#ifdef OS_WIN 1.64 + friend LRESULT CALLBACK PluginWindowProc(HWND hWnd, 1.65 + UINT message, 1.66 + WPARAM wParam, 1.67 + LPARAM lParam); 1.68 + static LRESULT CALLBACK PluginWindowProcInternal(HWND hWnd, 1.69 + UINT message, 1.70 + WPARAM wParam, 1.71 + LPARAM lParam); 1.72 +#endif 1.73 + 1.74 +protected: 1.75 + virtual bool AnswerNPP_SetWindow(const NPRemoteWindow& window) MOZ_OVERRIDE; 1.76 + 1.77 + virtual bool 1.78 + AnswerNPP_GetValue_NPPVpluginWantsAllNetworkStreams(bool* wantsAllStreams, NPError* rv) MOZ_OVERRIDE; 1.79 + virtual bool 1.80 + AnswerNPP_GetValue_NPPVpluginNeedsXEmbed(bool* needs, NPError* rv) MOZ_OVERRIDE; 1.81 + virtual bool 1.82 + AnswerNPP_GetValue_NPPVpluginScriptableNPObject(PPluginScriptableObjectChild** value, 1.83 + NPError* result) MOZ_OVERRIDE; 1.84 + virtual bool 1.85 + AnswerNPP_GetValue_NPPVpluginNativeAccessibleAtkPlugId(nsCString* aPlugId, 1.86 + NPError* aResult) MOZ_OVERRIDE; 1.87 + virtual bool 1.88 + AnswerNPP_SetValue_NPNVprivateModeBool(const bool& value, NPError* result) MOZ_OVERRIDE; 1.89 + 1.90 + virtual bool 1.91 + AnswerNPP_HandleEvent(const NPRemoteEvent& event, int16_t* handled) MOZ_OVERRIDE; 1.92 + virtual bool 1.93 + AnswerNPP_HandleEvent_Shmem(const NPRemoteEvent& event, 1.94 + Shmem& mem, 1.95 + int16_t* handled, 1.96 + Shmem* rtnmem) MOZ_OVERRIDE; 1.97 + virtual bool 1.98 + AnswerNPP_HandleEvent_IOSurface(const NPRemoteEvent& event, 1.99 + const uint32_t& surface, 1.100 + int16_t* handled) MOZ_OVERRIDE; 1.101 + 1.102 + // Async rendering 1.103 + virtual bool 1.104 + RecvAsyncSetWindow(const gfxSurfaceType& aSurfaceType, 1.105 + const NPRemoteWindow& aWindow) MOZ_OVERRIDE; 1.106 + 1.107 + virtual void 1.108 + DoAsyncSetWindow(const gfxSurfaceType& aSurfaceType, 1.109 + const NPRemoteWindow& aWindow, 1.110 + bool aIsAsync); 1.111 + 1.112 + virtual PPluginSurfaceChild* 1.113 + AllocPPluginSurfaceChild(const WindowsSharedMemoryHandle&, 1.114 + const gfxIntSize&, const bool&) MOZ_OVERRIDE { 1.115 + return new PPluginSurfaceChild(); 1.116 + } 1.117 + 1.118 + virtual bool DeallocPPluginSurfaceChild(PPluginSurfaceChild* s) MOZ_OVERRIDE { 1.119 + delete s; 1.120 + return true; 1.121 + } 1.122 + 1.123 + virtual bool 1.124 + AnswerPaint(const NPRemoteEvent& event, int16_t* handled) MOZ_OVERRIDE 1.125 + { 1.126 + PaintTracker pt; 1.127 + return AnswerNPP_HandleEvent(event, handled); 1.128 + } 1.129 + 1.130 + virtual bool 1.131 + RecvWindowPosChanged(const NPRemoteEvent& event) MOZ_OVERRIDE; 1.132 + 1.133 + virtual bool 1.134 + RecvContentsScaleFactorChanged(const double& aContentsScaleFactor) MOZ_OVERRIDE; 1.135 + 1.136 + virtual bool 1.137 + AnswerNPP_Destroy(NPError* result) MOZ_OVERRIDE; 1.138 + 1.139 + virtual PPluginScriptableObjectChild* 1.140 + AllocPPluginScriptableObjectChild() MOZ_OVERRIDE; 1.141 + 1.142 + virtual bool 1.143 + DeallocPPluginScriptableObjectChild(PPluginScriptableObjectChild* aObject) MOZ_OVERRIDE; 1.144 + 1.145 + virtual bool 1.146 + RecvPPluginScriptableObjectConstructor(PPluginScriptableObjectChild* aActor) MOZ_OVERRIDE; 1.147 + 1.148 + virtual PBrowserStreamChild* 1.149 + AllocPBrowserStreamChild(const nsCString& url, 1.150 + const uint32_t& length, 1.151 + const uint32_t& lastmodified, 1.152 + PStreamNotifyChild* notifyData, 1.153 + const nsCString& headers, 1.154 + const nsCString& mimeType, 1.155 + const bool& seekable, 1.156 + NPError* rv, 1.157 + uint16_t *stype) MOZ_OVERRIDE; 1.158 + 1.159 + virtual bool 1.160 + AnswerPBrowserStreamConstructor( 1.161 + PBrowserStreamChild* aActor, 1.162 + const nsCString& url, 1.163 + const uint32_t& length, 1.164 + const uint32_t& lastmodified, 1.165 + PStreamNotifyChild* notifyData, 1.166 + const nsCString& headers, 1.167 + const nsCString& mimeType, 1.168 + const bool& seekable, 1.169 + NPError* rv, 1.170 + uint16_t* stype) MOZ_OVERRIDE; 1.171 + 1.172 + virtual bool 1.173 + DeallocPBrowserStreamChild(PBrowserStreamChild* stream) MOZ_OVERRIDE; 1.174 + 1.175 + virtual PPluginStreamChild* 1.176 + AllocPPluginStreamChild(const nsCString& mimeType, 1.177 + const nsCString& target, 1.178 + NPError* result) MOZ_OVERRIDE; 1.179 + 1.180 + virtual bool 1.181 + DeallocPPluginStreamChild(PPluginStreamChild* stream) MOZ_OVERRIDE; 1.182 + 1.183 + virtual PStreamNotifyChild* 1.184 + AllocPStreamNotifyChild(const nsCString& url, const nsCString& target, 1.185 + const bool& post, const nsCString& buffer, 1.186 + const bool& file, 1.187 + NPError* result) MOZ_OVERRIDE; 1.188 + 1.189 + virtual bool 1.190 + DeallocPStreamNotifyChild(PStreamNotifyChild* notifyData) MOZ_OVERRIDE; 1.191 + 1.192 + virtual bool 1.193 + AnswerSetPluginFocus() MOZ_OVERRIDE; 1.194 + 1.195 + virtual bool 1.196 + AnswerUpdateWindow() MOZ_OVERRIDE; 1.197 + 1.198 + virtual bool 1.199 + RecvNPP_DidComposite() MOZ_OVERRIDE; 1.200 + 1.201 +#if defined(MOZ_X11) && defined(XP_UNIX) && !defined(XP_MACOSX) 1.202 + bool CreateWindow(const NPRemoteWindow& aWindow); 1.203 + void DeleteWindow(); 1.204 +#endif 1.205 + 1.206 +public: 1.207 + PluginInstanceChild(const NPPluginFuncs* aPluginIface); 1.208 + 1.209 + virtual ~PluginInstanceChild(); 1.210 + 1.211 + bool Initialize(); 1.212 + 1.213 + NPP GetNPP() 1.214 + { 1.215 + return &mData; 1.216 + } 1.217 + 1.218 + NPError 1.219 + NPN_GetValue(NPNVariable aVariable, void* aValue); 1.220 + 1.221 + NPError 1.222 + NPN_SetValue(NPPVariable aVariable, void* aValue); 1.223 + 1.224 + PluginScriptableObjectChild* 1.225 + GetActorForNPObject(NPObject* aObject); 1.226 + 1.227 + NPError 1.228 + NPN_NewStream(NPMIMEType aMIMEType, const char* aWindow, 1.229 + NPStream** aStream); 1.230 + 1.231 + void InvalidateRect(NPRect* aInvalidRect); 1.232 + 1.233 +#ifdef MOZ_WIDGET_COCOA 1.234 + void Invalidate(); 1.235 +#endif // definied(MOZ_WIDGET_COCOA) 1.236 + 1.237 + uint32_t ScheduleTimer(uint32_t interval, bool repeat, TimerFunc func); 1.238 + void UnscheduleTimer(uint32_t id); 1.239 + 1.240 + void AsyncCall(PluginThreadCallback aFunc, void* aUserData); 1.241 + 1.242 + int GetQuirks(); 1.243 + 1.244 + void NPN_URLRedirectResponse(void* notifyData, NPBool allow); 1.245 + 1.246 + NPError NPN_InitAsyncSurface(NPSize *size, NPImageFormat format, 1.247 + void *initData, NPAsyncSurface *surface); 1.248 + NPError NPN_FinalizeAsyncSurface(NPAsyncSurface *surface); 1.249 + 1.250 + void NPN_SetCurrentAsyncSurface(NPAsyncSurface *surface, NPRect *changed); 1.251 + 1.252 + void DoAsyncRedraw(); 1.253 +private: 1.254 + friend class PluginModuleChild; 1.255 + 1.256 + NPError 1.257 + InternalGetNPObjectForValue(NPNVariable aValue, 1.258 + NPObject** aObject); 1.259 + 1.260 + bool IsAsyncDrawing(); 1.261 + 1.262 + NPError DeallocateAsyncBitmapSurface(NPAsyncSurface *aSurface); 1.263 + 1.264 + virtual bool RecvUpdateBackground(const SurfaceDescriptor& aBackground, 1.265 + const nsIntRect& aRect) MOZ_OVERRIDE; 1.266 + 1.267 + virtual PPluginBackgroundDestroyerChild* 1.268 + AllocPPluginBackgroundDestroyerChild() MOZ_OVERRIDE; 1.269 + 1.270 + virtual bool 1.271 + RecvPPluginBackgroundDestroyerConstructor(PPluginBackgroundDestroyerChild* aActor) MOZ_OVERRIDE; 1.272 + 1.273 + virtual bool 1.274 + DeallocPPluginBackgroundDestroyerChild(PPluginBackgroundDestroyerChild* aActor) MOZ_OVERRIDE; 1.275 + 1.276 +#if defined(OS_WIN) 1.277 + static bool RegisterWindowClass(); 1.278 + bool CreatePluginWindow(); 1.279 + void DestroyPluginWindow(); 1.280 + void ReparentPluginWindow(HWND hWndParent); 1.281 + void SizePluginWindow(int width, int height); 1.282 + int16_t WinlessHandleEvent(NPEvent& event); 1.283 + void CreateWinlessPopupSurrogate(); 1.284 + void DestroyWinlessPopupSurrogate(); 1.285 + void InitPopupMenuHook(); 1.286 + void SetupFlashMsgThrottle(); 1.287 + void UnhookWinlessFlashThrottle(); 1.288 + void HookSetWindowLongPtr(); 1.289 + static inline bool SetWindowLongHookCheck(HWND hWnd, 1.290 + int nIndex, 1.291 + LONG_PTR newLong); 1.292 + void FlashThrottleMessage(HWND, UINT, WPARAM, LPARAM, bool); 1.293 + static LRESULT CALLBACK DummyWindowProc(HWND hWnd, 1.294 + UINT message, 1.295 + WPARAM wParam, 1.296 + LPARAM lParam); 1.297 + static LRESULT CALLBACK PluginWindowProc(HWND hWnd, 1.298 + UINT message, 1.299 + WPARAM wParam, 1.300 + LPARAM lParam); 1.301 + static BOOL WINAPI TrackPopupHookProc(HMENU hMenu, 1.302 + UINT uFlags, 1.303 + int x, 1.304 + int y, 1.305 + int nReserved, 1.306 + HWND hWnd, 1.307 + CONST RECT *prcRect); 1.308 + static BOOL CALLBACK EnumThreadWindowsCallback(HWND hWnd, 1.309 + LPARAM aParam); 1.310 + static LRESULT CALLBACK WinlessHiddenFlashWndProc(HWND hWnd, 1.311 + UINT message, 1.312 + WPARAM wParam, 1.313 + LPARAM lParam); 1.314 +#ifdef _WIN64 1.315 + static LONG_PTR WINAPI SetWindowLongPtrAHook(HWND hWnd, 1.316 + int nIndex, 1.317 + LONG_PTR newLong); 1.318 + static LONG_PTR WINAPI SetWindowLongPtrWHook(HWND hWnd, 1.319 + int nIndex, 1.320 + LONG_PTR newLong); 1.321 + 1.322 +#else 1.323 + static LONG WINAPI SetWindowLongAHook(HWND hWnd, 1.324 + int nIndex, 1.325 + LONG newLong); 1.326 + static LONG WINAPI SetWindowLongWHook(HWND hWnd, 1.327 + int nIndex, 1.328 + LONG newLong); 1.329 +#endif 1.330 + 1.331 + class FlashThrottleAsyncMsg : public ChildAsyncCall 1.332 + { 1.333 + public: 1.334 + FlashThrottleAsyncMsg(); 1.335 + FlashThrottleAsyncMsg(PluginInstanceChild* aInst, 1.336 + HWND aWnd, UINT aMsg, 1.337 + WPARAM aWParam, LPARAM aLParam, 1.338 + bool isWindowed) 1.339 + : ChildAsyncCall(aInst, nullptr, nullptr), 1.340 + mWnd(aWnd), 1.341 + mMsg(aMsg), 1.342 + mWParam(aWParam), 1.343 + mLParam(aLParam), 1.344 + mWindowed(isWindowed) 1.345 + {} 1.346 + 1.347 + void Run() MOZ_OVERRIDE; 1.348 + 1.349 + WNDPROC GetProc(); 1.350 + HWND GetWnd() { return mWnd; } 1.351 + UINT GetMsg() { return mMsg; } 1.352 + WPARAM GetWParam() { return mWParam; } 1.353 + LPARAM GetLParam() { return mLParam; } 1.354 + 1.355 + private: 1.356 + HWND mWnd; 1.357 + UINT mMsg; 1.358 + WPARAM mWParam; 1.359 + LPARAM mLParam; 1.360 + bool mWindowed; 1.361 + }; 1.362 + 1.363 +#endif 1.364 + const NPPluginFuncs* mPluginIface; 1.365 + NPP_t mData; 1.366 + NPWindow mWindow; 1.367 +#if defined(XP_MACOSX) 1.368 + double mContentsScaleFactor; 1.369 +#endif 1.370 + int16_t mDrawingModel; 1.371 + NPAsyncSurface* mCurrentAsyncSurface; 1.372 + struct AsyncBitmapData { 1.373 + void *mRemotePtr; 1.374 + Shmem mShmem; 1.375 + }; 1.376 + 1.377 + static PLDHashOperator DeleteSurface(NPAsyncSurface* surf, nsAutoPtr<AsyncBitmapData> &data, void* userArg); 1.378 + nsClassHashtable<nsPtrHashKey<NPAsyncSurface>, AsyncBitmapData> mAsyncBitmaps; 1.379 + Shmem mRemoteImageDataShmem; 1.380 + mozilla::layers::RemoteImageData *mRemoteImageData; 1.381 + nsAutoPtr<CrossProcessMutex> mRemoteImageDataMutex; 1.382 + mozilla::Mutex mAsyncInvalidateMutex; 1.383 + CancelableTask *mAsyncInvalidateTask; 1.384 + 1.385 + // Cached scriptable actors to avoid IPC churn 1.386 + PluginScriptableObjectChild* mCachedWindowActor; 1.387 + PluginScriptableObjectChild* mCachedElementActor; 1.388 + 1.389 +#if defined(MOZ_X11) && defined(XP_UNIX) && !defined(XP_MACOSX) 1.390 + NPSetWindowCallbackStruct mWsInfo; 1.391 +#if (MOZ_WIDGET_GTK == 2) 1.392 + bool mXEmbed; 1.393 + XtClient mXtClient; 1.394 +#endif 1.395 +#elif defined(OS_WIN) 1.396 + HWND mPluginWindowHWND; 1.397 + WNDPROC mPluginWndProc; 1.398 + HWND mPluginParentHWND; 1.399 + int mNestedEventLevelDepth; 1.400 + HWND mCachedWinlessPluginHWND; 1.401 + HWND mWinlessPopupSurrogateHWND; 1.402 + nsIntPoint mPluginSize; 1.403 + WNDPROC mWinlessThrottleOldWndProc; 1.404 + HWND mWinlessHiddenMsgHWND; 1.405 +#endif 1.406 + 1.407 + friend class ChildAsyncCall; 1.408 + 1.409 + Mutex mAsyncCallMutex; 1.410 + nsTArray<ChildAsyncCall*> mPendingAsyncCalls; 1.411 + nsTArray<nsAutoPtr<ChildTimer> > mTimers; 1.412 + 1.413 + /** 1.414 + * During destruction we enumerate all remaining scriptable objects and 1.415 + * invalidate/delete them. Enumeration can re-enter, so maintain a 1.416 + * hash separate from PluginModuleChild.mObjectMap. 1.417 + */ 1.418 + nsAutoPtr< nsTHashtable<DeletingObjectEntry> > mDeletingHash; 1.419 + 1.420 +#if defined(OS_WIN) 1.421 +private: 1.422 + // Shared dib rendering management for windowless plugins. 1.423 + bool SharedSurfaceSetWindow(const NPRemoteWindow& aWindow); 1.424 + int16_t SharedSurfacePaint(NPEvent& evcopy); 1.425 + void SharedSurfaceRelease(); 1.426 + bool AlphaExtractCacheSetup(); 1.427 + void AlphaExtractCacheRelease(); 1.428 + void UpdatePaintClipRect(RECT* aRect); 1.429 + 1.430 +private: 1.431 + enum { 1.432 + RENDER_NATIVE, 1.433 + RENDER_BACK_ONE, 1.434 + RENDER_BACK_TWO 1.435 + }; 1.436 + gfx::SharedDIBWin mSharedSurfaceDib; 1.437 + struct { 1.438 + uint16_t doublePass; 1.439 + HDC hdc; 1.440 + HBITMAP bmp; 1.441 + } mAlphaExtract; 1.442 +#endif // defined(OS_WIN) 1.443 +#if defined(MOZ_WIDGET_COCOA) 1.444 +private: 1.445 +#if defined(__i386__) 1.446 + NPEventModel mEventModel; 1.447 +#endif 1.448 + CGColorSpaceRef mShColorSpace; 1.449 + CGContextRef mShContext; 1.450 + mozilla::RefPtr<nsCARenderer> mCARenderer; 1.451 + void *mCGLayer; 1.452 + 1.453 + // Core Animation drawing model requires a refresh timer. 1.454 + uint32_t mCARefreshTimer; 1.455 + 1.456 +public: 1.457 + const NPCocoaEvent* getCurrentEvent() { 1.458 + return mCurrentEvent; 1.459 + } 1.460 + 1.461 + bool CGDraw(CGContextRef ref, nsIntRect aUpdateRect); 1.462 + 1.463 +#if defined(__i386__) 1.464 + NPEventModel EventModel() { return mEventModel; } 1.465 +#endif 1.466 + 1.467 +private: 1.468 + const NPCocoaEvent *mCurrentEvent; 1.469 +#endif 1.470 + 1.471 + bool CanPaintOnBackground(); 1.472 + 1.473 + bool IsVisible() { 1.474 +#ifdef XP_MACOSX 1.475 + return mWindow.clipRect.top != mWindow.clipRect.bottom && 1.476 + mWindow.clipRect.left != mWindow.clipRect.right; 1.477 +#else 1.478 + return mWindow.clipRect.top != 0 || 1.479 + mWindow.clipRect.left != 0 || 1.480 + mWindow.clipRect.bottom != 0 || 1.481 + mWindow.clipRect.right != 0; 1.482 +#endif 1.483 + } 1.484 + 1.485 + // ShowPluginFrame - in general does four things: 1.486 + // 1) Create mCurrentSurface optimized for rendering to parent process 1.487 + // 2) Updated mCurrentSurface to be a complete copy of mBackSurface 1.488 + // 3) Draw the invalidated plugin area into mCurrentSurface 1.489 + // 4) Send it to parent process. 1.490 + bool ShowPluginFrame(void); 1.491 + 1.492 + // If we can read back safely from mBackSurface, copy 1.493 + // mSurfaceDifferenceRect from mBackSurface to mFrontSurface. 1.494 + // @return Whether the back surface could be read. 1.495 + bool ReadbackDifferenceRect(const nsIntRect& rect); 1.496 + 1.497 + // Post ShowPluginFrame task 1.498 + void AsyncShowPluginFrame(void); 1.499 + 1.500 + // In the PaintRect functions, aSurface is the size of the full plugin 1.501 + // window. Each PaintRect function renders into the subrectangle aRect of 1.502 + // aSurface (possibly more if we're working around a Flash bug). 1.503 + 1.504 + // Paint plugin content rectangle to surface with bg color filling 1.505 + void PaintRectToSurface(const nsIntRect& aRect, 1.506 + gfxASurface* aSurface, 1.507 + const gfxRGBA& aColor); 1.508 + 1.509 + // Render plugin content to surface using 1.510 + // white/black image alpha extraction algorithm 1.511 + void PaintRectWithAlphaExtraction(const nsIntRect& aRect, 1.512 + gfxASurface* aSurface); 1.513 + 1.514 + // Call plugin NPAPI function to render plugin content to surface 1.515 + // @param - aSurface - should be compatible with current platform plugin rendering 1.516 + // @return - FALSE if plugin not painted to surface 1.517 + void PaintRectToPlatformSurface(const nsIntRect& aRect, 1.518 + gfxASurface* aSurface); 1.519 + 1.520 + // Update NPWindow platform attributes and call plugin "setwindow" 1.521 + // @param - aForceSetWindow - call setwindow even if platform attributes are the same 1.522 + void UpdateWindowAttributes(bool aForceSetWindow = false); 1.523 + 1.524 + // Create optimized mCurrentSurface for parent process rendering 1.525 + // @return FALSE if optimized surface not created 1.526 + bool CreateOptSurface(void); 1.527 + 1.528 + // Create mHelperSurface if mCurrentSurface non compatible with plugins 1.529 + // @return TRUE if helper surface created successfully, or not needed 1.530 + bool MaybeCreatePlatformHelperSurface(void); 1.531 + 1.532 + // Make sure that we have surface for rendering 1.533 + bool EnsureCurrentBuffer(void); 1.534 + 1.535 + // Helper function for delayed InvalidateRect call 1.536 + // non null mCurrentInvalidateTask will call this function 1.537 + void InvalidateRectDelayed(void); 1.538 + 1.539 + // Clear mCurrentSurface/mCurrentSurfaceActor/mHelperSurface 1.540 + void ClearCurrentSurface(); 1.541 + 1.542 + // Swap mCurrentSurface/mBackSurface and their associated actors 1.543 + void SwapSurfaces(); 1.544 + 1.545 + // Clear all surfaces in response to NPP_Destroy 1.546 + void ClearAllSurfaces(); 1.547 + 1.548 + // Set as true when SetupLayer called 1.549 + // and go with different path in InvalidateRect function 1.550 + bool mLayersRendering; 1.551 + 1.552 + // Current surface available for rendering 1.553 + nsRefPtr<gfxASurface> mCurrentSurface; 1.554 + 1.555 + // Back surface, just keeping reference to 1.556 + // surface which is on ParentProcess side 1.557 + nsRefPtr<gfxASurface> mBackSurface; 1.558 + 1.559 +#ifdef XP_MACOSX 1.560 + // Current IOSurface available for rendering 1.561 + // We can't use thebes gfxASurface like other platforms. 1.562 + PluginUtilsOSX::nsDoubleBufferCARenderer mDoubleBufferCARenderer; 1.563 +#endif 1.564 + 1.565 + // (Not to be confused with mBackSurface). This is a recent copy 1.566 + // of the opaque pixels under our object frame, if 1.567 + // |mIsTransparent|. We ask the plugin render directly onto a 1.568 + // copy of the background pixels if available, and fall back on 1.569 + // alpha recovery otherwise. 1.570 + nsRefPtr<gfxASurface> mBackground; 1.571 + 1.572 +#ifdef XP_WIN 1.573 + // These actors mirror mCurrentSurface/mBackSurface 1.574 + PPluginSurfaceChild* mCurrentSurfaceActor; 1.575 + PPluginSurfaceChild* mBackSurfaceActor; 1.576 +#endif 1.577 + 1.578 + // Accumulated invalidate rect, while back buffer is not accessible, 1.579 + // in plugin coordinates. 1.580 + nsIntRect mAccumulatedInvalidRect; 1.581 + 1.582 + // Plugin only call SetTransparent 1.583 + // and does not remember their transparent state 1.584 + // and p->getvalue return always false 1.585 + bool mIsTransparent; 1.586 + 1.587 + // Surface type optimized of parent process 1.588 + gfxSurfaceType mSurfaceType; 1.589 + 1.590 + // Keep InvalidateRect task pointer to be able Cancel it on Destroy 1.591 + CancelableTask *mCurrentInvalidateTask; 1.592 + 1.593 + // Keep AsyncSetWindow task pointer to be able to Cancel it on Destroy 1.594 + CancelableTask *mCurrentAsyncSetWindowTask; 1.595 + 1.596 + // True while plugin-child in plugin call 1.597 + // Use to prevent plugin paint re-enter 1.598 + bool mPendingPluginCall; 1.599 + 1.600 + // On some platforms, plugins may not support rendering to a surface with 1.601 + // alpha, or not support rendering to an image surface. 1.602 + // In those cases we need to draw to a temporary platform surface; we cache 1.603 + // that surface here. 1.604 + nsRefPtr<gfxASurface> mHelperSurface; 1.605 + 1.606 + // true when plugin does not support painting to ARGB32 1.607 + // surface this is false if plugin supports 1.608 + // NPPVpluginTransparentAlphaBool (which is not part of 1.609 + // NPAPI yet) 1.610 + bool mDoAlphaExtraction; 1.611 + 1.612 + // true when the plugin has painted at least once. We use this to ensure 1.613 + // that we ask a plugin to paint at least once even if it's invisible; 1.614 + // some plugin (instances) rely on this in order to work properly. 1.615 + bool mHasPainted; 1.616 + 1.617 + // Cached rectangle rendered to previous surface(mBackSurface) 1.618 + // Used for reading back to current surface and syncing data, 1.619 + // in plugin coordinates. 1.620 + nsIntRect mSurfaceDifferenceRect; 1.621 +}; 1.622 + 1.623 +} // namespace plugins 1.624 +} // namespace mozilla 1.625 + 1.626 +#endif // ifndef dom_plugins_PluginInstanceChild_h