diff options
19 files changed, 130 insertions, 180 deletions
diff --git a/Source/WebCore/platform/graphics/android/GLWebViewState.cpp b/Source/WebCore/platform/graphics/android/GLWebViewState.cpp index 99eb1c6..1b0513b 100644 --- a/Source/WebCore/platform/graphics/android/GLWebViewState.cpp +++ b/Source/WebCore/platform/graphics/android/GLWebViewState.cpp @@ -132,10 +132,10 @@ void GLWebViewState::setViewport(const SkRect& viewport, float scale) int viewMaxTileX = static_cast<int>(ceilf((viewport.width()-1) * invTileContentWidth)) + 1; int viewMaxTileY = static_cast<int>(ceilf((viewport.height()-1) * invTileContentHeight)) + 1; - TilesManager* manager = TilesManager::instance(); - int maxTextureCount = viewMaxTileX * viewMaxTileY * (manager->highEndGfx() ? 4 : 2); + TilesManager* tilesManager = TilesManager::instance(); + int maxTextureCount = viewMaxTileX * viewMaxTileY * (tilesManager->highEndGfx() ? 4 : 2); - manager->setMaxTextureCount(maxTextureCount); + tilesManager->setMaxTextureCount(maxTextureCount); // TODO: investigate whether we can move this return earlier. if ((m_viewport == viewport) diff --git a/Source/WebCore/platform/graphics/android/layers/BaseLayerAndroid.cpp b/Source/WebCore/platform/graphics/android/layers/BaseLayerAndroid.cpp index 1de5ae7..ce520b4 100644 --- a/Source/WebCore/platform/graphics/android/layers/BaseLayerAndroid.cpp +++ b/Source/WebCore/platform/graphics/android/layers/BaseLayerAndroid.cpp @@ -53,4 +53,17 @@ void BaseLayerAndroid::getLocalTransform(SkMatrix* matrix) const matrix->preConcat(getMatrix()); } +IFrameLayerAndroid* BaseLayerAndroid::updatePosition(SkRect viewport, + IFrameLayerAndroid* parentIframeLayer) +{ + if (viewport.fRight > getWidth() || viewport.fBottom > getHeight()) { + // To handle the viewport expanding past the layer's size with HW accel, + // expand the size of the layer, so that tiles will cover the viewport. + setSize(std::max(viewport.fRight, getWidth()), + std::max(viewport.fBottom, getHeight())); + } + + return LayerAndroid::updatePosition(viewport, parentIframeLayer); +} + } // namespace WebCore diff --git a/Source/WebCore/platform/graphics/android/layers/BaseLayerAndroid.h b/Source/WebCore/platform/graphics/android/layers/BaseLayerAndroid.h index 0ef39c8..f4cf9f3 100644 --- a/Source/WebCore/platform/graphics/android/layers/BaseLayerAndroid.h +++ b/Source/WebCore/platform/graphics/android/layers/BaseLayerAndroid.h @@ -49,6 +49,8 @@ public: virtual void getLocalTransform(SkMatrix* matrix) const; virtual const TransformationMatrix* drawTransform() const { return 0; } + virtual IFrameLayerAndroid* updatePosition(SkRect viewport, + IFrameLayerAndroid* parentIframeLayer); private: // TODO: move to SurfaceCollection. Color m_color; diff --git a/Source/WebCore/platform/graphics/android/layers/Layer.h b/Source/WebCore/platform/graphics/android/layers/Layer.h index 996547b..d87c699 100644 --- a/Source/WebCore/platform/graphics/android/layers/Layer.h +++ b/Source/WebCore/platform/graphics/android/layers/Layer.h @@ -157,6 +157,9 @@ protected: bool m_hasOverflowChildren; + // invalidation region + SkRegion m_dirtyRegion; +private: bool isAncestor(const Layer*) const; Layer* fParent; @@ -173,9 +176,6 @@ protected: SkTDArray<Layer*> m_children; - // invalidation region - SkRegion m_dirtyRegion; - WebCore::GLWebViewState* m_state; typedef SkRefCnt INHERITED; diff --git a/Source/WebCore/platform/graphics/android/layers/LayerAndroid.cpp b/Source/WebCore/platform/graphics/android/layers/LayerAndroid.cpp index df3fa42..81427b8 100644 --- a/Source/WebCore/platform/graphics/android/layers/LayerAndroid.cpp +++ b/Source/WebCore/platform/graphics/android/layers/LayerAndroid.cpp @@ -254,7 +254,7 @@ void LayerAndroid::addDirtyArea() area.intersect(clip); IntRect dirtyArea(area.x(), area.y(), area.width(), area.height()); - m_state->addDirtyArea(dirtyArea); + state()->addDirtyArea(dirtyArea); } void LayerAndroid::addAnimation(PassRefPtr<AndroidAnimation> prpAnim) @@ -411,7 +411,6 @@ void LayerAndroid::updatePositions() void LayerAndroid::updateGLPositionsAndScale(const TransformationMatrix& parentMatrix, const FloatRect& clipping, float opacity, float scale) { - m_atomicSync.lock(); IntSize layerSize(getSize().width(), getSize().height()); FloatPoint anchorPoint(getAnchorPoint().fX, getAnchorPoint().fY); FloatPoint position(getPosition().fX - m_offset.x(), getPosition().fY - m_offset.y()); @@ -428,7 +427,6 @@ void LayerAndroid::updateGLPositionsAndScale(const TransformationMatrix& parentM -originY, -anchorPointZ()); - m_atomicSync.unlock(); setDrawTransform(localMatrix); if (m_drawTransform.isIdentityOrTranslation()) { // adjust the translation coordinates of the draw transform matrix so @@ -610,50 +608,6 @@ void LayerAndroid::mergeInvalsInto(LayerAndroid* replacementTree) replacementLayer->markAsDirty(m_dirtyRegion); } -bool LayerAndroid::updateWithTree(LayerAndroid* newTree) -{ -// Disable fast update for now -#if (0) - bool needsRepaint = false; - int count = this->countChildren(); - for (int i = 0; i < count; i++) - needsRepaint |= this->getChild(i)->updateWithTree(newTree); - - if (newTree) { - LayerAndroid* newLayer = newTree->findById(uniqueId()); - needsRepaint |= updateWithLayer(newLayer); - } - return needsRepaint; -#else - return true; -#endif -} - -// Return true to indicate to WebViewCore that the updates -// are too complicated to be fully handled and we need a full -// call to webkit (e.g. handle repaints) -bool LayerAndroid::updateWithLayer(LayerAndroid* layer) -{ - if (!layer) - return true; - - android::AutoMutex lock(m_atomicSync); - m_position = layer->m_position; - m_anchorPoint = layer->m_anchorPoint; - m_size = layer->m_size; - m_opacity = layer->m_opacity; - m_transform = layer->m_transform; - - if (m_imageCRC != layer->m_imageCRC) - m_visible = false; - - if ((m_content != layer->m_content) - || (m_imageCRC != layer->m_imageCRC)) - return true; - - return false; -} - static inline bool compareLayerZ(const LayerAndroid* a, const LayerAndroid* b) { return a->zValue() > b->zValue(); @@ -857,7 +811,7 @@ bool LayerAndroid::drawGL(bool layerTilesDisabled) ImagesManager::instance()->releaseImage(m_imageCRC); } - m_state->glExtras()->drawGL(this); + state()->glExtras()->drawGL(this); bool askScreenUpdate = false; m_atomicSync.lock(); diff --git a/Source/WebCore/platform/graphics/android/layers/LayerAndroid.h b/Source/WebCore/platform/graphics/android/layers/LayerAndroid.h index 6239418..9a803a9 100644 --- a/Source/WebCore/platform/graphics/android/layers/LayerAndroid.h +++ b/Source/WebCore/platform/graphics/android/layers/LayerAndroid.h @@ -257,12 +257,6 @@ public: friend LayerAndroid* android::deserializeLayer(int version, SkStream* stream); friend void android::cleanupImageRefs(LayerAndroid* layer); - // Update layers using another tree. Only works for basic properties - // such as the position, the transform. Return true if anything more - // complex is needed. - bool updateWithTree(LayerAndroid*); - virtual bool updateWithLayer(LayerAndroid*); - LayerType type() { return m_type; } virtual SubclassType subclassType() { return LayerAndroid::StandardLayer; } diff --git a/Source/WebCore/platform/graphics/android/layers/ScrollableLayerAndroid.h b/Source/WebCore/platform/graphics/android/layers/ScrollableLayerAndroid.h index 1f289e6..52f5e7e 100644 --- a/Source/WebCore/platform/graphics/android/layers/ScrollableLayerAndroid.h +++ b/Source/WebCore/platform/graphics/android/layers/ScrollableLayerAndroid.h @@ -43,8 +43,6 @@ public: virtual LayerAndroid* copy() const { return new ScrollableLayerAndroid(*this); } virtual SubclassType subclassType() { return LayerAndroid::ScrollableLayer; } - virtual bool updateWithLayer(LayerAndroid*) { return true; } - // Scrolls to the given position in the layer. // Returns whether or not any scrolling was required. virtual bool scrollTo(int x, int y); diff --git a/Source/WebCore/platform/graphics/android/rendering/ImageTexture.cpp b/Source/WebCore/platform/graphics/android/rendering/ImageTexture.cpp index b2ead6a..9890331 100644 --- a/Source/WebCore/platform/graphics/android/rendering/ImageTexture.cpp +++ b/Source/WebCore/platform/graphics/android/rendering/ImageTexture.cpp @@ -174,8 +174,8 @@ bool ImageTexture::prepareGL(GLWebViewState* state) return false; if (!m_texture && m_picture) { - bool isLayerTile = true; - m_texture = new TileGrid(isLayerTile); + bool isBaseSurface = false; + m_texture = new TileGrid(isBaseSurface); SkRegion region; region.setRect(0, 0, m_image->width(), m_image->height()); m_texture->markAsDirty(region); @@ -198,8 +198,6 @@ const TransformationMatrix* ImageTexture::transform() if (!m_layer) return 0; - FloatPoint p(0, 0); - p = m_layer->drawTransform()->mapPoint(p); IntRect layerArea = m_layer->unclippedArea(); float scaleW = static_cast<float>(layerArea.width()) / static_cast<float>(m_image->width()); float scaleH = static_cast<float>(layerArea.height()) / static_cast<float>(m_image->height()); diff --git a/Source/WebCore/platform/graphics/android/rendering/Surface.h b/Source/WebCore/platform/graphics/android/rendering/Surface.h index 27c997e..756fabd 100644 --- a/Source/WebCore/platform/graphics/android/rendering/Surface.h +++ b/Source/WebCore/platform/graphics/android/rendering/Surface.h @@ -56,7 +56,7 @@ public: void computeTexturesAmount(TexturesResult* result); - LayerAndroid* getFirstLayer() { return m_layers[0]; } + LayerAndroid* getFirstLayer() const { return m_layers[0]; } bool needsTexture() { return m_needsTexture; } bool hasText() { return m_hasText; } bool isBase(); diff --git a/Source/WebCore/platform/graphics/android/rendering/SurfaceCollection.cpp b/Source/WebCore/platform/graphics/android/rendering/SurfaceCollection.cpp index 0bbaf91..cd5ceef 100644 --- a/Source/WebCore/platform/graphics/android/rendering/SurfaceCollection.cpp +++ b/Source/WebCore/platform/graphics/android/rendering/SurfaceCollection.cpp @@ -95,6 +95,15 @@ void SurfaceCollection::prepareGL(const SkRect& visibleRect) m_surfaces[i]->prepareGL(layerTilesDisabled); } +static inline bool compareSurfaceZ(const Surface* a, const Surface* b) +{ + const LayerAndroid* la = a->getFirstLayer(); + const LayerAndroid* lb = b->getFirstLayer(); + + // swap drawing order if zValue suggests it AND the layers are in the same stacking context + return (la->zValue() > lb->zValue()) && (la->getParent() == lb->getParent()); +} + bool SurfaceCollection::drawGL(const SkRect& visibleRect) { #ifdef DEBUG_COUNT @@ -105,8 +114,16 @@ bool SurfaceCollection::drawGL(const SkRect& visibleRect) updateLayerPositions(visibleRect); bool layerTilesDisabled = m_compositedRoot->state()->layersRenderingMode() > GLWebViewState::kClippedTextures; + + // create a duplicate vector of surfaces, sorted by z value + Vector <Surface*> surfaces; + for (unsigned int i = 0; i < m_surfaces.size(); i++) + surfaces.append(m_surfaces[i]); + std::stable_sort(surfaces.begin()+1, surfaces.end(), compareSurfaceZ); + + // draw the sorted vector for (unsigned int i = 0; i < m_surfaces.size(); i++) - needsRedraw |= m_surfaces[i]->drawGL(layerTilesDisabled); + needsRedraw |= surfaces[i]->drawGL(layerTilesDisabled); return needsRedraw; } diff --git a/Source/WebCore/platform/graphics/android/rendering/SurfaceCollectionManager.cpp b/Source/WebCore/platform/graphics/android/rendering/SurfaceCollectionManager.cpp index 8fb4d4b..91335c7 100644 --- a/Source/WebCore/platform/graphics/android/rendering/SurfaceCollectionManager.cpp +++ b/Source/WebCore/platform/graphics/android/rendering/SurfaceCollectionManager.cpp @@ -205,9 +205,17 @@ int SurfaceCollectionManager::drawGL(double currentTime, IntRect& viewRect, returnFlags |= uirenderer::DrawGlInfo::kStatusInvoke; if (!shouldDraw) { - if (didCollectionSwap) { + if (didCollectionSwap + || (!m_paintingCollection + && m_drawingCollection + && m_drawingCollection->isReady())) { + // either a swap just occurred, or there is no more work to be done: do a full draw m_drawingCollection->swapTiles(); returnFlags |= uirenderer::DrawGlInfo::kStatusDraw; + } else { + // current collection not ready - invoke functor in process mode + // until either drawing or painting collection is ready + returnFlags |= uirenderer::DrawGlInfo::kStatusInvoke; } return returnFlags; diff --git a/Source/WebCore/platform/graphics/android/rendering/Tile.cpp b/Source/WebCore/platform/graphics/android/rendering/Tile.cpp index 35fded1..178958d 100644 --- a/Source/WebCore/platform/graphics/android/rendering/Tile.cpp +++ b/Source/WebCore/platform/graphics/android/rendering/Tile.cpp @@ -511,11 +511,6 @@ void Tile::validatePaint() { // paintBitmap() may have cleared m_dirty) m_dirty = true; } - - if (m_deferredDirty) { - ALOGV("Note: deferred dirty flag set, possibly a missed paint on tile %p", this); - m_deferredDirty = false; - } } else { ALOGV("Note: paint was unsuccessful."); m_state = Unpainted; diff --git a/Source/WebCore/platform/graphics/android/rendering/Tile.h b/Source/WebCore/platform/graphics/android/rendering/Tile.h index 7010301..cc10799 100644 --- a/Source/WebCore/platform/graphics/android/rendering/Tile.h +++ b/Source/WebCore/platform/graphics/android/rendering/Tile.h @@ -151,9 +151,6 @@ private: // redrawn in the backTexture bool m_dirty; - // currently only for debugging, to be used for tracking down dropped repaints - bool m_deferredDirty; - // used to signal that a repaint is pending bool m_repaintPending; diff --git a/Source/WebCore/platform/graphics/android/rendering/TileGrid.cpp b/Source/WebCore/platform/graphics/android/rendering/TileGrid.cpp index 0e900a9..2510d52 100644 --- a/Source/WebCore/platform/graphics/android/rendering/TileGrid.cpp +++ b/Source/WebCore/platform/graphics/android/rendering/TileGrid.cpp @@ -80,7 +80,7 @@ bool TileGrid::isReady() // in order to unblock the zooming process. // FIXME: have a better system -- maybe keeping the last scale factor // able to fully render everything - ALOGV("TT %p, ready %d, visible %d, texturesRemain %d", + ALOGV("TG %p, ready %d, visible %d, texturesRemain %d", this, tilesAllReady, tilesVisible, TilesManager::instance()->layerTexturesRemain()); @@ -102,7 +102,7 @@ void TileGrid::swapTiles() for (unsigned int i = 0; i < m_tiles.size(); i++) if (m_tiles[i]->swapTexturesIfNeeded()) swaps++; - ALOGV("TT %p swapping, swaps = %d", this, swaps); + ALOGV("TG %p swapping, swaps = %d", this, swaps); } IntRect TileGrid::computeTilesArea(const IntRect& contentArea, float scale) @@ -113,7 +113,7 @@ IntRect TileGrid::computeTilesArea(const IntRect& contentArea, float scale) ceilf(contentArea.width() * scale), ceilf(contentArea.height() * scale)); - ALOGV("TT %p prepare, scale %f, area %d x %d", this, scale, area.width(), area.height()); + ALOGV("TG %p prepare, scale %f, area %d x %d", this, scale, area.width(), area.height()); if (area.width() == 0 && area.height() == 0) { computedArea.setWidth(0); @@ -153,8 +153,9 @@ void TileGrid::prepareGL(GLWebViewState* state, float scale, bool goingDown = m_prevTileY < m_area.y(); m_prevTileY = m_area.y(); + TilesManager* tilesManager = TilesManager::instance(); if (scale != m_scale) - TilesManager::instance()->removeOperationsForFilter(new ScaleFilter(painter, m_scale)); + tilesManager->removeOperationsForFilter(new ScaleFilter(painter, m_scale)); m_scale = scale; @@ -164,11 +165,11 @@ void TileGrid::prepareGL(GLWebViewState* state, float scale, m_tiles[i]->markAsDirty(m_dirtyRegion); // log inval region for the base surface - if (m_isBaseSurface && TilesManager::instance()->getProfiler()->enabled()) { + if (m_isBaseSurface && tilesManager->getProfiler()->enabled()) { SkRegion::Iterator iterator(m_dirtyRegion); while (!iterator.done()) { SkIRect r = iterator.rect(); - TilesManager::instance()->getProfiler()->nextInval(r, scale); + tilesManager->getProfiler()->nextInval(r, scale); iterator.next(); } } @@ -192,10 +193,13 @@ void TileGrid::prepareGL(GLWebViewState* state, float scale, if (useExpandPrefetch) { IntRect fullArea = computeTilesArea(unclippedArea, scale); IntRect expandedArea = m_area; - expandedArea.inflate(EXPANDED_BOUNDS_INFLATE); + + // on systems reporting highEndGfx=true and useMinimalMemory not set, use expanded bounds + if (tilesManager->highEndGfx() && !tilesManager->useMinimalMemory()) + expandedArea.inflate(EXPANDED_BOUNDS_INFLATE); if (isLowResPrefetch) - expandedArea.inflate(EXPANDED_PREFETCH_BOUNDS_Y_INFLATE); + expandedArea.inflateY(EXPANDED_PREFETCH_BOUNDS_Y_INFLATE); // clip painting area to content expandedArea.intersect(fullArea); @@ -209,7 +213,7 @@ void TileGrid::prepareGL(GLWebViewState* state, float scale, void TileGrid::markAsDirty(const SkRegion& invalRegion) { - ALOGV("TT %p markAsDirty, current region empty %d, new empty %d", + ALOGV("TG %p markAsDirty, current region empty %d, new empty %d", this, m_dirtyRegion.isEmpty(), invalRegion.isEmpty()); m_dirtyRegion.op(invalRegion, SkRegion::kUnion_Op); } @@ -235,7 +239,7 @@ void TileGrid::prepareTile(int x, int y, TilePainter* painter, tile->reserveTexture(); if (tile->backTexture() && tile->isDirty() && !tile->isRepaintPending()) { - ALOGV("painting TT %p's tile %d %d for LG %p", this, x, y, painter); + ALOGV("painting TG %p's tile %d %d for LG %p", this, x, y, painter); PaintTileOperation *operation = new PaintTileOperation(tile, painter, state, isLowResPrefetch); TilesManager::instance()->scheduleOperation(operation); @@ -326,7 +330,7 @@ void TileGrid::drawGL(const IntRect& visibleArea, float opacity, if (semiOpaqueBaseSurface) drawMissingRegion(missingRegion, opacity, background); - ALOGV("TT %p drew %d tiles, scale %f", + ALOGV("TG %p drew %d tiles, scale %f", this, drawn, m_scale); } @@ -368,7 +372,7 @@ void TileGrid::removeTiles() void TileGrid::discardTextures() { - ALOGV("TT %p discarding textures", this); + ALOGV("TG %p discarding textures", this); for (unsigned int i = 0; i < m_tiles.size(); i++) m_tiles[i]->discardTextures(); } diff --git a/Source/WebCore/platform/graphics/android/rendering/TransferQueue.cpp b/Source/WebCore/platform/graphics/android/rendering/TransferQueue.cpp index ec0d9e7..af19f30 100644 --- a/Source/WebCore/platform/graphics/android/rendering/TransferQueue.cpp +++ b/Source/WebCore/platform/graphics/android/rendering/TransferQueue.cpp @@ -102,7 +102,7 @@ void TransferQueue::initGLResources(int width, int height) m_sharedSurfaceTexture = #if GPU_UPLOAD_WITHOUT_DRAW new android::SurfaceTexture(m_sharedSurfaceTextureId, true, - GL_TEXTURE_2D, false, bufferQueue); + GL_TEXTURE_2D, true, bufferQueue); #else new android::SurfaceTexture(m_sharedSurfaceTextureId, true, GL_TEXTURE_EXTERNAL_OES, true, diff --git a/Source/WebKit/android/WebCoreSupport/ChromeClientAndroid.cpp b/Source/WebKit/android/WebCoreSupport/ChromeClientAndroid.cpp index 207fe9a..c10f5b3 100644 --- a/Source/WebKit/android/WebCoreSupport/ChromeClientAndroid.cpp +++ b/Source/WebKit/android/WebCoreSupport/ChromeClientAndroid.cpp @@ -95,7 +95,7 @@ void ChromeClientAndroid::scheduleCompositingLayerSync() m_needsLayerSync = true; WebViewCore* webViewCore = WebViewCore::getWebViewCore(m_webFrame->page()->mainFrame()->view()); if (webViewCore) - webViewCore->layersDraw(); + webViewCore->contentDraw(); } void ChromeClientAndroid::setNeedsOneShotDrawingSynchronization() diff --git a/Source/WebKit/android/jni/WebViewCore.cpp b/Source/WebKit/android/jni/WebViewCore.cpp index debf249..bf87668 100644 --- a/Source/WebKit/android/jni/WebViewCore.cpp +++ b/Source/WebKit/android/jni/WebViewCore.cpp @@ -323,7 +323,6 @@ struct WebViewCore::JavaGlue { jweak m_obj; jmethodID m_scrollTo; jmethodID m_contentDraw; - jmethodID m_layersDraw; jmethodID m_requestListBox; jmethodID m_openFileChooser; jmethodID m_requestSingleListBox; @@ -397,7 +396,7 @@ struct WebViewCore::TextFieldInitDataGlue { jfieldID m_name; jfieldID m_label; jfieldID m_maxLength; - jfieldID m_nodeBounds; + jfieldID m_contentBounds; jfieldID m_nodeLayerId; jfieldID m_contentRect; }; @@ -456,7 +455,6 @@ WebViewCore::WebViewCore(JNIEnv* env, jobject javaWebViewCore, WebCore::Frame* m m_javaGlue->m_obj = env->NewWeakGlobalRef(javaWebViewCore); m_javaGlue->m_scrollTo = GetJMethod(env, clazz, "contentScrollTo", "(IIZZ)V"); m_javaGlue->m_contentDraw = GetJMethod(env, clazz, "contentDraw", "()V"); - m_javaGlue->m_layersDraw = GetJMethod(env, clazz, "layersDraw", "()V"); m_javaGlue->m_requestListBox = GetJMethod(env, clazz, "requestListBox", "([Ljava/lang/String;[I[I)V"); m_javaGlue->m_openFileChooser = GetJMethod(env, clazz, "openFileChooser", "(Ljava/lang/String;)Ljava/lang/String;"); m_javaGlue->m_requestSingleListBox = GetJMethod(env, clazz, "requestListBox", "([Ljava/lang/String;[II)V"); @@ -523,7 +521,7 @@ WebViewCore::WebViewCore(JNIEnv* env, jobject javaWebViewCore, WebCore::Frame* m m_textFieldInitDataGlue->m_name = env->GetFieldID(tfidClazz, "mName", "Ljava/lang/String;"); m_textFieldInitDataGlue->m_label = env->GetFieldID(tfidClazz, "mLabel", "Ljava/lang/String;"); m_textFieldInitDataGlue->m_maxLength = env->GetFieldID(tfidClazz, "mMaxLength", "I"); - m_textFieldInitDataGlue->m_nodeBounds = env->GetFieldID(tfidClazz, "mNodeBounds", "Landroid/graphics/Rect;"); + m_textFieldInitDataGlue->m_contentBounds = env->GetFieldID(tfidClazz, "mContentBounds", "Landroid/graphics/Rect;"); m_textFieldInitDataGlue->m_nodeLayerId = env->GetFieldID(tfidClazz, "mNodeLayerId", "I"); m_textFieldInitDataGlue->m_contentRect = env->GetFieldID(tfidClazz, "mContentRect", "Landroid/graphics/Rect;"); m_textFieldInitDataGlue->m_constructor = GetJMethod(env, tfidClazz, "<init>", "()V"); @@ -858,18 +856,6 @@ void WebViewCore::rebuildPictureSet(PictureSet* pictureSet) #endif } -bool WebViewCore::updateLayers(LayerAndroid* layers) -{ - // We update the layers - ChromeClientAndroid* chromeC = static_cast<ChromeClientAndroid*>(m_mainFrame->page()->chrome()->client()); - GraphicsLayerAndroid* root = static_cast<GraphicsLayerAndroid*>(chromeC->layersSync()); - if (root) { - LayerAndroid* updatedLayer = root->contentLayer(); - return layers->updateWithTree(updatedLayer); - } - return true; -} - void WebViewCore::notifyAnimationStarted() { // We notify webkit that the animations have begun @@ -1020,16 +1006,6 @@ void WebViewCore::contentDraw() checkException(env); } -void WebViewCore::layersDraw() -{ - JNIEnv* env = JSC::Bindings::getJNIEnv(); - AutoJObject javaObject = m_javaGlue->object(env); - if (!javaObject.get()) - return; - env->CallVoidMethod(javaObject.get(), m_javaGlue->m_layersDraw); - checkException(env); -} - void WebViewCore::contentInvalidate(const WebCore::IntRect &r) { DBG_SET_LOGD("rect={%d,%d,w=%d,h=%d}", r.x(), r.y(), r.width(), r.height()); @@ -1649,7 +1625,7 @@ SelectText* WebViewCore::createSelectText(const VisibleSelection& selection) RenderText* renderText = toRenderText(r); int caretOffset; InlineBox* inlineBox; - start.getInlineBoxAndOffset(DOWNSTREAM, inlineBox, caretOffset); + start.getInlineBoxAndOffset(selection.affinity(), inlineBox, caretOffset); startHandle = renderText->localCaretRect(inlineBox, caretOffset); FloatPoint absoluteOffset = renderText->localToAbsolute(startHandle.location()); startHandle.setX(absoluteOffset.x() - layerOffset.x()); @@ -1698,19 +1674,19 @@ SelectText* WebViewCore::createSelectText(const VisibleSelection& selection) selectTextContainer->setText(range->text()); selectTextContainer->setTextRect(SelectText::StartHandle, - positionToTextRect(selection.start())); + positionToTextRect(selection.start(), selection.affinity())); selectTextContainer->setTextRect(SelectText::EndHandle, - positionToTextRect(selection.end())); + positionToTextRect(selection.end(), selection.affinity())); return selectTextContainer; } -IntRect WebViewCore::positionToTextRect(const Position& position) +IntRect WebViewCore::positionToTextRect(const Position& position, EAffinity affinity) { IntRect textRect; InlineBox* inlineBox; int offset; - position.getInlineBoxAndOffset(VP_DEFAULT_AFFINITY, inlineBox, offset); + position.getInlineBoxAndOffset(affinity, inlineBox, offset); if (inlineBox && inlineBox->isInlineTextBox()) { InlineTextBox* box = static_cast<InlineTextBox*>(inlineBox); RootInlineBox* root = box->root(); @@ -2960,17 +2936,17 @@ void WebViewCore::passToJs(int generation, const WTF::String& current, updateTextSelection(); } -void WebViewCore::scrollFocusedTextInput(float xPercent, int y) +WebCore::IntRect WebViewCore::scrollFocusedTextInput(float xPercent, int y) { WebCore::Node* focus = currentFocus(); if (!focus) { clearTextEntry(); - return; + return WebCore::IntRect(); } WebCore::RenderTextControl* renderText = toRenderTextControl(focus); if (!renderText) { clearTextEntry(); - return; + return WebCore::IntRect(); } int x = (int) (xPercent * (renderText->scrollWidth() - @@ -2978,6 +2954,9 @@ void WebViewCore::scrollFocusedTextInput(float xPercent, int y) renderText->setScrollLeft(x); renderText->setScrollTop(y); focus->document()->frame()->selection()->recomputeCaretRect(); + LayerAndroid* layer = 0; + platformLayerIdFromNode(focus, &layer); + return absoluteContentRect(focus, layer); } void WebViewCore::setFocusControllerActive(bool active) @@ -3420,22 +3399,23 @@ bool WebViewCore::isAutoCompleteEnabled(Node* node) return isEnabled; } -WebCore::IntRect WebViewCore::boundingRect(WebCore::Node* node, +WebCore::IntRect WebViewCore::absoluteContentRect(WebCore::Node* node, LayerAndroid* layer) { - // Caret selection - IntRect boundingRect; + IntRect contentRect; if (node) { RenderObject* render = node->renderer(); - if (render && !render->isBody()) { + if (render && render->isBox() && !render->isBody()) { IntPoint offset = convertGlobalContentToFrameContent(IntPoint(), node->document()->frame()); WebViewCore::layerToAbsoluteOffset(layer, offset); - boundingRect = render->absoluteBoundingBoxRect(true); - boundingRect.move(-offset.x(), -offset.y()); + + RenderBox* renderBox = toRenderBox(render); + contentRect = renderBox->absoluteContentBox(); + contentRect.move(-offset.x(), -offset.y()); } } - return boundingRect; + return contentRect; } jobject WebViewCore::createTextFieldInitData(Node* node) @@ -3468,8 +3448,8 @@ jobject WebViewCore::createTextFieldInitData(Node* node) env->SetIntField(initData, classDef->m_maxLength, getMaxLength(node)); LayerAndroid* layer = 0; int layerId = platformLayerIdFromNode(node, &layer); - IntRect bounds = boundingRect(node, layer); - env->SetObjectField(initData, classDef->m_nodeBounds, + IntRect bounds = absoluteContentRect(node, layer); + env->SetObjectField(initData, classDef->m_contentBounds, intRectToRect(env, bounds)); env->SetIntField(initData, classDef->m_nodeLayerId, layerId); IntRect contentRect; @@ -4551,10 +4531,12 @@ static void PassToJs(JNIEnv* env, jobject obj, jint nativeClass, } static void ScrollFocusedTextInput(JNIEnv* env, jobject obj, jint nativeClass, - jfloat xPercent, jint y) + jfloat xPercent, jint y, jobject contentBounds) { WebViewCore* viewImpl = reinterpret_cast<WebViewCore*>(nativeClass); - viewImpl->scrollFocusedTextInput(xPercent, y); + IntRect bounds = viewImpl->scrollFocusedTextInput(xPercent, y); + if (contentBounds) + GraphicsJNI::irect_to_jrect(bounds, env, contentBounds); } static void SetFocusControllerActive(JNIEnv* env, jobject obj, jint nativeClass, @@ -4580,19 +4562,6 @@ void WebViewCore::addVisitedLink(const UChar* string, int length) m_groupForVisitedLinks->addVisitedLink(string, length); } -static bool UpdateLayers(JNIEnv* env, jobject obj, jint nativeClass, - jint jbaseLayer) -{ - WebViewCore* viewImpl = (WebViewCore*) nativeClass; - BaseLayerAndroid* baseLayer = (BaseLayerAndroid*) jbaseLayer; - if (baseLayer) { - LayerAndroid* root = static_cast<LayerAndroid*>(baseLayer->getChild(0)); - if (root) - return viewImpl->updateLayers(root); - } - return true; -} - static void NotifyAnimationStarted(JNIEnv* env, jobject obj, jint nativeClass) { WebViewCore* viewImpl = (WebViewCore*) nativeClass; @@ -5116,7 +5085,7 @@ static JNINativeMethod gJavaWebViewCoreMethods[] = { (void*) MoveMouse }, { "passToJs", "(IILjava/lang/String;IIZZZZ)V", (void*) PassToJs }, - { "nativeScrollFocusedTextInput", "(IFI)V", + { "nativeScrollFocusedTextInput", "(IFILandroid/graphics/Rect;)V", (void*) ScrollFocusedTextInput }, { "nativeSetFocusControllerActive", "(IZ)V", (void*) SetFocusControllerActive }, @@ -5138,8 +5107,6 @@ static JNINativeMethod gJavaWebViewCoreMethods[] = { (void*) RetrieveImageSource }, { "nativeGetContentMinPrefWidth", "(I)I", (void*) GetContentMinPrefWidth }, - { "nativeUpdateLayers", "(II)Z", - (void*) UpdateLayers }, { "nativeNotifyAnimationStarted", "(I)V", (void*) NotifyAnimationStarted }, { "nativeRecordContent", "(ILandroid/graphics/Region;Landroid/graphics/Point;)I", diff --git a/Source/WebKit/android/jni/WebViewCore.h b/Source/WebKit/android/jni/WebViewCore.h index a6b305b..00b4bda 100644 --- a/Source/WebKit/android/jni/WebViewCore.h +++ b/Source/WebKit/android/jni/WebViewCore.h @@ -415,7 +415,7 @@ namespace android { /** * Scroll the focused textfield to (x, y) in document space */ - void scrollFocusedTextInput(float x, int y); + WebCore::IntRect scrollFocusedTextInput(float x, int y); /** * Set the FocusController's active and focused states, so that * the caret will draw (true) or not. @@ -753,9 +753,10 @@ namespace android { static int getMaxLength(WebCore::Node* node); static WTF::String getFieldName(WebCore::Node* node); static bool isAutoCompleteEnabled(WebCore::Node* node); - WebCore::IntRect boundingRect(WebCore::Node* node, - WebCore::LayerAndroid* layer); - static WebCore::IntRect positionToTextRect(const WebCore::Position& position); + WebCore::IntRect absoluteContentRect(WebCore::Node* node, + WebCore::LayerAndroid* layer); + static WebCore::IntRect positionToTextRect(const WebCore::Position& position, + WebCore::EAffinity affinity); // called from constructor, to add this to a global list static void addInstance(WebViewCore*); diff --git a/Source/WebKit/android/nav/WebView.cpp b/Source/WebKit/android/nav/WebView.cpp index a4381e6..44ad1c5 100644 --- a/Source/WebKit/android/nav/WebView.cpp +++ b/Source/WebKit/android/nav/WebView.cpp @@ -306,7 +306,8 @@ PictureSet* draw(SkCanvas* canvas, SkColor bgColor, DrawExtras extras, bool spli int sc = canvas->save(SkCanvas::kClip_SaveFlag); canvas->clipRect(SkRect::MakeLTRB(0, 0, content->width(), content->height()), SkRegion::kDifference_Op); - canvas->drawColor(bgColor); + Color c = m_baseLayer->getBackgroundColor(); + canvas->drawColor(SkColorSetARGBInline(c.alpha(), c.red(), c.green(), c.blue())); canvas->restoreToCount(sc); // call this to be sure we've adjusted for any scrolling or animations @@ -592,6 +593,19 @@ void setTextSelection(SelectText *selection) { setDrawExtra(selection, DrawExtrasSelection); } +const TransformationMatrix* getLayerTransform(int layerId) { + if (layerId != -1 && m_baseLayer) { + LayerAndroid* layer = m_baseLayer->findById(layerId); + // We need to make sure the drawTransform is up to date as this is + // called before a draw() or drawGL() + if (layer) { + m_baseLayer->updateLayerPositions(m_visibleRect); + return layer->drawTransform(); + } + } + return 0; +} + int getHandleLayerId(SelectText::HandleId handleId, SkIPoint& cursorPoint, FloatQuad& textBounds) { SelectText* selectText = static_cast<SelectText*>(getDrawExtra(DrawExtrasSelection)); @@ -602,36 +616,24 @@ int getHandleLayerId(SelectText::HandleId handleId, SkIPoint& cursorPoint, IntRect textRect = selectText->textRect(handleId); // Rects exclude the last pixel on right/bottom. We want only included pixels. cursorPoint.set(cursorRect.x(), cursorRect.maxY() - 1); - textRect.setHeight(textRect.height() - 1); - textRect.setWidth(textRect.width() - 1); + textRect.setHeight(std::max(1, textRect.height() - 1)); + textRect.setWidth(std::max(1, textRect.width() - 1)); textBounds = FloatQuad(textRect); - if (layerId != -1) { - // We need to make sure the drawTransform is up to date as this is - // called before a draw() or drawGL() - m_baseLayer->updateLayerPositions(m_visibleRect); - LayerAndroid* root = m_baseLayer; - LayerAndroid* layer = root ? root->findById(layerId) : 0; - if (layer && layer->drawTransform()) { - const TransformationMatrix* transform = layer->drawTransform(); - // We're overloading the concept of Rect to be just the two - // points (bottom-left and top-right. - cursorPoint = transform->mapPoint(cursorPoint); - textBounds = transform->mapQuad(textBounds); - } + const TransformationMatrix* transform = getLayerTransform(layerId); + if (transform) { + // We're overloading the concept of Rect to be just the two + // points (bottom-left and top-right. + cursorPoint = transform->mapPoint(cursorPoint); + textBounds = transform->mapQuad(textBounds); } return layerId; } void mapLayerRect(int layerId, SkIRect& rect) { - if (layerId != -1) { - // We need to make sure the drawTransform is up to date as this is - // called before a draw() or drawGL() - m_baseLayer->updateLayerPositions(m_visibleRect); - LayerAndroid* layer = m_baseLayer ? m_baseLayer->findById(layerId) : 0; - if (layer && layer->drawTransform()) - rect = layer->drawTransform()->mapRect(rect); - } + const TransformationMatrix* transform = getLayerTransform(layerId); + if (transform) + transform->mapRect(rect); } void floatQuadToQuadF(JNIEnv* env, const FloatQuad& nativeTextQuad, |