Bug 1505743 - [Wayland] Clear Wayland buffer when GtkWindow is mapped. r=jhorak

Differential Revision: https://phabricator.services.mozilla.com/D11999

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Martin Stransky 2018-11-20 15:39:32 +00:00
Родитель de6960336a
Коммит b18cbdec0a
6 изменённых файлов: 48 добавлений и 10 удалений

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

@ -475,6 +475,11 @@ void WindowBackBuffer::Release()
mWidth = mHeight = 0;
}
void WindowBackBuffer::Clear()
{
memset(mShmPool.GetImageData(), 0, mHeight * mWidth * BUFFER_BPP);
}
WindowBackBuffer::WindowBackBuffer(nsWaylandDisplay* aWaylandDisplay,
int aWidth, int aHeight)
: mShmPool(aWaylandDisplay, aWidth*aHeight*BUFFER_BPP)
@ -674,15 +679,19 @@ WindowSurfaceWayland::GetWaylandBufferToDraw(int aWidth, int aHeight)
}
already_AddRefed<gfx::DrawTarget>
WindowSurfaceWayland::LockWaylandBuffer(int aWidth, int aHeight)
WindowSurfaceWayland::LockWaylandBuffer(int aWidth, int aHeight, bool aClearBuffer)
{
WindowBackBuffer* buffer = GetWaylandBufferToDraw(aWidth, aHeight);
if (buffer) {
return buffer->Lock();
if (!buffer) {
NS_WARNING("WindowSurfaceWayland::LockWaylandBuffer(): No buffer available");
return nullptr;
}
NS_WARNING("WindowSurfaceWayland::LockWaylandBuffer(): No buffer available");
return nullptr;
if (aClearBuffer) {
buffer->Clear();
}
return buffer->Lock();
}
already_AddRefed<gfx::DrawTarget>
@ -733,7 +742,8 @@ WindowSurfaceWayland::Lock(const LayoutDeviceIntRegion& aRegion)
if (mDrawToWaylandBufferDirectly) {
RefPtr<gfx::DrawTarget> dt = LockWaylandBuffer(screenRect.width,
screenRect.height);
screenRect.height,
mWindow->WaylandSurfaceNeedsClear());
if (dt) {
return dt.forget();
}
@ -760,7 +770,8 @@ WindowSurfaceWayland::CommitImageSurfaceToWaylandBuffer(const LayoutDeviceIntReg
}
RefPtr<gfx::DrawTarget> dt = LockWaylandBuffer(screenRect.width,
screenRect.height);
screenRect.height,
mWindow->WaylandSurfaceNeedsClear());
RefPtr<gfx::SourceSurface> surf =
gfx::Factory::CreateSourceSurfaceForCairoSurface(mImageSurface->CairoSurface(),
mImageSurface->GetSize(),

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

@ -75,6 +75,7 @@ public:
void Detach();
bool IsAttached() { return mAttached; }
void Clear();
bool Resize(int aWidth, int aHeight);
bool SetImageDataFromBuffer(class WindowBackBuffer* aSourceBuffer);
@ -118,7 +119,8 @@ public:
private:
WindowBackBuffer* GetWaylandBufferToDraw(int aWidth, int aHeight);
already_AddRefed<gfx::DrawTarget> LockWaylandBuffer(int aWidth, int aHeight);
already_AddRefed<gfx::DrawTarget> LockWaylandBuffer(int aWidth, int aHeight,
bool aClearBuffer);
already_AddRefed<gfx::DrawTarget> LockImageSurface(const gfx::IntSize& aLockSize);
bool CommitImageSurfaceToWaylandBuffer(const LayoutDeviceIntRegion& aRegion);
void CommitWaylandBuffer();

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

@ -213,6 +213,7 @@ moz_container_init (MozContainer *container)
container->subsurface = nullptr;
container->eglwindow = nullptr;
container->parent_surface_committed = false;
container->needs_clear = true;
GdkDisplay *gdk_display = gtk_widget_get_display(GTK_WIDGET(container));
if (!GDK_IS_X11_DISPLAY(gdk_display)) {
@ -266,8 +267,9 @@ moz_container_map_surface(MozContainer *container)
if (GDK_IS_X11_DISPLAY(display))
return false;
if (container->subsurface && container->surface)
if (container->subsurface && container->surface) {
return true;
}
if (!container->parent_surface_committed) {
if (!container->parent_surface_committed_handler) {
@ -313,6 +315,8 @@ moz_container_map_surface(MozContainer *container)
wl_region* region = wl_compositor_create_region(compositor);
wl_surface_set_input_region(container->surface, region);
wl_region_destroy(region);
container->needs_clear = true;
}
return true;
}
@ -337,7 +341,6 @@ moz_container_unmap_surface(MozContainer *container)
}
container->parent_surface_committed = false;
}
#endif
void
@ -641,4 +644,12 @@ moz_container_has_wl_egl_window(MozContainer *container)
{
return container->eglwindow ? true : false;
}
gboolean
moz_container_needs_clear(MozContainer *container)
{
gboolean state = container->needs_clear;
container->needs_clear = false;
return state;
}
#endif

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

@ -73,6 +73,7 @@ struct _MozContainer
struct wl_surface *surface;
struct wl_subsurface *subsurface;
struct wl_egl_window *eglwindow;
gboolean needs_clear;
gboolean parent_surface_committed;
gulong parent_surface_committed_handler;
#endif
@ -100,6 +101,7 @@ void moz_container_move (MozContainer *container,
struct wl_surface* moz_container_get_wl_surface(MozContainer *container);
struct wl_egl_window* moz_container_get_wl_egl_window(MozContainer *container);
gboolean moz_container_has_wl_egl_window(MozContainer *container);
gboolean moz_container_needs_clear(MozContainer *container);
#endif
#endif /* __MOZ_CONTAINER_H__ */

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

@ -7323,6 +7323,17 @@ nsWindow::GetWaylandSurface()
NS_WARNING("nsWindow::GetWaylandSurfaces(): We don't have any mContainer for drawing!");
return nullptr;
}
bool
nsWindow::WaylandSurfaceNeedsClear()
{
if (mContainer) {
return moz_container_needs_clear(MOZ_CONTAINER(mContainer));
}
NS_WARNING("nsWindow::WaylandSurfaceNeedsClear(): We don't have any mContainer!");
return false;
}
#endif
#ifdef MOZ_X11

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

@ -388,6 +388,7 @@ public:
#ifdef MOZ_WAYLAND
wl_display* GetWaylandDisplay();
wl_surface* GetWaylandSurface();
bool WaylandSurfaceNeedsClear();
#endif
virtual void GetCompositorWidgetInitData(mozilla::widget::CompositorWidgetInitData* aInitData) override;