зеркало из https://github.com/mozilla/pjs.git
Fix scissor rect and use the Java compositor's cached viewport metrics when drawing decorations
This commit is contained in:
Родитель
70b8c86816
Коммит
79c9ae2965
|
@ -1345,16 +1345,6 @@ protected:
|
||||||
bool mDirty;
|
bool mDirty;
|
||||||
};
|
};
|
||||||
|
|
||||||
#ifdef MOZ_WIDGET_ANDROID
|
|
||||||
class TransformLayerUserData : public LayerUserData {
|
|
||||||
public:
|
|
||||||
gfx3DMatrix matrix;
|
|
||||||
|
|
||||||
TransformLayerUserData(gfx3DMatrix& aMatrix) : matrix(aMatrix) {}
|
|
||||||
virtual ~TransformLayerUserData() {}
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -186,14 +186,6 @@ CompositorParent::Composite()
|
||||||
//layer->AsShadowLayer()->SetShadowTransform(worldTransform);
|
//layer->AsShadowLayer()->SetShadowTransform(worldTransform);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef MOZ_WIDGET_ANDROID
|
|
||||||
// Hang the transform of the root layer off the layer manager.
|
|
||||||
gfx3DMatrix transform = layer->GetTransform();
|
|
||||||
transform *= v;
|
|
||||||
TransformLayerUserData* transformUserData = new TransformLayerUserData(transform);
|
|
||||||
mLayerManager->SetUserData(nsGkAtoms::transform, transformUserData);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
mLayerManager->EndEmptyTransaction();
|
mLayerManager->EndEmptyTransaction();
|
||||||
|
|
||||||
#ifdef COMPOSITOR_PERFORMANCE_WARNING
|
#ifdef COMPOSITOR_PERFORMANCE_WARNING
|
||||||
|
|
|
@ -225,24 +225,17 @@ public class GeckoGLLayerClient extends GeckoLayerClient
|
||||||
}
|
}
|
||||||
|
|
||||||
/** For Gecko to use. */
|
/** For Gecko to use. */
|
||||||
public LayerRenderer.Frame createFrame(float offsetX, float offsetY, float zoomFactor) {
|
public LayerRenderer.Frame createFrame() {
|
||||||
// Create the shaders and textures if necessary.
|
// Create the shaders and textures if necessary.
|
||||||
if (!mLayerRendererInitialized) {
|
if (!mLayerRendererInitialized) {
|
||||||
mLayerRenderer.createProgram();
|
mLayerRenderer.createProgram();
|
||||||
mLayerRendererInitialized = true;
|
mLayerRendererInitialized = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// FIXME: This geometry is surely wrong.
|
|
||||||
ViewportMetrics metrics = getLayerController().getViewportMetrics();
|
|
||||||
FloatSize pageSize = metrics.getPageSize(), screenSize = metrics.getSize();
|
|
||||||
RectF viewport = new RectF(offsetX, offsetY, offsetX + screenSize.width,
|
|
||||||
offsetY + screenSize.height);
|
|
||||||
|
|
||||||
// Build the contexts and create the frame.
|
// Build the contexts and create the frame.
|
||||||
Layer.RenderContext pageContext = mLayerRenderer.createContext(viewport, pageSize,
|
Layer.RenderContext pageContext = mLayerRenderer.createPageContext();
|
||||||
zoomFactor);
|
|
||||||
Layer.RenderContext screenContext = mLayerRenderer.createScreenContext();
|
Layer.RenderContext screenContext = mLayerRenderer.createScreenContext();
|
||||||
return mLayerRenderer.createFrame(false, pageContext, screenContext);
|
return mLayerRenderer.createFrame(pageContext, screenContext);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** For Gecko to use. */
|
/** For Gecko to use. */
|
||||||
|
|
|
@ -277,7 +277,7 @@ public class LayerRenderer implements GLSurfaceView.Renderer {
|
||||||
*/
|
*/
|
||||||
public void onDrawFrame(GL10 gl) {
|
public void onDrawFrame(GL10 gl) {
|
||||||
RenderContext pageContext = createPageContext(), screenContext = createScreenContext();
|
RenderContext pageContext = createPageContext(), screenContext = createScreenContext();
|
||||||
Frame frame = createFrame(true, pageContext, screenContext);
|
Frame frame = createFrame(pageContext, screenContext);
|
||||||
synchronized (mView.getController()) {
|
synchronized (mView.getController()) {
|
||||||
frame.beginDrawing();
|
frame.beginDrawing();
|
||||||
frame.drawBackground();
|
frame.drawBackground();
|
||||||
|
@ -316,7 +316,7 @@ public class LayerRenderer implements GLSurfaceView.Renderer {
|
||||||
return createContext(viewport, pageSize, 1.0f);
|
return createContext(viewport, pageSize, 1.0f);
|
||||||
}
|
}
|
||||||
|
|
||||||
private RenderContext createPageContext() {
|
public RenderContext createPageContext() {
|
||||||
LayerController layerController = mView.getController();
|
LayerController layerController = mView.getController();
|
||||||
|
|
||||||
Rect viewport = new Rect();
|
Rect viewport = new Rect();
|
||||||
|
@ -327,7 +327,7 @@ public class LayerRenderer implements GLSurfaceView.Renderer {
|
||||||
return createContext(new RectF(viewport), pageSize, zoomFactor);
|
return createContext(new RectF(viewport), pageSize, zoomFactor);
|
||||||
}
|
}
|
||||||
|
|
||||||
public RenderContext createContext(RectF viewport, FloatSize pageSize, float zoomFactor) {
|
private RenderContext createContext(RectF viewport, FloatSize pageSize, float zoomFactor) {
|
||||||
return new RenderContext(viewport, pageSize, zoomFactor, mPositionHandle, mTextureHandle,
|
return new RenderContext(viewport, pageSize, zoomFactor, mPositionHandle, mTextureHandle,
|
||||||
mCoordBuffer);
|
mCoordBuffer);
|
||||||
}
|
}
|
||||||
|
@ -448,9 +448,8 @@ public class LayerRenderer implements GLSurfaceView.Renderer {
|
||||||
return shader;
|
return shader;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Frame createFrame(boolean scissor, RenderContext pageContext,
|
public Frame createFrame(RenderContext pageContext, RenderContext screenContext) {
|
||||||
RenderContext screenContext) {
|
return new Frame(pageContext, screenContext);
|
||||||
return new Frame(scissor, pageContext, screenContext);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
class FadeRunnable implements Runnable {
|
class FadeRunnable implements Runnable {
|
||||||
|
@ -490,8 +489,6 @@ public class LayerRenderer implements GLSurfaceView.Renderer {
|
||||||
}
|
}
|
||||||
|
|
||||||
public class Frame {
|
public class Frame {
|
||||||
// Whether to use a scissor rect to clip the page.
|
|
||||||
private final boolean mScissor;
|
|
||||||
// The timestamp recording the start of this frame.
|
// The timestamp recording the start of this frame.
|
||||||
private long mFrameStartTime;
|
private long mFrameStartTime;
|
||||||
// A rendering context for page-positioned layers, and one for screen-positioned layers.
|
// A rendering context for page-positioned layers, and one for screen-positioned layers.
|
||||||
|
@ -499,12 +496,18 @@ public class LayerRenderer implements GLSurfaceView.Renderer {
|
||||||
// Whether a layer was updated.
|
// Whether a layer was updated.
|
||||||
private boolean mUpdated;
|
private boolean mUpdated;
|
||||||
|
|
||||||
public Frame(boolean scissor, RenderContext pageContext, RenderContext screenContext) {
|
public Frame(RenderContext pageContext, RenderContext screenContext) {
|
||||||
mScissor = scissor;
|
|
||||||
mPageContext = pageContext;
|
mPageContext = pageContext;
|
||||||
mScreenContext = screenContext;
|
mScreenContext = screenContext;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void setScissorRect() {
|
||||||
|
Rect scissorRect = transformToScissorRect(getPageRect());
|
||||||
|
GLES20.glEnable(GLES20.GL_SCISSOR_TEST);
|
||||||
|
GLES20.glScissor(scissorRect.left, scissorRect.top,
|
||||||
|
scissorRect.width(), scissorRect.height());
|
||||||
|
}
|
||||||
|
|
||||||
public void beginDrawing() {
|
public void beginDrawing() {
|
||||||
mFrameStartTime = SystemClock.uptimeMillis();
|
mFrameStartTime = SystemClock.uptimeMillis();
|
||||||
|
|
||||||
|
@ -574,23 +577,22 @@ public class LayerRenderer implements GLSurfaceView.Renderer {
|
||||||
if (!untransformedPageRect.contains(mView.getController().getViewport()))
|
if (!untransformedPageRect.contains(mView.getController().getViewport()))
|
||||||
mShadowLayer.draw(mPageContext);
|
mShadowLayer.draw(mPageContext);
|
||||||
|
|
||||||
/* Define the scissor rect, if necessary. */
|
|
||||||
if (mScissor) {
|
|
||||||
Rect scissorRect = transformToScissorRect(pageRect);
|
|
||||||
GLES20.glEnable(GLES20.GL_SCISSOR_TEST);
|
|
||||||
GLES20.glScissor(scissorRect.left, scissorRect.top,
|
|
||||||
scissorRect.width(), scissorRect.height());
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Draw the checkerboard. */
|
/* Draw the checkerboard. */
|
||||||
|
setScissorRect();
|
||||||
mCheckerboardLayer.draw(mScreenContext);
|
mCheckerboardLayer.draw(mScreenContext);
|
||||||
|
GLES20.glDisable(GLES20.GL_SCISSOR_TEST);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Draws the layer the client added to us.
|
// Draws the layer the client added to us.
|
||||||
void drawRootLayer() {
|
void drawRootLayer() {
|
||||||
Layer rootLayer = mView.getController().getRoot();
|
Layer rootLayer = mView.getController().getRoot();
|
||||||
if (rootLayer != null)
|
if (rootLayer == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
setScissorRect();
|
||||||
rootLayer.draw(mPageContext);
|
rootLayer.draw(mPageContext);
|
||||||
|
GLES20.glDisable(GLES20.GL_SCISSOR_TEST);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void drawForeground() {
|
public void drawForeground() {
|
||||||
|
|
|
@ -387,8 +387,7 @@ AndroidGeckoGLLayerClient::InitGeckoGLLayerClientClass(JNIEnv *jEnv)
|
||||||
|
|
||||||
jGetViewTransformMethod = getMethod("getViewTransform",
|
jGetViewTransformMethod = getMethod("getViewTransform",
|
||||||
"()Lorg/mozilla/gecko/gfx/ViewTransform;");
|
"()Lorg/mozilla/gecko/gfx/ViewTransform;");
|
||||||
jCreateFrameMethod = getMethod("createFrame",
|
jCreateFrameMethod = getMethod("createFrame", "()Lorg/mozilla/gecko/gfx/LayerRenderer$Frame;");
|
||||||
"(FFF)Lorg/mozilla/gecko/gfx/LayerRenderer$Frame;");
|
|
||||||
jActivateProgramMethod = getMethod("activateProgram", "()V");
|
jActivateProgramMethod = getMethod("activateProgram", "()V");
|
||||||
jDeactivateProgramMethod = getMethod("deactivateProgram", "()V");
|
jDeactivateProgramMethod = getMethod("deactivateProgram", "()V");
|
||||||
#endif
|
#endif
|
||||||
|
@ -931,8 +930,7 @@ AndroidGeckoGLLayerClient::GetViewTransform(AndroidViewTransform& aViewTransform
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
AndroidGeckoGLLayerClient::CreateFrame(AndroidLayerRendererFrame& aFrame,
|
AndroidGeckoGLLayerClient::CreateFrame(AndroidLayerRendererFrame& aFrame)
|
||||||
float aXOffset, float aYOffset, float aZoomFactor)
|
|
||||||
{
|
{
|
||||||
JNIEnv *env = GetJNIForThread();
|
JNIEnv *env = GetJNIForThread();
|
||||||
NS_ABORT_IF_FALSE(env, "No JNI environment at CreateFrame()!");
|
NS_ABORT_IF_FALSE(env, "No JNI environment at CreateFrame()!");
|
||||||
|
@ -940,8 +938,7 @@ AndroidGeckoGLLayerClient::CreateFrame(AndroidLayerRendererFrame& aFrame,
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
jobject frameJObj = env->CallObjectMethod(wrapped_obj, jCreateFrameMethod, aXOffset, aYOffset,
|
jobject frameJObj = env->CallObjectMethod(wrapped_obj, jCreateFrameMethod);
|
||||||
aZoomFactor);
|
|
||||||
NS_ABORT_IF_FALSE(frameJObj, "No frame object!");
|
NS_ABORT_IF_FALSE(frameJObj, "No frame object!");
|
||||||
aFrame.Init(frameJObj);
|
aFrame.Init(frameJObj);
|
||||||
}
|
}
|
||||||
|
|
|
@ -270,8 +270,7 @@ public:
|
||||||
: mViewTransformGetter(*this) { Init(jobj); }
|
: mViewTransformGetter(*this) { Init(jobj); }
|
||||||
|
|
||||||
void GetViewTransform(AndroidViewTransform& aViewTransform);
|
void GetViewTransform(AndroidViewTransform& aViewTransform);
|
||||||
void CreateFrame(AndroidLayerRendererFrame& aFrame, float aXOffset, float aYOffset,
|
void CreateFrame(AndroidLayerRendererFrame& aFrame);
|
||||||
float aZoomFactor);
|
|
||||||
void ActivateProgram();
|
void ActivateProgram();
|
||||||
void DeactivateProgram();
|
void DeactivateProgram();
|
||||||
|
|
||||||
|
|
|
@ -2396,18 +2396,9 @@ void
|
||||||
nsWindow::DrawWindowUnderlay(LayerManager* aManager, nsIntRect aRect) {
|
nsWindow::DrawWindowUnderlay(LayerManager* aManager, nsIntRect aRect) {
|
||||||
AndroidBridge::AutoLocalJNIFrame jniFrame(GetJNIForThread());
|
AndroidBridge::AutoLocalJNIFrame jniFrame(GetJNIForThread());
|
||||||
|
|
||||||
mozilla::layers::LayerUserData* userData = aManager->GetUserData(nsGkAtoms::transform);
|
|
||||||
mozilla::layers::TransformLayerUserData* transformUserData =
|
|
||||||
static_cast<mozilla::layers::TransformLayerUserData*>(userData);
|
|
||||||
NS_ABORT_IF_FALSE(userData, "No transform user data!");
|
|
||||||
|
|
||||||
// Transform the unit square to figure out the offset and scale we need.
|
|
||||||
gfxRect rect(0, 0, 1, 1);
|
|
||||||
transformUserData->matrix.TransformBounds(rect);
|
|
||||||
|
|
||||||
AndroidGeckoLayerClient& client = AndroidBridge::Bridge()->GetLayerClient();
|
AndroidGeckoLayerClient& client = AndroidBridge::Bridge()->GetLayerClient();
|
||||||
AndroidGeckoGLLayerClient& glClient = static_cast<AndroidGeckoGLLayerClient&>(client);
|
AndroidGeckoGLLayerClient& glClient = static_cast<AndroidGeckoGLLayerClient&>(client);
|
||||||
glClient.CreateFrame(mLayerRendererFrame, rect.x, rect.y, rect.width);
|
glClient.CreateFrame(mLayerRendererFrame);
|
||||||
|
|
||||||
glClient.ActivateProgram();
|
glClient.ActivateProgram();
|
||||||
mLayerRendererFrame.BeginDrawing();
|
mLayerRendererFrame.BeginDrawing();
|
||||||
|
|
Загрузка…
Ссылка в новой задаче