OSDN Git Service

Fix issues with setting viewstate before initializing
authorJohn Reck <jreck@google.com>
Sat, 4 Jun 2011 07:48:50 +0000 (00:48 -0700)
committerJohn Reck <jreck@google.com>
Sun, 5 Jun 2011 02:52:34 +0000 (19:52 -0700)
 Allow drawing without a CachedRoot (just skip drawing extras in that case)
 Initialize PictureSet correctly when using the SkPicture ctor
 If delay-setting a layer on glWebViewState, set isAfterFirstLayout to
 true to force the baseLayer update.

Change-Id: I9b24fd2e8450acf0138433edce8700c9ec227e52

Source/WebKit/android/jni/PictureSet.cpp
Source/WebKit/android/nav/WebView.cpp

index 181256c..98d7438 100644 (file)
@@ -83,13 +83,19 @@ PictureSet::PictureSet()
 
 PictureSet::PictureSet(SkPicture* picture)
 {
-    if (!picture)
+    mBaseArea = mAdditionalArea = 0;
+    if (!picture) {
+        mWidth = mHeight = 0;
         return;
+    }
+    mWidth = picture->width();
+    mHeight = picture->height();
+    mBaseArea = mWidth * mHeight;
     Pictures pictureAndBounds;
     pictureAndBounds.mPicture = picture;
     SkSafeRef(pictureAndBounds.mPicture);
     pictureAndBounds.mEmpty = false;
-    pictureAndBounds.mArea.setRect(0, 0, picture->width(), picture->height());
+    pictureAndBounds.mArea.setRect(0, 0, mWidth, mHeight);
     pictureAndBounds.mSplit = false;
     pictureAndBounds.mBase = true;
     pictureAndBounds.mElapsed = 0;
index 405b28e..8d3082b 100644 (file)
@@ -383,6 +383,7 @@ void resetCursorRing()
 
 bool drawCursorPreamble(CachedRoot* root)
 {
+    if (!root) return false;
     const CachedFrame* frame;
     const CachedNode* node = root->currentCursor(&frame);
     if (!node) {
@@ -444,7 +445,7 @@ bool drawGL(WebCore::IntRect& viewRect, WebCore::IntRect* invalRect, WebCore::In
             SkIRect rect;
             rect.set(0, 0, m_baseLayer->content()->width(), m_baseLayer->content()->height());
             region.setRect(rect);
-            m_glWebViewState->setBaseLayer(m_baseLayer, region, false, false);
+            m_glWebViewState->setBaseLayer(m_baseLayer, region, false, true);
         }
     }
 
@@ -453,7 +454,6 @@ bool drawGL(WebCore::IntRect& viewRect, WebCore::IntRect* invalRect, WebCore::In
         DBG_NAV_LOG("!root");
         if (extras == DrawExtrasCursorRing)
             resetCursorRing();
-        return false;
     }
     DrawExtra* extra = 0;
     switch (extras) {
@@ -491,7 +491,7 @@ bool drawGL(WebCore::IntRect& viewRect, WebCore::IntRect* invalRect, WebCore::In
             extra->draw(canvas, &mainPicture, &rect);
             picture.endRecording();
         }
-    } else if (extras == DrawExtrasCursorRing && m_ring.m_isButton) {
+    } else if (root && extras == DrawExtrasCursorRing && m_ring.m_isButton) {
         const CachedFrame* cachedFrame;
         const CachedNode* cachedCursor = root->currentCursor(&cachedFrame);
         if (cachedCursor) {
@@ -538,7 +538,6 @@ PictureSet* draw(SkCanvas* canvas, SkColor bgColor, int extras, bool split)
         DBG_NAV_LOG("!root");
         if (extras == DrawExtrasCursorRing)
             resetCursorRing();
-        return ret;
     }
     LayerAndroid mainPicture(m_navPictureUI);
     DrawExtra* extra = 0;