michael@0: /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- michael@0: * vim: sw=4 ts=4 et : michael@0: * This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: #ifndef dom_plugins_PluginInstanceParent_h michael@0: #define dom_plugins_PluginInstanceParent_h 1 michael@0: michael@0: #include "mozilla/plugins/PPluginInstanceParent.h" michael@0: #include "mozilla/plugins/PluginScriptableObjectParent.h" michael@0: #if defined(OS_WIN) michael@0: #include "mozilla/gfx/SharedDIBWin.h" michael@0: #include michael@0: #include "nsRefPtrHashtable.h" michael@0: #elif defined(MOZ_WIDGET_COCOA) michael@0: #include "mozilla/gfx/QuartzSupport.h" michael@0: #endif michael@0: michael@0: #include "npfunctions.h" michael@0: #include "nsAutoPtr.h" michael@0: #include "nsDataHashtable.h" michael@0: #include "nsHashKeys.h" michael@0: #include "nsRect.h" michael@0: michael@0: #ifdef MOZ_X11 michael@0: class gfxXlibSurface; michael@0: #endif michael@0: #include "mozilla/unused.h" michael@0: michael@0: class gfxASurface; michael@0: class gfxContext; michael@0: michael@0: namespace mozilla { michael@0: namespace layers { michael@0: class ImageContainer; michael@0: class CompositionNotifySink; michael@0: } michael@0: namespace plugins { michael@0: michael@0: class PBrowserStreamParent; michael@0: class PluginModuleParent; michael@0: michael@0: class PluginInstanceParent : public PPluginInstanceParent michael@0: { michael@0: friend class PluginModuleParent; michael@0: friend class BrowserStreamParent; michael@0: friend class PluginStreamParent; michael@0: friend class StreamNotifyParent; michael@0: michael@0: public: michael@0: PluginInstanceParent(PluginModuleParent* parent, michael@0: NPP npp, michael@0: const nsCString& mimeType, michael@0: const NPNetscapeFuncs* npniface); michael@0: michael@0: virtual ~PluginInstanceParent(); michael@0: michael@0: bool Init(); michael@0: NPError Destroy(); michael@0: michael@0: virtual void ActorDestroy(ActorDestroyReason why) MOZ_OVERRIDE; michael@0: michael@0: virtual PPluginScriptableObjectParent* michael@0: AllocPPluginScriptableObjectParent() MOZ_OVERRIDE; michael@0: michael@0: virtual bool michael@0: RecvPPluginScriptableObjectConstructor(PPluginScriptableObjectParent* aActor) MOZ_OVERRIDE; michael@0: michael@0: virtual bool michael@0: DeallocPPluginScriptableObjectParent(PPluginScriptableObjectParent* aObject) MOZ_OVERRIDE; michael@0: virtual PBrowserStreamParent* michael@0: AllocPBrowserStreamParent(const nsCString& url, michael@0: const uint32_t& length, michael@0: const uint32_t& lastmodified, michael@0: PStreamNotifyParent* notifyData, michael@0: const nsCString& headers, michael@0: const nsCString& mimeType, michael@0: const bool& seekable, michael@0: NPError* rv, michael@0: uint16_t *stype) MOZ_OVERRIDE; michael@0: virtual bool michael@0: DeallocPBrowserStreamParent(PBrowserStreamParent* stream) MOZ_OVERRIDE; michael@0: michael@0: virtual PPluginStreamParent* michael@0: AllocPPluginStreamParent(const nsCString& mimeType, michael@0: const nsCString& target, michael@0: NPError* result) MOZ_OVERRIDE; michael@0: virtual bool michael@0: DeallocPPluginStreamParent(PPluginStreamParent* stream) MOZ_OVERRIDE; michael@0: michael@0: virtual bool michael@0: AnswerNPN_GetValue_NPNVnetscapeWindow(NativeWindowHandle* value, michael@0: NPError* result) MOZ_OVERRIDE; michael@0: virtual bool michael@0: AnswerNPN_GetValue_NPNVWindowNPObject( michael@0: PPluginScriptableObjectParent** value, michael@0: NPError* result) MOZ_OVERRIDE; michael@0: virtual bool michael@0: AnswerNPN_GetValue_NPNVPluginElementNPObject( michael@0: PPluginScriptableObjectParent** value, michael@0: NPError* result) MOZ_OVERRIDE; michael@0: virtual bool michael@0: AnswerNPN_GetValue_NPNVprivateModeBool(bool* value, NPError* result) MOZ_OVERRIDE; michael@0: michael@0: virtual bool michael@0: AnswerNPN_GetValue_DrawingModelSupport(const NPNVariable& model, bool* value) MOZ_OVERRIDE; michael@0: michael@0: virtual bool michael@0: AnswerNPN_GetValue_NPNVdocumentOrigin(nsCString* value, NPError* result) MOZ_OVERRIDE; michael@0: michael@0: virtual bool michael@0: AnswerNPN_SetValue_NPPVpluginWindow(const bool& windowed, NPError* result) MOZ_OVERRIDE; michael@0: virtual bool michael@0: AnswerNPN_SetValue_NPPVpluginTransparent(const bool& transparent, michael@0: NPError* result) MOZ_OVERRIDE; michael@0: virtual bool michael@0: AnswerNPN_SetValue_NPPVpluginUsesDOMForCursor(const bool& useDOMForCursor, michael@0: NPError* result) MOZ_OVERRIDE; michael@0: virtual bool michael@0: AnswerNPN_SetValue_NPPVpluginDrawingModel(const int& drawingModel, michael@0: OptionalShmem *remoteImageData, michael@0: CrossProcessMutexHandle *mutex, michael@0: NPError* result) MOZ_OVERRIDE; michael@0: virtual bool michael@0: AnswerNPN_SetValue_NPPVpluginEventModel(const int& eventModel, michael@0: NPError* result) MOZ_OVERRIDE; michael@0: michael@0: virtual bool michael@0: AnswerNPN_GetURL(const nsCString& url, const nsCString& target, michael@0: NPError *result) MOZ_OVERRIDE; michael@0: michael@0: virtual bool michael@0: AnswerNPN_PostURL(const nsCString& url, const nsCString& target, michael@0: const nsCString& buffer, const bool& file, michael@0: NPError* result) MOZ_OVERRIDE; michael@0: michael@0: virtual PStreamNotifyParent* michael@0: AllocPStreamNotifyParent(const nsCString& url, const nsCString& target, michael@0: const bool& post, const nsCString& buffer, michael@0: const bool& file, michael@0: NPError* result) MOZ_OVERRIDE; michael@0: michael@0: virtual bool michael@0: AnswerPStreamNotifyConstructor(PStreamNotifyParent* actor, michael@0: const nsCString& url, michael@0: const nsCString& target, michael@0: const bool& post, const nsCString& buffer, michael@0: const bool& file, michael@0: NPError* result) MOZ_OVERRIDE; michael@0: michael@0: virtual bool michael@0: DeallocPStreamNotifyParent(PStreamNotifyParent* notifyData) MOZ_OVERRIDE; michael@0: michael@0: virtual bool michael@0: RecvNPN_InvalidateRect(const NPRect& rect) MOZ_OVERRIDE; michael@0: michael@0: // Async rendering michael@0: virtual bool michael@0: RecvShow(const NPRect& updatedRect, michael@0: const SurfaceDescriptor& newSurface, michael@0: SurfaceDescriptor* prevSurface) MOZ_OVERRIDE; michael@0: michael@0: virtual PPluginSurfaceParent* michael@0: AllocPPluginSurfaceParent(const WindowsSharedMemoryHandle& handle, michael@0: const gfxIntSize& size, michael@0: const bool& transparent) MOZ_OVERRIDE; michael@0: michael@0: virtual bool michael@0: DeallocPPluginSurfaceParent(PPluginSurfaceParent* s) MOZ_OVERRIDE; michael@0: michael@0: virtual bool michael@0: AnswerNPN_PushPopupsEnabledState(const bool& aState) MOZ_OVERRIDE; michael@0: michael@0: virtual bool michael@0: AnswerNPN_PopPopupsEnabledState() MOZ_OVERRIDE; michael@0: michael@0: virtual bool michael@0: AnswerNPN_GetValueForURL(const NPNURLVariable& variable, michael@0: const nsCString& url, michael@0: nsCString* value, NPError* result) MOZ_OVERRIDE; michael@0: michael@0: virtual bool michael@0: AnswerNPN_SetValueForURL(const NPNURLVariable& variable, michael@0: const nsCString& url, michael@0: const nsCString& value, NPError* result) MOZ_OVERRIDE; michael@0: michael@0: virtual bool michael@0: AnswerNPN_GetAuthenticationInfo(const nsCString& protocol, michael@0: const nsCString& host, michael@0: const int32_t& port, michael@0: const nsCString& scheme, michael@0: const nsCString& realm, michael@0: nsCString* username, michael@0: nsCString* password, michael@0: NPError* result) MOZ_OVERRIDE; michael@0: michael@0: virtual bool michael@0: AnswerNPN_ConvertPoint(const double& sourceX, michael@0: const bool& ignoreDestX, michael@0: const double& sourceY, michael@0: const bool& ignoreDestY, michael@0: const NPCoordinateSpace& sourceSpace, michael@0: const NPCoordinateSpace& destSpace, michael@0: double *destX, michael@0: double *destY, michael@0: bool *result) MOZ_OVERRIDE; michael@0: michael@0: virtual bool michael@0: AnswerNPN_InitAsyncSurface(const gfxIntSize& size, michael@0: const NPImageFormat& format, michael@0: NPRemoteAsyncSurface* surfData, michael@0: bool* result) MOZ_OVERRIDE; michael@0: michael@0: virtual bool michael@0: RecvRedrawPlugin() MOZ_OVERRIDE; michael@0: michael@0: virtual bool michael@0: RecvNegotiatedCarbon() MOZ_OVERRIDE; michael@0: michael@0: virtual bool RecvReleaseDXGISharedSurface(const DXGISharedSurfaceHandle &aHandle) MOZ_OVERRIDE; michael@0: michael@0: NPError NPP_SetWindow(const NPWindow* aWindow); michael@0: michael@0: NPError NPP_GetValue(NPPVariable variable, void* retval); michael@0: NPError NPP_SetValue(NPNVariable variable, void* value); michael@0: michael@0: void NPP_URLRedirectNotify(const char* url, int32_t status, michael@0: void* notifyData); michael@0: michael@0: NPError NPP_NewStream(NPMIMEType type, NPStream* stream, michael@0: NPBool seekable, uint16_t* stype); michael@0: NPError NPP_DestroyStream(NPStream* stream, NPReason reason); michael@0: michael@0: void NPP_Print(NPPrint* platformPrint); michael@0: michael@0: int16_t NPP_HandleEvent(void* event); michael@0: michael@0: void NPP_URLNotify(const char* url, NPReason reason, void* notifyData); michael@0: michael@0: PluginModuleParent* Module() michael@0: { michael@0: return mParent; michael@0: } michael@0: michael@0: const NPNetscapeFuncs* GetNPNIface() michael@0: { michael@0: return mNPNIface; michael@0: } michael@0: michael@0: bool michael@0: RegisterNPObjectForActor(NPObject* aObject, michael@0: PluginScriptableObjectParent* aActor); michael@0: michael@0: void michael@0: UnregisterNPObject(NPObject* aObject); michael@0: michael@0: PluginScriptableObjectParent* michael@0: GetActorForNPObject(NPObject* aObject); michael@0: michael@0: NPP michael@0: GetNPP() michael@0: { michael@0: return mNPP; michael@0: } michael@0: michael@0: virtual bool michael@0: AnswerPluginFocusChange(const bool& gotFocus) MOZ_OVERRIDE; michael@0: michael@0: nsresult AsyncSetWindow(NPWindow* window); michael@0: nsresult GetImageContainer(mozilla::layers::ImageContainer** aContainer); michael@0: nsresult GetImageSize(nsIntSize* aSize); michael@0: #ifdef XP_MACOSX michael@0: nsresult IsRemoteDrawingCoreAnimation(bool *aDrawing); michael@0: nsresult ContentsScaleFactorChanged(double aContentsScaleFactor); michael@0: #endif michael@0: nsresult SetBackgroundUnknown(); michael@0: nsresult BeginUpdateBackground(const nsIntRect& aRect, michael@0: gfxContext** aCtx); michael@0: nsresult EndUpdateBackground(gfxContext* aCtx, michael@0: const nsIntRect& aRect); michael@0: void DidComposite() { unused << SendNPP_DidComposite(); } michael@0: michael@0: private: michael@0: // Create an appropriate platform surface for a background of size michael@0: // |aSize|. Return true if successful. michael@0: bool CreateBackground(const nsIntSize& aSize); michael@0: void DestroyBackground(); michael@0: SurfaceDescriptor BackgroundDescriptor() /*const*/; michael@0: michael@0: typedef mozilla::layers::ImageContainer ImageContainer; michael@0: ImageContainer *GetImageContainer(); michael@0: michael@0: virtual PPluginBackgroundDestroyerParent* michael@0: AllocPPluginBackgroundDestroyerParent() MOZ_OVERRIDE; michael@0: michael@0: virtual bool michael@0: DeallocPPluginBackgroundDestroyerParent(PPluginBackgroundDestroyerParent* aActor) MOZ_OVERRIDE; michael@0: michael@0: bool InternalGetValueForNPObject(NPNVariable aVariable, michael@0: PPluginScriptableObjectParent** aValue, michael@0: NPError* aResult); michael@0: michael@0: bool IsAsyncDrawing(); michael@0: michael@0: private: michael@0: PluginModuleParent* mParent; michael@0: NPP mNPP; michael@0: const NPNetscapeFuncs* mNPNIface; michael@0: NPWindowType mWindowType; michael@0: Shmem mRemoteImageDataShmem; michael@0: nsAutoPtr mRemoteImageDataMutex; michael@0: int16_t mDrawingModel; michael@0: nsAutoPtr mNotifySink; michael@0: michael@0: nsDataHashtable, PluginScriptableObjectParent*> mScriptableObjects; michael@0: michael@0: #if defined(OS_WIN) michael@0: private: michael@0: // Used in rendering windowless plugins in other processes. michael@0: bool SharedSurfaceSetWindow(const NPWindow* aWindow, NPRemoteWindow& aRemoteWindow); michael@0: void SharedSurfaceBeforePaint(RECT &rect, NPRemoteEvent& npremoteevent); michael@0: void SharedSurfaceAfterPaint(NPEvent* npevent); michael@0: void SharedSurfaceRelease(); michael@0: // Used in handling parent/child forwarding of events. michael@0: static LRESULT CALLBACK PluginWindowHookProc(HWND hWnd, UINT message, michael@0: WPARAM wParam, LPARAM lParam); michael@0: void SubclassPluginWindow(HWND aWnd); michael@0: void UnsubclassPluginWindow(); michael@0: michael@0: private: michael@0: gfx::SharedDIBWin mSharedSurfaceDib; michael@0: nsIntRect mPluginPort; michael@0: nsIntRect mSharedSize; michael@0: HWND mPluginHWND; michael@0: WNDPROC mPluginWndProc; michael@0: bool mNestedEventState; michael@0: michael@0: // This will automatically release the textures when this object goes away. michael@0: nsRefPtrHashtable, ID3D10Texture2D> mTextureMap; michael@0: #endif // defined(XP_WIN) michael@0: #if defined(MOZ_WIDGET_COCOA) michael@0: private: michael@0: Shmem mShSurface; michael@0: uint16_t mShWidth; michael@0: uint16_t mShHeight; michael@0: CGColorSpaceRef mShColorSpace; michael@0: RefPtr mIOSurface; michael@0: RefPtr mFrontIOSurface; michael@0: #endif // definied(MOZ_WIDGET_COCOA) michael@0: michael@0: // ObjectFrame layer wrapper michael@0: nsRefPtr mFrontSurface; michael@0: // For windowless+transparent instances, this surface contains a michael@0: // "pretty recent" copy of the pixels under its frame. michael@0: // On the plugin side, we use this surface to avoid doing alpha michael@0: // recovery when possible. This surface is created and owned by michael@0: // the browser, but a "read-only" reference is sent to the plugin. michael@0: // michael@0: // We have explicitly chosen not to provide any guarantees about michael@0: // the consistency of the pixels in |mBackground|. A plugin may michael@0: // be able to observe partial updates to the background. michael@0: nsRefPtr mBackground; michael@0: michael@0: nsRefPtr mImageContainer; michael@0: }; michael@0: michael@0: michael@0: } // namespace plugins michael@0: } // namespace mozilla michael@0: michael@0: #endif // ifndef dom_plugins_PluginInstanceParent_h