Bug 732091 - Part 4: Add JNI-exposed functions on GeckoLayerClient to allow the compositor to update various properties. r=Cwiiis

This commit is contained in:
Kartikaya Gupta 2012-03-12 11:50:21 -04:00
Родитель a3b9d3c4f9
Коммит 7c8258165b
5 изменённых файлов: 79 добавлений и 0 удалений

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

@ -322,6 +322,31 @@ public class GeckoLayerClient implements GeckoEventResponder,
return null;
}
/** This function is invoked by Gecko via JNI; be careful when modifying signature. */
public void setFirstPaintViewport(float offsetX, float offsetY, float zoom, float pageWidth, float pageHeight) {
synchronized (mLayerController) {
ViewportMetrics currentMetrics = new ViewportMetrics(mLayerController.getViewportMetrics());
currentMetrics.setOrigin(new PointF(offsetX, offsetY));
currentMetrics.setZoomFactor(zoom);
currentMetrics.setPageSize(new FloatSize(pageWidth, pageHeight));
mLayerController.setViewportMetrics(currentMetrics);
mLayerController.abortPanZoomAnimation();
}
}
/** This function is invoked by Gecko via JNI; be careful when modifying signature. */
public void setPageSize(float zoom, float pageWidth, float pageHeight) {
synchronized (mLayerController) {
// adjust the page dimensions to account for differences in zoom
// between the rendered content (which is what the compositor tells us)
// and our zoom level (which may have diverged).
float ourZoom = mLayerController.getZoomFactor();
pageWidth = pageWidth * ourZoom / zoom;
pageHeight = pageHeight * ourZoom /zoom;
mLayerController.setPageSize(new FloatSize(pageWidth, pageHeight));
}
}
/** This function is invoked by Gecko via JNI; be careful when modifying signature. */
/* This functions needs to be fast because it is called by the compositor every frame.
* It avoids taking any locks or allocating any objects. We keep around a

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

@ -1881,6 +1881,26 @@ AndroidBridge::ScheduleResumeComposition()
}
}
void
AndroidBridge::SetFirstPaintViewport(float aOffsetX, float aOffsetY, float aZoom, float aPageWidth, float aPageHeight)
{
AndroidGeckoLayerClient *client = mLayerClient;
if (!client)
return;
client->SetFirstPaintViewport(aOffsetX, aOffsetY, aZoom, aPageWidth, aPageHeight);
}
void
AndroidBridge::SetPageSize(float aZoom, float aPageWidth, float aPageHeight)
{
AndroidGeckoLayerClient *client = mLayerClient;
if (!client)
return;
client->SetPageSize(aZoom, aPageWidth, aPageHeight);
}
void
AndroidBridge::SetViewTransformGetter(AndroidViewTransformGetter& aViewTransformGetter)
{

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

@ -409,6 +409,8 @@ public:
void ScheduleComposite();
void SchedulePauseComposition();
void ScheduleResumeComposition();
void SetFirstPaintViewport(float aOffsetX, float aOffsetY, float aZoom, float aPageWidth, float aPageHeight);
void SetPageSize(float aZoom, float aPageWidth, float aPageHeight);
void SetViewTransformGetter(AndroidViewTransformGetter& aViewTransformGetter);
void GetViewTransform(nsIntPoint& aScrollOffset, float& aScaleX, float& aScaleY);

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

@ -113,6 +113,8 @@ jmethodID AndroidAddress::jGetThoroughfareMethod;
jclass AndroidGeckoLayerClient::jGeckoLayerClientClass = 0;
jmethodID AndroidGeckoLayerClient::jBeginDrawingMethod = 0;
jmethodID AndroidGeckoLayerClient::jEndDrawingMethod = 0;
jmethodID AndroidGeckoLayerClient::jSetFirstPaintViewport = 0;
jmethodID AndroidGeckoLayerClient::jSetPageSize = 0;
jmethodID AndroidGeckoLayerClient::jGetViewTransformMethod = 0;
jmethodID AndroidGeckoLayerClient::jCreateFrameMethod = 0;
jmethodID AndroidGeckoLayerClient::jActivateProgramMethod = 0;
@ -349,6 +351,8 @@ AndroidGeckoLayerClient::InitGeckoLayerClientClass(JNIEnv *jEnv)
jBeginDrawingMethod = getMethod("beginDrawing", "(IILjava/lang/String;)Z");
jEndDrawingMethod = getMethod("endDrawing", "()V");
jSetFirstPaintViewport = getMethod("setFirstPaintViewport", "(FFFFF)V");
jSetPageSize = getMethod("setPageSize", "(FFF)V");
jGetViewTransformMethod = getMethod("getViewTransform",
"()Lorg/mozilla/gecko/gfx/ViewTransform;");
jCreateFrameMethod = getMethod("createFrame", "()Lorg/mozilla/gecko/gfx/LayerRenderer$Frame;");
@ -789,6 +793,30 @@ AndroidGeckoLayerClient::EndDrawing()
return env->CallVoidMethod(wrapped_obj, jEndDrawingMethod);
}
void
AndroidGeckoLayerClient::SetFirstPaintViewport(float aOffsetX, float aOffsetY, float aZoom, float aPageWidth, float aPageHeight)
{
NS_ASSERTION(!isNull(), "SetFirstPaintViewport called on null layer client!");
JNIEnv *env = GetJNIForThread();
if (!env)
return;
AndroidBridge::AutoLocalJNIFrame jniFrame(env);
return env->CallVoidMethod(wrapped_obj, jSetFirstPaintViewport, aOffsetX, aOffsetY, aZoom, aPageWidth, aPageHeight);
}
void
AndroidGeckoLayerClient::SetPageSize(float aZoom, float aPageWidth, float aPageHeight)
{
NS_ASSERTION(!isNull(), "SetPageSize called on null layer client!");
JNIEnv *env = GetJNIForThread();
if (!env)
return;
AndroidBridge::AutoLocalJNIFrame jniFrame(env);
return env->CallVoidMethod(wrapped_obj, jSetPageSize, aZoom, aPageWidth, aPageHeight);
}
jobject
AndroidGeckoSurfaceView::GetSoftwareDrawBitmap()
{

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

@ -226,6 +226,8 @@ public:
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 GetViewTransform(AndroidViewTransform& aViewTransform);
void CreateFrame(AndroidLayerRendererFrame& aFrame);
void ActivateProgram();
@ -235,6 +237,8 @@ protected:
static jclass jGeckoLayerClientClass;
static jmethodID jBeginDrawingMethod;
static jmethodID jEndDrawingMethod;
static jmethodID jSetFirstPaintViewport;
static jmethodID jSetPageSize;
static jmethodID jGetViewTransformMethod;
static jmethodID jCreateFrameMethod;
static jmethodID jActivateProgramMethod;