author | Kartikaya Gupta <kgupta@mozilla.com> |
Tue, 20 Mar 2012 00:05:45 -0400 | |
changeset 89792 | 3f893a92408a0e1a65252f964dbdb158cd905a8a |
parent 89791 | 4e78e02149342b6970f23f4b89e4b9db1dcf916e |
child 89793 | f93f7553317f5ac91433083612f783da14277342 |
push id | 7324 |
push user | kgupta@mozilla.com |
push date | Tue, 20 Mar 2012 04:27:34 +0000 |
treeherder | mozilla-inbound@22af7bc45a18 [default view] [failures only] |
perfherder | [talos] [build metrics] [platform microbench] (compared to previous push) |
reviewers | Cwiiis |
bugs | 731603 |
milestone | 14.0a1 |
first release with | nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
|
last release without | nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
|
--- a/gfx/layers/ipc/CompositorParent.cpp +++ b/gfx/layers/ipc/CompositorParent.cpp @@ -281,17 +281,25 @@ CompositorParent::TransformShadowTree() } else if (metrics && (metrics->mContentSize != mContentSize)) { mContentSize = metrics->mContentSize; mozilla::AndroidBridge::Bridge()->SetPageSize(1/rootScaleX, mContentSize.width, mContentSize.height); } // We synchronise the viewport information with Java after sending the above // notifications, so that Java can take these into account in its response. - SyncViewportInfo(); + if (metrics) { + // Calculate the absolute display port to send to Java + nsIntRect displayPort = metrics->mDisplayPort; + nsIntPoint scrollOffset = metrics->mViewportScrollOffset; + displayPort.x += scrollOffset.x; + displayPort.y += scrollOffset.y; + + mozilla::AndroidBridge::Bridge()->SyncViewportInfo(displayPort, 1/rootScaleX, mScrollOffset, mXScale, mYScale); + } // Handle transformations for asynchronous panning and zooming. We determine the // zoom used by Gecko from the transformation set on the root layer, and we // determine the scroll offset used by Gecko from the frame metrics of the // primary scrollable layer. We compare this to the desired zoom and scroll // offset in the view transform we obtained from Java in order to compute the // transformation we need to apply. if (metrics && metrics->IsScrollable()) { @@ -307,35 +315,16 @@ CompositorParent::TransformShadowTree() shadow->SetShadowTransform(gfx3DMatrix(treeTransform) * currentTransform); } else { ViewTransform treeTransform(nsIntPoint(0,0), mXScale, mYScale); shadow->SetShadowTransform(gfx3DMatrix(treeTransform) * currentTransform); } #endif } -#ifdef MOZ_WIDGET_ANDROID -void -CompositorParent::SyncViewportInfo() -{ - ContainerLayer* container = GetPrimaryScrollableLayer()->AsContainerLayer(); - const FrameMetrics* metrics = &container->GetFrameMetrics(); - - if (metrics) { - // Calculate the absolute display port to send to Java - nsIntRect displayPort = container->GetFrameMetrics().mDisplayPort; - nsIntPoint scrollOffset = metrics->mViewportScrollOffset; - displayPort.x += scrollOffset.x; - displayPort.y += scrollOffset.y; - - mozilla::AndroidBridge::Bridge()->SyncViewportInfo(displayPort, mScrollOffset, mXScale, mYScale); - } -} -#endif - void CompositorParent::ShadowLayersUpdated(bool isFirstPaint) { mIsFirstPaint = mIsFirstPaint || isFirstPaint; const nsTArray<PLayersParent*>& shadowParents = ManagedPLayersParent(); NS_ABORT_IF_FALSE(shadowParents.Length() <= 1, "can only support at most 1 ShadowLayersParent"); if (shadowParents.Length()) {
--- a/gfx/layers/ipc/CompositorParent.h +++ b/gfx/layers/ipc/CompositorParent.h @@ -118,23 +118,16 @@ private: void Composite(); void ScheduleComposition(); void TransformShadowTree(); // Platform specific functions #ifdef MOZ_WIDGET_ANDROID /** - * Informs Java of the current display port, and asks Java for its viewport - * position and zoom, to use in updating the world transform in - * TransformShadowTree. - */ - void SyncViewportInfo(); - - /** * Does a breadth-first search to find the first layer in the tree with a * displayport set. */ Layer* GetPrimaryScrollableLayer(); #endif nsRefPtr<LayerManager> mLayerManager; base::Thread* mCompositorThread;
--- a/mobile/android/base/gfx/GeckoLayerClient.java +++ b/mobile/android/base/gfx/GeckoLayerClient.java @@ -387,17 +387,17 @@ public class GeckoLayerClient implements * The compositor invokes this function on every frame to figure out what part of the * page to display, and to inform Java of the current display port. Since it is called * on every frame, it needs to be ultra-fast. * It avoids taking any locks or allocating any objects. We keep around a * mCurrentViewTransform so we don't need to allocate a new ViewTransform * everytime we're called. NOTE: we might be able to return a ImmutableViewportMetrics * which would avoid the copy into mCurrentViewTransform. */ - public ViewTransform syncViewportInfo(int x, int y, int width, int height) { + public ViewTransform syncViewportInfo(int x, int y, int width, int height, float resolution) { // getViewportMetrics is thread safe so we don't need to synchronize // on mLayerController. // We save the viewport metrics here, so we later use it later in // createFrame (which will be called by nsWindow::DrawWindowUnderlay on // the native side, by the compositor). The LayerController's viewport // metrics can change between here and there, as it's accessed outside // of the compositor thread. mFrameMetrics = mLayerController.getViewportMetrics();
--- a/widget/android/AndroidBridge.cpp +++ b/widget/android/AndroidBridge.cpp @@ -1905,23 +1905,23 @@ AndroidBridge::SetPageSize(float aZoom, AndroidGeckoLayerClient *client = mLayerClient; if (!client) return; client->SetPageSize(aZoom, aPageWidth, aPageHeight); } void -AndroidBridge::SyncViewportInfo(const nsIntRect& aDisplayPort, nsIntPoint& aScrollOffset, float& aScaleX, float& aScaleY) +AndroidBridge::SyncViewportInfo(const nsIntRect& aDisplayPort, float aDisplayResolution, nsIntPoint& aScrollOffset, float& aScaleX, float& aScaleY) { AndroidGeckoLayerClient *client = mLayerClient; if (!client) return; - client->SyncViewportInfo(aDisplayPort, aScrollOffset, aScaleX, aScaleY); + client->SyncViewportInfo(aDisplayPort, aDisplayResolution, aScrollOffset, aScaleX, aScaleY); } AndroidBridge::AndroidBridge() : mLayerClient(NULL) { } AndroidBridge::~AndroidBridge()
--- a/widget/android/AndroidBridge.h +++ b/widget/android/AndroidBridge.h @@ -404,17 +404,17 @@ public: void GetCurrentNetworkInformation(hal::NetworkInformation* aNetworkInfo); void EnableNetworkNotifications(); void DisableNetworkNotifications(); void SetCompositorParent(mozilla::layers::CompositorParent* aCompositorParent, base::Thread* aCompositorThread); void SetFirstPaintViewport(float aOffsetX, float aOffsetY, float aZoom, float aPageWidth, float aPageHeight); void SetPageSize(float aZoom, float aPageWidth, float aPageHeight); - void SyncViewportInfo(const nsIntRect& aDisplayPort, nsIntPoint& aScrollOffset, float& aScaleX, float& aScaleY); + void SyncViewportInfo(const nsIntRect& aDisplayPort, float aDisplayResolution, nsIntPoint& aScrollOffset, float& aScaleX, float& aScaleY); jobject CreateSurface(); void DestroySurface(jobject surface); void ShowSurface(jobject surface, const gfxRect& aRect, bool aInverted, bool aBlend); void HideSurface(jobject surface); protected: static AndroidBridge *sBridge;
--- a/widget/android/AndroidJavaWrappers.cpp +++ b/widget/android/AndroidJavaWrappers.cpp @@ -270,17 +270,17 @@ AndroidGeckoLayerClient::InitGeckoLayerC jGeckoLayerClientClass = getClassGlobalRef("org/mozilla/gecko/gfx/GeckoLayerClient"); jBeginDrawingMethod = getMethod("beginDrawing", "(IILjava/lang/String;)Z"); jEndDrawingMethod = getMethod("endDrawing", "()V"); jSetFirstPaintViewport = getMethod("setFirstPaintViewport", "(FFFFF)V"); jSetPageSize = getMethod("setPageSize", "(FFF)V"); jSyncViewportInfoMethod = getMethod("syncViewportInfo", - "(IIII)Lorg/mozilla/gecko/gfx/ViewTransform;"); + "(IIIIF)Lorg/mozilla/gecko/gfx/ViewTransform;"); jCreateFrameMethod = getMethod("createFrame", "()Lorg/mozilla/gecko/gfx/LayerRenderer$Frame;"); jActivateProgramMethod = getMethod("activateProgram", "()V"); jDeactivateProgramMethod = getMethod("deactivateProgram", "()V"); #endif } void AndroidLayerRendererFrame::InitLayerRendererFrameClass(JNIEnv *jEnv) @@ -702,29 +702,30 @@ AndroidGeckoLayerClient::SetPageSize(flo if (!env) return; AndroidBridge::AutoLocalJNIFrame jniFrame(env); return env->CallVoidMethod(wrapped_obj, jSetPageSize, aZoom, aPageWidth, aPageHeight); } void -AndroidGeckoLayerClient::SyncViewportInfo(const nsIntRect& aDisplayPort, nsIntPoint& aScrollOffset, float& aScaleX, float& aScaleY) +AndroidGeckoLayerClient::SyncViewportInfo(const nsIntRect& aDisplayPort, float aDisplayResolution, nsIntPoint& aScrollOffset, float& aScaleX, float& aScaleY) { NS_ASSERTION(!isNull(), "SyncViewportInfo called on null layer client!"); JNIEnv *env = GetJNIForThread(); // this is called on the compositor thread if (!env) return; AndroidViewTransform viewTransform; AndroidBridge::AutoLocalJNIFrame jniFrame(env); jobject viewTransformJObj = env->CallObjectMethod(wrapped_obj, jSyncViewportInfoMethod, aDisplayPort.x, aDisplayPort.y, - aDisplayPort.width, aDisplayPort.height); + aDisplayPort.width, aDisplayPort.height, + aDisplayResolution); NS_ABORT_IF_FALSE(viewTransformJObj, "No view transform object!"); viewTransform.Init(viewTransformJObj); aScrollOffset = nsIntPoint(viewTransform.GetX(), viewTransform.GetY()); aScaleX = aScaleY = viewTransform.GetScale(); } jobject
--- a/widget/android/AndroidJavaWrappers.h +++ b/widget/android/AndroidJavaWrappers.h @@ -201,17 +201,17 @@ public: AndroidGeckoLayerClient() {} AndroidGeckoLayerClient(jobject jobj) { Init(jobj); } bool BeginDrawing(int aWidth, int aHeight, const nsAString &aMetadata); void EndDrawing(); void SetFirstPaintViewport(float aOffsetX, float aOffsetY, float aZoom, float aPageWidth, float aPageHeight); void SetPageSize(float aZoom, float aPageWidth, float aPageHeight); - void SyncViewportInfo(const nsIntRect& aDisplayPort, nsIntPoint& aScrollOffset, float& aScaleX, float& aScaleY); + void SyncViewportInfo(const nsIntRect& aDisplayPort, float aDisplayResolution, nsIntPoint& aScrollOffset, float& aScaleX, float& aScaleY); void CreateFrame(AndroidLayerRendererFrame& aFrame); void ActivateProgram(); void DeactivateProgram(); protected: static jclass jGeckoLayerClientClass; static jmethodID jBeginDrawingMethod; static jmethodID jEndDrawingMethod;