dom/plugins/ipc/PluginInstanceChild.h

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

michael@0 1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
michael@0 2 * vim: sw=4 ts=4 et :
michael@0 3 * This Source Code Form is subject to the terms of the Mozilla Public
michael@0 4 * License, v. 2.0. If a copy of the MPL was not distributed with this
michael@0 5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
michael@0 6
michael@0 7 #ifndef dom_plugins_PluginInstanceChild_h
michael@0 8 #define dom_plugins_PluginInstanceChild_h 1
michael@0 9
michael@0 10 #include "mozilla/plugins/PPluginInstanceChild.h"
michael@0 11 #include "mozilla/plugins/PluginScriptableObjectChild.h"
michael@0 12 #include "mozilla/plugins/StreamNotifyChild.h"
michael@0 13 #include "mozilla/plugins/PPluginSurfaceChild.h"
michael@0 14 #include "mozilla/ipc/CrossProcessMutex.h"
michael@0 15 #include "nsClassHashtable.h"
michael@0 16 #if defined(OS_WIN)
michael@0 17 #include "mozilla/gfx/SharedDIBWin.h"
michael@0 18 #elif defined(MOZ_WIDGET_COCOA)
michael@0 19 #include "PluginUtilsOSX.h"
michael@0 20 #include "mozilla/gfx/QuartzSupport.h"
michael@0 21 #include "base/timer.h"
michael@0 22
michael@0 23 #endif
michael@0 24
michael@0 25 #include "npfunctions.h"
michael@0 26 #include "nsAutoPtr.h"
michael@0 27 #include "nsTArray.h"
michael@0 28 #include "ChildAsyncCall.h"
michael@0 29 #include "ChildTimer.h"
michael@0 30 #include "nsRect.h"
michael@0 31 #include "nsTHashtable.h"
michael@0 32 #include "mozilla/PaintTracker.h"
michael@0 33
michael@0 34 #include <map>
michael@0 35
michael@0 36 #if (MOZ_WIDGET_GTK == 2)
michael@0 37 #include "gtk2xtbin.h"
michael@0 38 #endif
michael@0 39
michael@0 40 class gfxASurface;
michael@0 41
michael@0 42 namespace mozilla {
michael@0 43
michael@0 44 namespace layers {
michael@0 45 struct RemoteImageData;
michael@0 46 }
michael@0 47
michael@0 48 namespace plugins {
michael@0 49
michael@0 50 class PBrowserStreamChild;
michael@0 51 class BrowserStreamChild;
michael@0 52 class StreamNotifyChild;
michael@0 53
michael@0 54 class PluginInstanceChild : public PPluginInstanceChild
michael@0 55 {
michael@0 56 friend class BrowserStreamChild;
michael@0 57 friend class PluginStreamChild;
michael@0 58 friend class StreamNotifyChild;
michael@0 59
michael@0 60 #ifdef OS_WIN
michael@0 61 friend LRESULT CALLBACK PluginWindowProc(HWND hWnd,
michael@0 62 UINT message,
michael@0 63 WPARAM wParam,
michael@0 64 LPARAM lParam);
michael@0 65 static LRESULT CALLBACK PluginWindowProcInternal(HWND hWnd,
michael@0 66 UINT message,
michael@0 67 WPARAM wParam,
michael@0 68 LPARAM lParam);
michael@0 69 #endif
michael@0 70
michael@0 71 protected:
michael@0 72 virtual bool AnswerNPP_SetWindow(const NPRemoteWindow& window) MOZ_OVERRIDE;
michael@0 73
michael@0 74 virtual bool
michael@0 75 AnswerNPP_GetValue_NPPVpluginWantsAllNetworkStreams(bool* wantsAllStreams, NPError* rv) MOZ_OVERRIDE;
michael@0 76 virtual bool
michael@0 77 AnswerNPP_GetValue_NPPVpluginNeedsXEmbed(bool* needs, NPError* rv) MOZ_OVERRIDE;
michael@0 78 virtual bool
michael@0 79 AnswerNPP_GetValue_NPPVpluginScriptableNPObject(PPluginScriptableObjectChild** value,
michael@0 80 NPError* result) MOZ_OVERRIDE;
michael@0 81 virtual bool
michael@0 82 AnswerNPP_GetValue_NPPVpluginNativeAccessibleAtkPlugId(nsCString* aPlugId,
michael@0 83 NPError* aResult) MOZ_OVERRIDE;
michael@0 84 virtual bool
michael@0 85 AnswerNPP_SetValue_NPNVprivateModeBool(const bool& value, NPError* result) MOZ_OVERRIDE;
michael@0 86
michael@0 87 virtual bool
michael@0 88 AnswerNPP_HandleEvent(const NPRemoteEvent& event, int16_t* handled) MOZ_OVERRIDE;
michael@0 89 virtual bool
michael@0 90 AnswerNPP_HandleEvent_Shmem(const NPRemoteEvent& event,
michael@0 91 Shmem& mem,
michael@0 92 int16_t* handled,
michael@0 93 Shmem* rtnmem) MOZ_OVERRIDE;
michael@0 94 virtual bool
michael@0 95 AnswerNPP_HandleEvent_IOSurface(const NPRemoteEvent& event,
michael@0 96 const uint32_t& surface,
michael@0 97 int16_t* handled) MOZ_OVERRIDE;
michael@0 98
michael@0 99 // Async rendering
michael@0 100 virtual bool
michael@0 101 RecvAsyncSetWindow(const gfxSurfaceType& aSurfaceType,
michael@0 102 const NPRemoteWindow& aWindow) MOZ_OVERRIDE;
michael@0 103
michael@0 104 virtual void
michael@0 105 DoAsyncSetWindow(const gfxSurfaceType& aSurfaceType,
michael@0 106 const NPRemoteWindow& aWindow,
michael@0 107 bool aIsAsync);
michael@0 108
michael@0 109 virtual PPluginSurfaceChild*
michael@0 110 AllocPPluginSurfaceChild(const WindowsSharedMemoryHandle&,
michael@0 111 const gfxIntSize&, const bool&) MOZ_OVERRIDE {
michael@0 112 return new PPluginSurfaceChild();
michael@0 113 }
michael@0 114
michael@0 115 virtual bool DeallocPPluginSurfaceChild(PPluginSurfaceChild* s) MOZ_OVERRIDE {
michael@0 116 delete s;
michael@0 117 return true;
michael@0 118 }
michael@0 119
michael@0 120 virtual bool
michael@0 121 AnswerPaint(const NPRemoteEvent& event, int16_t* handled) MOZ_OVERRIDE
michael@0 122 {
michael@0 123 PaintTracker pt;
michael@0 124 return AnswerNPP_HandleEvent(event, handled);
michael@0 125 }
michael@0 126
michael@0 127 virtual bool
michael@0 128 RecvWindowPosChanged(const NPRemoteEvent& event) MOZ_OVERRIDE;
michael@0 129
michael@0 130 virtual bool
michael@0 131 RecvContentsScaleFactorChanged(const double& aContentsScaleFactor) MOZ_OVERRIDE;
michael@0 132
michael@0 133 virtual bool
michael@0 134 AnswerNPP_Destroy(NPError* result) MOZ_OVERRIDE;
michael@0 135
michael@0 136 virtual PPluginScriptableObjectChild*
michael@0 137 AllocPPluginScriptableObjectChild() MOZ_OVERRIDE;
michael@0 138
michael@0 139 virtual bool
michael@0 140 DeallocPPluginScriptableObjectChild(PPluginScriptableObjectChild* aObject) MOZ_OVERRIDE;
michael@0 141
michael@0 142 virtual bool
michael@0 143 RecvPPluginScriptableObjectConstructor(PPluginScriptableObjectChild* aActor) MOZ_OVERRIDE;
michael@0 144
michael@0 145 virtual PBrowserStreamChild*
michael@0 146 AllocPBrowserStreamChild(const nsCString& url,
michael@0 147 const uint32_t& length,
michael@0 148 const uint32_t& lastmodified,
michael@0 149 PStreamNotifyChild* notifyData,
michael@0 150 const nsCString& headers,
michael@0 151 const nsCString& mimeType,
michael@0 152 const bool& seekable,
michael@0 153 NPError* rv,
michael@0 154 uint16_t *stype) MOZ_OVERRIDE;
michael@0 155
michael@0 156 virtual bool
michael@0 157 AnswerPBrowserStreamConstructor(
michael@0 158 PBrowserStreamChild* aActor,
michael@0 159 const nsCString& url,
michael@0 160 const uint32_t& length,
michael@0 161 const uint32_t& lastmodified,
michael@0 162 PStreamNotifyChild* notifyData,
michael@0 163 const nsCString& headers,
michael@0 164 const nsCString& mimeType,
michael@0 165 const bool& seekable,
michael@0 166 NPError* rv,
michael@0 167 uint16_t* stype) MOZ_OVERRIDE;
michael@0 168
michael@0 169 virtual bool
michael@0 170 DeallocPBrowserStreamChild(PBrowserStreamChild* stream) MOZ_OVERRIDE;
michael@0 171
michael@0 172 virtual PPluginStreamChild*
michael@0 173 AllocPPluginStreamChild(const nsCString& mimeType,
michael@0 174 const nsCString& target,
michael@0 175 NPError* result) MOZ_OVERRIDE;
michael@0 176
michael@0 177 virtual bool
michael@0 178 DeallocPPluginStreamChild(PPluginStreamChild* stream) MOZ_OVERRIDE;
michael@0 179
michael@0 180 virtual PStreamNotifyChild*
michael@0 181 AllocPStreamNotifyChild(const nsCString& url, const nsCString& target,
michael@0 182 const bool& post, const nsCString& buffer,
michael@0 183 const bool& file,
michael@0 184 NPError* result) MOZ_OVERRIDE;
michael@0 185
michael@0 186 virtual bool
michael@0 187 DeallocPStreamNotifyChild(PStreamNotifyChild* notifyData) MOZ_OVERRIDE;
michael@0 188
michael@0 189 virtual bool
michael@0 190 AnswerSetPluginFocus() MOZ_OVERRIDE;
michael@0 191
michael@0 192 virtual bool
michael@0 193 AnswerUpdateWindow() MOZ_OVERRIDE;
michael@0 194
michael@0 195 virtual bool
michael@0 196 RecvNPP_DidComposite() MOZ_OVERRIDE;
michael@0 197
michael@0 198 #if defined(MOZ_X11) && defined(XP_UNIX) && !defined(XP_MACOSX)
michael@0 199 bool CreateWindow(const NPRemoteWindow& aWindow);
michael@0 200 void DeleteWindow();
michael@0 201 #endif
michael@0 202
michael@0 203 public:
michael@0 204 PluginInstanceChild(const NPPluginFuncs* aPluginIface);
michael@0 205
michael@0 206 virtual ~PluginInstanceChild();
michael@0 207
michael@0 208 bool Initialize();
michael@0 209
michael@0 210 NPP GetNPP()
michael@0 211 {
michael@0 212 return &mData;
michael@0 213 }
michael@0 214
michael@0 215 NPError
michael@0 216 NPN_GetValue(NPNVariable aVariable, void* aValue);
michael@0 217
michael@0 218 NPError
michael@0 219 NPN_SetValue(NPPVariable aVariable, void* aValue);
michael@0 220
michael@0 221 PluginScriptableObjectChild*
michael@0 222 GetActorForNPObject(NPObject* aObject);
michael@0 223
michael@0 224 NPError
michael@0 225 NPN_NewStream(NPMIMEType aMIMEType, const char* aWindow,
michael@0 226 NPStream** aStream);
michael@0 227
michael@0 228 void InvalidateRect(NPRect* aInvalidRect);
michael@0 229
michael@0 230 #ifdef MOZ_WIDGET_COCOA
michael@0 231 void Invalidate();
michael@0 232 #endif // definied(MOZ_WIDGET_COCOA)
michael@0 233
michael@0 234 uint32_t ScheduleTimer(uint32_t interval, bool repeat, TimerFunc func);
michael@0 235 void UnscheduleTimer(uint32_t id);
michael@0 236
michael@0 237 void AsyncCall(PluginThreadCallback aFunc, void* aUserData);
michael@0 238
michael@0 239 int GetQuirks();
michael@0 240
michael@0 241 void NPN_URLRedirectResponse(void* notifyData, NPBool allow);
michael@0 242
michael@0 243 NPError NPN_InitAsyncSurface(NPSize *size, NPImageFormat format,
michael@0 244 void *initData, NPAsyncSurface *surface);
michael@0 245 NPError NPN_FinalizeAsyncSurface(NPAsyncSurface *surface);
michael@0 246
michael@0 247 void NPN_SetCurrentAsyncSurface(NPAsyncSurface *surface, NPRect *changed);
michael@0 248
michael@0 249 void DoAsyncRedraw();
michael@0 250 private:
michael@0 251 friend class PluginModuleChild;
michael@0 252
michael@0 253 NPError
michael@0 254 InternalGetNPObjectForValue(NPNVariable aValue,
michael@0 255 NPObject** aObject);
michael@0 256
michael@0 257 bool IsAsyncDrawing();
michael@0 258
michael@0 259 NPError DeallocateAsyncBitmapSurface(NPAsyncSurface *aSurface);
michael@0 260
michael@0 261 virtual bool RecvUpdateBackground(const SurfaceDescriptor& aBackground,
michael@0 262 const nsIntRect& aRect) MOZ_OVERRIDE;
michael@0 263
michael@0 264 virtual PPluginBackgroundDestroyerChild*
michael@0 265 AllocPPluginBackgroundDestroyerChild() MOZ_OVERRIDE;
michael@0 266
michael@0 267 virtual bool
michael@0 268 RecvPPluginBackgroundDestroyerConstructor(PPluginBackgroundDestroyerChild* aActor) MOZ_OVERRIDE;
michael@0 269
michael@0 270 virtual bool
michael@0 271 DeallocPPluginBackgroundDestroyerChild(PPluginBackgroundDestroyerChild* aActor) MOZ_OVERRIDE;
michael@0 272
michael@0 273 #if defined(OS_WIN)
michael@0 274 static bool RegisterWindowClass();
michael@0 275 bool CreatePluginWindow();
michael@0 276 void DestroyPluginWindow();
michael@0 277 void ReparentPluginWindow(HWND hWndParent);
michael@0 278 void SizePluginWindow(int width, int height);
michael@0 279 int16_t WinlessHandleEvent(NPEvent& event);
michael@0 280 void CreateWinlessPopupSurrogate();
michael@0 281 void DestroyWinlessPopupSurrogate();
michael@0 282 void InitPopupMenuHook();
michael@0 283 void SetupFlashMsgThrottle();
michael@0 284 void UnhookWinlessFlashThrottle();
michael@0 285 void HookSetWindowLongPtr();
michael@0 286 static inline bool SetWindowLongHookCheck(HWND hWnd,
michael@0 287 int nIndex,
michael@0 288 LONG_PTR newLong);
michael@0 289 void FlashThrottleMessage(HWND, UINT, WPARAM, LPARAM, bool);
michael@0 290 static LRESULT CALLBACK DummyWindowProc(HWND hWnd,
michael@0 291 UINT message,
michael@0 292 WPARAM wParam,
michael@0 293 LPARAM lParam);
michael@0 294 static LRESULT CALLBACK PluginWindowProc(HWND hWnd,
michael@0 295 UINT message,
michael@0 296 WPARAM wParam,
michael@0 297 LPARAM lParam);
michael@0 298 static BOOL WINAPI TrackPopupHookProc(HMENU hMenu,
michael@0 299 UINT uFlags,
michael@0 300 int x,
michael@0 301 int y,
michael@0 302 int nReserved,
michael@0 303 HWND hWnd,
michael@0 304 CONST RECT *prcRect);
michael@0 305 static BOOL CALLBACK EnumThreadWindowsCallback(HWND hWnd,
michael@0 306 LPARAM aParam);
michael@0 307 static LRESULT CALLBACK WinlessHiddenFlashWndProc(HWND hWnd,
michael@0 308 UINT message,
michael@0 309 WPARAM wParam,
michael@0 310 LPARAM lParam);
michael@0 311 #ifdef _WIN64
michael@0 312 static LONG_PTR WINAPI SetWindowLongPtrAHook(HWND hWnd,
michael@0 313 int nIndex,
michael@0 314 LONG_PTR newLong);
michael@0 315 static LONG_PTR WINAPI SetWindowLongPtrWHook(HWND hWnd,
michael@0 316 int nIndex,
michael@0 317 LONG_PTR newLong);
michael@0 318
michael@0 319 #else
michael@0 320 static LONG WINAPI SetWindowLongAHook(HWND hWnd,
michael@0 321 int nIndex,
michael@0 322 LONG newLong);
michael@0 323 static LONG WINAPI SetWindowLongWHook(HWND hWnd,
michael@0 324 int nIndex,
michael@0 325 LONG newLong);
michael@0 326 #endif
michael@0 327
michael@0 328 class FlashThrottleAsyncMsg : public ChildAsyncCall
michael@0 329 {
michael@0 330 public:
michael@0 331 FlashThrottleAsyncMsg();
michael@0 332 FlashThrottleAsyncMsg(PluginInstanceChild* aInst,
michael@0 333 HWND aWnd, UINT aMsg,
michael@0 334 WPARAM aWParam, LPARAM aLParam,
michael@0 335 bool isWindowed)
michael@0 336 : ChildAsyncCall(aInst, nullptr, nullptr),
michael@0 337 mWnd(aWnd),
michael@0 338 mMsg(aMsg),
michael@0 339 mWParam(aWParam),
michael@0 340 mLParam(aLParam),
michael@0 341 mWindowed(isWindowed)
michael@0 342 {}
michael@0 343
michael@0 344 void Run() MOZ_OVERRIDE;
michael@0 345
michael@0 346 WNDPROC GetProc();
michael@0 347 HWND GetWnd() { return mWnd; }
michael@0 348 UINT GetMsg() { return mMsg; }
michael@0 349 WPARAM GetWParam() { return mWParam; }
michael@0 350 LPARAM GetLParam() { return mLParam; }
michael@0 351
michael@0 352 private:
michael@0 353 HWND mWnd;
michael@0 354 UINT mMsg;
michael@0 355 WPARAM mWParam;
michael@0 356 LPARAM mLParam;
michael@0 357 bool mWindowed;
michael@0 358 };
michael@0 359
michael@0 360 #endif
michael@0 361 const NPPluginFuncs* mPluginIface;
michael@0 362 NPP_t mData;
michael@0 363 NPWindow mWindow;
michael@0 364 #if defined(XP_MACOSX)
michael@0 365 double mContentsScaleFactor;
michael@0 366 #endif
michael@0 367 int16_t mDrawingModel;
michael@0 368 NPAsyncSurface* mCurrentAsyncSurface;
michael@0 369 struct AsyncBitmapData {
michael@0 370 void *mRemotePtr;
michael@0 371 Shmem mShmem;
michael@0 372 };
michael@0 373
michael@0 374 static PLDHashOperator DeleteSurface(NPAsyncSurface* surf, nsAutoPtr<AsyncBitmapData> &data, void* userArg);
michael@0 375 nsClassHashtable<nsPtrHashKey<NPAsyncSurface>, AsyncBitmapData> mAsyncBitmaps;
michael@0 376 Shmem mRemoteImageDataShmem;
michael@0 377 mozilla::layers::RemoteImageData *mRemoteImageData;
michael@0 378 nsAutoPtr<CrossProcessMutex> mRemoteImageDataMutex;
michael@0 379 mozilla::Mutex mAsyncInvalidateMutex;
michael@0 380 CancelableTask *mAsyncInvalidateTask;
michael@0 381
michael@0 382 // Cached scriptable actors to avoid IPC churn
michael@0 383 PluginScriptableObjectChild* mCachedWindowActor;
michael@0 384 PluginScriptableObjectChild* mCachedElementActor;
michael@0 385
michael@0 386 #if defined(MOZ_X11) && defined(XP_UNIX) && !defined(XP_MACOSX)
michael@0 387 NPSetWindowCallbackStruct mWsInfo;
michael@0 388 #if (MOZ_WIDGET_GTK == 2)
michael@0 389 bool mXEmbed;
michael@0 390 XtClient mXtClient;
michael@0 391 #endif
michael@0 392 #elif defined(OS_WIN)
michael@0 393 HWND mPluginWindowHWND;
michael@0 394 WNDPROC mPluginWndProc;
michael@0 395 HWND mPluginParentHWND;
michael@0 396 int mNestedEventLevelDepth;
michael@0 397 HWND mCachedWinlessPluginHWND;
michael@0 398 HWND mWinlessPopupSurrogateHWND;
michael@0 399 nsIntPoint mPluginSize;
michael@0 400 WNDPROC mWinlessThrottleOldWndProc;
michael@0 401 HWND mWinlessHiddenMsgHWND;
michael@0 402 #endif
michael@0 403
michael@0 404 friend class ChildAsyncCall;
michael@0 405
michael@0 406 Mutex mAsyncCallMutex;
michael@0 407 nsTArray<ChildAsyncCall*> mPendingAsyncCalls;
michael@0 408 nsTArray<nsAutoPtr<ChildTimer> > mTimers;
michael@0 409
michael@0 410 /**
michael@0 411 * During destruction we enumerate all remaining scriptable objects and
michael@0 412 * invalidate/delete them. Enumeration can re-enter, so maintain a
michael@0 413 * hash separate from PluginModuleChild.mObjectMap.
michael@0 414 */
michael@0 415 nsAutoPtr< nsTHashtable<DeletingObjectEntry> > mDeletingHash;
michael@0 416
michael@0 417 #if defined(OS_WIN)
michael@0 418 private:
michael@0 419 // Shared dib rendering management for windowless plugins.
michael@0 420 bool SharedSurfaceSetWindow(const NPRemoteWindow& aWindow);
michael@0 421 int16_t SharedSurfacePaint(NPEvent& evcopy);
michael@0 422 void SharedSurfaceRelease();
michael@0 423 bool AlphaExtractCacheSetup();
michael@0 424 void AlphaExtractCacheRelease();
michael@0 425 void UpdatePaintClipRect(RECT* aRect);
michael@0 426
michael@0 427 private:
michael@0 428 enum {
michael@0 429 RENDER_NATIVE,
michael@0 430 RENDER_BACK_ONE,
michael@0 431 RENDER_BACK_TWO
michael@0 432 };
michael@0 433 gfx::SharedDIBWin mSharedSurfaceDib;
michael@0 434 struct {
michael@0 435 uint16_t doublePass;
michael@0 436 HDC hdc;
michael@0 437 HBITMAP bmp;
michael@0 438 } mAlphaExtract;
michael@0 439 #endif // defined(OS_WIN)
michael@0 440 #if defined(MOZ_WIDGET_COCOA)
michael@0 441 private:
michael@0 442 #if defined(__i386__)
michael@0 443 NPEventModel mEventModel;
michael@0 444 #endif
michael@0 445 CGColorSpaceRef mShColorSpace;
michael@0 446 CGContextRef mShContext;
michael@0 447 mozilla::RefPtr<nsCARenderer> mCARenderer;
michael@0 448 void *mCGLayer;
michael@0 449
michael@0 450 // Core Animation drawing model requires a refresh timer.
michael@0 451 uint32_t mCARefreshTimer;
michael@0 452
michael@0 453 public:
michael@0 454 const NPCocoaEvent* getCurrentEvent() {
michael@0 455 return mCurrentEvent;
michael@0 456 }
michael@0 457
michael@0 458 bool CGDraw(CGContextRef ref, nsIntRect aUpdateRect);
michael@0 459
michael@0 460 #if defined(__i386__)
michael@0 461 NPEventModel EventModel() { return mEventModel; }
michael@0 462 #endif
michael@0 463
michael@0 464 private:
michael@0 465 const NPCocoaEvent *mCurrentEvent;
michael@0 466 #endif
michael@0 467
michael@0 468 bool CanPaintOnBackground();
michael@0 469
michael@0 470 bool IsVisible() {
michael@0 471 #ifdef XP_MACOSX
michael@0 472 return mWindow.clipRect.top != mWindow.clipRect.bottom &&
michael@0 473 mWindow.clipRect.left != mWindow.clipRect.right;
michael@0 474 #else
michael@0 475 return mWindow.clipRect.top != 0 ||
michael@0 476 mWindow.clipRect.left != 0 ||
michael@0 477 mWindow.clipRect.bottom != 0 ||
michael@0 478 mWindow.clipRect.right != 0;
michael@0 479 #endif
michael@0 480 }
michael@0 481
michael@0 482 // ShowPluginFrame - in general does four things:
michael@0 483 // 1) Create mCurrentSurface optimized for rendering to parent process
michael@0 484 // 2) Updated mCurrentSurface to be a complete copy of mBackSurface
michael@0 485 // 3) Draw the invalidated plugin area into mCurrentSurface
michael@0 486 // 4) Send it to parent process.
michael@0 487 bool ShowPluginFrame(void);
michael@0 488
michael@0 489 // If we can read back safely from mBackSurface, copy
michael@0 490 // mSurfaceDifferenceRect from mBackSurface to mFrontSurface.
michael@0 491 // @return Whether the back surface could be read.
michael@0 492 bool ReadbackDifferenceRect(const nsIntRect& rect);
michael@0 493
michael@0 494 // Post ShowPluginFrame task
michael@0 495 void AsyncShowPluginFrame(void);
michael@0 496
michael@0 497 // In the PaintRect functions, aSurface is the size of the full plugin
michael@0 498 // window. Each PaintRect function renders into the subrectangle aRect of
michael@0 499 // aSurface (possibly more if we're working around a Flash bug).
michael@0 500
michael@0 501 // Paint plugin content rectangle to surface with bg color filling
michael@0 502 void PaintRectToSurface(const nsIntRect& aRect,
michael@0 503 gfxASurface* aSurface,
michael@0 504 const gfxRGBA& aColor);
michael@0 505
michael@0 506 // Render plugin content to surface using
michael@0 507 // white/black image alpha extraction algorithm
michael@0 508 void PaintRectWithAlphaExtraction(const nsIntRect& aRect,
michael@0 509 gfxASurface* aSurface);
michael@0 510
michael@0 511 // Call plugin NPAPI function to render plugin content to surface
michael@0 512 // @param - aSurface - should be compatible with current platform plugin rendering
michael@0 513 // @return - FALSE if plugin not painted to surface
michael@0 514 void PaintRectToPlatformSurface(const nsIntRect& aRect,
michael@0 515 gfxASurface* aSurface);
michael@0 516
michael@0 517 // Update NPWindow platform attributes and call plugin "setwindow"
michael@0 518 // @param - aForceSetWindow - call setwindow even if platform attributes are the same
michael@0 519 void UpdateWindowAttributes(bool aForceSetWindow = false);
michael@0 520
michael@0 521 // Create optimized mCurrentSurface for parent process rendering
michael@0 522 // @return FALSE if optimized surface not created
michael@0 523 bool CreateOptSurface(void);
michael@0 524
michael@0 525 // Create mHelperSurface if mCurrentSurface non compatible with plugins
michael@0 526 // @return TRUE if helper surface created successfully, or not needed
michael@0 527 bool MaybeCreatePlatformHelperSurface(void);
michael@0 528
michael@0 529 // Make sure that we have surface for rendering
michael@0 530 bool EnsureCurrentBuffer(void);
michael@0 531
michael@0 532 // Helper function for delayed InvalidateRect call
michael@0 533 // non null mCurrentInvalidateTask will call this function
michael@0 534 void InvalidateRectDelayed(void);
michael@0 535
michael@0 536 // Clear mCurrentSurface/mCurrentSurfaceActor/mHelperSurface
michael@0 537 void ClearCurrentSurface();
michael@0 538
michael@0 539 // Swap mCurrentSurface/mBackSurface and their associated actors
michael@0 540 void SwapSurfaces();
michael@0 541
michael@0 542 // Clear all surfaces in response to NPP_Destroy
michael@0 543 void ClearAllSurfaces();
michael@0 544
michael@0 545 // Set as true when SetupLayer called
michael@0 546 // and go with different path in InvalidateRect function
michael@0 547 bool mLayersRendering;
michael@0 548
michael@0 549 // Current surface available for rendering
michael@0 550 nsRefPtr<gfxASurface> mCurrentSurface;
michael@0 551
michael@0 552 // Back surface, just keeping reference to
michael@0 553 // surface which is on ParentProcess side
michael@0 554 nsRefPtr<gfxASurface> mBackSurface;
michael@0 555
michael@0 556 #ifdef XP_MACOSX
michael@0 557 // Current IOSurface available for rendering
michael@0 558 // We can't use thebes gfxASurface like other platforms.
michael@0 559 PluginUtilsOSX::nsDoubleBufferCARenderer mDoubleBufferCARenderer;
michael@0 560 #endif
michael@0 561
michael@0 562 // (Not to be confused with mBackSurface). This is a recent copy
michael@0 563 // of the opaque pixels under our object frame, if
michael@0 564 // |mIsTransparent|. We ask the plugin render directly onto a
michael@0 565 // copy of the background pixels if available, and fall back on
michael@0 566 // alpha recovery otherwise.
michael@0 567 nsRefPtr<gfxASurface> mBackground;
michael@0 568
michael@0 569 #ifdef XP_WIN
michael@0 570 // These actors mirror mCurrentSurface/mBackSurface
michael@0 571 PPluginSurfaceChild* mCurrentSurfaceActor;
michael@0 572 PPluginSurfaceChild* mBackSurfaceActor;
michael@0 573 #endif
michael@0 574
michael@0 575 // Accumulated invalidate rect, while back buffer is not accessible,
michael@0 576 // in plugin coordinates.
michael@0 577 nsIntRect mAccumulatedInvalidRect;
michael@0 578
michael@0 579 // Plugin only call SetTransparent
michael@0 580 // and does not remember their transparent state
michael@0 581 // and p->getvalue return always false
michael@0 582 bool mIsTransparent;
michael@0 583
michael@0 584 // Surface type optimized of parent process
michael@0 585 gfxSurfaceType mSurfaceType;
michael@0 586
michael@0 587 // Keep InvalidateRect task pointer to be able Cancel it on Destroy
michael@0 588 CancelableTask *mCurrentInvalidateTask;
michael@0 589
michael@0 590 // Keep AsyncSetWindow task pointer to be able to Cancel it on Destroy
michael@0 591 CancelableTask *mCurrentAsyncSetWindowTask;
michael@0 592
michael@0 593 // True while plugin-child in plugin call
michael@0 594 // Use to prevent plugin paint re-enter
michael@0 595 bool mPendingPluginCall;
michael@0 596
michael@0 597 // On some platforms, plugins may not support rendering to a surface with
michael@0 598 // alpha, or not support rendering to an image surface.
michael@0 599 // In those cases we need to draw to a temporary platform surface; we cache
michael@0 600 // that surface here.
michael@0 601 nsRefPtr<gfxASurface> mHelperSurface;
michael@0 602
michael@0 603 // true when plugin does not support painting to ARGB32
michael@0 604 // surface this is false if plugin supports
michael@0 605 // NPPVpluginTransparentAlphaBool (which is not part of
michael@0 606 // NPAPI yet)
michael@0 607 bool mDoAlphaExtraction;
michael@0 608
michael@0 609 // true when the plugin has painted at least once. We use this to ensure
michael@0 610 // that we ask a plugin to paint at least once even if it's invisible;
michael@0 611 // some plugin (instances) rely on this in order to work properly.
michael@0 612 bool mHasPainted;
michael@0 613
michael@0 614 // Cached rectangle rendered to previous surface(mBackSurface)
michael@0 615 // Used for reading back to current surface and syncing data,
michael@0 616 // in plugin coordinates.
michael@0 617 nsIntRect mSurfaceDifferenceRect;
michael@0 618 };
michael@0 619
michael@0 620 } // namespace plugins
michael@0 621 } // namespace mozilla
michael@0 622
michael@0 623 #endif // ifndef dom_plugins_PluginInstanceChild_h

mercurial