From 4bd5cc1f3100f6c7b7b4c872a2106dd3653884af Mon Sep 17 00:00:00 2001 From: Derek Sollenberger Date: Fri, 18 Feb 2011 14:04:07 -0500 Subject: Ensure non-ready tiles are painted with the page background color. bug: 3465059 Change-Id: Ia6e5ec7e9f68d641f5bf0df34c04c5c9958a4046 --- WebCore/platform/graphics/android/BaseLayerAndroid.cpp | 1 + WebCore/platform/graphics/android/BaseTile.cpp | 2 +- WebCore/platform/graphics/android/GLWebViewState.cpp | 1 + WebCore/platform/graphics/android/GLWebViewState.h | 5 +++++ 4 files changed, 8 insertions(+), 1 deletion(-) diff --git a/WebCore/platform/graphics/android/BaseLayerAndroid.cpp b/WebCore/platform/graphics/android/BaseLayerAndroid.cpp index d2c41dc..584add1 100644 --- a/WebCore/platform/graphics/android/BaseLayerAndroid.cpp +++ b/WebCore/platform/graphics/android/BaseLayerAndroid.cpp @@ -263,6 +263,7 @@ bool BaseLayerAndroid::drawGL(IntRect& viewRect, SkRect& visibleRect, XLOG("drawBasePicture drawGL() viewRect: %d, %d, %d, %d", left, top, width, height); + m_glWebViewState->setBackgroundColor(color); glClearColor((float)m_color.red() / 255.0, (float)m_color.green() / 255.0, (float)m_color.blue() / 255.0, 1); diff --git a/WebCore/platform/graphics/android/BaseTile.cpp b/WebCore/platform/graphics/android/BaseTile.cpp index a69e6f9..bfd5118 100644 --- a/WebCore/platform/graphics/android/BaseTile.cpp +++ b/WebCore/platform/graphics/android/BaseTile.cpp @@ -257,7 +257,7 @@ void BaseTile::paintBitmap() SkCanvas* canvas = texture->canvas(); canvas->save(); - canvas->drawARGB(0, 0, 0, 0, SkXfermode::kClear_Mode); + canvas->drawColor(tiledPage->glWebViewState()->getBackgroundColor()); canvas->scale(scale, scale); canvas->translate(-x * w, -y * h); diff --git a/WebCore/platform/graphics/android/GLWebViewState.cpp b/WebCore/platform/graphics/android/GLWebViewState.cpp index 71f3fe5..3d2f6c8 100644 --- a/WebCore/platform/graphics/android/GLWebViewState.cpp +++ b/WebCore/platform/graphics/android/GLWebViewState.cpp @@ -68,6 +68,7 @@ GLWebViewState::GLWebViewState(android::Mutex* buttonMutex) , m_usePageA(true) , m_globalButtonMutex(buttonMutex) , m_baseLayerUpdate(true) + , m_backgroundColor(SK_ColorWHITE) { m_viewport.setEmpty(); m_previousViewport.setEmpty(); diff --git a/WebCore/platform/graphics/android/GLWebViewState.h b/WebCore/platform/graphics/android/GLWebViewState.h index 91bb2d7..d265b41 100644 --- a/WebCore/platform/graphics/android/GLWebViewState.h +++ b/WebCore/platform/graphics/android/GLWebViewState.h @@ -208,6 +208,9 @@ public: bool drawGL(IntRect& rect, SkRect& viewport, float scale, SkColor color = SK_ColorWHITE); + void setBackgroundColor(SkColor color) { m_backgroundColor = color; } + SkColor getBackgroundColor() { return m_backgroundColor; } + private: void inval(const IntRect& rect); // caller must hold m_baseLayerLock @@ -247,6 +250,8 @@ private: bool m_baseLayerUpdate; IntRect m_invalidateRect; + + SkColor m_backgroundColor; }; } // namespace WebCore -- cgit v1.1 From 49a6d4f2c272010e14806805cb2ca55e6fe8a782 Mon Sep 17 00:00:00 2001 From: Steve Block Date: Wed, 2 Mar 2011 17:26:25 +0000 Subject: Avoid Android modifications to JavaNPObjectV8.cpp/h https://android-git.corp.google.com/g/40387 fixed a long-standing bug to avoid leaking references to injected Java objects. However, it did so by making changes to JavaNPObjectV8.cpp/h which were never upstreamed. This change avoids the need for these changes. This change also avoids the use of a local PassRefPtr, which was incorrectly introduced in https://android-git.corp.google.com/g/36204. Change-Id: I6b17e85f7991e5226e00e7b041c38e2ca3d0cf57 --- WebCore/bridge/jni/v8/JavaNPObjectV8.cpp | 4 +--- WebCore/bridge/jni/v8/JavaNPObjectV8.h | 4 +--- WebKit/android/jni/WebCoreFrameBridge.cpp | 4 ++-- 3 files changed, 4 insertions(+), 8 deletions(-) diff --git a/WebCore/bridge/jni/v8/JavaNPObjectV8.cpp b/WebCore/bridge/jni/v8/JavaNPObjectV8.cpp index 7aa55b5..3bb8e27 100644 --- a/WebCore/bridge/jni/v8/JavaNPObjectV8.cpp +++ b/WebCore/bridge/jni/v8/JavaNPObjectV8.cpp @@ -68,9 +68,7 @@ static NPClass JavaNPObjectClass = { 0 // construct }; -// ANDROID-specific change. TODO: Upstream -NPObject* JavaInstanceToNPObject(PassRefPtr instance) -// END ANDROID-specific change +NPObject* JavaInstanceToNPObject(JavaInstance* instance) { JavaNPObject* object = reinterpret_cast(_NPN_CreateObject(0, &JavaNPObjectClass)); object->m_instance = instance; diff --git a/WebCore/bridge/jni/v8/JavaNPObjectV8.h b/WebCore/bridge/jni/v8/JavaNPObjectV8.h index e68a5aa..31b0ac7 100644 --- a/WebCore/bridge/jni/v8/JavaNPObjectV8.h +++ b/WebCore/bridge/jni/v8/JavaNPObjectV8.h @@ -41,9 +41,7 @@ struct JavaNPObject { RefPtr m_instance; }; -// ANDROID-specific change. TODO: Upstream -NPObject* JavaInstanceToNPObject(PassRefPtr); -// END ANDROID-specific change +NPObject* JavaInstanceToNPObject(JavaInstance*); JavaInstance* ExtractJavaInstance(NPObject*); bool JavaNPObjectHasMethod(NPObject*, NPIdentifier name); diff --git a/WebKit/android/jni/WebCoreFrameBridge.cpp b/WebKit/android/jni/WebCoreFrameBridge.cpp index c187d92..e48e406 100644 --- a/WebKit/android/jni/WebCoreFrameBridge.cpp +++ b/WebKit/android/jni/WebCoreFrameBridge.cpp @@ -1699,10 +1699,10 @@ static void AddJavascriptInterface(JNIEnv *env, jobject obj, jint nativeFramePoi } #elif USE(V8) if (pFrame) { - PassRefPtr addedObject = WeakJavaInstance::create(javascriptObj); + RefPtr addedObject = WeakJavaInstance::create(javascriptObj); const char* name = getCharactersFromJStringInEnv(env, interfaceName); // Pass ownership of the added object to bindToWindowObject. - NPObject* npObject = JavaInstanceToNPObject(addedObject); + NPObject* npObject = JavaInstanceToNPObject(addedObject.get()); pFrame->script()->bindToWindowObject(pFrame, name, npObject); // bindToWindowObject calls NPN_RetainObject on the // returned one (see createV8ObjectForNPObject in V8NPObject.cpp). -- cgit v1.1 From cf23e9ed3418921db12c7a804b0bbe9b68dd046f Mon Sep 17 00:00:00 2001 From: Nicolas Roard Date: Tue, 1 Mar 2011 12:46:27 -0800 Subject: Fix Browser ANR The dtor of GLWebViewState is calling the dtor of its TiledPage variables; the dtor of TiledPage wait until any pending painting operations running in the TextureGenerator thread are done. The painting operations ultimately paint using the current GLWebViewState's base layer. We were doing unref() on the baselayer before destroying the TiledPage... bug:3429924 Change-Id: I685e7fca5e5bae796f808debbf7e4ce668b83e6b --- WebCore/platform/graphics/android/GLWebViewState.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/WebCore/platform/graphics/android/GLWebViewState.cpp b/WebCore/platform/graphics/android/GLWebViewState.cpp index c25a6e8..5e1285f 100644 --- a/WebCore/platform/graphics/android/GLWebViewState.cpp +++ b/WebCore/platform/graphics/android/GLWebViewState.cpp @@ -96,9 +96,15 @@ GLWebViewState::GLWebViewState(android::Mutex* buttonMutex) GLWebViewState::~GLWebViewState() { - SkSafeUnref(m_currentBaseLayer); + // We have to destroy the two tiled pages first as their destructor + // may depend on the existence of this GLWebViewState and some of its + // instance variables in order to complete. + // Explicitely, currently we need to have the m_currentBaseLayer around + // in order to complete any pending paint operations (the tiled pages + // will remove any pending operations, and wait if one is underway). delete m_tiledPageA; delete m_tiledPageB; + SkSafeUnref(m_currentBaseLayer); #ifdef DEBUG_COUNT ClassTracker::instance()->decrement("GLWebViewState"); #endif -- cgit v1.1 From fa6d8d4e38dc2396cc0240f9f5a02a0295fd2a20 Mon Sep 17 00:00:00 2001 From: Nicolas Roard Date: Thu, 3 Mar 2011 10:16:31 -0800 Subject: Do not merge: Cherry-pick change I9942e8e4 from master Wait the remaining of the 60FPS cap delay rather than not paint. Returning true if called faster than 60FPS means we are not drawing and ask for the framework to call us again; this works in general because the framework recopy the previous framebuffer. But in some cases, it didn't, causing the webview to flicker. A correct fix would be to introduce the capping in framework rather than try to doing it in the webview; in the meantime we will sleep the remaining of the delay as a workaround, so that we still provide the GPU benefits we wanted (at >60FPS the GPU was being saturated in some cases). bug:3500655 Change-Id: Ibaa1d93e0a13433a2c842b19b58538894fdaa7e4 --- WebCore/platform/graphics/android/GLWebViewState.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/WebCore/platform/graphics/android/GLWebViewState.cpp b/WebCore/platform/graphics/android/GLWebViewState.cpp index 5e1285f..20a231c 100644 --- a/WebCore/platform/graphics/android/GLWebViewState.cpp +++ b/WebCore/platform/graphics/android/GLWebViewState.cpp @@ -342,8 +342,10 @@ bool GLWebViewState::drawGL(IntRect& rect, SkRect& viewport, float scale, SkColo double currentTime = WTF::currentTime(); double delta = currentTime - m_prevDrawTime; - if (delta < FRAMERATE_CAP) - return true; + if (delta < FRAMERATE_CAP) { + unsigned int usecs = (FRAMERATE_CAP - delta) * 1E6; + usleep(usecs); + } m_prevDrawTime = currentTime; -- cgit v1.1 From a4d9914a8b1d4795aac0993263ac70f364855126 Mon Sep 17 00:00:00 2001 From: Nicolas Roard Date: Wed, 9 Mar 2011 16:08:15 -0800 Subject: Fix for gmail messages not showing after the first one. We were not resetting the unusable state (set by the clearView() function) when receiving new content... bug:4080072 Change-Id: Ie1110b511392b0a7fd21bbc23aa1b824eb8a78ad --- WebCore/platform/graphics/android/BaseTile.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/WebCore/platform/graphics/android/BaseTile.cpp b/WebCore/platform/graphics/android/BaseTile.cpp index 47be13b..3da0b3a 100644 --- a/WebCore/platform/graphics/android/BaseTile.cpp +++ b/WebCore/platform/graphics/android/BaseTile.cpp @@ -381,6 +381,9 @@ void BaseTile::paintBitmap() if (!m_currentDirtyArea->isEmpty()) m_dirty = true; + if (!m_dirty) + m_usable = true; + m_painting = false; m_atomicSync.unlock(); -- cgit v1.1 From c621d4e92755093cf8383d65fcf1c5a54c23d4c0 Mon Sep 17 00:00:00 2001 From: Cary Clark Date: Fri, 11 Mar 2011 11:05:21 -0500 Subject: allow multiple invals to return first difference The shape of the text selection changed recently, so the inval computation for the shape area was slightly incorrect. But most of the problem is caused by multiple calls to draw the selection area. The old assumption was that successive calls to compute the inval could each work from the prior state, since only the difference between the last inval and the current inval needs to be redrawn. Now, there are multiple calls to compute the area, and any of them need to return the last difference computed, only computing a new difference if the selection changed. Keep track of the last changed selection, so that the last position, the current position, and the last drawn position can be tracked correctly. bug:4073219 Change-Id: Ic9b9d037329e8f792b5ec09c112e665dbdfd0b81 --- WebKit/android/nav/SelectText.cpp | 41 +++++++++++++++++++++------------------ WebKit/android/nav/SelectText.h | 3 +++ 2 files changed, 25 insertions(+), 19 deletions(-) diff --git a/WebKit/android/nav/SelectText.cpp b/WebKit/android/nav/SelectText.cpp index bae0feb..f8ea799 100644 --- a/WebKit/android/nav/SelectText.cpp +++ b/WebKit/android/nav/SelectText.cpp @@ -1308,12 +1308,11 @@ static WTF::String text(const SkPicture& picture, const SkIRect& area, #define CONTROL_WIDTH 21 #define STROKE_WIDTH 1.0f #define STROKE_OUTSET 3.5f - +#define STROKE_I_OUTSET 4 // (int) ceil(STROKE_OUTSET) #define STROKE_COLOR 0x66000000 #define OUTER_COLOR 0x33000000 #define INNER_COLOR 0xe6aae300 -#define DROP_HEIGHT 4 #define SLOP 35 SelectText::SelectText() @@ -1459,18 +1458,18 @@ void SelectText::drawSelectionPointer(SkCanvas* canvas, IntRect* inval) static void addStart(SkRegion* diff, const SkIRect& rect) { SkIRect bounds; - bounds.set(rect.fLeft - CONTROL_WIDTH - STROKE_WIDTH, - rect.fBottom - STROKE_WIDTH, rect.fLeft + STROKE_WIDTH, - rect.fBottom + CONTROL_HEIGHT + DROP_HEIGHT + STROKE_WIDTH); + bounds.set(rect.fLeft - CONTROL_WIDTH - STROKE_I_OUTSET, + rect.fBottom - STROKE_I_OUTSET, rect.fLeft + STROKE_I_OUTSET, + rect.fBottom + CONTROL_HEIGHT + STROKE_I_OUTSET); diff->op(bounds, SkRegion::kUnion_Op); } static void addEnd(SkRegion* diff, const SkIRect& rect) { SkIRect bounds; - bounds.set(rect.fLeft - STROKE_WIDTH, rect.fBottom - STROKE_WIDTH, - rect.fLeft + CONTROL_WIDTH + STROKE_WIDTH, - rect.fBottom + CONTROL_HEIGHT + DROP_HEIGHT + STROKE_WIDTH); + bounds.set(rect.fRight - STROKE_I_OUTSET, rect.fBottom - STROKE_I_OUTSET, + rect.fRight + CONTROL_WIDTH + STROKE_I_OUTSET, + rect.fBottom + CONTROL_HEIGHT + STROKE_I_OUTSET); diff->op(bounds, SkRegion::kUnion_Op); } @@ -1486,7 +1485,9 @@ void SelectText::drawSelectionRegion(SkCanvas* canvas, IntRect* inval) m_selStart.fLeft, m_selStart.fTop, m_selStart.fRight, m_selStart.fBottom, m_selEnd.fLeft, m_selEnd.fTop, m_selEnd.fRight, m_selEnd.fBottom, ivisBounds.fLeft, ivisBounds.fTop, ivisBounds.fRight, ivisBounds.fBottom); - SkRegion diff(m_selRegion); + if (m_lastSelRegion != m_selRegion) + m_lastSelRegion.set(m_selRegion); + SkRegion diff(m_lastSelRegion); m_selRegion.setEmpty(); m_flipped = buildSelection(*m_picture, ivisBounds, m_selStart, m_startBase, m_selEnd, m_endBase, &m_selRegion); @@ -1517,20 +1518,20 @@ void SelectText::drawSelectionRegion(SkCanvas* canvas, IntRect* inval) DBG_NAV_LOGD("lastStart=(%d,%d,r=%d,b=%d) m_lastEnd=(%d,%d,r=%d,b=%d)", m_lastStart.fLeft, m_lastStart.fTop, m_lastStart.fRight, m_lastStart.fBottom, m_lastEnd.fLeft, m_lastEnd.fTop, m_lastEnd.fRight, m_lastEnd.fBottom); + if (!m_lastDrawnStart.isEmpty()) + addStart(&diff, m_lastDrawnStart); if (m_lastStart != m_selStart) { - if (!m_lastStart.isEmpty()) { - addStart(&diff, m_lastStart); - m_lastStart = m_selStart; - } - addStart(&diff, m_selStart); + m_lastDrawnStart = m_lastStart; + m_lastStart = m_selStart; } + addStart(&diff, m_selStart); + if (!m_lastDrawnEnd.isEmpty()) + addEnd(&diff, m_lastDrawnEnd); if (m_lastEnd != m_selEnd) { - if (!m_lastEnd.isEmpty()) { - addEnd(&diff, m_lastEnd); - m_lastEnd = m_selEnd; - } - addEnd(&diff, m_selEnd); + m_lastDrawnEnd = m_lastEnd; + m_lastEnd = m_selEnd; } + addEnd(&diff, m_selEnd); SkIRect iBounds = diff.getBounds(); DBG_NAV_LOGD("diff=(%d,%d,r=%d,b=%d)", iBounds.fLeft, iBounds.fTop, iBounds.fRight, iBounds.fBottom); @@ -1799,8 +1800,10 @@ void SelectText::reset() DBG_NAV_LOG("m_extendSelection=false"); m_selStart.setEmpty(); m_lastStart.setEmpty(); + m_lastDrawnStart.setEmpty(); m_selEnd.setEmpty(); m_lastEnd.setEmpty(); + m_lastDrawnEnd.setEmpty(); m_extendSelection = false; m_startSelection = false; SkSafeUnref(m_picture); diff --git a/WebKit/android/nav/SelectText.h b/WebKit/android/nav/SelectText.h index 3b15c0b..42239cf 100644 --- a/WebKit/android/nav/SelectText.h +++ b/WebKit/android/nav/SelectText.h @@ -84,11 +84,14 @@ private: SkIRect m_selEnd; SkIRect m_lastStart; SkIRect m_lastEnd; + SkIRect m_lastDrawnStart; + SkIRect m_lastDrawnEnd; SkIRect m_wordBounds; int m_startBase; int m_endBase; int m_layerId; SkIRect m_visibleRect; // constrains picture computations to visible area + SkRegion m_lastSelRegion; SkRegion m_selRegion; // computed from sel start, end SkPicture m_startControl; SkPicture m_endControl; -- cgit v1.1 From cc3d8b1aa20539f66307b1ef187f4b601051a136 Mon Sep 17 00:00:00 2001 From: Nicolas Roard Date: Thu, 17 Mar 2011 10:31:57 -0700 Subject: Fix Browser ANR The problem was that when attempting to forcefully destroy a texture in TilesManager::cleanupLayersTextures(), the call to LayerAndroid::removeTexture() may fail if the texture was busy being painted -- the call to BackedDoubleBufferedTexture::release() would return false, and the layer may thus still keep a pointer to the texture. But the release() call, while indicating it failed, was only delaying the release -- as soon as the texture was marked as not busy, it could set its owner to nil. We could thus have a situation where the layer did not reset its texture pointers because the owner of the texture was not yet changed, but the texture would then reset its owner to nil as soon as it was not busy painting. In TilesManager::cleanupLayersTexture() the next step before deleting a texture is to check that the texture does not have an owner -- but by then the texture could have been marked as not busy, and removed its owner, letting TilesManager destroying it. bug:3472320 Change-Id: I3bcf169b30dfacba1773d3b79a3c0d205bf3cbdb --- .../graphics/android/BackedDoubleBufferedTexture.cpp | 18 +++++++++--------- .../graphics/android/BackedDoubleBufferedTexture.h | 1 + WebCore/platform/graphics/android/LayerAndroid.cpp | 8 ++++++-- 3 files changed, 16 insertions(+), 11 deletions(-) diff --git a/WebCore/platform/graphics/android/BackedDoubleBufferedTexture.cpp b/WebCore/platform/graphics/android/BackedDoubleBufferedTexture.cpp index 470ecf1..f68050f 100644 --- a/WebCore/platform/graphics/android/BackedDoubleBufferedTexture.cpp +++ b/WebCore/platform/graphics/android/BackedDoubleBufferedTexture.cpp @@ -228,16 +228,16 @@ bool BackedDoubleBufferedTexture::setOwner(TextureOwner* owner) bool BackedDoubleBufferedTexture::release(TextureOwner* owner) { android::Mutex::Autolock lock(m_busyLock); - if (m_owner == owner) { - if (!m_busy) { - m_owner = 0; - return true; - } else { - m_delayedRelease = true; - m_delayedReleaseOwner = owner; - } + if (m_owner != owner) + return false; + + if (!m_busy) { + m_owner = 0; + } else { + m_delayedRelease = true; + m_delayedReleaseOwner = owner; } - return false; + return true; } void BackedDoubleBufferedTexture::setTile(TextureInfo* info, int x, int y, diff --git a/WebCore/platform/graphics/android/BackedDoubleBufferedTexture.h b/WebCore/platform/graphics/android/BackedDoubleBufferedTexture.h index 2d19806..f612114 100644 --- a/WebCore/platform/graphics/android/BackedDoubleBufferedTexture.h +++ b/WebCore/platform/graphics/android/BackedDoubleBufferedTexture.h @@ -96,6 +96,7 @@ public: // private member accessor functions TextureOwner* owner() { return m_owner; } // only used by the consumer thread + TextureOwner* delayedReleaseOwner() { return m_delayedReleaseOwner; } SkCanvas* canvas(); // only used by the producer thread SkBitmap* bitmap() { return m_bitmap; } diff --git a/WebCore/platform/graphics/android/LayerAndroid.cpp b/WebCore/platform/graphics/android/LayerAndroid.cpp index 89ce301..33d98ea 100644 --- a/WebCore/platform/graphics/android/LayerAndroid.cpp +++ b/WebCore/platform/graphics/android/LayerAndroid.cpp @@ -186,9 +186,13 @@ bool LayerAndroid::removeTexture(BackedDoubleBufferedTexture* aTexture) m_reservedTexture != m_drawingTexture) textureReleased &= m_reservedTexture->release(this); } - if (m_drawingTexture && m_drawingTexture->owner() != this) + if (m_drawingTexture && + ((m_drawingTexture->owner() != this) || + (m_drawingTexture->delayedReleaseOwner() == this))) m_drawingTexture = 0; - if (m_reservedTexture && m_reservedTexture->owner() != this) + if (m_reservedTexture && + ((m_reservedTexture->owner() != this) || + (m_reservedTexture->delayedReleaseOwner() == this))) m_reservedTexture = 0; return textureReleased; } -- cgit v1.1 From 7390ca223995b634c2a56f7c378a6261e1b2a734 Mon Sep 17 00:00:00 2001 From: Nicolas Roard Date: Fri, 18 Mar 2011 15:42:12 -0700 Subject: Fix for missing invals bug:4124433 Change-Id: I8cc7203dad408eff30da33f1c9a0a77dd7c97d66 --- WebKit/android/nav/WebView.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/WebKit/android/nav/WebView.cpp b/WebKit/android/nav/WebView.cpp index 6e85873..7ab890e 100644 --- a/WebKit/android/nav/WebView.cpp +++ b/WebKit/android/nav/WebView.cpp @@ -1509,7 +1509,7 @@ class GLDrawFunctor : Functor { IntRect finalInval; if (inval.isEmpty()) { finalInval = webViewRect; - retVal = false; + retVal = true; } else { finalInval.setX(webViewRect.x() + inval.x()); finalInval.setY(webViewRect.y() + inval.y() + titlebarHeight); -- cgit v1.1 From 6f400b68f091edc36db750f8742f9bcbf4f6d7b2 Mon Sep 17 00:00:00 2001 From: Nicolas Roard Date: Sat, 19 Mar 2011 19:01:15 -0700 Subject: Fix native crash Don't save the extras in the picture when drawing. bug:4126884 bug:4132721 Change-Id: I52c46a33f847e64c1f8245a0bb84445a948d72a4 --- WebCore/platform/graphics/android/LayerAndroid.cpp | 14 +++++++++----- WebCore/platform/graphics/android/LayerAndroid.h | 1 + 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/WebCore/platform/graphics/android/LayerAndroid.cpp b/WebCore/platform/graphics/android/LayerAndroid.cpp index 2df63a9..dba1ceb 100644 --- a/WebCore/platform/graphics/android/LayerAndroid.cpp +++ b/WebCore/platform/graphics/android/LayerAndroid.cpp @@ -1033,6 +1033,7 @@ void LayerAndroid::paintBitmapGL() contentDraw(nCanvas); picture.endRecording(); picture.draw(canvas); + extraDraw(canvas); m_atomicSync.lock(); texture->setTextureInfoFor(this); @@ -1048,6 +1049,14 @@ void LayerAndroid::paintBitmapGL() XLOG("LayerAndroid %d paintBitmapGL UPDATING DONE", uniqueId()); } +void LayerAndroid::extraDraw(SkCanvas* canvas) +{ + m_atomicSync.lock(); + if (m_extra) + canvas->drawPicture(*m_extra); + m_atomicSync.unlock(); +} + void LayerAndroid::contentDraw(SkCanvas* canvas) { if (m_contentsImage) { @@ -1058,11 +1067,6 @@ void LayerAndroid::contentDraw(SkCanvas* canvas) canvas->drawPicture(*m_recordingPicture); } - m_atomicSync.lock(); - if (m_extra) - canvas->drawPicture(*m_extra); - m_atomicSync.unlock(); - if (TilesManager::instance()->getShowVisualIndicator()) { float w = getSize().width(); float h = getSize().height(); diff --git a/WebCore/platform/graphics/android/LayerAndroid.h b/WebCore/platform/graphics/android/LayerAndroid.h index 98a0a15..0846930 100644 --- a/WebCore/platform/graphics/android/LayerAndroid.h +++ b/WebCore/platform/graphics/android/LayerAndroid.h @@ -243,6 +243,7 @@ public: void needsRepaint() { m_pictureUsed++; } unsigned int pictureUsed() { return m_pictureUsed; } void contentDraw(SkCanvas*); + void extraDraw(SkCanvas*); virtual bool isMedia() const { return false; } virtual bool isVideo() const { return false; } -- cgit v1.1 From 7b37c76fec303c8fe9b2a85df12c0e5e21f059fb Mon Sep 17 00:00:00 2001 From: Patrick Scott Date: Thu, 17 Mar 2011 13:43:29 -0400 Subject: Turns out args should not be decoded twice. This should help out in some cases with redirect/login loops. Bug: 4110115 Change-Id: I42fff7e9227423b9b5ce94234ad6d606234fe252 --- WebKit/android/jni/WebCoreFrameBridge.cpp | 3 --- 1 file changed, 3 deletions(-) diff --git a/WebKit/android/jni/WebCoreFrameBridge.cpp b/WebKit/android/jni/WebCoreFrameBridge.cpp index 49eac3c..7d1adb0 100644 --- a/WebKit/android/jni/WebCoreFrameBridge.cpp +++ b/WebKit/android/jni/WebCoreFrameBridge.cpp @@ -1023,9 +1023,6 @@ void WebFrame::autoLogin(const std::string& loginHeader) if (realm.isEmpty() || args.isEmpty()) return; - // Args is double-encoded as it contains urls. - args = WebCore::decodeURLEscapeSequences(args); - JNIEnv* env = getJNIEnv(); jstring jRealm = wtfStringToJstring(env, realm, true); jstring jAccount = wtfStringToJstring(env, account); -- cgit v1.1 From 8ea490ba34adaeded4cc96836b7244d3f813443a Mon Sep 17 00:00:00 2001 From: Mike Reed Date: Fri, 25 Mar 2011 11:51:24 -0400 Subject: try faster dashing if we're drawing a horizontal line, try using a bitmap-shader to simulate the dash, as this can be much faster than the general SkDashPathEffect. bug:4163023 Change-Id: I362543d6efb83ebf395cbe92c2d889c590a7c2df --- .../graphics/android/GraphicsContextAndroid.cpp | 52 +++++++++++++++++++--- 1 file changed, 45 insertions(+), 7 deletions(-) diff --git a/WebCore/platform/graphics/android/GraphicsContextAndroid.cpp b/WebCore/platform/graphics/android/GraphicsContextAndroid.cpp index f9df8cc..1a32ef5 100644 --- a/WebCore/platform/graphics/android/GraphicsContextAndroid.cpp +++ b/WebCore/platform/graphics/android/GraphicsContextAndroid.cpp @@ -62,6 +62,37 @@ template T* deepCopyPtr(const T* src) return src ? new T(*src) : 0; } +// Set a bitmap shader that mimics dashing by width-on, width-off. +// Returns false if it could not succeed (e.g. there was an existing shader) +static bool setBitmapDash(SkPaint* paint, int width) { + if (width <= 0 || paint->getShader()) + return false; + + SkColor c = paint->getColor(); + + SkBitmap bm; + bm.setConfig(SkBitmap::kARGB_8888_Config, 2, 1); + bm.allocPixels(); + bm.lockPixels(); + + // set the ON pixel + *bm.getAddr32(0, 0) = SkPreMultiplyARGB(0xFF, SkColorGetR(c), + SkColorGetG(c), SkColorGetB(c)); + // set the OFF pixel + *bm.getAddr32(1, 0) = 0; + bm.unlockPixels(); + + SkMatrix matrix; + matrix.setScale(SkIntToScalar(width), SK_Scalar1); + + SkShader* s = SkShader::CreateBitmapShader(bm, SkShader::kRepeat_TileMode, + SkShader::kClamp_TileMode); + s->setLocalMatrix(matrix); + + paint->setShader(s)->unref(); + return true; +} + // TODO / questions // alpha: how does this interact with the alpha in Color? multiply them together? @@ -277,7 +308,7 @@ public: // Sets up the paint for stroking. Returns true if the style is really // just a dash of squares (the size of the paint's stroke-width. - bool setupPaintStroke(SkPaint* paint, SkRect* rect) + bool setupPaintStroke(SkPaint* paint, SkRect* rect, bool isHLine = false) { this->setupPaintCommon(paint); paint->setColor(m_state->applyAlpha(m_state->strokeColor)); @@ -317,12 +348,19 @@ public: } if (width > 0) { - // TODO: Add this back when SkDashPathEffect's performance has been improved - //SkScalar intervals[] = { width, width }; - //pe = new SkDashPathEffect(intervals, 2, 0); - //paint->setPathEffect(pe)->unref(); // Return true if we're basically a dotted dash of squares - return RoundToInt(width) == RoundToInt(paint->getStrokeWidth()); + bool justSqrs = RoundToInt(width) == RoundToInt(paint->getStrokeWidth()); + + if (justSqrs || !isHLine || !setBitmapDash(paint, width)) { +#if 0 + // this is slow enough that we just skip it for now + // see http://b/issue?id=4163023 + SkScalar intervals[] = { width, width }; + pe = new SkDashPathEffect(intervals, 2, 0); + paint->setPathEffect(pe)->unref(); +#endif + } + return justSqrs; } return false; } @@ -520,7 +558,7 @@ void GraphicsContext::drawLine(const IntPoint& point1, const IntPoint& point2) const int idy = SkAbs32(point2.y() - point1.y()); // Special-case horizontal and vertical lines that are really just dots - if (m_data->setupPaintStroke(&paint, 0) && (!idx || !idy)) { + if (m_data->setupPaintStroke(&paint, 0, !idy) && (!idx || !idy)) { const SkScalar diameter = paint.getStrokeWidth(); const SkScalar radius = SkScalarHalf(diameter); SkScalar x = SkIntToScalar(SkMin32(point1.x(), point2.x())); -- cgit v1.1