diff options
Diffstat (limited to 'Source/WebCore')
10 files changed, 96 insertions, 10 deletions
diff --git a/Source/WebCore/platform/graphics/android/GLWebViewState.cpp b/Source/WebCore/platform/graphics/android/GLWebViewState.cpp index efcf877..2d7b177 100644 --- a/Source/WebCore/platform/graphics/android/GLWebViewState.cpp +++ b/Source/WebCore/platform/graphics/android/GLWebViewState.cpp @@ -31,6 +31,7 @@ #include "BaseLayerAndroid.h" #include "ClassTracker.h" #include "GLUtils.h" +#include "ImagesManager.h" #include "LayerAndroid.h" #include "SkPath.h" #include "TilesManager.h" @@ -295,8 +296,10 @@ void GLWebViewState::setViewport(SkRect& viewport, float scale) // allocate max possible number of tiles visible with this viewport int viewMaxTileX = static_cast<int>(ceilf((viewport.width()-1) * invTileContentWidth)) + 1; int viewMaxTileY = static_cast<int>(ceilf((viewport.height()-1) * invTileContentHeight)) + 1; + + // NOTE: fetching 4 viewports worth, may need to be adjusted per-device int maxTextureCount = (viewMaxTileX + TILE_PREFETCH_DISTANCE * 2) * - (viewMaxTileY + TILE_PREFETCH_DISTANCE * 2) * 2; + (viewMaxTileY + TILE_PREFETCH_DISTANCE * 2) * 4; TilesManager::instance()->setMaxTextureCount(maxTextureCount); m_tiledPageA->updateBaseTileSize(); m_tiledPageB->updateBaseTileSize(); @@ -445,6 +448,11 @@ bool GLWebViewState::drawGL(IntRect& rect, SkRect& viewport, IntRect* invalRect, // the BaseTiles' texture. TilesManager::instance()->transferQueue()->updateDirtyBaseTiles(); + // Upload any pending ImageTexture + // Return true if we still have some images to upload. + // TODO: upload as many textures as possible within a certain time limit + bool ret = ImagesManager::instance()->uploadTextures(); + if (scale < MIN_SCALE_WARNING || scale > MAX_SCALE_WARNING) XLOGC("WARNING, scale seems corrupted after update: %e", scale); @@ -457,7 +465,7 @@ bool GLWebViewState::drawGL(IntRect& rect, SkRect& viewport, IntRect* invalRect, // set up zoom manager, shaders, etc. m_backgroundColor = baseLayer->getBackgroundColor(); double currentTime = setupDrawing(rect, viewport, webViewRect, titleBarHeight, clip, scale); - bool ret = baseLayer->drawGL(currentTime, compositedRoot, rect, + ret |= baseLayer->drawGL(currentTime, compositedRoot, rect, viewport, scale, buffersSwappedPtr); m_glExtras.drawGL(webViewRect, viewport, titleBarHeight); diff --git a/Source/WebCore/platform/graphics/android/ImageTexture.cpp b/Source/WebCore/platform/graphics/android/ImageTexture.cpp index 814373c..96f7713 100644 --- a/Source/WebCore/platform/graphics/android/ImageTexture.cpp +++ b/Source/WebCore/platform/graphics/android/ImageTexture.cpp @@ -26,6 +26,7 @@ #include "config.h" #include "ImageTexture.h" +#include "ImagesManager.h" #include "SkDevice.h" #include "TilesManager.h" @@ -92,6 +93,14 @@ void ImageTexture::prepareGL() if (m_textureId) return; + ImagesManager::instance()->scheduleTextureUpload(this); +} + +void ImageTexture::uploadGLTexture() +{ + if (m_textureId) + return; + glGenTextures(1, &m_textureId); GLUtils::createTextureWithBitmap(m_textureId, *m_image); } diff --git a/Source/WebCore/platform/graphics/android/ImageTexture.h b/Source/WebCore/platform/graphics/android/ImageTexture.h index 18ff7ef..7f35f06 100644 --- a/Source/WebCore/platform/graphics/android/ImageTexture.h +++ b/Source/WebCore/platform/graphics/android/ImageTexture.h @@ -64,6 +64,7 @@ public: virtual ~ImageTexture(); void prepareGL(); + void uploadGLTexture(); void drawGL(LayerAndroid* painter); void drawCanvas(SkCanvas*, SkRect&); void retain() { m_refCount++; } diff --git a/Source/WebCore/platform/graphics/android/ImagesManager.cpp b/Source/WebCore/platform/graphics/android/ImagesManager.cpp index 3518832..21f9fe9 100644 --- a/Source/WebCore/platform/graphics/android/ImagesManager.cpp +++ b/Source/WebCore/platform/graphics/android/ImagesManager.cpp @@ -105,4 +105,25 @@ ImageTexture* ImagesManager::getTextureForImage(SkBitmapRef* img, bool retain) return image; } +void ImagesManager::scheduleTextureUpload(ImageTexture* texture) +{ + if (m_imagesToUpload.contains(texture)) + return; + + texture->retain(); + m_imagesToUpload.append(texture); +} + +bool ImagesManager::uploadTextures() +{ + // scheduleUpload and uploadTextures are called on the same thread + if (!m_imagesToUpload.size()) + return false; + ImageTexture* texture = m_imagesToUpload.last(); + texture->uploadGLTexture(); + m_imagesToUpload.removeLast(); + removeImage(texture->imageRef()); + return m_imagesToUpload.size(); +} + } // namespace WebCore diff --git a/Source/WebCore/platform/graphics/android/ImagesManager.h b/Source/WebCore/platform/graphics/android/ImagesManager.h index 1b5d322..2fcb9fd 100644 --- a/Source/WebCore/platform/graphics/android/ImagesManager.h +++ b/Source/WebCore/platform/graphics/android/ImagesManager.h @@ -30,6 +30,7 @@ #include "SkBitmap.h" #include "SkBitmapRef.h" #include "SkRefCnt.h" +#include "Vector.h" namespace WebCore { @@ -43,6 +44,8 @@ public: void removeImage(SkBitmapRef* img); ImageTexture* getTextureForImage(SkBitmapRef* img, bool retain = true); void showImages(); + void scheduleTextureUpload(ImageTexture* texture); + bool uploadTextures(); private: ImagesManager() {} @@ -51,6 +54,7 @@ private: android::Mutex m_imagesLock; HashMap<SkBitmapRef*, ImageTexture*> m_images; + Vector<ImageTexture*> m_imagesToUpload; }; } // namespace WebCore diff --git a/Source/WebCore/platform/graphics/android/LayerAndroid.cpp b/Source/WebCore/platform/graphics/android/LayerAndroid.cpp index 4162e0b..4a0e2bb 100644 --- a/Source/WebCore/platform/graphics/android/LayerAndroid.cpp +++ b/Source/WebCore/platform/graphics/android/LayerAndroid.cpp @@ -768,6 +768,8 @@ void LayerAndroid::assignTextureTo(LayerAndroid* newTree) 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++) @@ -778,6 +780,9 @@ bool LayerAndroid::updateWithTree(LayerAndroid* newTree) needsRepaint |= updateWithLayer(newLayer); } return needsRepaint; +#else + return true; +#endif } // Return true to indicate to WebViewCore that the updates diff --git a/Source/WebCore/platform/graphics/android/TilesManager.cpp b/Source/WebCore/platform/graphics/android/TilesManager.cpp index 74cc764..7edc4b8 100644 --- a/Source/WebCore/platform/graphics/android/TilesManager.cpp +++ b/Source/WebCore/platform/graphics/android/TilesManager.cpp @@ -69,7 +69,7 @@ // number to cap the layer tile texturs, it worked on both phones and tablets. // TODO: after merge the pool of base tiles and layer tiles, we should revisit // the logic of allocation management. -#define MAX_TEXTURE_ALLOCATION ((6+TILE_PREFETCH_DISTANCE*2)*(5+TILE_PREFETCH_DISTANCE*2)*2) +#define MAX_TEXTURE_ALLOCATION ((6+TILE_PREFETCH_DISTANCE*2)*(5+TILE_PREFETCH_DISTANCE*2)*4) #define TILE_WIDTH 256 #define TILE_HEIGHT 256 #define LAYER_TILE_WIDTH 256 diff --git a/Source/WebCore/platform/graphics/android/android_graphics.cpp b/Source/WebCore/platform/graphics/android/android_graphics.cpp index e50cfec..e255d29 100644 --- a/Source/WebCore/platform/graphics/android/android_graphics.cpp +++ b/Source/WebCore/platform/graphics/android/android_graphics.cpp @@ -132,19 +132,19 @@ void CursorRing::setIsButton(const CachedNode* node) bool CursorRing::setup() { - m_node->localCursorRings(m_frame, &m_rings); + m_node->cursorRings(m_frame, &m_rings); if (!m_rings.size()) { DBG_NAV_LOG("!rings.size()"); m_viewImpl->m_hasCursorBounds = false; return false; } setIsButton(m_node); - m_bounds = m_node->localBounds(m_frame); + m_bounds = m_node->bounds(m_frame); m_viewImpl->updateCursorBounds(m_root, m_frame, m_node); bool useHitBounds = m_node->useHitBounds(); if (useHitBounds) - m_bounds = m_node->localHitBounds(m_frame); + m_bounds = m_node->hitBounds(m_frame); if (useHitBounds || m_node->useBounds()) { m_rings.clear(); m_rings.append(m_bounds); diff --git a/Source/WebCore/rendering/RenderBlock.cpp b/Source/WebCore/rendering/RenderBlock.cpp index 792b809..8fa021f 100644 --- a/Source/WebCore/rendering/RenderBlock.cpp +++ b/Source/WebCore/rendering/RenderBlock.cpp @@ -226,6 +226,9 @@ void RenderBlock::styleWillChange(StyleDifference diff, const RenderStyle* newSt if (cb->isRenderBlock()) toRenderBlock(cb)->removePositionedObjects(this); } + + if (containsFloats() && !isFloating() && !isPositioned() && (newStyle->position() == AbsolutePosition || newStyle->position() == FixedPosition)) + markAllDescendantsWithFloatsForLayout(); } RenderBox::styleWillChange(diff, newStyle); @@ -269,12 +272,33 @@ void RenderBlock::styleDidChange(StyleDifference diff, const RenderStyle* oldSty } // After our style changed, if we lose our ability to propagate floats into next sibling - // blocks, then we need to mark our descendants with floats for layout and clear all floats - // from next sibling blocks that exist in our floating objects list. See bug 56299. + // blocks, then we need to find the top most parent containing that overhanging float and + // then mark its descendants with floats for layout and clear all floats from its next + // sibling blocks that exist in our floating objects list. See bug 56299 and 62875. bool canPropagateFloatIntoSibling = !isFloatingOrPositioned() && !avoidsFloats(); if (diff == StyleDifferenceLayout && s_canPropagateFloatIntoSibling && !canPropagateFloatIntoSibling && hasOverhangingFloats()) { - markAllDescendantsWithFloatsForLayout(); - markSiblingsWithFloatsForLayout(); + RenderBlock* parentBlock = this; + FloatingObjectSet& floatingObjectSet = m_floatingObjects->set(); + FloatingObjectSetIterator end = floatingObjectSet.end(); + + for (RenderObject* curr = parent(); curr && !curr->isRenderView(); curr = curr->parent()) { + if (curr->isRenderBlock()) { + RenderBlock* currBlock = toRenderBlock(curr); + + if (currBlock->hasOverhangingFloats()) { + for (FloatingObjectSetIterator it = floatingObjectSet.begin(); it != end; ++it) { + RenderBox* renderer = (*it)->renderer(); + if (currBlock->hasOverhangingFloat(renderer)) { + parentBlock = currBlock; + break; + } + } + } + } + } + + parentBlock->markAllDescendantsWithFloatsForLayout(); + parentBlock->markSiblingsWithFloatsForLayout(); } } @@ -3738,6 +3762,19 @@ int RenderBlock::addOverhangingFloats(RenderBlock* child, int logicalLeftOffset, return lowestFloatLogicalBottom; } +bool RenderBlock::hasOverhangingFloat(RenderBox* renderer) +{ + if (!m_floatingObjects || hasColumns() || !parent()) + return false; + + FloatingObjectSet& floatingObjectSet = m_floatingObjects->set(); + FloatingObjectSetIterator it = floatingObjectSet.find<RenderBox*, FloatingObjectHashTranslator>(renderer); + if (it == floatingObjectSet.end()) + return false; + + return logicalBottomForFloat(*it) > logicalHeight(); +} + void RenderBlock::addIntrudingFloats(RenderBlock* prev, int logicalLeftOffset, int logicalTopOffset) { // If the parent or previous sibling doesn't have any floats to add, don't bother. diff --git a/Source/WebCore/rendering/RenderBlock.h b/Source/WebCore/rendering/RenderBlock.h index d45ab66..7ca13c6 100644 --- a/Source/WebCore/rendering/RenderBlock.h +++ b/Source/WebCore/rendering/RenderBlock.h @@ -542,6 +542,7 @@ private: virtual bool avoidsFloats() const; bool hasOverhangingFloats() { return parent() && !hasColumns() && containsFloats() && lowestFloatLogicalBottom() > logicalHeight(); } + bool hasOverhangingFloat(RenderBox*); void addIntrudingFloats(RenderBlock* prev, int xoffset, int yoffset); int addOverhangingFloats(RenderBlock* child, int xoffset, int yoffset, bool makeChildPaintOtherFloats); |