Bug 731603 - Propagate a layersUpdated flag to Java for robocop use. r=ajuma

This commit is contained in:
Kartikaya Gupta 2012-03-20 00:06:56 -04:00
Родитель a9fe2cdfa1
Коммит fdeefb7eab
7 изменённых файлов: 26 добавлений и 14 удалений

Просмотреть файл

@ -62,6 +62,7 @@ CompositorParent::CompositorParent(nsIWidget* aWidget, base::Thread* aCompositor
, mCurrentCompositeTask(NULL)
, mPaused(false)
, mIsFirstPaint(false)
, mLayersUpdated(false)
{
MOZ_COUNT_CTOR(CompositorParent);
}
@ -293,7 +294,9 @@ CompositorParent::TransformShadowTree()
displayPort.x += scrollOffset.x;
displayPort.y += scrollOffset.y;
mozilla::AndroidBridge::Bridge()->SyncViewportInfo(displayPort, 1/rootScaleX, mScrollOffset, mXScale, mYScale);
mozilla::AndroidBridge::Bridge()->SyncViewportInfo(displayPort, 1/rootScaleX, mLayersUpdated,
mScrollOffset, mXScale, mYScale);
mLayersUpdated = false;
}
// Handle transformations for asynchronous panning and zooming. We determine the
@ -324,6 +327,7 @@ void
CompositorParent::ShadowLayersUpdated(bool isFirstPaint)
{
mIsFirstPaint = mIsFirstPaint || isFirstPaint;
mLayersUpdated = true;
const nsTArray<PLayersParent*>& shadowParents = ManagedPLayersParent();
NS_ABORT_IF_FALSE(shadowParents.Length() <= 1,
"can only support at most 1 ShadowLayersParent");

Просмотреть файл

@ -151,6 +151,10 @@ private:
// size and zoom into account when providing us with the next view transform.
bool mIsFirstPaint;
// This flag is set during a layers update, so that the first composition
// after a layers update has it set. It is cleared after that first composition.
bool mLayersUpdated;
DISALLOW_EVIL_CONSTRUCTORS(CompositorParent);
};

Просмотреть файл

@ -145,11 +145,6 @@ public class GeckoLayerClient implements GeckoEventResponder,
RectF position = mGeckoViewport.getViewport();
mRootLayer.setPositionAndResolution(RectUtils.round(position), mGeckoViewport.getZoomFactor());
}
/* Used by robocop for testing purposes */
if (mDrawListener != null) {
mDrawListener.drawFinished();
}
}
RectF getDisplayPort() {
@ -392,7 +387,7 @@ public class GeckoLayerClient implements GeckoEventResponder,
* 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, float resolution) {
public ViewTransform syncViewportInfo(int x, int y, int width, int height, float resolution, boolean layersUpdated) {
// 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
@ -409,6 +404,11 @@ public class GeckoLayerClient implements GeckoEventResponder,
mGeckoDisplayPort.set(x, y, x + width, y + height);
mRootLayer.setDisplayPort(mGeckoDisplayPort);
if (layersUpdated && mDrawListener != null) {
/* Used by robocop for testing purposes */
mDrawListener.drawFinished();
}
return mCurrentViewTransform;
}

Просмотреть файл

@ -1910,13 +1910,14 @@ AndroidBridge::SetPageSize(float aZoom, float aPageWidth, float aPageHeight)
}
void
AndroidBridge::SyncViewportInfo(const nsIntRect& aDisplayPort, float aDisplayResolution, nsIntPoint& aScrollOffset, float& aScaleX, float& aScaleY)
AndroidBridge::SyncViewportInfo(const nsIntRect& aDisplayPort, float aDisplayResolution, bool aLayersUpdated,
nsIntPoint& aScrollOffset, float& aScaleX, float& aScaleY)
{
AndroidGeckoLayerClient *client = mLayerClient;
if (!client)
return;
client->SyncViewportInfo(aDisplayPort, aDisplayResolution, aScrollOffset, aScaleX, aScaleY);
client->SyncViewportInfo(aDisplayPort, aDisplayResolution, aLayersUpdated, aScrollOffset, aScaleX, aScaleY);
}
AndroidBridge::AndroidBridge()

Просмотреть файл

@ -409,7 +409,8 @@ public:
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, float aDisplayResolution, nsIntPoint& aScrollOffset, float& aScaleX, float& aScaleY);
void SyncViewportInfo(const nsIntRect& aDisplayPort, float aDisplayResolution, bool aLayersUpdated,
nsIntPoint& aScrollOffset, float& aScaleX, float& aScaleY);
jobject CreateSurface();
void DestroySurface(jobject surface);

Просмотреть файл

@ -275,7 +275,7 @@ AndroidGeckoLayerClient::InitGeckoLayerClientClass(JNIEnv *jEnv)
jSetFirstPaintViewport = getMethod("setFirstPaintViewport", "(FFFFF)V");
jSetPageSize = getMethod("setPageSize", "(FFF)V");
jSyncViewportInfoMethod = getMethod("syncViewportInfo",
"(IIIIF)Lorg/mozilla/gecko/gfx/ViewTransform;");
"(IIIIFZ)Lorg/mozilla/gecko/gfx/ViewTransform;");
jCreateFrameMethod = getMethod("createFrame", "()Lorg/mozilla/gecko/gfx/LayerRenderer$Frame;");
jActivateProgramMethod = getMethod("activateProgram", "()V");
jDeactivateProgramMethod = getMethod("deactivateProgram", "()V");
@ -707,7 +707,8 @@ AndroidGeckoLayerClient::SetPageSize(float aZoom, float aPageWidth, float aPageH
}
void
AndroidGeckoLayerClient::SyncViewportInfo(const nsIntRect& aDisplayPort, float aDisplayResolution, nsIntPoint& aScrollOffset, float& aScaleX, float& aScaleY)
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
@ -720,7 +721,7 @@ AndroidGeckoLayerClient::SyncViewportInfo(const nsIntRect& aDisplayPort, float a
jobject viewTransformJObj = env->CallObjectMethod(wrapped_obj, jSyncViewportInfoMethod,
aDisplayPort.x, aDisplayPort.y,
aDisplayPort.width, aDisplayPort.height,
aDisplayResolution);
aDisplayResolution, aLayersUpdated);
NS_ABORT_IF_FALSE(viewTransformJObj, "No view transform object!");
viewTransform.Init(viewTransformJObj);

Просмотреть файл

@ -206,7 +206,8 @@ public:
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, float aDisplayResolution, nsIntPoint& aScrollOffset, float& aScaleX, float& aScaleY);
void SyncViewportInfo(const nsIntRect& aDisplayPort, float aDisplayResolution, bool aLayersUpdated,
nsIntPoint& aScrollOffset, float& aScaleX, float& aScaleY);
void CreateFrame(AndroidLayerRendererFrame& aFrame);
void ActivateProgram();
void DeactivateProgram();