Bug 1627716 - Remove now-unused SetRenderOffset code related to DynamicToolbarAnimator. r=jrmuizel

Depends on D71776

Differential Revision: https://phabricator.services.mozilla.com/D71777
This commit is contained in:
Kartikaya Gupta 2020-04-22 11:50:40 +00:00
parent 763e05dece
commit c840d0f81a
6 changed files with 1 additions and 145 deletions

View File

@ -300,12 +300,6 @@ class Compositor : public TextureSourceProvider {
*/
virtual void SetDestinationSurfaceSize(const gfx::IntSize& aSize) = 0;
/**
* Declare an offset to use when rendering layers. This will be ignored when
* rendering to a target instead of the screen.
*/
virtual void SetScreenRenderOffset(const ScreenPoint& aOffset) = 0;
void DrawGeometry(const gfx::Rect& aRect, const gfx::IntRect& aClipRect,
const EffectChain& aEffectChain, gfx::Float aOpacity,
const gfx::Matrix4x4& aTransform,

View File

@ -149,8 +149,6 @@ class BasicCompositor : public Compositor {
int32_t GetMaxTextureSize() const override;
void SetDestinationSurfaceSize(const gfx::IntSize& aSize) override {}
void SetScreenRenderOffset(const ScreenPoint& aOffset) override {}
void MakeCurrent(MakeCurrentFlags aFlags = 0) override {}
#ifdef MOZ_DUMP_PAINTING

View File

@ -1042,35 +1042,6 @@ static void ClearLayerFlags(Layer* aLayer) {
});
}
#if defined(MOZ_WIDGET_ANDROID)
class ScopedCompositorRenderOffset {
public:
ScopedCompositorRenderOffset(CompositorOGL* aCompositor,
const ScreenPoint& aOffset)
: mCompositor(aCompositor),
mOriginalOffset(mCompositor->GetScreenRenderOffset()),
mOriginalProjection(mCompositor->GetProjMatrix()) {
ScreenPoint offset(mOriginalOffset.x + aOffset.x,
mOriginalOffset.y + aOffset.y);
mCompositor->SetScreenRenderOffset(offset);
// Calling CompositorOGL::SetScreenRenderOffset does not affect the
// projection matrix so adjust that as well.
gfx::Matrix4x4 mat = mOriginalProjection;
mat.PreTranslate(aOffset.x, aOffset.y, 0.0f);
mCompositor->SetProjMatrix(mat);
}
~ScopedCompositorRenderOffset() {
mCompositor->SetScreenRenderOffset(mOriginalOffset);
mCompositor->SetProjMatrix(mOriginalProjection);
}
private:
CompositorOGL* const mCompositor;
const ScreenPoint mOriginalOffset;
const gfx::Matrix4x4 mOriginalProjection;
};
#endif // defined(MOZ_WIDGET_ANDROID)
bool LayerManagerComposite::Render(const nsIntRegion& aInvalidRegion,
const nsIntRegion& aOpaqueRegion) {
AUTO_PROFILER_LABEL("LayerManagerComposite::Render", GRAPHICS);
@ -1171,11 +1142,6 @@ bool LayerManagerComposite::Render(const nsIntRegion& aInvalidRegion,
IntRect bounds = *maybeBounds;
IntRect clipRect = rootLayerClip.valueOr(bounds);
#if defined(MOZ_WIDGET_ANDROID)
ScreenCoord offset = GetContentShiftForToolbar();
ScopedCompositorRenderOffset scopedOffset(mCompositor->AsCompositorOGL(),
ScreenPoint(0.0f, offset));
#endif
// Prepare our layers.
{
@ -1287,11 +1253,6 @@ bool LayerManagerComposite::Render(const nsIntRegion& aInvalidRegion,
UpdateDebugOverlayNativeLayers();
} else {
#if defined(MOZ_WIDGET_ANDROID)
if (AndroidDynamicToolbarAnimator::IsEnabled()) {
// Depending on the content shift the toolbar may be rendered on top of
// some of the content so it must be rendered after the content.
RenderToolbar();
}
HandlePixelsTarget();
#endif // defined(MOZ_WIDGET_ANDROID)
@ -1469,67 +1430,6 @@ void LayerManagerComposite::RenderToPresentationSurface() {
mCompositor->EndFrame();
}
ScreenCoord LayerManagerComposite::GetContentShiftForToolbar() {
ScreenCoord result(0.0f);
if (!AndroidDynamicToolbarAnimator::IsEnabled()) {
return result;
}
// If mTarget not null we are not drawing to the screen so
// there will not be any content offset.
if (mTarget) {
return result;
}
if (CompositorBridgeParent* bridge =
mCompositor->GetCompositorBridgeParent()) {
AndroidDynamicToolbarAnimator* animator =
bridge->GetAndroidDynamicToolbarAnimator();
MOZ_RELEASE_ASSERT(animator);
result.value = (float)animator->GetCurrentContentOffset().value;
}
return result;
}
void LayerManagerComposite::RenderToolbar() {
// If mTarget is not null we are not drawing to the screen so
// don't draw the toolbar.
if (mTarget) {
return;
}
if (CompositorBridgeParent* bridge =
mCompositor->GetCompositorBridgeParent()) {
AndroidDynamicToolbarAnimator* animator =
bridge->GetAndroidDynamicToolbarAnimator();
MOZ_RELEASE_ASSERT(animator);
animator->UpdateToolbarSnapshotTexture(mCompositor->AsCompositorOGL());
int32_t toolbarHeight = animator->GetCurrentToolbarHeight();
if (toolbarHeight == 0) {
return;
}
EffectChain effects;
effects.mPrimaryEffect = animator->GetToolbarEffect();
// If GetToolbarEffect returns null, nothing is rendered for the static
// snapshot of the toolbar. If the real toolbar chrome is not covering this
// portion of the surface, the clear color of the surface will be visible.
// On Android the clear color is the background color of the page.
if (effects.mPrimaryEffect) {
ScopedCompositorRenderOffset toolbarOffset(
mCompositor->AsCompositorOGL(),
ScreenPoint(0.0f, -animator->GetCurrentContentOffset()));
mCompositor->DrawQuad(gfx::Rect(0, 0, mRenderBounds.width, toolbarHeight),
IntRect(0, 0, mRenderBounds.width, toolbarHeight),
effects, 1.0, gfx::Matrix4x4());
}
}
}
// Used by robocop tests to get a snapshot of the frame buffer.
void LayerManagerComposite::HandlePixelsTarget() {
if (!mScreenPixelsTarget) {

View File

@ -71,17 +71,6 @@ class CompositorD3D11 : public Compositor {
void SetDestinationSurfaceSize(const gfx::IntSize& aSize) override {}
/**
* Declare an offset to use when rendering layers. This will be ignored when
* rendering to a target instead of the screen.
*/
void SetScreenRenderOffset(const ScreenPoint& aOffset) override {
if (aOffset.x || aOffset.y) {
MOZ_CRASH("SetScreenRenderOffset not supported by CompositorD3D11.");
}
// If the offset is 0, 0 that's okay.
}
void ClearRect(const gfx::Rect& aRect) override;
void DrawQuad(const gfx::Rect& aRect, const gfx::IntRect& aClipRect,

View File

@ -600,18 +600,12 @@ void CompositorOGL::PrepareViewport(CompositingRenderTargetOGL* aRenderTarget) {
viewMatrix.PreScale(1.0f, -1.0f);
MOZ_ASSERT(mCurrentRenderTarget, "No destination");
// If we're drawing directly to the window then we want to offset
// drawing by the render offset.
if (!mTarget && mCurrentRenderTarget->IsWindow()) {
viewMatrix.PreTranslate(mRenderOffset.x, mRenderOffset.y);
}
Matrix4x4 matrix3d = Matrix4x4::From2D(viewMatrix);
matrix3d._33 = 0.0f;
mProjMatrix = matrix3d;
mGLContext->fDepthRange(0.0f, 1.0f);
} else {
// XXX take into account mRenderOffset
bool depthEnable;
float zNear, zFar;
aRenderTarget->GetProjection(mProjMatrix, depthEnable, zNear, zFar);
@ -1469,13 +1463,8 @@ void CompositorOGL::DrawGeometry(const Geometry& aGeometry,
IntPoint offset = mCurrentRenderTarget->GetOrigin();
clipRect -= offset;
// clipRect is in destination coordinate space (after all
// transforms and offsets have been applied) so if our
// drawing is going to be shifted by mRenderOffset then we need
// to shift the clip rect by the same amount.
if (!mTarget && mCurrentRenderTarget->IsWindow()) {
clipRect.MoveBy(mRenderOffset.x + mSurfaceOrigin.x,
mRenderOffset.y - mSurfaceOrigin.y);
clipRect.MoveBy(mSurfaceOrigin.x, -mSurfaceOrigin.y);
}
ScopedGLState scopedScissorTestState(mGLContext, LOCAL_GL_SCISSOR_TEST, true);

View File

@ -208,10 +208,6 @@ class CompositorOGL final : public Compositor {
*/
void SetDestinationSurfaceSize(const gfx::IntSize& aSize) override;
void SetScreenRenderOffset(const ScreenPoint& aOffset) override {
mRenderOffset = aOffset;
}
void MakeCurrent(MakeCurrentFlags aFlags = 0) override;
#ifdef MOZ_DUMP_PAINTING
@ -250,18 +246,10 @@ class CompositorOGL final : public Compositor {
*/
GLuint GetTemporaryTexture(GLenum aTarget, GLenum aUnit);
const gfx::Matrix4x4& GetProjMatrix() const { return mProjMatrix; }
void SetProjMatrix(const gfx::Matrix4x4& aProjMatrix) {
mProjMatrix = aProjMatrix;
}
const gfx::IntSize GetDestinationSurfaceSize() const {
return gfx::IntSize(mSurfaceSize.width, mSurfaceSize.height);
}
const ScreenPoint& GetScreenRenderOffset() const { return mRenderOffset; }
/**
* Allow the origin of the surface to be offset so that content does not
* start at (0, 0) on the surface.
@ -306,8 +294,6 @@ class CompositorOGL final : public Compositor {
/** The size of the surface we are rendering to */
gfx::IntSize mSurfaceSize;
ScreenPoint mRenderOffset;
/** The origin of the content on the surface */
ScreenIntPoint mSurfaceOrigin;