[haiku-webkit-commits] r448 - webkit/trunk/WebKit/haiku/API

  • From: webkit@xxxxxxxxxxxxxxx
  • To: haiku-webkit-commits@xxxxxxxxxxxxx
  • Date: Wed, 21 Apr 2010 16:35:40 +0000

Author: stippi
Date: Wed Apr 21 16:35:40 2010
New Revision: 448
URL: http://mmlr.dyndns.org/changeset/448

Log:
* Found the bug that caused graphical glitches with scrolling slashdot.org:
  scroll() called internalPaint() to paint the part uncovered by scrolling, but
  we need to make sure the FrameView does not need to be layouted. paint() would
  make sure of this, now also scroll().
* Prevent re-entering paint() from within layoutRecursiveIfNeeded().
* Use CopyBits() for scrolling instead of rolling our own, moves load to
  app_server thread and avoids having to call Sync() (which we wrongly did not
  do before).

Modified:
   webkit/trunk/WebKit/haiku/API/WebPage.cpp
   webkit/trunk/WebKit/haiku/API/WebPage.h

Modified: webkit/trunk/WebKit/haiku/API/WebPage.cpp
==============================================================================
--- webkit/trunk/WebKit/haiku/API/WebPage.cpp   Wed Apr 21 11:49:28 2010        
(r447)
+++ webkit/trunk/WebKit/haiku/API/WebPage.cpp   Wed Apr 21 16:35:40 2010        
(r448)
@@ -191,6 +191,7 @@
     , fDisplayedStatusMessage()
     , fPageVisible(true)
     , fPageDirty(false)
+    , fLayoutingView(false)
     , fToolbarsVisible(true)
     , fStatusbarVisible(true)
     , fMenubarVisible(true)
@@ -618,7 +619,7 @@
 
 void BWebPage::paint(BRect rect, bool immediate)
 {
-       if (!rect.IsValid())
+       if (fLayoutingView || !rect.IsValid())
                return;
     // Block any drawing as long as the BWebView is hidden
     // (should be extended to when the containing BWebWindow is not
@@ -642,9 +643,10 @@
        // Since calling layoutIfNeededRecursive can cycle back into paint(),
        // call this method before locking the window and before holding the
        // offscreen view lock.
+       fLayoutingView = true;
        view->layoutIfNeededRecursive();
+       fLayoutingView = false;
 
-//    if (fWebView->LockLooperWithTimeout(5000) != B_OK)
     if (!fWebView->LockLooper())
         return;
     BView* offscreenView = fWebView->OffscreenView();
@@ -662,7 +664,7 @@
     if (!rect.IsValid())
         rect = offscreenView->Bounds();
     BRegion region(rect);
-    internalPaint(offscreenView, &region);
+    internalPaint(offscreenView, view, &region);
 
     offscreenView->UnlockLooper();
 
@@ -697,8 +699,6 @@
        BRect rectAtDst = rectAtSrc.OffsetByCopy(xOffset, yOffset);
        BRegion repaintRegion(rectAtSrc);
        if (clip.Intersects(rectAtSrc) && clip.Intersects(rectAtDst)) {
-               uint8* src = reinterpret_cast<uint8*>(bitmap->Bits());
-               uint32 bytesPerRow = bitmap->BytesPerRow();
                // clip source rect
                rectAtSrc = rectAtSrc & clip;
                // clip dest rect
@@ -710,74 +710,35 @@
                rectAtDst.OffsetBy(xOffset, yOffset);
                repaintRegion.Exclude(rectAtDst);
 
-               // calc offset in buffer
-               src += (int32)rectAtSrc.left * 4
-                       + (int32)rectAtSrc.top * bytesPerRow;
-
-               uint32 width = rectAtSrc.IntegerWidth() + 1;
-               uint32 height = rectAtSrc.IntegerHeight() + 1;
-
-               int32 xIncrement;
-               int32 yIncrement;
-
-               if (yOffset == 0 && xOffset > 0) {
-                       // copy from right to left
-                       xIncrement = -1;
-                       src += (width - 1) * 4;
-               } else {
-                       // copy from left to right
-                       xIncrement = 1;
-               }
-
-               if (yOffset > 0) {
-                       // copy from bottom to top
-                       yIncrement = -bytesPerRow;
-                       src += (height - 1) * bytesPerRow;
-               } else {
-                       // copy from top to bottom
-                       yIncrement = bytesPerRow;
-               }
+               offscreenView->CopyBits(rectAtSrc, rectAtDst);
+       }
 
-               uint8* dst = src + yOffset * bytesPerRow + xOffset * 4;
+       if (repaintRegion.Frame().IsValid()) {
+        WebCore::Frame* frame = fMainFrame->Frame();
+        WebCore::FrameView* view = frame->view();
+        // Make sure the view is layouted, since it will refuse to paint
+        // otherwise.
+        fLayoutingView = true;
+        view->layoutIfNeededRecursive();
+        fLayoutingView = false;
 
-               if (xIncrement == 1) {
-                       for (uint32 y = 0; y < height; y++) {
-                               memcpy(dst, src, width * 4);
-                               src += yIncrement;
-                               dst += yIncrement;
-                       }
-               } else {
-                       for (uint32 y = 0; y < height; y++) {
-                               uint32* srcHandle = (uint32*)src;
-                               uint32* dstHandle = (uint32*)dst;
-                               for (uint32 x = 0; x < width; x++) {
-                                       *dstHandle = *srcHandle;
-                                       srcHandle += xIncrement;
-                                       dstHandle += xIncrement;
-                               }
-                               src += yIncrement;
-                               dst += yIncrement;
-                       }
-               }
+               internalPaint(offscreenView, view, &repaintRegion);
        }
 
-       if (repaintRegion.Frame().IsValid())
-               internalPaint(offscreenView, &repaintRegion);
-
     bitmap->Unlock();
 
     // Notify the view that it can now pull the bitmap in its own thread
     fWebView->SetOffscreenViewClean(rectToScroll, false);
 }
 
-void BWebPage::internalPaint(BView* offscreenView, BRegion* dirty)
+void BWebPage::internalPaint(BView* offscreenView,
+                             WebCore::FrameView* frameView, BRegion* dirty)
 {
-    WebCore::Frame* frame = fMainFrame->Frame();
-    WebCore::FrameView* view = frame->view();
+    ASSERT(!frameView->needsLayout());
     offscreenView->PushState();
     offscreenView->ConstrainClippingRegion(dirty);
     WebCore::GraphicsContext context(offscreenView);
-    view->paint(&context, IntRect(dirty->Frame()));
+    frameView->paint(&context, IntRect(dirty->Frame()));
     offscreenView->PopState();
 }
 

Modified: webkit/trunk/WebKit/haiku/API/WebPage.h
==============================================================================
--- webkit/trunk/WebKit/haiku/API/WebPage.h     Wed Apr 21 11:49:28 2010        
(r447)
+++ webkit/trunk/WebKit/haiku/API/WebPage.h     Wed Apr 21 16:35:40 2010        
(r448)
@@ -50,6 +50,7 @@
 class FrameLoaderClientHaiku;
 class InspectorClientHaiku;
 
+class FrameView;
 class Page;
 class ResourceHandle;
 class ResourceRequest;
@@ -186,7 +187,8 @@
        void paint(BRect rect, bool immediate);
        void scroll(int scrollDeltaX, int scrollDeltaY, const BRect& 
rectToScroll,
                const BRect& clipRect);
-       void internalPaint(BView* view, BRegion* dirty);
+       void internalPaint(BView* view, WebCore::FrameView* frameView,
+               BRegion* dirty);
 
        void setLoadingProgress(float progress);
        void setStatusMessage(const BString& message);
@@ -231,6 +233,7 @@
 
                    bool                                fPageVisible;
                    bool                                fPageDirty;
+                   bool                                fLayoutingView;
 
                        bool                            fToolbarsVisible;
                        bool                            fStatusbarVisible;

Other related posts:

  • » [haiku-webkit-commits] r448 - webkit/trunk/WebKit/haiku/API - webkit