Forráskód Böngészése

LibWeb: Fill OOPWV with the palette base color until we have pixels

We were painting unfinished pixels while waiting for the WebContent
process to render the page. This caused OOPWV to flicker black
sometimes, which looked pretty bad.

This way we still flicker, but at least we flicker with the correct
palette color. :^)
Andreas Kling 4 éve
szülő
commit
cdf87d2204

+ 10 - 1
Libraries/LibWeb/OutOfProcessWebView.cpp

@@ -31,6 +31,7 @@
 #include <LibGUI/Painter.h>
 #include <LibGUI/Painter.h>
 #include <LibGUI/ScrollBar.h>
 #include <LibGUI/ScrollBar.h>
 #include <LibGUI/Window.h>
 #include <LibGUI/Window.h>
+#include <LibGfx/Palette.h>
 #include <LibGfx/SystemTheme.h>
 #include <LibGfx/SystemTheme.h>
 
 
 REGISTER_WIDGET(Web, OutOfProcessWebView)
 REGISTER_WIDGET(Web, OutOfProcessWebView)
@@ -76,8 +77,14 @@ void OutOfProcessWebView::paint_event(GUI::PaintEvent& event)
         return;
         return;
 
 
     GUI::Painter painter(*this);
     GUI::Painter painter(*this);
-    painter.add_clip_rect(frame_inner_rect());
     painter.add_clip_rect(event.rect());
     painter.add_clip_rect(event.rect());
+
+    if (!m_has_usable_bitmap) {
+        painter.fill_rect(frame_inner_rect(), palette().base());
+        return;
+    }
+
+    painter.add_clip_rect(frame_inner_rect());
     painter.translate(frame_thickness(), frame_thickness());
     painter.translate(frame_thickness(), frame_thickness());
 
 
     ASSERT(m_front_bitmap);
     ASSERT(m_front_bitmap);
@@ -92,6 +99,7 @@ void OutOfProcessWebView::resize_event(GUI::ResizeEvent& event)
 
 
     m_front_bitmap = nullptr;
     m_front_bitmap = nullptr;
     m_back_bitmap = nullptr;
     m_back_bitmap = nullptr;
+    m_has_usable_bitmap = false;
 
 
     if (available_size().is_empty())
     if (available_size().is_empty())
         return;
         return;
@@ -143,6 +151,7 @@ void OutOfProcessWebView::theme_change_event(GUI::ThemeChangeEvent& event)
 void OutOfProcessWebView::notify_server_did_paint(Badge<WebContentClient>, i32 shbuf_id)
 void OutOfProcessWebView::notify_server_did_paint(Badge<WebContentClient>, i32 shbuf_id)
 {
 {
     if (m_back_bitmap->shbuf_id() == shbuf_id) {
     if (m_back_bitmap->shbuf_id() == shbuf_id) {
+        m_has_usable_bitmap = true;
         swap(m_back_bitmap, m_front_bitmap);
         swap(m_back_bitmap, m_front_bitmap);
         update();
         update();
     }
     }

+ 2 - 0
Libraries/LibWeb/OutOfProcessWebView.h

@@ -89,6 +89,8 @@ private:
     RefPtr<WebContentClient> m_client;
     RefPtr<WebContentClient> m_client;
     RefPtr<Gfx::Bitmap> m_front_bitmap;
     RefPtr<Gfx::Bitmap> m_front_bitmap;
     RefPtr<Gfx::Bitmap> m_back_bitmap;
     RefPtr<Gfx::Bitmap> m_back_bitmap;
+
+    bool m_has_usable_bitmap { false };
 };
 };
 
 
 }
 }