зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1783542 - Use widget size from ResumeAndResize rather than querying native window. r=gfx-reviewers,aosmond
On Android we have until now determined the compositor widget's size by querying the values from the ANativeWindow. However, since bug 1780093 landed we can now switch between which Surface we are rendering in to, and as a result we appear to be using the wrong size some of the time. This patch is a speculative attempt to fix this, by using the size passed to ResumeAndResize() (which itself comes from the Surface's surfaceChanged() callback) rather than querying the window. Differential Revision: https://phabricator.services.mozilla.com/D154909
This commit is contained in:
Родитель
734922ce3d
Коммит
3b0edb46fc
|
@ -7,6 +7,7 @@
|
|||
|
||||
#if defined(MOZ_WIDGET_ANDROID)
|
||||
# include "apz/src/APZCTreeManager.h"
|
||||
# include "mozilla/widget/AndroidCompositorWidget.h"
|
||||
#endif
|
||||
#include <utility>
|
||||
|
||||
|
@ -85,6 +86,10 @@ mozilla::ipc::IPCResult UiCompositorControllerParent::RecvResumeAndResize(
|
|||
if (parent) {
|
||||
// Front-end expects a first paint callback upon resume/resize.
|
||||
parent->ForceIsFirstPaint();
|
||||
#if defined(MOZ_WIDGET_ANDROID)
|
||||
parent->GetWidget()->AsAndroid()->NotifyClientSizeChanged(
|
||||
LayoutDeviceIntSize(aWidth, aHeight));
|
||||
#endif
|
||||
parent->ResumeCompositionAndResize(aX, aY, aWidth, aHeight);
|
||||
}
|
||||
return IPC_OK();
|
||||
|
|
|
@ -83,29 +83,6 @@ bool AndroidCompositorWidget::OnResumeComposition() {
|
|||
return false;
|
||||
}
|
||||
|
||||
JNIEnv* const env = jni::GetEnvForThread();
|
||||
ANativeWindow* const nativeWindow =
|
||||
ANativeWindow_fromSurface(env, reinterpret_cast<jobject>(mSurface.Get()));
|
||||
if (!nativeWindow) {
|
||||
gfxCriticalError() << "OnResumeComposition called with invalid Surface";
|
||||
return false;
|
||||
}
|
||||
|
||||
const int32_t width = ANativeWindow_getWidth(nativeWindow);
|
||||
const int32_t height = ANativeWindow_getHeight(nativeWindow);
|
||||
mClientSize = LayoutDeviceIntSize(std::min(width, MOZ_WIDGET_MAX_SIZE),
|
||||
std::min(height, MOZ_WIDGET_MAX_SIZE));
|
||||
|
||||
ANativeWindow_release(nativeWindow);
|
||||
|
||||
// A negative return value from ANativeWindow_getWidth/Height can indicate the
|
||||
// underlying BufferQueue has been abandoned, and subsequent EGLSurface
|
||||
// creation will fail.
|
||||
if (mClientSize.width < 0 || mClientSize.height < 0) {
|
||||
gfxCriticalNote << "ANativeWindow_getWidth/Height returned error: "
|
||||
<< mClientSize;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -119,7 +96,9 @@ LayoutDeviceIntSize AndroidCompositorWidget::GetClientSize() {
|
|||
|
||||
void AndroidCompositorWidget::NotifyClientSizeChanged(
|
||||
const LayoutDeviceIntSize& aClientSize) {
|
||||
mClientSize = aClientSize;
|
||||
mClientSize =
|
||||
LayoutDeviceIntSize(std::min(aClientSize.width, MOZ_WIDGET_MAX_SIZE),
|
||||
std::min(aClientSize.height, MOZ_WIDGET_MAX_SIZE));
|
||||
}
|
||||
|
||||
} // namespace widget
|
||||
|
|
|
@ -48,6 +48,7 @@ class AndroidCompositorWidget : public CompositorWidget {
|
|||
AndroidCompositorWidget* AsAndroid() override { return this; }
|
||||
|
||||
LayoutDeviceIntSize GetClientSize() override;
|
||||
void NotifyClientSizeChanged(const LayoutDeviceIntSize& aClientSize);
|
||||
|
||||
protected:
|
||||
int32_t mWidgetId;
|
||||
|
@ -57,8 +58,6 @@ class AndroidCompositorWidget : public CompositorWidget {
|
|||
int32_t mFormat;
|
||||
LayoutDeviceIntSize mClientSize;
|
||||
|
||||
void NotifyClientSizeChanged(const LayoutDeviceIntSize& aClientSize);
|
||||
|
||||
private:
|
||||
// Called whenever the compositor surface may have changed. The derived class
|
||||
// should update mSurface to the new compositor surface.
|
||||
|
|
Загрузка…
Ссылка в новой задаче