diff options
Diffstat (limited to 'Source')
14 files changed, 160 insertions, 176 deletions
diff --git a/Source/WebCore/platform/graphics/android/BaseTileTexture.cpp b/Source/WebCore/platform/graphics/android/BaseTileTexture.cpp index 7e6a57d..7c6fb7a 100644 --- a/Source/WebCore/platform/graphics/android/BaseTileTexture.cpp +++ b/Source/WebCore/platform/graphics/android/BaseTileTexture.cpp @@ -255,6 +255,7 @@ void BaseTileTexture::setOwnTextureTileInfoFromQueue(const TextureTileInfo* info m_ownTextureTileInfo.m_scale = info->m_scale; m_ownTextureTileInfo.m_painter = info->m_painter; m_ownTextureTileInfo.m_picture = info->m_picture; + m_ownTextureTileInfo.m_inverted = TilesManager::instance()->invertedScreen(); } bool BaseTileTexture::readyFor(BaseTile* baseTile) @@ -264,7 +265,8 @@ bool BaseTileTexture::readyFor(BaseTile* baseTile) (info->m_x == baseTile->x()) && (info->m_y == baseTile->y()) && (info->m_scale == baseTile->scale()) && - (info->m_painter == baseTile->painter())) + (info->m_painter == baseTile->painter()) && + (info->m_inverted == TilesManager::instance()->invertedScreen())) return true; XLOG("readyFor return false for tile x, y (%d %d) texId %d ," diff --git a/Source/WebCore/platform/graphics/android/BaseTileTexture.h b/Source/WebCore/platform/graphics/android/BaseTileTexture.h index b21659f..bc66195 100644 --- a/Source/WebCore/platform/graphics/android/BaseTileTexture.h +++ b/Source/WebCore/platform/graphics/android/BaseTileTexture.h @@ -48,6 +48,7 @@ public: , m_texture(0) , m_painter(0) , m_picture(0) + , m_inverted(false) { } int m_x; @@ -57,6 +58,7 @@ public: TextureInfo* m_texture; TilePainter* m_painter; unsigned int m_picture; + bool m_inverted; }; // While in the queue, the BaseTile can be re-used, the updated bitmap diff --git a/Source/WebCore/platform/graphics/android/FontAndroid.cpp b/Source/WebCore/platform/graphics/android/FontAndroid.cpp index 332e571..b56e37c 100644 --- a/Source/WebCore/platform/graphics/android/FontAndroid.cpp +++ b/Source/WebCore/platform/graphics/android/FontAndroid.cpp @@ -427,7 +427,6 @@ public: private: void setupFontForScriptRun(); - void setupComplexFont(const char* fontName, const FontPlatformData& platformData); HB_FontRec* allocHarfbuzzFont(); void deleteGlyphArrays(); void createGlyphArrays(int); @@ -466,7 +465,6 @@ private: // each word break we accumulate error. This is the // number of pixels that we are behind so far. unsigned m_letterSpacing; // pixels to be added after each glyph. - FontPlatformData* m_complexPlatformData; }; @@ -481,7 +479,6 @@ TextRunWalker::TextRunWalker(const TextRun& run, unsigned startingX, const Font* , m_padPerWordBreak(0) , m_padError(0) , m_letterSpacing(0) - , m_complexPlatformData(0) { // Do not use |run| inside this constructor. Use |m_run| instead. @@ -510,7 +507,6 @@ TextRunWalker::~TextRunWalker() fastFree(m_item.font); deleteGlyphArrays(); delete[] m_item.log_clusters; - delete m_complexPlatformData; } bool TextRunWalker::isWordBreak(unsigned index, bool isRTL) @@ -624,48 +620,15 @@ void TextRunWalker::setWordAndLetterSpacing(int wordSpacingAdjustment, setLetterSpacingAdjustment(letterSpacingAdjustment); } -void TextRunWalker::setupComplexFont(const char* filename, - const FontPlatformData& platformData) -{ - delete m_complexPlatformData; - - SkTypeface* typeface = SkTypeface::CreateFromFile(filename); - m_complexPlatformData = new FontPlatformData(platformData, typeface); - SkSafeUnref(typeface); - m_item.face = m_complexPlatformData->harfbuzzFace(); - m_item.font->userData = m_complexPlatformData; -} - void TextRunWalker::setupFontForScriptRun() { - const FontData* fontData = m_font->glyphDataForCharacter(m_run[0], false).fontData; + const FontData* fontData = m_font->glyphDataForCharacter( + m_item.string[m_item.item.pos], false).fontData; const FontPlatformData& platformData = fontData->fontDataForCharacter(' ')->platformData(); - - if (m_item.item.script == HB_Script_Devanagari) { - setupComplexFont("/system/fonts/Lohit_Hindi.ttf", platformData); - } else if (m_item.item.script == HB_Script_Thai) { - setupComplexFont("/system/fonts/DroidSansThai.ttf", platformData); - } else if (m_item.item.script == HB_Script_Arabic) { - setupComplexFont("/system/fonts/DroidNaskh-Regular.ttf", platformData); - } else if (m_item.item.script == HB_Script_Hebrew) { - switch (platformData.typeface()->style()) { - case SkTypeface::kBold: - case SkTypeface::kBoldItalic: - setupComplexFont("/system/fonts/DroidSansHebrew-Bold.ttf", platformData); - break; - case SkTypeface::kNormal: - case SkTypeface::kItalic: - default: - setupComplexFont("/system/fonts/DroidSansHebrew-Regular.ttf", platformData); - break; - } - } else { - // HB_Script_Common; includes Ethiopic - m_item.face = platformData.harfbuzzFace(); - void* opaquePlatformData = const_cast<FontPlatformData*>(&platformData); - m_item.font->userData = opaquePlatformData; - } + m_item.face = platformData.harfbuzzFace(); + void* opaquePlatformData = const_cast<FontPlatformData*>(&platformData); + m_item.font->userData = opaquePlatformData; } HB_FontRec* TextRunWalker::allocHarfbuzzFont() diff --git a/Source/WebCore/platform/graphics/android/FontPlatformData.h b/Source/WebCore/platform/graphics/android/FontPlatformData.h index 56ce6e9..3313aca 100644 --- a/Source/WebCore/platform/graphics/android/FontPlatformData.h +++ b/Source/WebCore/platform/graphics/android/FontPlatformData.h @@ -55,7 +55,6 @@ public: FontPlatformData(SkTypeface*, float textSize, bool fakeBold, bool fakeItalic); FontPlatformData(const FontPlatformData& src, float textSize); FontPlatformData(float size, bool syntheticBold, bool syntheticOblique); - FontPlatformData(const FontPlatformData& src, SkTypeface* typeface); ~FontPlatformData(); @@ -88,7 +87,6 @@ public: #endif HB_FaceRec_* harfbuzzFace() const; - SkTypeface* typeface() const { return mTypeface; } private: class RefCountedHarfbuzzFace : public RefCounted<RefCountedHarfbuzzFace> { diff --git a/Source/WebCore/platform/graphics/android/FontPlatformDataAndroid.cpp b/Source/WebCore/platform/graphics/android/FontPlatformDataAndroid.cpp index 1c3c5d9..337a94d 100644 --- a/Source/WebCore/platform/graphics/android/FontPlatformDataAndroid.cpp +++ b/Source/WebCore/platform/graphics/android/FontPlatformDataAndroid.cpp @@ -127,17 +127,6 @@ FontPlatformData::FontPlatformData(float size, bool bold, bool oblique) trace(5); } -FontPlatformData::FontPlatformData(const FontPlatformData& src, SkTypeface* tf) - : mTypeface(tf), mTextSize(src.mTextSize), mFakeBold(src.mFakeBold), mFakeItalic(src.mFakeItalic) -{ - if (hashTableDeletedFontValue() != mTypeface) { - SkSafeRef(mTypeface); - } - - inc_count(); - trace(6); -} - FontPlatformData::~FontPlatformData() { dec_count(); diff --git a/Source/WebCore/platform/graphics/android/GLWebViewState.cpp b/Source/WebCore/platform/graphics/android/GLWebViewState.cpp index 9978327..53d32f7 100644 --- a/Source/WebCore/platform/graphics/android/GLWebViewState.cpp +++ b/Source/WebCore/platform/graphics/android/GLWebViewState.cpp @@ -83,6 +83,8 @@ GLWebViewState::GLWebViewState(android::Mutex* buttonMutex) , m_focusRingTexture(-1) , m_goingDown(true) , m_goingLeft(false) + , m_expandedTileBoundsX(0) + , m_expandedTileBoundsY(0) { m_viewport.setEmpty(); m_previousViewport.setEmpty(); @@ -426,12 +428,11 @@ void GLWebViewState::swapPages() int GLWebViewState::baseContentWidth() { - return m_currentBaseLayer ? m_currentBaseLayer->getWidth() : 0; - + return m_currentBaseLayer ? m_currentBaseLayer->content()->width() : 0; } int GLWebViewState::baseContentHeight() { - return m_currentBaseLayer ? m_currentBaseLayer->getHeight() : 0; + return m_currentBaseLayer ? m_currentBaseLayer->content()->height() : 0; } void GLWebViewState::setViewport(SkRect& viewport, float scale) @@ -455,8 +456,8 @@ void GLWebViewState::setViewport(SkRect& viewport, float scale) static_cast<int>(ceilf(viewport.fRight * invTileContentWidth)), static_cast<int>(ceilf(viewport.fBottom * invTileContentHeight))); - int maxTextureCount = (m_viewportTileBounds.width() + TilesManager::instance()->expandedTileBoundsX() * 2 + 1) * - (m_viewportTileBounds.height() + TilesManager::instance()->expandedTileBoundsY() * 2 + 1) * 2; + int maxTextureCount = (m_viewportTileBounds.width() + TILE_PREFETCH_DISTANCE * 2 + 1) * + (m_viewportTileBounds.height() + TILE_PREFETCH_DISTANCE * 2 + 1) * 2; TilesManager::instance()->setMaxTextureCount(maxTextureCount); m_tiledPageA->updateBaseTileSize(); m_tiledPageB->updateBaseTileSize(); @@ -532,6 +533,13 @@ bool GLWebViewState::drawGL(IntRect& rect, SkRect& viewport, IntRect* invalRect, return false; } + float viewWidth = (viewport.fRight - viewport.fLeft) * TILE_PREFETCH_RATIO; + float viewHeight = (viewport.fBottom - viewport.fTop) * TILE_PREFETCH_RATIO; + bool useHorzPrefetch = viewWidth < baseContentWidth(); + bool useVertPrefetch = viewHeight < baseContentHeight(); + m_expandedTileBoundsX = (useHorzPrefetch) ? TILE_PREFETCH_DISTANCE : 0; + m_expandedTileBoundsY = (useVertPrefetch) ? TILE_PREFETCH_DISTANCE : 0; + XLOG("drawGL, rect(%d, %d, %d, %d), viewport(%.2f, %.2f, %.2f, %.2f)", rect.x(), rect.y(), rect.width(), rect.height(), viewport.fLeft, viewport.fTop, viewport.fRight, viewport.fBottom); @@ -554,6 +562,9 @@ bool GLWebViewState::drawGL(IntRect& rect, SkRect& viewport, IntRect* invalRect, // the BaseTiles' texture. TilesManager::instance()->transferQueue()->updateDirtyBaseTiles(); + // gather the textures we can use + TilesManager::instance()->gatherLayerTextures(); + if (compositedRoot != m_previouslyUsedRoot) TilesManager::instance()->swapLayersTextures(m_previouslyUsedRoot, compositedRoot); @@ -562,11 +573,21 @@ bool GLWebViewState::drawGL(IntRect& rect, SkRect& viewport, IntRect* invalRect, SkSafeRef(compositedRoot); SkSafeUnref(m_previouslyUsedRoot); m_previouslyUsedRoot = compositedRoot; + + ret |= TilesManager::instance()->invertedScreenSwitch(); + if (ret) { - if (m_frameworkInval.isEmpty()) { - // ret==true && empty inval region means we've inval'd everything, - // but don't have new content. Keep redrawing full view (0,0,0,0) - // until tile generation catches up and we swap pages. + // ret==true && empty inval region means we've inval'd everything, + // but don't have new content. Keep redrawing full view (0,0,0,0) + // until tile generation catches up and we swap pages. + bool fullScreenInval = m_frameworkInval.isEmpty(); + + if (TilesManager::instance()->invertedScreenSwitch()) { + fullScreenInval = true; + TilesManager::instance()->setInvertedScreenSwitch(false); + } + + if (fullScreenInval) { invalRect->setX(0); invalRect->setY(0); invalRect->setWidth(0); diff --git a/Source/WebCore/platform/graphics/android/GLWebViewState.h b/Source/WebCore/platform/graphics/android/GLWebViewState.h index 82b6f12..34af317 100644 --- a/Source/WebCore/platform/graphics/android/GLWebViewState.h +++ b/Source/WebCore/platform/graphics/android/GLWebViewState.h @@ -42,6 +42,12 @@ // #define MEASURES_PERF #define MAX_MEASURES_PERF 2000 +// Prefetch and render 2 tiles ahead of the scroll +#define TILE_PREFETCH_DISTANCE 0 + +// ratio of content to view required for prefetching to enable +#define TILE_PREFETCH_RATIO 1.2 + namespace WebCore { class BaseLayerAndroid; @@ -248,6 +254,9 @@ public: m_goingLeft = goingLeft; } + int expandedTileBoundsX() { return m_expandedTileBoundsX; } + int expandedTileBoundsY() { return m_expandedTileBoundsY; } + private: void inval(const IntRect& rect); // caller must hold m_baseLayerLock void invalRegion(const SkRegion& region); @@ -308,6 +317,9 @@ private: bool m_goingDown; bool m_goingLeft; + + int m_expandedTileBoundsX; + int m_expandedTileBoundsY; }; } // namespace WebCore diff --git a/Source/WebCore/platform/graphics/android/PaintTileOperation.cpp b/Source/WebCore/platform/graphics/android/PaintTileOperation.cpp index 064ffb9..3aac918 100644 --- a/Source/WebCore/platform/graphics/android/PaintTileOperation.cpp +++ b/Source/WebCore/platform/graphics/android/PaintTileOperation.cpp @@ -76,8 +76,12 @@ int PaintTileOperation::priority() if (!m_tile || m_tile->usedLevel() < 0) return -1; + // for now, use a constant value for layers, + // lower than the base layer tiles (as layers + // will always be on top of the base surface) if (m_tile->isLayerTile()) - return 25; // for now, use a constant value. + return -2; + bool goingDown = m_tile->page()->scrollingDown(); SkIRect *rect = m_tile->page()->expandedTileBounds(); diff --git a/Source/WebCore/platform/graphics/android/TiledPage.cpp b/Source/WebCore/platform/graphics/android/TiledPage.cpp index a8be501..a69f9d1 100644 --- a/Source/WebCore/platform/graphics/android/TiledPage.cpp +++ b/Source/WebCore/platform/graphics/android/TiledPage.cpp @@ -245,6 +245,7 @@ void TiledPage::prepare(bool goingDown, bool goingLeft, const SkIRect& tileBound if (!m_glWebViewState) return; + TilesManager::instance()->gatherTextures(); // update the tiles distance from the viewport updateTileState(tileBounds); m_prepare = true; @@ -258,25 +259,21 @@ void TiledPage::prepare(bool goingDown, bool goingLeft, const SkIRect& tileBound int lastTileX = tileBounds.fRight - 1; int lastTileY = tileBounds.fBottom - 1; - const int baseContentHeight = m_glWebViewState->baseContentHeight(); - const int baseContentWidth = m_glWebViewState->baseContentWidth(); - // Expand number of tiles to allow tiles outside of viewport to be prepared for // smoother scrolling. int nTilesToPrepare = nbTilesWidth * nbTilesHeight; int nMaxTilesPerPage = m_baseTileSize / 2; - int expandX = TilesManager::instance()->expandedTileBoundsX(); - int expandY = TilesManager::instance()->expandedTileBoundsY(); - if (nTilesToPrepare + (nbTilesHeight * expandX * 2) <= nMaxTilesPerPage) { - firstTileX -= expandX; - lastTileX += expandX; - nbTilesWidth += expandX * 2; - } - if (nTilesToPrepare + (nbTilesWidth * expandY * 2) <= nMaxTilesPerPage) { - firstTileY -= expandY; - lastTileY += expandY; - nbTilesHeight += expandY * 2; - } + int expandX = m_glWebViewState->expandedTileBoundsX(); + int expandY = m_glWebViewState->expandedTileBoundsY(); + + firstTileX -= expandX; + lastTileX += expandX; + nbTilesWidth += expandX * 2; + + firstTileY -= expandY; + lastTileY += expandY; + nbTilesHeight += expandY * 2; + m_expandedTileBounds.fLeft = firstTileX; m_expandedTileBounds.fTop = firstTileY; m_expandedTileBounds.fRight = lastTileX; @@ -317,10 +314,10 @@ void TiledPage::draw(float transparency, const SkIRect& tileBounds) const float tileHeight = TilesManager::tileHeight() * m_invScale; SkIRect actualTileBounds = tileBounds; - actualTileBounds.fTop -= TilesManager::instance()->expandedTileBoundsY(); - actualTileBounds.fBottom += TilesManager::instance()->expandedTileBoundsY(); - actualTileBounds.fLeft -= TilesManager::instance()->expandedTileBoundsX(); - actualTileBounds.fRight += TilesManager::instance()->expandedTileBoundsX(); + actualTileBounds.fTop -= m_glWebViewState->expandedTileBoundsY(); + actualTileBounds.fBottom += m_glWebViewState->expandedTileBoundsY(); + actualTileBounds.fLeft -= m_glWebViewState->expandedTileBoundsX(); + actualTileBounds.fRight += m_glWebViewState->expandedTileBoundsX(); for (int j = 0; j < m_baseTileSize; j++) { BaseTile& tile = m_baseTiles[j]; diff --git a/Source/WebCore/platform/graphics/android/TilesManager.cpp b/Source/WebCore/platform/graphics/android/TilesManager.cpp index c634be0..d7c7952 100644 --- a/Source/WebCore/platform/graphics/android/TilesManager.cpp +++ b/Source/WebCore/platform/graphics/android/TilesManager.cpp @@ -58,19 +58,8 @@ #endif // DEBUG -// Important: We need at least twice as much textures as is needed to cover -// one viewport, otherwise the allocation may stall. -// We need n textures for one TiledPage, and another n textures for the -// second page used when scaling. -// In our case, we use 300x300 textures. On the tablet, this equates to -// at least 24 textures. That is consuming almost 50MB GPU memory. -// 24*300*300*4(bpp)*2(pages)*3(triple buffering in Surface Texture) = 49.4MB -// In order to avoid OOM issue, we limit the bounds number to 0 for now. -// TODO: We should either dynamically change the outer bound by detecting the -// HW limit or save further in the GPU memory consumption. -#define EXPANDED_TILE_BOUNDS_X 0 -#define EXPANDED_TILE_BOUNDS_Y 0 -#define MAX_TEXTURE_ALLOCATION 3+(6+EXPANDED_TILE_BOUNDS_X*2)*(4+EXPANDED_TILE_BOUNDS_Y*2)*2 +// Number of tiles for base layer +#define MAX_TEXTURE_ALLOCATION 51 #define TILE_WIDTH 256 #define TILE_HEIGHT 256 #define LAYER_TILE_WIDTH 256 @@ -101,14 +90,17 @@ int TilesManager::getMaxTextureAllocation() TilesManager::TilesManager() : m_layersMemoryUsage(0) , m_maxTextureCount(0) - , m_expandedTileBounds(false) , m_generatorReady(false) , m_showVisualIndicator(false) , m_invertedScreen(false) + , m_invertedScreenSwitch(false) , m_drawRegistrationCount(0) { XLOG("TilesManager ctor"); m_textures.reserveCapacity(MAX_TEXTURE_ALLOCATION); + m_availableTextures.reserveCapacity(MAX_TEXTURE_ALLOCATION); + m_tilesTextures.reserveCapacity(LAYER_TILES); + m_availableTilesTextures.reserveCapacity(LAYER_TILES); m_pixmapsGenerationThread = new TexturesGenerator(); m_pixmapsGenerationThread->run("TexturesGenerator"); } @@ -212,6 +204,18 @@ void TilesManager::addPaintedSurface(PaintedSurface* surface) m_paintedSurfaces.append(surface); } +void TilesManager::gatherTextures() +{ + android::Mutex::Autolock lock(m_texturesLock); + m_availableTextures = m_textures; +} + +void TilesManager::gatherLayerTextures() +{ + android::Mutex::Autolock lock(m_texturesLock); + m_availableTilesTextures = m_tilesTextures; +} + BaseTileTexture* TilesManager::getAvailableTexture(BaseTile* owner) { android::Mutex::Autolock lock(m_texturesLock); @@ -221,26 +225,36 @@ BaseTileTexture* TilesManager::getAvailableTexture(BaseTile* owner) owner->texture()->setUsedLevel(0); XLOG("same owner (%d, %d), getAvailableTexture(%x) => texture %x", owner->x(), owner->y(), owner, owner->texture()); + if (owner->isLayerTile()) + m_availableTilesTextures.remove(m_availableTilesTextures.find(owner->texture())); + else + m_availableTextures.remove(m_availableTextures.find(owner->texture())); return owner->texture(); } if (owner->isLayerTile()) { - unsigned int max = m_tilesTextures.size(); + BaseTileTexture* layerTexture = 0; + unsigned int max = m_availableTilesTextures.size(); for (unsigned int i = 0; i < max; i++) { - BaseTileTexture* texture = m_tilesTextures[i]; + BaseTileTexture* texture = m_availableTilesTextures[i]; if (texture->owner() && texture->owner()->isRepaintPending()) continue; if (!texture->owner() && texture->acquire(owner)) { - return texture; + layerTexture = texture; + break; } if (texture->usedLevel() != 0 && texture->acquire(owner)) { - return texture; + layerTexture = texture; + break; } if (texture->scale() != owner->scale() && texture->acquire(owner)) { - return texture; + layerTexture = texture; + break; } } - return 0; + if (layerTexture) + m_availableTilesTextures.remove(m_availableTilesTextures.find(layerTexture)); + return layerTexture; } // The heuristic for selecting a texture is as follows: @@ -251,9 +265,9 @@ BaseTileTexture* TilesManager::getAvailableTexture(BaseTile* owner) BaseTileTexture* farthestTexture = 0; int farthestTextureLevel = 0; unsigned int lowestDrawCount = ~0; //maximum uint - const unsigned int max = m_textures.size(); + const unsigned int max = m_availableTextures.size(); for (unsigned int i = 0; i < max; i++) { - BaseTileTexture* texture = m_textures[i]; + BaseTileTexture* texture = m_availableTextures[i]; if (texture->usedLevel() == -1) { // found an unused texture, grab it farthestTexture = texture; @@ -276,6 +290,7 @@ BaseTileTexture* TilesManager::getAvailableTexture(BaseTile* owner) XLOG("farthest texture, getAvailableTexture(%x) => texture %x (level %d, drawCount %d)", owner, farthestTexture, farthestTextureLevel, lowestDrawCount); farthestTexture->setUsedLevel(0); + m_availableTextures.remove(m_availableTextures.find(farthestTexture)); return farthestTexture; } @@ -342,14 +357,6 @@ float TilesManager::layerTileHeight() return LAYER_TILE_HEIGHT; } -int TilesManager::expandedTileBoundsX() { - return m_expandedTileBounds ? EXPANDED_TILE_BOUNDS_X : 0; -} - -int TilesManager::expandedTileBoundsY() { - return m_expandedTileBounds ? EXPANDED_TILE_BOUNDS_Y : 0; -} - void TilesManager::registerGLWebViewState(GLWebViewState* state) { m_glWebViewStateMap.set(state, m_drawRegistrationCount); diff --git a/Source/WebCore/platform/graphics/android/TilesManager.h b/Source/WebCore/platform/graphics/android/TilesManager.h index 8f0ac7f..a383a2e 100644 --- a/Source/WebCore/platform/graphics/android/TilesManager.h +++ b/Source/WebCore/platform/graphics/android/TilesManager.h @@ -83,6 +83,8 @@ public: TransferQueue* transferQueue() { return &m_queue; } VideoLayerManager* videoLayerManager() { return &m_videoLayerManager; } + void gatherLayerTextures(); + void gatherTextures(); BaseTileTexture* getAvailableTexture(BaseTile* owner); void markGeneratorAsReady() @@ -106,18 +108,11 @@ public: static float tileHeight(); static float layerTileWidth(); static float layerTileHeight(); - int expandedTileBoundsX(); - int expandedTileBoundsY(); void registerGLWebViewState(GLWebViewState* state); void unregisterGLWebViewState(GLWebViewState* state); void allocateTiles(); - void setExpandedTileBounds(bool enabled) - { - m_expandedTileBounds = enabled; - } - bool getShowVisualIndicator() { return m_showVisualIndicator; @@ -148,11 +143,23 @@ public: return m_invertedScreen; } + bool invertedScreenSwitch() + { + return m_invertedScreenSwitch; + } + void setInvertedScreen(bool invert) { + if (m_invertedScreen != invert) + m_invertedScreenSwitch = true; m_invertedScreen = invert; } + void setInvertedScreenSwitch(bool invertedSwitch) + { + m_invertedScreenSwitch = invertedSwitch; + } + void setInvertedScreenContrast(float contrast) { m_shader.setContrast(contrast); @@ -169,18 +176,22 @@ private: } Vector<BaseTileTexture*> m_textures; + Vector<BaseTileTexture*> m_availableTextures; + Vector<BaseTileTexture*> m_tilesTextures; + Vector<BaseTileTexture*> m_availableTilesTextures; + Vector<PaintedSurface*> m_paintedSurfaces; unsigned int m_layersMemoryUsage; int m_maxTextureCount; - bool m_expandedTileBounds; bool m_generatorReady; bool m_showVisualIndicator; bool m_invertedScreen; + bool m_invertedScreenSwitch; sp<TexturesGenerator> m_pixmapsGenerationThread; diff --git a/Source/WebCore/platform/graphics/android/TransferQueue.cpp b/Source/WebCore/platform/graphics/android/TransferQueue.cpp index 1a377f2..8b4b596 100644 --- a/Source/WebCore/platform/graphics/android/TransferQueue.cpp +++ b/Source/WebCore/platform/graphics/android/TransferQueue.cpp @@ -297,50 +297,38 @@ void TransferQueue::updateQueueWithBitmap(const TileRenderInfo* renderInfo, renderInfo->x, renderInfo->y); return; } - // Dequeue the Surface Texture. - sp<ANativeWindow> ANW = m_ANW; - if (!ANW.get()) { + + // a) Dequeue the Surface Texture and write into the buffer + if (!m_ANW.get()) { XLOG("ERROR: ANW is null"); return; } - ANativeWindowBuffer* anb; - - int status = ANW->dequeueBuffer(ANW.get(), &anb); - GLUtils::checkSurfaceTextureError("dequeueBuffer", status); - // a) Update surface texture - sp<android::GraphicBuffer> buf(new android::GraphicBuffer(anb, false)); - status |= ANW->lockBuffer(ANW.get(), buf->getNativeBuffer()); // Mutex Lock - GLUtils::checkSurfaceTextureError("lockBuffer", status); - - // Fill the buffer with the content of the bitmap - uint8_t* img = 0; - status |= buf->lock(GRALLOC_USAGE_SW_WRITE_OFTEN, (void**)(&img)); - GLUtils::checkSurfaceTextureError("lock", status); - - if (status == NO_ERROR) { - int row, col; - int bpp = 4; // Now we only deal with RGBA8888 format. - int width = TilesManager::instance()->tileWidth(); - int height = TilesManager::instance()->tileHeight(); - if (!x && !y && bitmap.width() == width && bitmap.height() == height) { - bitmap.lockPixels(); - uint8_t* bitmapOrigin = static_cast<uint8_t*>(bitmap.getPixels()); - // Copied line by line since we need to handle the offsets and stride. - for (row = 0 ; row < bitmap.height(); row ++) { - uint8_t* dst = &(img[(buf->getStride() * (row + x) + y) * bpp]); - uint8_t* src = &(bitmapOrigin[bitmap.width() * row * bpp]); - memcpy(dst, src, bpp * bitmap.width()); - } - bitmap.unlockPixels(); - } else { - // TODO: implement the partial invalidate here! - XLOG("ERROR: don't expect to get here yet before we support partial inval"); + + ANativeWindow_Buffer buffer; + if (ANativeWindow_lock(m_ANW.get(), &buffer, 0)) + return; + + uint8_t* img = (uint8_t*)buffer.bits; + int row, col; + int bpp = 4; // Now we only deal with RGBA8888 format. + int width = TilesManager::instance()->tileWidth(); + int height = TilesManager::instance()->tileHeight(); + if (!x && !y && bitmap.width() == width && bitmap.height() == height) { + bitmap.lockPixels(); + uint8_t* bitmapOrigin = static_cast<uint8_t*>(bitmap.getPixels()); + // Copied line by line since we need to handle the offsets and stride. + for (row = 0 ; row < bitmap.height(); row ++) { + uint8_t* dst = &(img[(buffer.stride * (row + x) + y) * bpp]); + uint8_t* src = &(bitmapOrigin[bitmap.width() * row * bpp]); + memcpy(dst, src, bpp * bitmap.width()); } + bitmap.unlockPixels(); + } else { + // TODO: implement the partial invalidate here! + XLOG("ERROR: don't expect to get here yet before we support partial inval"); } - buf->unlock(); - status = ANW->queueBuffer(ANW.get(), buf->getNativeBuffer()); - GLUtils::checkSurfaceTextureError("queueBuffer", status); + ANativeWindow_unlockAndPost(m_ANW.get()); // b) After update the Surface Texture, now udpate the transfer queue info. addItemInTransferQueue(renderInfo); diff --git a/Source/WebKit/android/jni/WebCoreFrameBridge.cpp b/Source/WebKit/android/jni/WebCoreFrameBridge.cpp index afc251b..5fbe0a1 100644 --- a/Source/WebKit/android/jni/WebCoreFrameBridge.cpp +++ b/Source/WebKit/android/jni/WebCoreFrameBridge.cpp @@ -843,12 +843,6 @@ WebFrame::canHandleRequest(const WebCore::ResourceRequest& request) if (equalIgnoringCase(request.httpMethod(), "POST")) return true; const WebCore::KURL& requestUrl = request.url(); - bool isUserGesture = UserGestureIndicator::processingUserGesture(); - if (!mUserInitiatedAction && !isUserGesture && - (requestUrl.protocolIs("http") || requestUrl.protocolIs("https") || - requestUrl.protocolIs("file") || requestUrl.protocolIs("about") || - WebCore::protocolIsJavaScript(requestUrl.string()))) - return true; const WTF::String& url = requestUrl.string(); // Empty urls should not be sent to java if (url.isEmpty()) diff --git a/Source/WebKit/android/nav/WebView.cpp b/Source/WebKit/android/nav/WebView.cpp index c1cb95c..4b18b62 100644 --- a/Source/WebKit/android/nav/WebView.cpp +++ b/Source/WebKit/android/nav/WebView.cpp @@ -2517,7 +2517,7 @@ static void dumpToFile(const char text[], void* file) { } #endif -static void nativeSetProperty(JNIEnv *env, jobject obj, jstring jkey, jstring jvalue) +static bool nativeSetProperty(JNIEnv *env, jobject obj, jstring jkey, jstring jvalue) { WTF::String key = jstringToWtfString(env, jkey); WTF::String value = jstringToWtfString(env, jvalue); @@ -2526,11 +2526,14 @@ static void nativeSetProperty(JNIEnv *env, jobject obj, jstring jkey, jstring jv TilesManager::instance()->setInvertedScreen(true); else TilesManager::instance()->setInvertedScreen(false); + return true; } if (key == "inverted_contrast") { float contrast = value.toFloat(); TilesManager::instance()->setInvertedScreenContrast(contrast); + return true; } + return false; } static jstring nativeGetProperty(JNIEnv *env, jobject obj, jstring key) @@ -2608,11 +2611,6 @@ static bool nativeScrollLayer(JNIEnv* env, jobject obj, jint layerId, jint x, return false; } -static void nativeSetExpandedTileBounds(JNIEnv*, jobject, jboolean enabled) -{ - TilesManager::instance()->setExpandedTileBounds(enabled); -} - static void nativeUseHardwareAccelSkia(JNIEnv*, jobject, jboolean enabled) { BaseRenderer::setCurrentRendererType(enabled ? BaseRenderer::Ganesh : BaseRenderer::Raster); @@ -2827,13 +2825,11 @@ static JNINativeMethod gJavaWebViewMethods[] = { (void*) nativeScrollableLayer }, { "nativeScrollLayer", "(III)Z", (void*) nativeScrollLayer }, - { "nativeSetExpandedTileBounds", "(Z)V", - (void*) nativeSetExpandedTileBounds }, { "nativeUseHardwareAccelSkia", "(Z)V", (void*) nativeUseHardwareAccelSkia }, { "nativeGetBackgroundColor", "()I", (void*) nativeGetBackgroundColor }, - { "nativeSetProperty", "(Ljava/lang/String;Ljava/lang/String;)V", + { "nativeSetProperty", "(Ljava/lang/String;Ljava/lang/String;)Z", (void*) nativeSetProperty }, { "nativeGetProperty", "(Ljava/lang/String;)Ljava/lang/String;", (void*) nativeGetProperty }, |