summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Source/WebCore/platform/graphics/android/GLWebViewState.cpp9
-rw-r--r--Source/WebCore/platform/graphics/android/GLWebViewState.h4
-rw-r--r--Source/WebCore/platform/graphics/android/rendering/BaseRenderer.cpp2
-rw-r--r--Source/WebCore/platform/graphics/android/rendering/ImageTexture.cpp4
-rw-r--r--Source/WebCore/platform/graphics/android/rendering/ImageTexture.h2
-rw-r--r--Source/WebCore/platform/graphics/android/rendering/Surface.cpp2
-rw-r--r--Source/WebCore/platform/graphics/android/rendering/Surface.h2
-rw-r--r--Source/WebCore/platform/graphics/android/rendering/SurfaceBacking.cpp41
-rw-r--r--Source/WebCore/platform/graphics/android/rendering/SurfaceBacking.h4
-rw-r--r--Source/WebCore/platform/graphics/android/rendering/SurfaceCollectionManager.cpp11
-rw-r--r--Source/WebCore/platform/graphics/android/rendering/SurfaceCollectionManager.h6
-rw-r--r--Source/WebCore/platform/graphics/android/rendering/TileGrid.cpp1
-rw-r--r--Source/WebCore/platform/graphics/android/rendering/TilePainter.h3
-rw-r--r--Source/WebCore/platform/graphics/android/rendering/TileTexture.cpp6
-rw-r--r--Source/WebCore/platform/graphics/android/rendering/TileTexture.h4
-rw-r--r--Source/WebKit/android/jni/WebViewCore.cpp35
-rw-r--r--Source/WebKit/android/jni/WebViewCore.h1
17 files changed, 85 insertions, 52 deletions
diff --git a/Source/WebCore/platform/graphics/android/GLWebViewState.cpp b/Source/WebCore/platform/graphics/android/GLWebViewState.cpp
index 1b0513b..1b35a10 100644
--- a/Source/WebCore/platform/graphics/android/GLWebViewState.cpp
+++ b/Source/WebCore/platform/graphics/android/GLWebViewState.cpp
@@ -70,7 +70,7 @@ GLWebViewState::GLWebViewState()
, m_goingLeft(false)
, m_scale(1)
, m_layersRenderingMode(kAllTextures)
- , m_surfaceCollectionManager(this)
+ , m_surfaceCollectionManager()
{
m_viewport.setEmpty();
@@ -305,9 +305,10 @@ int GLWebViewState::drawGL(IntRect& rect, SkRect& viewport, IntRect* invalRect,
bool shouldDraw)
{
TilesManager* tilesManager = TilesManager::instance();
- tilesManager->getProfiler()->nextFrame(viewport.fLeft, viewport.fTop,
- viewport.fRight, viewport.fBottom,
- scale);
+ if (shouldDraw)
+ tilesManager->getProfiler()->nextFrame(viewport.fLeft, viewport.fTop,
+ viewport.fRight, viewport.fBottom,
+ scale);
tilesManager->incDrawGLCount();
ALOGV("drawGL, rect(%d, %d, %d, %d), viewport(%.2f, %.2f, %.2f, %.2f)",
diff --git a/Source/WebCore/platform/graphics/android/GLWebViewState.h b/Source/WebCore/platform/graphics/android/GLWebViewState.h
index 6d969dd..2b28619 100644
--- a/Source/WebCore/platform/graphics/android/GLWebViewState.h
+++ b/Source/WebCore/platform/graphics/android/GLWebViewState.h
@@ -192,10 +192,6 @@ public:
bool goingDown() { return m_goingDown; }
bool goingLeft() { return m_goingLeft; }
- void setDirection(bool goingDown, bool goingLeft) {
- m_goingDown = goingDown;
- m_goingLeft = goingLeft;
- }
float scale() { return m_scale; }
diff --git a/Source/WebCore/platform/graphics/android/rendering/BaseRenderer.cpp b/Source/WebCore/platform/graphics/android/rendering/BaseRenderer.cpp
index 833aea9..8bb1755 100644
--- a/Source/WebCore/platform/graphics/android/rendering/BaseRenderer.cpp
+++ b/Source/WebCore/platform/graphics/android/rendering/BaseRenderer.cpp
@@ -112,7 +112,7 @@ void BaseRenderer::renderTiledContent(TileRenderInfo& renderInfo)
setupPartialInval(renderInfo, &canvas);
canvas.translate(-renderInfo.x * tileSize.width(), -renderInfo.y * tileSize.height());
canvas.scale(renderInfo.scale, renderInfo.scale);
- renderInfo.tilePainter->paint(renderInfo.baseTile, &canvas);
+ renderInfo.tilePainter->paint(&canvas);
if (renderInfo.baseTile && renderInfo.baseTile->backTexture())
checkForPureColor(renderInfo, &canvas);
else
diff --git a/Source/WebCore/platform/graphics/android/rendering/ImageTexture.cpp b/Source/WebCore/platform/graphics/android/rendering/ImageTexture.cpp
index 9890331..cd43c03 100644
--- a/Source/WebCore/platform/graphics/android/rendering/ImageTexture.cpp
+++ b/Source/WebCore/platform/graphics/android/rendering/ImageTexture.cpp
@@ -215,14 +215,14 @@ float ImageTexture::opacity()
return m_layer->drawOpacity();
}
-bool ImageTexture::paint(Tile* tile, SkCanvas* canvas)
+bool ImageTexture::paint(SkCanvas* canvas)
{
if (!m_picture) {
ALOGV("IT %p COULDNT PAINT, NO PICTURE", this);
return false;
}
- ALOGV("IT %p painting tile %d, %d with picture %p", this, tile->x(), tile->y(), m_picture);
+ ALOGV("IT %p painting with picture %p", this, m_picture);
canvas->drawPicture(*m_picture);
return true;
diff --git a/Source/WebCore/platform/graphics/android/rendering/ImageTexture.h b/Source/WebCore/platform/graphics/android/rendering/ImageTexture.h
index 34430f1..9e1de32 100644
--- a/Source/WebCore/platform/graphics/android/rendering/ImageTexture.h
+++ b/Source/WebCore/platform/graphics/android/rendering/ImageTexture.h
@@ -86,7 +86,7 @@ public:
bool equalsCRC(unsigned crc);
// methods used by TileGrid
- virtual bool paint(Tile* tile, SkCanvas* canvas);
+ virtual bool paint(SkCanvas* canvas);
virtual float opacity();
int nbTextures();
diff --git a/Source/WebCore/platform/graphics/android/rendering/Surface.cpp b/Source/WebCore/platform/graphics/android/rendering/Surface.cpp
index f0d9e58..8f1596d 100644
--- a/Source/WebCore/platform/graphics/android/rendering/Surface.cpp
+++ b/Source/WebCore/platform/graphics/android/rendering/Surface.cpp
@@ -298,7 +298,7 @@ bool Surface::isBase()
return getFirstLayer()->subclassType() == LayerAndroid::BaseLayer;
}
-bool Surface::paint(Tile* tile, SkCanvas* canvas)
+bool Surface::paint(SkCanvas* canvas)
{
if (singleLayer()) {
getFirstLayer()->contentDraw(canvas, Layer::UnmergedLayers);
diff --git a/Source/WebCore/platform/graphics/android/rendering/Surface.h b/Source/WebCore/platform/graphics/android/rendering/Surface.h
index d197d43..0fced47 100644
--- a/Source/WebCore/platform/graphics/android/rendering/Surface.h
+++ b/Source/WebCore/platform/graphics/android/rendering/Surface.h
@@ -63,7 +63,7 @@ public:
bool isBase();
// TilePainter methods
- virtual bool paint(Tile* tile, SkCanvas* canvas);
+ virtual bool paint(SkCanvas* canvas);
virtual float opacity();
virtual Color* background();
diff --git a/Source/WebCore/platform/graphics/android/rendering/SurfaceBacking.cpp b/Source/WebCore/platform/graphics/android/rendering/SurfaceBacking.cpp
index 7c8f570..b8d751c 100644
--- a/Source/WebCore/platform/graphics/android/rendering/SurfaceBacking.cpp
+++ b/Source/WebCore/platform/graphics/android/rendering/SurfaceBacking.cpp
@@ -42,6 +42,7 @@ SurfaceBacking::SurfaceBacking(bool isBaseSurface)
{
m_frontTexture = new TileGrid(isBaseSurface);
m_backTexture = new TileGrid(isBaseSurface);
+ m_lowResTexture = new TileGrid(isBaseSurface);
m_scale = -1;
m_futureScale = -1;
m_zooming = false;
@@ -51,6 +52,7 @@ SurfaceBacking::~SurfaceBacking()
{
delete m_frontTexture;
delete m_backTexture;
+ delete m_lowResTexture;
}
void SurfaceBacking::prepareGL(GLWebViewState* state, bool allowZoom,
@@ -70,6 +72,9 @@ void SurfaceBacking::prepareGL(GLWebViewState* state, bool allowZoom,
m_futureScale = scale;
m_zoomUpdateTime = WTF::currentTime() + SurfaceBacking::s_zoomUpdateDelay;
m_zooming = true;
+
+ // release back texture's TileTextures, so they can be reused immediately
+ m_backTexture->discardTextures();
}
bool useExpandPrefetch = aggressiveRendering;
@@ -77,39 +82,43 @@ void SurfaceBacking::prepareGL(GLWebViewState* state, bool allowZoom,
this, scale, m_scale, m_futureScale, m_zooming,
m_frontTexture, m_backTexture);
- if (!m_zooming) {
- m_frontTexture->prepareGL(state, m_scale,
- prepareArea, unclippedArea, painter, false, useExpandPrefetch);
- if (aggressiveRendering) {
- // prepare the back tiled texture to render content in low res
- float lowResPrefetchScale = m_scale * LOW_RES_PREFETCH_SCALE_MODIFIER;
- m_backTexture->prepareGL(state, lowResPrefetchScale,
- prepareArea, unclippedArea, painter, true, useExpandPrefetch);
- m_backTexture->swapTiles();
- }
- } else if (m_zoomUpdateTime < WTF::currentTime()) {
+ if (m_zooming && (m_zoomUpdateTime < WTF::currentTime())) {
m_backTexture->prepareGL(state, m_futureScale,
- prepareArea, unclippedArea, painter, false, useExpandPrefetch);
+ prepareArea, unclippedArea, painter, false, false);
if (m_backTexture->isReady()) {
// zooming completed, swap the textures and new front tiles
swapTileGrids();
m_frontTexture->swapTiles();
m_backTexture->discardTextures();
+ m_lowResTexture->discardTextures();
m_scale = m_futureScale;
m_zooming = false;
}
}
+
+ if (!m_zooming) {
+ m_frontTexture->prepareGL(state, m_scale,
+ prepareArea, unclippedArea, painter, false, useExpandPrefetch);
+ if (aggressiveRendering) {
+ // prepare low res content
+ float lowResPrefetchScale = m_scale * LOW_RES_PREFETCH_SCALE_MODIFIER;
+ m_lowResTexture->prepareGL(state, lowResPrefetchScale,
+ prepareArea, unclippedArea, painter,
+ true, useExpandPrefetch);
+ m_lowResTexture->swapTiles();
+ }
+ }
}
void SurfaceBacking::drawGL(const IntRect& visibleArea, float opacity,
const TransformationMatrix* transform,
bool aggressiveRendering, const Color* background)
{
- // draw low res prefetch page, if needed
- if (aggressiveRendering && !m_zooming && m_frontTexture->isMissingContent())
- m_backTexture->drawGL(visibleArea, opacity, transform);
+ // draw low res prefetch page if zooming or front texture missing content
+ if (aggressiveRendering && isMissingContent())
+ m_lowResTexture->drawGL(visibleArea, opacity, transform);
m_frontTexture->drawGL(visibleArea, opacity, transform, background);
}
@@ -118,12 +127,14 @@ void SurfaceBacking::markAsDirty(const SkRegion& dirtyArea)
{
m_backTexture->markAsDirty(dirtyArea);
m_frontTexture->markAsDirty(dirtyArea);
+ m_lowResTexture->markAsDirty(dirtyArea);
}
void SurfaceBacking::swapTiles()
{
m_backTexture->swapTiles();
m_frontTexture->swapTiles();
+ m_lowResTexture->swapTiles();
}
void SurfaceBacking::computeTexturesAmount(TexturesResult* result, LayerAndroid* layer)
diff --git a/Source/WebCore/platform/graphics/android/rendering/SurfaceBacking.h b/Source/WebCore/platform/graphics/android/rendering/SurfaceBacking.h
index ec01dbe..bbac9b5 100644
--- a/Source/WebCore/platform/graphics/android/rendering/SurfaceBacking.h
+++ b/Source/WebCore/platform/graphics/android/rendering/SurfaceBacking.h
@@ -61,7 +61,7 @@ public:
bool isMissingContent()
{
- return !m_zooming && m_frontTexture->isMissingContent();
+ return m_zooming || m_frontTexture->isMissingContent();
}
int nbTextures(IntRect& area, float scale)
@@ -80,6 +80,8 @@ private:
TileGrid* m_frontTexture;
TileGrid* m_backTexture;
+ TileGrid* m_lowResTexture;
+
float m_scale;
float m_futureScale;
double m_zoomUpdateTime;
diff --git a/Source/WebCore/platform/graphics/android/rendering/SurfaceCollectionManager.cpp b/Source/WebCore/platform/graphics/android/rendering/SurfaceCollectionManager.cpp
index 8c9cad5..52a8e44 100644
--- a/Source/WebCore/platform/graphics/android/rendering/SurfaceCollectionManager.cpp
+++ b/Source/WebCore/platform/graphics/android/rendering/SurfaceCollectionManager.cpp
@@ -36,9 +36,8 @@
namespace WebCore {
-SurfaceCollectionManager::SurfaceCollectionManager(GLWebViewState* state)
- : m_state(state)
- , m_drawingCollection(0)
+SurfaceCollectionManager::SurfaceCollectionManager()
+ : m_drawingCollection(0)
, m_paintingCollection(0)
, m_queuedCollection(0)
, m_fastSwapMode(false)
@@ -59,8 +58,6 @@ void SurfaceCollectionManager::swap()
// swap can't be called unless painting just finished
ASSERT(m_paintingCollection);
- android::Mutex::Autolock lock(m_paintSwapLock);
-
ALOGV("SWAPPING, D %p, P %p, Q %p",
m_drawingCollection, m_paintingCollection, m_queuedCollection);
@@ -90,8 +87,6 @@ void SurfaceCollectionManager::swap()
// clear all of the content in the three collections held by the collection manager
void SurfaceCollectionManager::clearCollections()
{
- ALOGV("SurfaceCollectionManager %p removing PS from state %p", this, m_state);
-
SkSafeUnref(m_drawingCollection);
m_drawingCollection = 0;
SkSafeUnref(m_paintingCollection);
@@ -109,8 +104,6 @@ bool SurfaceCollectionManager::updateWithSurfaceCollection(SurfaceCollection* ne
// can't have a queued collection unless have a painting collection too
ASSERT(m_paintingCollection || !m_queuedCollection);
- android::Mutex::Autolock lock(m_paintSwapLock);
-
if (!newCollection || brandNew) {
clearCollections();
if (brandNew) {
diff --git a/Source/WebCore/platform/graphics/android/rendering/SurfaceCollectionManager.h b/Source/WebCore/platform/graphics/android/rendering/SurfaceCollectionManager.h
index cc98899..125bf02 100644
--- a/Source/WebCore/platform/graphics/android/rendering/SurfaceCollectionManager.h
+++ b/Source/WebCore/platform/graphics/android/rendering/SurfaceCollectionManager.h
@@ -41,7 +41,7 @@ class SurfaceCollection;
class TEST_EXPORT SurfaceCollectionManager {
public:
- SurfaceCollectionManager(GLWebViewState* state);
+ SurfaceCollectionManager();
~SurfaceCollectionManager();
@@ -58,10 +58,6 @@ private:
void swap();
void clearCollections();
- android::Mutex m_paintSwapLock;
-
- GLWebViewState* m_state;
-
SurfaceCollection* m_drawingCollection;
SurfaceCollection* m_paintingCollection;
SurfaceCollection* m_queuedCollection;
diff --git a/Source/WebCore/platform/graphics/android/rendering/TileGrid.cpp b/Source/WebCore/platform/graphics/android/rendering/TileGrid.cpp
index a58a1d2..85bdf29 100644
--- a/Source/WebCore/platform/graphics/android/rendering/TileGrid.cpp
+++ b/Source/WebCore/platform/graphics/android/rendering/TileGrid.cpp
@@ -341,7 +341,6 @@ void TileGrid::drawMissingRegion(const SkRegion& region, float opacity,
SkRegion::Iterator iterator(region);
const float tileWidth = TilesManager::tileWidth() / m_scale;
const float tileHeight = TilesManager::tileHeight() / m_scale;
- ShaderProgram* shader = TilesManager::instance()->shader();
while (!iterator.done()) {
SkIRect r = iterator.rect();
SkRect rect;
diff --git a/Source/WebCore/platform/graphics/android/rendering/TilePainter.h b/Source/WebCore/platform/graphics/android/rendering/TilePainter.h
index d992aee..53dfadc 100644
--- a/Source/WebCore/platform/graphics/android/rendering/TilePainter.h
+++ b/Source/WebCore/platform/graphics/android/rendering/TilePainter.h
@@ -33,14 +33,13 @@ class SkCanvas;
namespace WebCore {
-class Tile;
class Color;
class TilePainter : public SkRefCnt {
// TODO: investigate webkit threadsafe ref counting
public:
virtual ~TilePainter() { }
- virtual bool paint(Tile* tile, SkCanvas* canvas) = 0;
+ virtual bool paint(SkCanvas* canvas) = 0;
virtual float opacity() { return 1.0; }
enum SurfaceType { Painted, Image };
virtual SurfaceType type() { return Painted; }
diff --git a/Source/WebCore/platform/graphics/android/rendering/TileTexture.cpp b/Source/WebCore/platform/graphics/android/rendering/TileTexture.cpp
index 39effd7..126a7ac 100644
--- a/Source/WebCore/platform/graphics/android/rendering/TileTexture.cpp
+++ b/Source/WebCore/platform/graphics/android/rendering/TileTexture.cpp
@@ -77,15 +77,15 @@ void TileTexture::discardGLTexture()
}
}
-bool TileTexture::acquire(TextureOwner* owner, bool force)
+bool TileTexture::acquire(TextureOwner* owner)
{
if (m_owner == owner)
return true;
- return setOwner(owner, force);
+ return setOwner(owner);
}
-bool TileTexture::setOwner(TextureOwner* owner, bool force)
+bool TileTexture::setOwner(TextureOwner* owner)
{
bool proceed = true;
if (m_owner && m_owner != owner)
diff --git a/Source/WebCore/platform/graphics/android/rendering/TileTexture.h b/Source/WebCore/platform/graphics/android/rendering/TileTexture.h
index 5fe43b0..b008b7d 100644
--- a/Source/WebCore/platform/graphics/android/rendering/TileTexture.h
+++ b/Source/WebCore/platform/graphics/android/rendering/TileTexture.h
@@ -51,11 +51,11 @@ public:
// allows consumer thread to assign ownership of the texture to the tile. It
// returns false if ownership cannot be transferred because the tile is busy
- bool acquire(TextureOwner* owner, bool force = false);
+ bool acquire(TextureOwner* owner);
bool release(TextureOwner* owner);
// set the texture owner if not busy. Return false if busy, true otherwise.
- bool setOwner(TextureOwner* owner, bool force = false);
+ bool setOwner(TextureOwner* owner);
// private member accessor functions
TextureOwner* owner() { return m_owner; } // only used by the consumer thread
diff --git a/Source/WebKit/android/jni/WebViewCore.cpp b/Source/WebKit/android/jni/WebViewCore.cpp
index 7da8103..9f66d7e 100644
--- a/Source/WebKit/android/jni/WebViewCore.cpp
+++ b/Source/WebKit/android/jni/WebViewCore.cpp
@@ -3132,6 +3132,32 @@ void WebViewCore::chromeTakeFocus(FocusDirection direction)
env->CallVoidMethod(javaObject.get(), m_javaGlue->m_chromeTakeFocus, direction);
}
+void WebViewCore::setInitialFocus(const WebCore::PlatformKeyboardEvent& platformEvent)
+{
+ Frame* frame = focusedFrame();
+ Document* document = frame->document();
+ if (document)
+ document->setFocusedNode(0);
+ FocusDirection direction;
+ switch (platformEvent.nativeVirtualKeyCode()) {
+ case AKEYCODE_DPAD_LEFT:
+ direction = FocusDirectionLeft;
+ break;
+ case AKEYCODE_DPAD_RIGHT:
+ direction = FocusDirectionRight;
+ break;
+ case AKEYCODE_DPAD_UP:
+ direction = FocusDirectionUp;
+ break;
+ default:
+ direction = FocusDirectionDown;
+ break;
+ }
+ RefPtr<KeyboardEvent> webkitEvent = KeyboardEvent::create(platformEvent, 0);
+ m_mainFrame->page()->focusController()->setInitialFocus(direction,
+ webkitEvent.get());
+}
+
#if USE(ACCELERATED_COMPOSITING)
GraphicsLayerAndroid* WebViewCore::graphicsRootLayer() const
{
@@ -4401,6 +4427,14 @@ static jboolean Key(JNIEnv* env, jobject obj, jint nativeClass, jint keyCode,
unichar, repeatCount, isDown, isShift, isAlt, isSym));
}
+static void SetInitialFocus(JNIEnv* env, jobject obj, jint nativeClass,
+ jint keyDirection)
+{
+ WebViewCore* viewImpl = reinterpret_cast<WebViewCore*>(nativeClass);
+ viewImpl->setInitialFocus(PlatformKeyboardEvent(keyDirection,
+ 0, 0, false, false, false, false));
+}
+
static void ContentInvalidateAll(JNIEnv* env, jobject obj, jint nativeClass)
{
reinterpret_cast<WebViewCore*>(nativeClass)->contentInvalidateAll();
@@ -5073,6 +5107,7 @@ static JNINativeMethod gJavaWebViewCoreMethods[] = {
(void*) FindAll },
{ "nativeFindNext", "(IZ)I",
(void*) FindNext },
+ { "nativeSetInitialFocus", "(II)V", (void*) SetInitialFocus },
};
int registerWebViewCore(JNIEnv* env)
diff --git a/Source/WebKit/android/jni/WebViewCore.h b/Source/WebKit/android/jni/WebViewCore.h
index 82a65cf..eec98b0 100644
--- a/Source/WebKit/android/jni/WebViewCore.h
+++ b/Source/WebKit/android/jni/WebViewCore.h
@@ -321,6 +321,7 @@ namespace android {
bool key(const WebCore::PlatformKeyboardEvent& event);
bool chromeCanTakeFocus(WebCore::FocusDirection direction);
void chromeTakeFocus(WebCore::FocusDirection direction);
+ void setInitialFocus(const WebCore::PlatformKeyboardEvent& event);
/**
* Handle touch event