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