diff options
Diffstat (limited to 'Source/WebCore')
8 files changed, 97 insertions, 10 deletions
diff --git a/Source/WebCore/platform/android/RenderThemeAndroid.cpp b/Source/WebCore/platform/android/RenderThemeAndroid.cpp index c6e3bc5..7ef814e 100644 --- a/Source/WebCore/platform/android/RenderThemeAndroid.cpp +++ b/Source/WebCore/platform/android/RenderThemeAndroid.cpp @@ -212,9 +212,12 @@ void RenderThemeAndroid::adjustButtonStyle(CSSStyleSelector*, RenderStyle* style { // Code is taken from RenderThemeSafari.cpp // It makes sure we have enough space for the button text. - const int padding = 8; - style->setPaddingLeft(Length(padding, Fixed)); - style->setPaddingRight(Length(padding, Fixed)); + const int paddingHoriz = 12; + const int paddingVert = 8; + style->setPaddingLeft(Length(paddingHoriz, Fixed)); + style->setPaddingRight(Length(paddingHoriz, Fixed)); + style->setPaddingTop(Length(paddingVert, Fixed)); + style->setPaddingBottom(Length(paddingVert, Fixed)); // Set a min-height so that we can't get smaller than the mini button. style->setMinHeight(Length(15, Fixed)); diff --git a/Source/WebCore/platform/graphics/android/BaseLayerAndroid.cpp b/Source/WebCore/platform/graphics/android/BaseLayerAndroid.cpp index 0ab28d7..547ac39 100644 --- a/Source/WebCore/platform/graphics/android/BaseLayerAndroid.cpp +++ b/Source/WebCore/platform/graphics/android/BaseLayerAndroid.cpp @@ -54,6 +54,12 @@ #endif // DEBUG +// TODO: dynamically determine based on DPI +#define PREFETCH_SCALE_MODIFIER 0.3 +#define PREFETCH_OPACITY 1 +#define PREFETCH_X_DIST 1 +#define PREFETCH_Y_DIST 2 + namespace WebCore { using namespace android; @@ -116,6 +122,49 @@ void BaseLayerAndroid::drawCanvas(SkCanvas* canvas) } #if USE(ACCELERATED_COMPOSITING) + +void BaseLayerAndroid::prefetchBasePicture(SkRect& viewport, float currentScale, + TiledPage* prefetchTiledPage) +{ + SkIRect bounds; + float prefetchScale = currentScale * PREFETCH_SCALE_MODIFIER; + + float invTileWidth = (prefetchScale) + / TilesManager::instance()->tileWidth(); + float invTileHeight = (prefetchScale) + / TilesManager::instance()->tileHeight(); + bool goingDown = m_glWebViewState->goingDown(); + bool goingLeft = m_glWebViewState->goingLeft(); + + + XLOG("fetch rect %f %f %f %f, scale %f", + viewport.fLeft, + viewport.fTop, + viewport.fRight, + viewport.fBottom, + scale); + + bounds.fLeft = static_cast<int>(floorf(viewport.fLeft * invTileWidth)) - PREFETCH_X_DIST; + bounds.fTop = static_cast<int>(floorf(viewport.fTop * invTileHeight)) - PREFETCH_Y_DIST; + bounds.fRight = static_cast<int>(ceilf(viewport.fRight * invTileWidth)) + PREFETCH_X_DIST; + bounds.fBottom = static_cast<int>(ceilf(viewport.fBottom * invTileHeight)) + PREFETCH_Y_DIST; + + XLOG("prefetch rect %d %d %d %d, scale %f, preparing page %p", + bounds.fLeft, bounds.fTop, + bounds.fRight, bounds.fBottom, + scale * PREFETCH_SCALE, + prefetchTiledPage); + + prefetchTiledPage->setScale(prefetchScale); + prefetchTiledPage->updateTileDirtiness(bounds); + prefetchTiledPage->prepare(goingDown, goingLeft, bounds, + TiledPage::ExpandedBounds); + prefetchTiledPage->swapBuffersIfReady(bounds, + prefetchScale, + TiledPage::SwapWhateverIsReady); + prefetchTiledPage->draw(PREFETCH_OPACITY, bounds); +} + bool BaseLayerAndroid::drawBasePictureInGL(SkRect& viewport, float scale, double currentTime, bool* buffersSwappedPtr) { @@ -183,6 +232,13 @@ bool BaseLayerAndroid::drawBasePictureInGL(SkRect& viewport, float scale, bool scrolling = m_scrollState != NotScrolling; bool zooming = ZoomManager::kNoScaleRequest != zoomManager->scaleRequestState(); + // prefetch in the nextTiledPage if unused by zooming (even if not scrolling + // since we want the tiles to be ready before they're needed) + bool usePrefetchPage = !zooming; + nextTiledPage->setIsPrefetchPage(usePrefetchPage); + if (usePrefetchPage) + prefetchBasePicture(viewport, scale, nextTiledPage); + // When we aren't zooming, we should TRY and swap tile buffers if they're // ready. When scrolling, we swap whatever's ready. Otherwise, buffer until // the entire page is ready and then swap. @@ -287,7 +343,6 @@ bool BaseLayerAndroid::drawGL(double currentTime, LayerAndroid* compositedRoot, m_glWebViewState->resetLayersDirtyArea(); } - m_glWebViewState->paintExtras(); m_previousVisible = visibleRect; diff --git a/Source/WebCore/platform/graphics/android/BaseLayerAndroid.h b/Source/WebCore/platform/graphics/android/BaseLayerAndroid.h index a42a372..26fd158 100644 --- a/Source/WebCore/platform/graphics/android/BaseLayerAndroid.h +++ b/Source/WebCore/platform/graphics/android/BaseLayerAndroid.h @@ -66,6 +66,8 @@ public: void swapExtra(BaseLayerAndroid* base) { m_extra.swap(base->m_extra); } private: #if USE(ACCELERATED_COMPOSITING) + void prefetchBasePicture(SkRect& viewport, float currentScale, + TiledPage* prefetchTiledPage); bool drawBasePictureInGL(SkRect& viewport, float scale, double currentTime, bool* buffersSwappedPtr); diff --git a/Source/WebCore/platform/graphics/android/GLWebViewState.cpp b/Source/WebCore/platform/graphics/android/GLWebViewState.cpp index 40a9428..0b2d058 100644 --- a/Source/WebCore/platform/graphics/android/GLWebViewState.cpp +++ b/Source/WebCore/platform/graphics/android/GLWebViewState.cpp @@ -180,8 +180,12 @@ void GLWebViewState::setRings(Vector<IntRect>& rings, bool isPressed) android::Mutex::Autolock lock(m_baseLayerLock); m_displayRings = true; m_rings.setEmpty(); - for (size_t i = 0; i < rings.size(); i++) - m_rings.op(rings.at(i), SkRegion::kUnion_Op); + for (size_t i = 0; i < rings.size(); i++) { + if (i == 0) + m_rings.setRect(rings.at(i)); + else + m_rings.op(rings.at(i), SkRegion::kUnion_Op); + } m_ringsIsPressed = isPressed; } @@ -507,8 +511,6 @@ bool GLWebViewState::drawGL(IntRect& rect, SkRect& viewport, IntRect* invalRect, IntRect& webViewRect, int titleBarHeight, IntRect& clip, float scale, bool* buffersSwappedPtr) { - glFinish(); - TilesManager::instance()->getProfiler()->nextFrame(viewport.fLeft, viewport.fTop, viewport.fRight, @@ -571,6 +573,10 @@ bool GLWebViewState::drawGL(IntRect& rect, SkRect& viewport, IntRect* invalRect, double currentTime = setupDrawing(rect, viewport, webViewRect, titleBarHeight, clip, scale); bool ret = baseLayer->drawGL(currentTime, compositedRoot, rect, viewport, scale, buffersSwappedPtr); + // Reset the clip to make sure we can draw the rings. If this isn't done, the + // current clip will be the clip of whatever layer was last drawn + TilesManager::instance()->shader()->clip(clip); + paintExtras(); glBindBuffer(GL_ARRAY_BUFFER, 0); diff --git a/Source/WebCore/platform/graphics/android/GraphicsContextAndroid.cpp b/Source/WebCore/platform/graphics/android/GraphicsContextAndroid.cpp index e015f5a..86e1f63 100644 --- a/Source/WebCore/platform/graphics/android/GraphicsContextAndroid.cpp +++ b/Source/WebCore/platform/graphics/android/GraphicsContextAndroid.cpp @@ -380,12 +380,13 @@ public: m_state->antiAliasClipPaths.append(clipPath); if (!haveLayerOutstanding) { SkRect bounds = clipPath.getBounds(); - if (m_platformGfxCtx && m_platformGfxCtx->mCanvas) + if (m_platformGfxCtx && m_platformGfxCtx->mCanvas) { m_platformGfxCtx->mCanvas->saveLayerAlpha(&bounds, 255, static_cast<SkCanvas::SaveFlags>(SkCanvas::kHasAlphaLayer_SaveFlag | SkCanvas::kFullColorLayer_SaveFlag | SkCanvas::kClipToLayer_SaveFlag)); - else + m_platformGfxCtx->mCanvas->save(); + } else ASSERT(0); } } @@ -395,6 +396,10 @@ public: // Anti-aliased clipping: // // Refer to PlatformContextSkia.cpp's applyAntiAliasedClipPaths() for more details + + if (m_platformGfxCtx && m_platformGfxCtx->mCanvas) + m_platformGfxCtx->mCanvas->restore(); + SkPaint paint; paint.setXfermodeMode(SkXfermode::kClear_Mode); paint.setAntiAlias(true); diff --git a/Source/WebCore/platform/graphics/android/PaintTileOperation.cpp b/Source/WebCore/platform/graphics/android/PaintTileOperation.cpp index aa3f320..19b49f1 100644 --- a/Source/WebCore/platform/graphics/android/PaintTileOperation.cpp +++ b/Source/WebCore/platform/graphics/android/PaintTileOperation.cpp @@ -81,6 +81,10 @@ int PaintTileOperation::priority() unsigned long long drawDelta = currentDraw - m_tile->drawCount(); int priority = 100000 * (int)std::min(drawDelta, (unsigned long long)1000); + // prioritize the prefetch page, if it exists + if (!m_tile->page() || !m_tile->page()->isPrefetchPage()) + priority += 200000; + // prioritize unpainted tiles, within the same drawCount if (m_tile->frontTexture()) priority += 50000; diff --git a/Source/WebCore/platform/graphics/android/TiledPage.cpp b/Source/WebCore/platform/graphics/android/TiledPage.cpp index ede7d1b..2b8ebcc 100644 --- a/Source/WebCore/platform/graphics/android/TiledPage.cpp +++ b/Source/WebCore/platform/graphics/android/TiledPage.cpp @@ -31,6 +31,8 @@ #include "GLUtils.h" #include "IntRect.h" #include "PaintTileOperation.h" +#include "SkPaint.h" +#include "SkPaintFlagsDrawFilter.h" #include "TilesManager.h" #include <cutils/log.h> @@ -65,6 +67,7 @@ TiledPage::TiledPage(int id, GLWebViewState* state) , m_glWebViewState(state) , m_latestPictureInval(0) , m_prepare(false) + , m_isPrefetchPage(false) { m_baseTiles = new BaseTile[TilesManager::getMaxTextureAllocation() + 1]; #ifdef DEBUG_COUNT @@ -366,9 +369,15 @@ void TiledPage::draw(float transparency, const SkIRect& tileBounds) bool TiledPage::paint(BaseTile* tile, SkCanvas* canvas, unsigned int* pictureUsed) { + // TODO: consider other flags so the pre-rendered tiles aren't so ugly + static SkPaintFlagsDrawFilter prefetchFilter(SkPaint::kAllFlags, 0); + if (!m_glWebViewState) return false; + if (isPrefetchPage()) + canvas->setDrawFilter(&prefetchFilter); + *pictureUsed = m_glWebViewState->paintBaseLayerContent(canvas); return true; } diff --git a/Source/WebCore/platform/graphics/android/TiledPage.h b/Source/WebCore/platform/graphics/android/TiledPage.h index 946421c..c903abc 100644 --- a/Source/WebCore/platform/graphics/android/TiledPage.h +++ b/Source/WebCore/platform/graphics/android/TiledPage.h @@ -98,6 +98,8 @@ public: void updateBaseTileSize(); bool scrollingDown() { return m_scrollingDown; } SkIRect* expandedTileBounds() { return &m_expandedTileBounds; } + bool isPrefetchPage() { return m_isPrefetchPage; } + void setIsPrefetchPage(bool isPrefetch) { m_isPrefetchPage = isPrefetch; } private: void prepareRow(bool goingLeft, int tilesInRow, int firstTileX, int y, const SkIRect& tileBounds); @@ -127,6 +129,7 @@ private: bool m_prepare; bool m_scrollingDown; SkIRect m_expandedTileBounds; + bool m_isPrefetchPage; }; } // namespace WebCore |