From cbcf60df5e43f377684606df25a9265642712a2e Mon Sep 17 00:00:00 2001 From: Olli Pettay Date: Thu, 8 May 2014 16:04:00 +0200 Subject: [PATCH] Bug 1003041 - Merge PRenderFrame() and InitRenderFrame() to avoid extra sync child->parent messaging. r=billm --- dom/ipc/PBrowser.ipdl | 4 +-- dom/ipc/TabChild.cpp | 11 +++++--- dom/ipc/TabChild.h | 5 +++- dom/ipc/TabParent.cpp | 43 +++++++++++--------------------- dom/ipc/TabParent.h | 16 ++++++------ layout/ipc/RenderFrameParent.cpp | 21 ++++++++-------- layout/ipc/RenderFrameParent.h | 13 ++++------ 7 files changed, 53 insertions(+), 60 deletions(-) diff --git a/dom/ipc/PBrowser.ipdl b/dom/ipc/PBrowser.ipdl index c3f47b850d05..8143c3052ffa 100644 --- a/dom/ipc/PBrowser.ipdl +++ b/dom/ipc/PBrowser.ipdl @@ -269,9 +269,7 @@ parent: * Create a layout frame (encapsulating a remote layer tree) for * the page that is currently loaded in the . */ - sync PRenderFrame(); - - sync InitRenderFrame(PRenderFrame aFrame) + sync PRenderFrame() returns (ScrollingBehavior scrolling, TextureFactoryIdentifier textureFactoryIdentifier, uint64_t layersId, bool success); diff --git a/dom/ipc/TabChild.cpp b/dom/ipc/TabChild.cpp index 25cdb3a669a5..6f2babbedc06 100644 --- a/dom/ipc/TabChild.cpp +++ b/dom/ipc/TabChild.cpp @@ -2379,7 +2379,10 @@ TabChild::RecvSetIsDocShellActive(const bool& aIsActive) } PRenderFrameChild* -TabChild::AllocPRenderFrameChild() +TabChild::AllocPRenderFrameChild(ScrollingBehavior* aScrolling, + TextureFactoryIdentifier* aTextureFactoryIdentifier, + uint64_t* aLayersId, + bool* aSuccess) { return new RenderFrameChild(); } @@ -2438,12 +2441,14 @@ TabChild::InitRenderingState() uint64_t id; bool success; RenderFrameChild* remoteFrame = - static_cast(SendPRenderFrameConstructor()); + static_cast(SendPRenderFrameConstructor( + &mScrolling, + &mTextureFactoryIdentifier, &id, + &success)); if (!remoteFrame) { NS_WARNING("failed to construct RenderFrame"); return false; } - SendInitRenderFrame(remoteFrame, &mScrolling, &mTextureFactoryIdentifier, &id, &success); if (!success) { NS_WARNING("failed to construct RenderFrame"); PRenderFrameChild::Send__delete__(remoteFrame); diff --git a/dom/ipc/TabChild.h b/dom/ipc/TabChild.h index 04f3e3bdbca5..ebe21c809f9c 100644 --- a/dom/ipc/TabChild.h +++ b/dom/ipc/TabChild.h @@ -457,7 +457,10 @@ public: } protected: - virtual PRenderFrameChild* AllocPRenderFrameChild() MOZ_OVERRIDE; + virtual PRenderFrameChild* AllocPRenderFrameChild(ScrollingBehavior* aScrolling, + TextureFactoryIdentifier* aTextureFactoryIdentifier, + uint64_t* aLayersId, + bool* aSuccess) MOZ_OVERRIDE; virtual bool DeallocPRenderFrameChild(PRenderFrameChild* aFrame) MOZ_OVERRIDE; virtual bool RecvDestroy() MOZ_OVERRIDE; virtual bool RecvSetUpdateHitRegion(const bool& aEnabled) MOZ_OVERRIDE; diff --git a/dom/ipc/TabParent.cpp b/dom/ipc/TabParent.cpp index b38492cab246..dd2a95c8c24d 100644 --- a/dom/ipc/TabParent.cpp +++ b/dom/ipc/TabParent.cpp @@ -1740,36 +1740,19 @@ TabParent::DeallocPColorPickerParent(PColorPickerParent* actor) return true; } -bool -TabParent::RecvInitRenderFrame(PRenderFrameParent* aFrame, - ScrollingBehavior* aScrolling, - TextureFactoryIdentifier* aTextureFactoryIdentifier, - uint64_t* aLayersId, - bool *aSuccess) -{ - *aScrolling = UseAsyncPanZoom() ? ASYNC_PAN_ZOOM : DEFAULT_SCROLLING; - *aTextureFactoryIdentifier = TextureFactoryIdentifier(); - *aLayersId = 0; - - nsRefPtr frameLoader = GetFrameLoader(); - if (!frameLoader) { - NS_WARNING("Can't allocate graphics resources. May already be shutting down."); - *aSuccess = false; - return true; - } - - static_cast(aFrame)->Init(frameLoader, *aScrolling, - aTextureFactoryIdentifier, aLayersId); - - *aSuccess = true; - return true; -} - PRenderFrameParent* -TabParent::AllocPRenderFrameParent() +TabParent::AllocPRenderFrameParent(ScrollingBehavior* aScrolling, + TextureFactoryIdentifier* aTextureFactoryIdentifier, + uint64_t* aLayersId, bool* aSuccess) { MOZ_ASSERT(ManagedPRenderFrameParent().IsEmpty()); - return new RenderFrameParent(); + + nsRefPtr frameLoader = GetFrameLoader(); + *aScrolling = UseAsyncPanZoom() ? ASYNC_PAN_ZOOM : DEFAULT_SCROLLING; + return new RenderFrameParent(frameLoader, + *aScrolling, + aTextureFactoryIdentifier, aLayersId, + aSuccess); } bool @@ -1919,7 +1902,11 @@ TabParent::RecvBrowserFrameOpenWindow(PBrowserParent* aOpener, } bool -TabParent::RecvPRenderFrameConstructor(PRenderFrameParent* actor) +TabParent::RecvPRenderFrameConstructor(PRenderFrameParent* aActor, + ScrollingBehavior* aScrolling, + TextureFactoryIdentifier* aFactoryIdentifier, + uint64_t* aLayersId, + bool* aSuccess) { return true; } diff --git a/dom/ipc/TabParent.h b/dom/ipc/TabParent.h index 607347385349..6cb86dd593bc 100644 --- a/dom/ipc/TabParent.h +++ b/dom/ipc/TabParent.h @@ -115,12 +115,11 @@ public: virtual bool RecvMoveFocus(const bool& aForward) MOZ_OVERRIDE; virtual bool RecvEvent(const RemoteDOMEvent& aEvent) MOZ_OVERRIDE; virtual bool RecvReplyKeyEvent(const WidgetKeyboardEvent& event); - virtual bool RecvPRenderFrameConstructor(PRenderFrameParent* actor) MOZ_OVERRIDE; - virtual bool RecvInitRenderFrame(PRenderFrameParent* aFrame, - ScrollingBehavior* scrolling, - TextureFactoryIdentifier* identifier, - uint64_t* layersId, - bool *aSuccess) MOZ_OVERRIDE; + virtual bool RecvPRenderFrameConstructor(PRenderFrameParent* aActor, + ScrollingBehavior* aScrolling, + TextureFactoryIdentifier* aFactoryIdentifier, + uint64_t* aLayersId, + bool* aSuccess) MOZ_OVERRIDE; virtual bool RecvBrowserFrameOpenWindow(PBrowserParent* aOpener, const nsString& aURL, const nsString& aName, @@ -328,7 +327,10 @@ protected: bool AllowContentIME(); nsIntPoint GetChildProcessOffset(); - virtual PRenderFrameParent* AllocPRenderFrameParent() MOZ_OVERRIDE; + virtual PRenderFrameParent* AllocPRenderFrameParent(ScrollingBehavior* aScrolling, + TextureFactoryIdentifier* aTextureFactoryIdentifier, + uint64_t* aLayersId, + bool* aSuccess) MOZ_OVERRIDE; virtual bool DeallocPRenderFrameParent(PRenderFrameParent* aFrame) MOZ_OVERRIDE; // IME diff --git a/layout/ipc/RenderFrameParent.cpp b/layout/ipc/RenderFrameParent.cpp index c5a841ef106f..2b0d4126ebdc 100644 --- a/layout/ipc/RenderFrameParent.cpp +++ b/layout/ipc/RenderFrameParent.cpp @@ -704,20 +704,20 @@ private: nsRegion mTouchSensitiveRegion; }; -RenderFrameParent::RenderFrameParent() +RenderFrameParent::RenderFrameParent(nsFrameLoader* aFrameLoader, + ScrollingBehavior aScrollingBehavior, + TextureFactoryIdentifier* aTextureFactoryIdentifier, + uint64_t* aId, + bool* aSuccess) : mLayersId(0) + , mFrameLoader(aFrameLoader) , mFrameLoaderDestroyed(false) , mBackgroundColor(gfxRGBA(1, 1, 1)) { -} - -void -RenderFrameParent::Init(nsFrameLoader* aFrameLoader, - ScrollingBehavior aScrollingBehavior, - TextureFactoryIdentifier* aTextureFactoryIdentifier, - uint64_t* aId) -{ - mFrameLoader = aFrameLoader; + *aSuccess = false; + if (!mFrameLoader) { + return; + } *aId = 0; @@ -752,6 +752,7 @@ RenderFrameParent::Init(nsFrameLoader* aFrameLoader, } // Set a default RenderFrameParent mFrameLoader->SetCurrentRemoteFrame(this); + *aSuccess = true; } APZCTreeManager* diff --git a/layout/ipc/RenderFrameParent.h b/layout/ipc/RenderFrameParent.h index f7d062aee0ba..7af1ce40f771 100644 --- a/layout/ipc/RenderFrameParent.h +++ b/layout/ipc/RenderFrameParent.h @@ -55,20 +55,17 @@ class RenderFrameParent : public PRenderFrameParent, public: typedef std::map > ViewMap; - /* Init should be called immediately after allocation. */ - RenderFrameParent(); - virtual ~RenderFrameParent(); /** * Select the desired scrolling behavior. If ASYNC_PAN_ZOOM is * chosen, then RenderFrameParent will watch input events and use * them to asynchronously pan and zoom. */ - void - Init(nsFrameLoader* aFrameLoader, - ScrollingBehavior aScrollingBehavior, - TextureFactoryIdentifier* aTextureFactoryIdentifier, - uint64_t* aId); + RenderFrameParent(nsFrameLoader* aFrameLoader, + ScrollingBehavior aScrollingBehavior, + TextureFactoryIdentifier* aTextureFactoryIdentifier, + uint64_t* aId, bool* aSuccess); + virtual ~RenderFrameParent(); void Destroy();