예제 #1
0
void
AndroidGeckoLayerClient::SyncFrameMetrics(const ScreenPoint& aScrollOffset, float aZoom, const CSSRect& aCssPageRect,
                                          bool aLayersUpdated, const CSSRect& aDisplayPort, const CSSToLayerScale& aDisplayResolution,
                                          bool aIsFirstPaint, LayerMargin& aFixedLayerMargins, ScreenPoint& aOffset)
{
    NS_ASSERTION(!isNull(), "SyncFrameMetrics called on null layer client!");
    JNIEnv *env = GetJNIForThread();    // this is called on the compositor thread
    if (!env)
        return;

    AutoLocalJNIFrame jniFrame(env);

    // convert the displayport rect from scroll-relative CSS pixels to document-relative device pixels
    LayerRect dpUnrounded = aDisplayPort * aDisplayResolution;
    dpUnrounded += LayerPoint::FromUnknownPoint(aScrollOffset.ToUnknownPoint());
    LayerIntRect dp = gfx::RoundedToInt(dpUnrounded);

    jobject viewTransformJObj = env->CallObjectMethod(wrapped_obj, jSyncFrameMetricsMethod,
            aScrollOffset.x, aScrollOffset.y, aZoom,
            aCssPageRect.x, aCssPageRect.y, aCssPageRect.XMost(), aCssPageRect.YMost(),
            aLayersUpdated, dp.x, dp.y, dp.width, dp.height, aDisplayResolution.scale,
            aIsFirstPaint);

    if (jniFrame.CheckForException())
        return;

    NS_ABORT_IF_FALSE(viewTransformJObj, "No view transform object!");

    AndroidViewTransform viewTransform;
    viewTransform.Init(viewTransformJObj);
    viewTransform.GetFixedLayerMargins(env, aFixedLayerMargins);
    aOffset.x = viewTransform.GetOffsetX(env);
    aOffset.y = viewTransform.GetOffsetY(env);
}
예제 #2
0
void
AndroidGeckoLayerClient::SyncViewportInfo(const nsIntRect& aDisplayPort, float aDisplayResolution, bool aLayersUpdated,
        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;

    AutoLocalJNIFrame jniFrame(env);

    jobject viewTransformJObj = env->CallObjectMethod(wrapped_obj, jSyncViewportInfoMethod,
                                aDisplayPort.x, aDisplayPort.y,
                                aDisplayPort.width, aDisplayPort.height,
                                aDisplayResolution, aLayersUpdated);
    if (jniFrame.CheckForException())
        return;

    NS_ABORT_IF_FALSE(viewTransformJObj, "No view transform object!");

    AndroidViewTransform viewTransform;
    viewTransform.Init(viewTransformJObj);

    aScrollOffset = nsIntPoint(viewTransform.GetX(env), viewTransform.GetY(env));
    aScaleX = aScaleY = viewTransform.GetScale(env);
}
예제 #3
0
void
AndroidGeckoLayerClient::SyncViewportInfo(const LayerIntRect& aDisplayPort, const CSSToLayerScale& aDisplayResolution,
                                          bool aLayersUpdated, ScreenPoint& aScrollOffset, CSSToScreenScale& aScale,
                                          LayerMargin& aFixedLayerMargins, ScreenPoint& aOffset)
{
    NS_ASSERTION(!isNull(), "SyncViewportInfo called on null layer client!");
    JNIEnv *env = GetJNIForThread();    // this is called on the compositor thread
    if (!env)
        return;

    AutoLocalJNIFrame jniFrame(env);

    jobject viewTransformJObj = env->CallObjectMethod(wrapped_obj, jSyncViewportInfoMethod,
                                                      aDisplayPort.x, aDisplayPort.y,
                                                      aDisplayPort.width, aDisplayPort.height,
                                                      aDisplayResolution.scale, aLayersUpdated);
    if (jniFrame.CheckForException())
        return;

    NS_ABORT_IF_FALSE(viewTransformJObj, "No view transform object!");

    AndroidViewTransform viewTransform;
    viewTransform.Init(viewTransformJObj);

    aScrollOffset = ScreenPoint(viewTransform.GetX(env), viewTransform.GetY(env));
    aScale.scale = viewTransform.GetScale(env);
    viewTransform.GetFixedLayerMargins(env, aFixedLayerMargins);

    aOffset.x = viewTransform.GetOffsetX(env);
    aOffset.y = viewTransform.GetOffsetY(env);
}
예제 #4
0
void
AndroidGeckoLayerClient::SyncFrameMetrics(const gfx::Point& aScrollOffset, float aZoom, const gfx::Rect& aCssPageRect,
                                          bool aLayersUpdated, const gfx::Rect& aDisplayPort, float aDisplayResolution,
                                          bool aIsFirstPaint, gfx::Margin& aFixedLayerMargins, gfx::Point& aOffset)
{
    NS_ASSERTION(!isNull(), "SyncFrameMetrics called on null layer client!");
    JNIEnv *env = GetJNIForThread();    // this is called on the compositor thread
    if (!env)
        return;

    AutoLocalJNIFrame jniFrame(env);

    // convert the displayport rect from scroll-relative CSS pixels to document-relative device pixels
    int dpX = NS_lround((aDisplayPort.x * aDisplayResolution) + aScrollOffset.x);
    int dpY = NS_lround((aDisplayPort.y * aDisplayResolution) + aScrollOffset.y);
    int dpW = NS_lround(aDisplayPort.width * aDisplayResolution);
    int dpH = NS_lround(aDisplayPort.height * aDisplayResolution);

    jobject viewTransformJObj = env->CallObjectMethod(wrapped_obj, jSyncFrameMetricsMethod,
            aScrollOffset.x, aScrollOffset.y, aZoom,
            aCssPageRect.x, aCssPageRect.y, aCssPageRect.XMost(), aCssPageRect.YMost(),
            aLayersUpdated, dpX, dpY, dpW, dpH, aDisplayResolution,
            aIsFirstPaint);

    if (jniFrame.CheckForException())
        return;

    NS_ABORT_IF_FALSE(viewTransformJObj, "No view transform object!");

    AndroidViewTransform viewTransform;
    viewTransform.Init(viewTransformJObj);
    viewTransform.GetFixedLayerMargins(env, aFixedLayerMargins);
    aOffset.x = viewTransform.GetOffsetX(env);
    aOffset.y = viewTransform.GetOffsetY(env);
}