summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Source/WebCore/Android.mk1
-rw-r--r--Source/WebCore/platform/graphics/android/BaseTile.cpp8
-rw-r--r--Source/WebCore/platform/graphics/android/BaseTile.h1
-rw-r--r--Source/WebCore/platform/graphics/android/BaseTileTexture.cpp24
-rw-r--r--Source/WebCore/platform/graphics/android/BaseTileTexture.h9
-rw-r--r--Source/WebCore/platform/graphics/android/GLExtras.cpp12
-rw-r--r--Source/WebCore/platform/graphics/android/GLWebViewState.cpp10
-rw-r--r--Source/WebCore/platform/graphics/android/GraphicsLayerAndroid.cpp1
-rw-r--r--Source/WebCore/platform/graphics/android/ImageBufferAndroid.cpp6
-rw-r--r--Source/WebCore/platform/graphics/android/ImageTexture.cpp28
-rw-r--r--Source/WebCore/platform/graphics/android/ImageTexture.h9
-rw-r--r--Source/WebCore/platform/graphics/android/ImagesManager.cpp129
-rw-r--r--Source/WebCore/platform/graphics/android/ImagesManager.h62
-rw-r--r--Source/WebCore/platform/graphics/android/LayerAndroid.cpp30
-rw-r--r--Source/WebCore/platform/graphics/android/MediaTexture.cpp3
-rw-r--r--Source/WebCore/platform/graphics/android/PaintedSurface.cpp16
-rw-r--r--Source/WebCore/platform/graphics/android/PaintedSurface.h14
-rw-r--r--Source/WebCore/platform/graphics/android/TilesManager.cpp46
-rw-r--r--Source/WebCore/platform/graphics/android/TilesManager.h7
-rw-r--r--Source/WebCore/platform/graphics/android/TransferQueue.cpp7
-rw-r--r--Source/WebCore/platform/graphics/android/android_graphics.cpp6
-rw-r--r--Source/WebCore/rendering/RenderBlock.cpp45
-rw-r--r--Source/WebCore/rendering/RenderBlock.h1
-rw-r--r--Source/WebKit/android/WebCoreSupport/FrameLoaderClientAndroid.cpp9
-rw-r--r--Source/WebKit/android/jni/ViewStateSerializer.cpp3
-rw-r--r--Source/WebKit/android/jni/WebCoreFrameBridge.cpp30
-rw-r--r--Source/WebKit/android/jni/WebViewCore.cpp18
-rw-r--r--Source/WebKit/android/jni/WebViewCore.h2
-rw-r--r--Source/WebKit/android/nav/CacheBuilder.cpp2
-rw-r--r--Source/WebKit/android/nav/CachedNode.cpp15
-rw-r--r--Source/WebKit/android/nav/CachedNode.h4
-rw-r--r--Source/WebKit/android/nav/WebView.cpp49
32 files changed, 397 insertions, 210 deletions
diff --git a/Source/WebCore/Android.mk b/Source/WebCore/Android.mk
index 7d08cc7..a516f48 100644
--- a/Source/WebCore/Android.mk
+++ b/Source/WebCore/Android.mk
@@ -656,6 +656,7 @@ LOCAL_SRC_FILES := $(LOCAL_SRC_FILES) \
platform/graphics/android/ImageAndroid.cpp \
platform/graphics/android/ImageBufferAndroid.cpp \
platform/graphics/android/ImageSourceAndroid.cpp \
+ platform/graphics/android/ImagesManager.cpp \
platform/graphics/android/ImageTexture.cpp \
platform/graphics/android/Layer.cpp \
platform/graphics/android/LayerAndroid.cpp \
diff --git a/Source/WebCore/platform/graphics/android/BaseTile.cpp b/Source/WebCore/platform/graphics/android/BaseTile.cpp
index b38c590..350001a 100644
--- a/Source/WebCore/platform/graphics/android/BaseTile.cpp
+++ b/Source/WebCore/platform/graphics/android/BaseTile.cpp
@@ -535,6 +535,14 @@ void BaseTile::backTextureTransfer() {
}
}
+void BaseTile::backTextureTransferFail() {
+ // transfer failed for some reason, mark dirty so it will (repaint and) be
+ // retransferred.
+ android::AutoMutex lock(m_atomicSync);
+ m_state = Unpainted;
+ // whether validatePaint is called before or after, it won't do anything
+}
+
void BaseTile::validatePaint() {
// ONLY CALL while m_atomicSync is locked (at the end of paintBitmap())
diff --git a/Source/WebCore/platform/graphics/android/BaseTile.h b/Source/WebCore/platform/graphics/android/BaseTile.h
index 27fffc6..cabf5f1 100644
--- a/Source/WebCore/platform/graphics/android/BaseTile.h
+++ b/Source/WebCore/platform/graphics/android/BaseTile.h
@@ -129,6 +129,7 @@ public:
void discardTextures();
bool swapTexturesIfNeeded();
void backTextureTransfer();
+ void backTextureTransferFail();
void setGLWebViewState(GLWebViewState* state) { m_glWebViewState = state; }
diff --git a/Source/WebCore/platform/graphics/android/BaseTileTexture.cpp b/Source/WebCore/platform/graphics/android/BaseTileTexture.cpp
index cedad99..5b7acdb 100644
--- a/Source/WebCore/platform/graphics/android/BaseTileTexture.cpp
+++ b/Source/WebCore/platform/graphics/android/BaseTileTexture.cpp
@@ -56,8 +56,6 @@ BaseTileTexture::BaseTileTexture(uint32_t w, uint32_t h)
: DoubleBufferedTexture(eglGetCurrentContext(),
TilesManager::instance()->getSharedTextureMode())
, m_owner(0)
- , m_delayedReleaseOwner(0)
- , m_delayedRelease(false)
, m_busy(false)
{
m_size.set(w, h);
@@ -137,13 +135,6 @@ void BaseTileTexture::setNotBusy()
{
android::Mutex::Autolock lock(m_busyLock);
m_busy = false;
- if (m_delayedRelease) {
- if (m_owner == m_delayedReleaseOwner)
- m_owner = 0;
-
- m_delayedRelease = false;
- m_delayedReleaseOwner = 0;
- }
m_busyCond.signal();
}
@@ -170,13 +161,8 @@ void BaseTileTexture::producerUpdate(TextureInfo* textureInfo, const SkBitmap& b
bool BaseTileTexture::acquire(TextureOwner* owner, bool force)
{
- if (m_owner == owner) {
- if (m_delayedRelease) {
- m_delayedRelease = false;
- m_delayedReleaseOwner = 0;
- }
+ if (m_owner == owner)
return true;
- }
return setOwner(owner, force);
}
@@ -219,17 +205,13 @@ bool BaseTileTexture::release(TextureOwner* owner)
if (m_owner != owner)
return false;
- if (!m_busy) {
- m_owner = 0;
- } else {
- m_delayedRelease = true;
- m_delayedReleaseOwner = owner;
- }
+ m_owner = 0;
return true;
}
void BaseTileTexture::releaseAndRemoveFromTile()
{
+ // NOTE: only call on UI thread, so m_owner won't be changing
if (m_owner) {
// clear both Tile->Texture and Texture->Tile links
m_owner->removeTexture(this);
diff --git a/Source/WebCore/platform/graphics/android/BaseTileTexture.h b/Source/WebCore/platform/graphics/android/BaseTileTexture.h
index 6a9ce43..cd8e78b 100644
--- a/Source/WebCore/platform/graphics/android/BaseTileTexture.h
+++ b/Source/WebCore/platform/graphics/android/BaseTileTexture.h
@@ -91,7 +91,6 @@ public:
// private member accessor functions
TextureOwner* owner() { return m_owner; } // only used by the consumer thread
- TextureOwner* delayedReleaseOwner() { return m_delayedReleaseOwner; }
bool busy();
void setNotBusy();
@@ -120,13 +119,9 @@ private:
SkSize m_size;
SkBitmap::Config m_config;
- TextureOwner* m_owner;
- // When trying to release a texture, we may delay this if the texture is
- // currently used (busy being painted). We use the following two variables
- // to do so in setNotBusy()
- TextureOwner* m_delayedReleaseOwner;
- bool m_delayedRelease;
+ // BaseTile owning the texture, only modified by UI thread
+ TextureOwner* m_owner;
// This values signals that the texture is currently in use by the consumer.
// This allows us to prevent the owner of the texture from changing while the
diff --git a/Source/WebCore/platform/graphics/android/GLExtras.cpp b/Source/WebCore/platform/graphics/android/GLExtras.cpp
index 540ca16..c6cb7f3 100644
--- a/Source/WebCore/platform/graphics/android/GLExtras.cpp
+++ b/Source/WebCore/platform/graphics/android/GLExtras.cpp
@@ -202,15 +202,8 @@ void GLExtras::drawFindOnPage(SkRect& viewport)
void GLExtras::drawGL(IntRect& webViewRect, SkRect& viewport, int titleBarHeight)
{
if (m_drawExtra) {
- // Update the clip. We want to use the screen clip
- FloatRect glclip;
- glclip.setX(webViewRect.x());
- glclip.setY(webViewRect.y() + titleBarHeight);
- glclip.setWidth(webViewRect.width());
- glclip.setHeight(webViewRect.height());
- XLOG("Setting clip [%fx%f, %f, %f]", glclip.x(), glclip.y(),
- glclip.width(), glclip.height());
- TilesManager::instance()->shader()->clip(glclip);
+ // TODO: Support clipping
+ glDisable(GL_SCISSOR_TEST);
if (m_drawExtra == m_ring)
drawCursorRings();
else if (m_drawExtra == m_findOnPage)
@@ -218,5 +211,6 @@ void GLExtras::drawGL(IntRect& webViewRect, SkRect& viewport, int titleBarHeight
else
XLOGC("m_drawExtra %p is unknown! (cursor: %p, find: %p",
m_drawExtra, m_ring, m_findOnPage);
+ glEnable(GL_SCISSOR_TEST);
}
}
diff --git a/Source/WebCore/platform/graphics/android/GLWebViewState.cpp b/Source/WebCore/platform/graphics/android/GLWebViewState.cpp
index 113ccde..bf392578 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"
@@ -445,6 +446,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);
CRASH();
@@ -459,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);
@@ -528,7 +534,7 @@ bool GLWebViewState::drawGL(IntRect& rect, SkRect& viewport, IntRect* invalRect,
SkSafeUnref(baseLayer);
#ifdef DEBUG
TilesManager::instance()->getTilesTracker()->showTrackTextures();
- TilesManager::instance()->showImages();
+ ImagesManager::instance()->showImages();
#endif
return ret;
}
diff --git a/Source/WebCore/platform/graphics/android/GraphicsLayerAndroid.cpp b/Source/WebCore/platform/graphics/android/GraphicsLayerAndroid.cpp
index eadac6b..89f96d8 100644
--- a/Source/WebCore/platform/graphics/android/GraphicsLayerAndroid.cpp
+++ b/Source/WebCore/platform/graphics/android/GraphicsLayerAndroid.cpp
@@ -24,6 +24,7 @@
#include "FloatRect.h"
#include "GraphicsContext.h"
#include "Image.h"
+#include "ImagesManager.h"
#include "Layer.h"
#include "Length.h"
#include "MediaLayer.h"
diff --git a/Source/WebCore/platform/graphics/android/ImageBufferAndroid.cpp b/Source/WebCore/platform/graphics/android/ImageBufferAndroid.cpp
index bbde998..691fbca 100644
--- a/Source/WebCore/platform/graphics/android/ImageBufferAndroid.cpp
+++ b/Source/WebCore/platform/graphics/android/ImageBufferAndroid.cpp
@@ -85,11 +85,9 @@ PassRefPtr<Image> ImageBuffer::copyImage() const
SkDevice* device = canvas->getDevice();
const SkBitmap& orig = device->accessBitmap(false);
- if (!PlatformBridge::canSatisfyMemoryAllocation(orig.getSize()))
- return 0;
-
SkBitmap copy;
- orig.copyTo(&copy, orig.config());
+ if (PlatformBridge::canSatisfyMemoryAllocation(orig.getSize()))
+ orig.copyTo(&copy, orig.config());
SkBitmapRef* ref = new SkBitmapRef(copy);
RefPtr<Image> image = BitmapImage::create(ref, 0);
diff --git a/Source/WebCore/platform/graphics/android/ImageTexture.cpp b/Source/WebCore/platform/graphics/android/ImageTexture.cpp
index 7e71740..96f7713 100644
--- a/Source/WebCore/platform/graphics/android/ImageTexture.cpp
+++ b/Source/WebCore/platform/graphics/android/ImageTexture.cpp
@@ -26,15 +26,19 @@
#include "config.h"
#include "ImageTexture.h"
+#include "ImagesManager.h"
#include "SkDevice.h"
#include "TilesManager.h"
-#ifdef DEBUG
-
#include <cutils/log.h>
#include <wtf/CurrentTime.h>
#include <wtf/text/CString.h>
+#undef XLOGC
+#define XLOGC(...) android_printLog(ANDROID_LOG_DEBUG, "ImageTexture", __VA_ARGS__)
+
+#ifdef DEBUG
+
#undef XLOG
#define XLOG(...) android_printLog(ANDROID_LOG_DEBUG, "ImageTexture", __VA_ARGS__)
@@ -84,7 +88,15 @@ ImageTexture::~ImageTexture()
delete m_image;
}
-void ImageTexture::prepare()
+void ImageTexture::prepareGL()
+{
+ if (m_textureId)
+ return;
+
+ ImagesManager::instance()->scheduleTextureUpload(this);
+}
+
+void ImageTexture::uploadGLTexture()
{
if (m_textureId)
return;
@@ -93,7 +105,7 @@ void ImageTexture::prepare()
GLUtils::createTextureWithBitmap(m_textureId, *m_image);
}
-void ImageTexture::draw(LayerAndroid* layer)
+void ImageTexture::drawGL(LayerAndroid* layer)
{
if (!layer)
return;
@@ -112,6 +124,11 @@ void ImageTexture::draw(LayerAndroid* layer)
layer->drawOpacity(), true);
}
+void ImageTexture::drawCanvas(SkCanvas* canvas, SkRect& rect)
+{
+ canvas->drawBitmapRect(*m_image, 0, rect);
+}
+
void ImageTexture::release()
{
if (m_refCount >= 1)
@@ -122,7 +139,8 @@ void ImageTexture::release()
void ImageTexture::deleteTexture()
{
- glDeleteTextures(1, &m_textureId);
+ if (m_textureId)
+ glDeleteTextures(1, &m_textureId);
}
} // namespace WebCore
diff --git a/Source/WebCore/platform/graphics/android/ImageTexture.h b/Source/WebCore/platform/graphics/android/ImageTexture.h
index c2ea77c..7f35f06 100644
--- a/Source/WebCore/platform/graphics/android/ImageTexture.h
+++ b/Source/WebCore/platform/graphics/android/ImageTexture.h
@@ -63,9 +63,10 @@ public:
ImageTexture(SkBitmapRef* img);
virtual ~ImageTexture();
- void prepare();
- void draw(LayerAndroid* painter);
- void deleteTexture();
+ void prepareGL();
+ void uploadGLTexture();
+ void drawGL(LayerAndroid* painter);
+ void drawCanvas(SkCanvas*, SkRect&);
void retain() { m_refCount++; }
void release();
unsigned int refCount() { return m_refCount; }
@@ -74,6 +75,8 @@ public:
private:
+ void deleteTexture();
+
SkBitmapRef* m_imageRef;
SkBitmap* m_image;
GLuint m_textureId;
diff --git a/Source/WebCore/platform/graphics/android/ImagesManager.cpp b/Source/WebCore/platform/graphics/android/ImagesManager.cpp
new file mode 100644
index 0000000..21f9fe9
--- /dev/null
+++ b/Source/WebCore/platform/graphics/android/ImagesManager.cpp
@@ -0,0 +1,129 @@
+/*
+ * Copyright 2011, The Android Open Source Project
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "ImagesManager.h"
+
+#include "ImageTexture.h"
+
+#include <cutils/log.h>
+#include <wtf/CurrentTime.h>
+#include <wtf/text/CString.h>
+
+#undef XLOGC
+#define XLOGC(...) android_printLog(ANDROID_LOG_DEBUG, "ImagesManager", __VA_ARGS__)
+
+#ifdef DEBUG
+
+#undef XLOG
+#define XLOG(...) android_printLog(ANDROID_LOG_DEBUG, "ImagesManager", __VA_ARGS__)
+
+#else
+
+#undef XLOG
+#define XLOG(...)
+
+#endif // DEBUG
+
+namespace WebCore {
+
+ImagesManager* ImagesManager::instance()
+{
+ if (!gInstance)
+ gInstance = new ImagesManager();
+
+ return gInstance;
+}
+
+ImagesManager* ImagesManager::gInstance = 0;
+
+void ImagesManager::addImage(SkBitmapRef* imgRef)
+{
+ if (!imgRef)
+ return;
+
+ android::Mutex::Autolock lock(m_imagesLock);
+ if (!m_images.contains(imgRef))
+ m_images.set(imgRef, new ImageTexture(imgRef));
+}
+
+void ImagesManager::removeImage(SkBitmapRef* imgRef)
+{
+ android::Mutex::Autolock lock(m_imagesLock);
+ if (!m_images.contains(imgRef))
+ return;
+
+ ImageTexture* image = m_images.get(imgRef);
+ image->release();
+
+ if (!image->refCount()) {
+ m_images.remove(imgRef);
+ delete image;
+ }
+}
+
+void ImagesManager::showImages()
+{
+ XLOGC("We have %d images", m_images.size());
+ HashMap<SkBitmapRef*, ImageTexture*>::iterator end = m_images.end();
+ int i = 0;
+ for (HashMap<SkBitmapRef*, ImageTexture*>::iterator it = m_images.begin(); it != end; ++it) {
+ XLOGC("Image %x (%d/%d) has %d references", it->first, i,
+ m_images.size(), it->second->refCount());
+ i++;
+ }
+}
+
+ImageTexture* ImagesManager::getTextureForImage(SkBitmapRef* img, bool retain)
+{
+ android::Mutex::Autolock lock(m_imagesLock);
+ ImageTexture* image = m_images.get(img);
+ if (retain && image)
+ image->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
new file mode 100644
index 0000000..2fcb9fd
--- /dev/null
+++ b/Source/WebCore/platform/graphics/android/ImagesManager.h
@@ -0,0 +1,62 @@
+/*
+ * Copyright 2011, The Android Open Source Project
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef ImagesManager_h
+#define ImagesManager_h
+
+#include "HashMap.h"
+#include "SkBitmap.h"
+#include "SkBitmapRef.h"
+#include "SkRefCnt.h"
+#include "Vector.h"
+
+namespace WebCore {
+
+class ImageTexture;
+
+class ImagesManager {
+public:
+ static ImagesManager* instance();
+
+ void addImage(SkBitmapRef* img);
+ void removeImage(SkBitmapRef* img);
+ ImageTexture* getTextureForImage(SkBitmapRef* img, bool retain = true);
+ void showImages();
+ void scheduleTextureUpload(ImageTexture* texture);
+ bool uploadTextures();
+
+private:
+ ImagesManager() {}
+
+ static ImagesManager* gInstance;
+
+ android::Mutex m_imagesLock;
+ HashMap<SkBitmapRef*, ImageTexture*> m_images;
+ Vector<ImageTexture*> m_imagesToUpload;
+};
+
+} // namespace WebCore
+
+#endif // ImagesManager
diff --git a/Source/WebCore/platform/graphics/android/LayerAndroid.cpp b/Source/WebCore/platform/graphics/android/LayerAndroid.cpp
index 91c44c6..4a0e2bb 100644
--- a/Source/WebCore/platform/graphics/android/LayerAndroid.cpp
+++ b/Source/WebCore/platform/graphics/android/LayerAndroid.cpp
@@ -7,6 +7,7 @@
#include "ClassTracker.h"
#include "DrawExtra.h"
#include "GLUtils.h"
+#include "ImagesManager.h"
#include "MediaLayer.h"
#include "PaintedSurface.h"
#include "ParseCanvas.h"
@@ -16,6 +17,7 @@
#include "SkPaint.h"
#include "SkPicture.h"
#include "TilesManager.h"
+
#include <wtf/CurrentTime.h>
#include <math.h>
@@ -102,7 +104,7 @@ LayerAndroid::LayerAndroid(const LayerAndroid& layer) : Layer(layer),
m_isFixed = layer.m_isFixed;
m_imageRef = layer.m_imageRef;
if (m_imageRef)
- TilesManager::instance()->addImage(m_imageRef);
+ ImagesManager::instance()->addImage(m_imageRef);
m_renderLayerPos = layer.m_renderLayerPos;
m_transform = layer.m_transform;
m_backfaceVisibility = layer.m_backfaceVisibility;
@@ -177,7 +179,7 @@ LayerAndroid::LayerAndroid(SkPicture* picture) : Layer(),
LayerAndroid::~LayerAndroid()
{
if (m_imageTexture)
- TilesManager::instance()->removeImage(m_imageTexture->imageRef());
+ ImagesManager::instance()->removeImage(m_imageTexture->imageRef());
delete m_extra;
SkSafeUnref(m_recordingPicture);
m_animations.clear();
@@ -667,7 +669,7 @@ void LayerAndroid::setContentsImage(SkBitmapRef* img)
if (!img)
return;
- TilesManager::instance()->addImage(img);
+ ImagesManager::instance()->addImage(img);
}
bool LayerAndroid::needsTexture()
@@ -766,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++)
@@ -776,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
@@ -814,7 +821,7 @@ void LayerAndroid::createTexture()
if (m_imageRef) {
if (!m_imageTexture) {
- m_imageTexture = TilesManager::instance()->getTextureForImage(m_imageRef);
+ m_imageTexture = ImagesManager::instance()->getTextureForImage(m_imageRef);
m_dirtyRegion.setEmpty();
}
if (m_texture) {
@@ -876,7 +883,7 @@ void LayerAndroid::prepare(GLWebViewState* glWebViewState)
m_texture->prepare(glWebViewState);
if (m_imageTexture)
- m_imageTexture->prepare();
+ m_imageTexture->prepareGL();
}
bool LayerAndroid::drawGL(GLWebViewState* glWebViewState, SkMatrix& matrix)
@@ -891,7 +898,7 @@ bool LayerAndroid::drawGL(GLWebViewState* glWebViewState, SkMatrix& matrix)
askScreenUpdate |= m_texture->draw();
if (m_imageTexture)
- m_imageTexture->draw(this);
+ m_imageTexture->drawGL(this);
// When the layer is dirty, the UI thread should be notified to redraw.
askScreenUpdate |= drawChildrenGL(glWebViewState, matrix);
@@ -977,6 +984,17 @@ void LayerAndroid::onDraw(SkCanvas* canvas, SkScalar opacity)
if (canvasOpacity < 255)
canvas->setDrawFilter(new OpacityDrawFilter(canvasOpacity));
+ if (m_imageRef) {
+ if (!m_imageTexture) {
+ m_imageTexture = ImagesManager::instance()->getTextureForImage(m_imageRef);
+ m_dirtyRegion.setEmpty();
+ }
+ if (m_imageTexture) {
+ SkRect dest;
+ dest.set(0, 0, getSize().width(), getSize().height());
+ m_imageTexture->drawCanvas(canvas, dest);
+ }
+ }
contentDraw(canvas);
}
diff --git a/Source/WebCore/platform/graphics/android/MediaTexture.cpp b/Source/WebCore/platform/graphics/android/MediaTexture.cpp
index 98dca22..3b215ee 100644
--- a/Source/WebCore/platform/graphics/android/MediaTexture.cpp
+++ b/Source/WebCore/platform/graphics/android/MediaTexture.cpp
@@ -70,7 +70,8 @@ MediaTexture::MediaTexture(jobject webViewRef) : android::LightRefBase<MediaText
MediaTexture::~MediaTexture()
{
- deleteTexture(m_contentTexture);
+ if (m_contentTexture)
+ deleteTexture(m_contentTexture, true);
for (unsigned int i = 0; i < m_videoTextures.size(); i++) {
deleteTexture(m_videoTextures[i], true);
}
diff --git a/Source/WebCore/platform/graphics/android/PaintedSurface.cpp b/Source/WebCore/platform/graphics/android/PaintedSurface.cpp
index 1eb51c7..d48c116 100644
--- a/Source/WebCore/platform/graphics/android/PaintedSurface.cpp
+++ b/Source/WebCore/platform/graphics/android/PaintedSurface.cpp
@@ -53,6 +53,22 @@
namespace WebCore {
+PaintedSurface::PaintedSurface(LayerAndroid* layer)
+ : m_layer(layer)
+ , m_tiledTexture(0)
+ , m_scale(0)
+ , m_pictureUsed(0)
+{
+ TilesManager::instance()->addPaintedSurface(this);
+ SkSafeRef(m_layer);
+#ifdef DEBUG_COUNT
+ ClassTracker::instance()->increment("PaintedSurface");
+#endif
+ m_tiledTexture = new TiledTexture(this);
+ if (layer && layer->picture())
+ m_updateManager.updatePicture(layer->picture());
+}
+
PaintedSurface::~PaintedSurface()
{
XLOG("dtor of %x m_layer: %x", this, m_layer);
diff --git a/Source/WebCore/platform/graphics/android/PaintedSurface.h b/Source/WebCore/platform/graphics/android/PaintedSurface.h
index cda5960..5df76db 100644
--- a/Source/WebCore/platform/graphics/android/PaintedSurface.h
+++ b/Source/WebCore/platform/graphics/android/PaintedSurface.h
@@ -47,19 +47,7 @@ class UpdateManager;
class PaintedSurface : public SkRefCnt {
public:
- PaintedSurface(LayerAndroid* layer)
- : m_layer(layer)
- , m_tiledTexture(0)
- , m_scale(0)
- , m_pictureUsed(0)
- {
- TilesManager::instance()->addPaintedSurface(this);
- SkSafeRef(m_layer);
-#ifdef DEBUG_COUNT
- ClassTracker::instance()->increment("PaintedSurface");
-#endif
- m_tiledTexture = new TiledTexture(this);
- }
+ PaintedSurface(LayerAndroid* layer);
virtual ~PaintedSurface();
// PaintedSurface methods
diff --git a/Source/WebCore/platform/graphics/android/TilesManager.cpp b/Source/WebCore/platform/graphics/android/TilesManager.cpp
index 2d0cc7f..74cc764 100644
--- a/Source/WebCore/platform/graphics/android/TilesManager.cpp
+++ b/Source/WebCore/platform/graphics/android/TilesManager.cpp
@@ -429,52 +429,6 @@ void TilesManager::unregisterGLWebViewState(GLWebViewState* state)
transferQueue()->discardQueue();
}
-void TilesManager::addImage(SkBitmapRef* imgRef)
-{
- if (!imgRef)
- return;
-
- android::Mutex::Autolock lock(m_imagesLock);
- if (!m_images.contains(imgRef))
- m_images.set(imgRef, new ImageTexture(imgRef));
-}
-
-void TilesManager::removeImage(SkBitmapRef* imgRef)
-{
- android::Mutex::Autolock lock(m_imagesLock);
- if (!m_images.contains(imgRef))
- return;
-
- ImageTexture* image = m_images.get(imgRef);
- image->release();
-
- if (!image->refCount()) {
- m_images.remove(imgRef);
- delete image;
- }
-}
-
-void TilesManager::showImages()
-{
- XLOGC("We have %d images", m_images.size());
- HashMap<SkBitmapRef*, ImageTexture*>::iterator end = m_images.end();
- int i = 0;
- for (HashMap<SkBitmapRef*, ImageTexture*>::iterator it = m_images.begin(); it != end; ++it) {
- XLOGC("Image %x (%d/%d) has %d references", it->first, i,
- m_images.size(), it->second->refCount());
- i++;
- }
-}
-
-ImageTexture* TilesManager::getTextureForImage(SkBitmapRef* img, bool retain)
-{
- android::Mutex::Autolock lock(m_imagesLock);
- ImageTexture* image = m_images.get(img);
- if (retain && image)
- image->retain();
- return image;
-}
-
TilesManager* TilesManager::instance()
{
if (!gInstance) {
diff --git a/Source/WebCore/platform/graphics/android/TilesManager.h b/Source/WebCore/platform/graphics/android/TilesManager.h
index b7d6aa6..4daecff 100644
--- a/Source/WebCore/platform/graphics/android/TilesManager.h
+++ b/Source/WebCore/platform/graphics/android/TilesManager.h
@@ -179,10 +179,6 @@ public:
{
return m_drawGLCount;
}
- void addImage(SkBitmapRef* img);
- void removeImage(SkBitmapRef* img);
- ImageTexture* getTextureForImage(SkBitmapRef* img, bool retain = true);
- void showImages();
private:
TilesManager();
@@ -215,7 +211,6 @@ private:
android::Mutex m_texturesLock;
android::Mutex m_generatorLock;
- android::Mutex m_imagesLock;
android::Condition m_generatorReadyCond;
static TilesManager* gInstance;
@@ -228,8 +223,6 @@ private:
TilesProfiler m_profiler;
TilesTracker m_tilesTracker;
unsigned long long m_drawGLCount;
-
- HashMap<SkBitmapRef*, ImageTexture*> m_images;
};
} // namespace WebCore
diff --git a/Source/WebCore/platform/graphics/android/TransferQueue.cpp b/Source/WebCore/platform/graphics/android/TransferQueue.cpp
index a9d6b9a..3fc1b93 100644
--- a/Source/WebCore/platform/graphics/android/TransferQueue.cpp
+++ b/Source/WebCore/platform/graphics/android/TransferQueue.cpp
@@ -361,11 +361,8 @@ void TransferQueue::updateQueueWithBitmap(const TileRenderInfo* renderInfo,
// failed placing bitmap in queue, discard tile's texture so it will be
// re-enqueued (and repainted)
BaseTile* tile = renderInfo->baseTile;
- if (tile) {
- BaseTileTexture* texture = tile->backTexture();
- if (texture)
- texture->releaseAndRemoveFromTile();
- }
+ if (tile)
+ tile->backTextureTransferFail();
}
}
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);
diff --git a/Source/WebKit/android/WebCoreSupport/FrameLoaderClientAndroid.cpp b/Source/WebKit/android/WebCoreSupport/FrameLoaderClientAndroid.cpp
index 3134a44..0be31eb 100644
--- a/Source/WebKit/android/WebCoreSupport/FrameLoaderClientAndroid.cpp
+++ b/Source/WebKit/android/WebCoreSupport/FrameLoaderClientAndroid.cpp
@@ -919,9 +919,13 @@ void FrameLoaderClientAndroid::transitionToCommittedFromCachedFrame(WebCore::Cac
#ifdef ANDROID_META_SUPPORT
platformData->restoreMetadata(m_frame->settings());
#endif
+
+#if ENABLE(ANDROID_OVERFLOW_SCROLL)
+#else
WebViewCore* webViewCore = WebViewCore::getWebViewCore(m_frame->view());
webViewCore->clearContent();
+#endif
m_webFrame->transitionToCommitted(m_frame);
}
@@ -956,7 +960,12 @@ void FrameLoaderClientAndroid::transitionToCommittedForNewPage() {
// Create a new WebFrameView for the new FrameView
WebFrameView* newFrameView = new WebFrameView(m_frame->view(), webViewCore);
+
+#if ENABLE(ANDROID_OVERFLOW_SCROLL)
+#else
webViewCore->clearContent();
+#endif
+
newFrameView->setLocation(bounds.x(), bounds.y());
newFrameView->setSize(bounds.width(), bounds.height());
newFrameView->setVisibleSize(visBounds.width(), visBounds.height());
diff --git a/Source/WebKit/android/jni/ViewStateSerializer.cpp b/Source/WebKit/android/jni/ViewStateSerializer.cpp
index c896637..93f4375 100644
--- a/Source/WebKit/android/jni/ViewStateSerializer.cpp
+++ b/Source/WebKit/android/jni/ViewStateSerializer.cpp
@@ -27,6 +27,7 @@
#include "BaseLayerAndroid.h"
#include "CreateJavaOutputStreamAdaptor.h"
+#include "ImagesManager.h"
#include "Layer.h"
#include "LayerAndroid.h"
#include "PictureSet.h"
@@ -302,7 +303,7 @@ void serializeLayer(LayerAndroid* layer, SkWStream* stream)
SkFlattenableWriteBuffer buffer(1024);
buffer.setFlags(SkFlattenableWriteBuffer::kCrossProcess_Flag);
ImageTexture* imagetexture =
- TilesManager::instance()->getTextureForImage(layer->m_imageRef, false);
+ ImagesManager::instance()->getTextureForImage(layer->m_imageRef, false);
if (imagetexture && imagetexture->bitmap())
imagetexture->bitmap()->flatten(buffer);
stream->write32(buffer.size());
diff --git a/Source/WebKit/android/jni/WebCoreFrameBridge.cpp b/Source/WebKit/android/jni/WebCoreFrameBridge.cpp
index 7f791ea..bb28d28 100644
--- a/Source/WebKit/android/jni/WebCoreFrameBridge.cpp
+++ b/Source/WebKit/android/jni/WebCoreFrameBridge.cpp
@@ -983,7 +983,7 @@ WebFrame::didReceiveAuthenticationChallenge(WebUrlLoaderClient* client, const st
}
void
-WebFrame::reportSslCertError(WebUrlLoaderClient* client, int cert_error, const std::string& cert, const std::string& url)
+WebFrame::reportSslCertError(WebUrlLoaderClient* client, int error, const std::string& cert, const std::string& url)
{
#ifdef ANDROID_INSTRUMENT
TimeCounterAuto counter(TimeCounter::JavaCallbackTimeCounter);
@@ -994,16 +994,14 @@ WebFrame::reportSslCertError(WebUrlLoaderClient* client, int cert_error, const s
return;
int jHandle = reinterpret_cast<int>(client);
+ // Don't copy the null terminator.
int len = cert.length();
- jbyteArray jCert = env->NewByteArray(len);
- jbyte* bytes = env->GetByteArrayElements(jCert, NULL);
- cert.copy(reinterpret_cast<char*>(bytes), len);
+ ScopedLocalRef<jbyteArray> jCert(env, env->NewByteArray(len));
+ env->SetByteArrayRegion(jCert.get(), 0, len, reinterpret_cast<const jbyte*>(cert.c_str()));
- jstring jUrl = env->NewStringUTF(url.c_str());
+ ScopedLocalRef<jstring> jUrl(env, env->NewStringUTF(url.c_str()));
- env->CallVoidMethod(javaFrame.get(), mJavaFrame->mReportSslCertError, jHandle, cert_error, jCert, jUrl);
- env->DeleteLocalRef(jCert);
- env->DeleteLocalRef(jUrl);
+ env->CallVoidMethod(javaFrame.get(), mJavaFrame->mReportSslCertError, jHandle, error, jCert.get(), jUrl.get());
checkException(env);
}
@@ -1057,12 +1055,10 @@ WebFrame::didReceiveData(const char* data, int size) {
if (!javaFrame.get())
return;
- jbyteArray jData = env->NewByteArray(size);
- jbyte* bytes = env->GetByteArrayElements(jData, NULL);
- memcpy(reinterpret_cast<char*>(bytes), data, size);
+ ScopedLocalRef<jbyteArray> jData(env, env->NewByteArray(size));
+ env->SetByteArrayRegion(jData.get(), 0, size, reinterpret_cast<const jbyte*>(data));
- env->CallVoidMethod(javaFrame.get(), mJavaFrame->mDidReceiveData, jData, size);
- env->DeleteLocalRef(jData);
+ env->CallVoidMethod(javaFrame.get(), mJavaFrame->mDidReceiveData, jData.get(), size);
checkException(env);
}
@@ -1091,13 +1087,11 @@ void WebFrame::setCertificate(const std::string& cert)
return;
int len = cert.length();
- jbyteArray jCert = env->NewByteArray(len);
- jbyte* bytes = env->GetByteArrayElements(jCert, NULL);
- cert.copy(reinterpret_cast<char*>(bytes), len);
+ ScopedLocalRef<jbyteArray> jCert(env, env->NewByteArray(len));
+ env->SetByteArrayRegion(jCert.get(), 0, len, reinterpret_cast<const jbyte*>(cert.c_str()));
- env->CallVoidMethod(javaFrame.get(), mJavaFrame->mSetCertificate, jCert);
+ env->CallVoidMethod(javaFrame.get(), mJavaFrame->mSetCertificate, jCert.get());
- env->DeleteLocalRef(jCert);
checkException(env);
}
#endif // USE(CHROME_NETWORK_STACK)
diff --git a/Source/WebKit/android/jni/WebViewCore.cpp b/Source/WebKit/android/jni/WebViewCore.cpp
index 134408a..f35f768 100644
--- a/Source/WebKit/android/jni/WebViewCore.cpp
+++ b/Source/WebKit/android/jni/WebViewCore.cpp
@@ -945,20 +945,22 @@ bool WebViewCore::updateLayers(LayerAndroid* layers)
return true;
}
-BaseLayerAndroid* WebViewCore::createBaseLayer()
+BaseLayerAndroid* WebViewCore::createBaseLayer(SkRegion* region)
{
BaseLayerAndroid* base = new BaseLayerAndroid();
base->setContent(m_content);
- m_skipContentDraw = true;
- bool layoutSucceeded = layoutIfNeededRecursive(m_mainFrame);
- m_skipContentDraw = false;
- // Layout only fails if called during a layout.
- LOG_ASSERT(layoutSucceeded, "Can never be called recursively");
+ if (!region->isEmpty()) {
+ m_skipContentDraw = true;
+ bool layoutSucceeded = layoutIfNeededRecursive(m_mainFrame);
+ m_skipContentDraw = false;
+ // Layout only fails if called during a layout.
+ LOG_ASSERT(layoutSucceeded, "Can never be called recursively");
+ }
#if USE(ACCELERATED_COMPOSITING)
// We set the background color
- if (m_mainFrame && m_mainFrame->document()
+ if (!region->isEmpty() && m_mainFrame && m_mainFrame->document()
&& m_mainFrame->document()->body()) {
Document* document = m_mainFrame->document();
RefPtr<RenderStyle> style = document->styleForElementIgnoringPendingStylesheets(document->body());
@@ -1013,7 +1015,7 @@ BaseLayerAndroid* WebViewCore::recordContent(SkRegion* region, SkIPoint* point)
region->getBounds().fBottom);
DBG_SET_LOG("end");
- return createBaseLayer();
+ return createBaseLayer(region);
}
void WebViewCore::splitContent(PictureSet* content)
diff --git a/Source/WebKit/android/jni/WebViewCore.h b/Source/WebKit/android/jni/WebViewCore.h
index 491a0ad..ea57c11 100644
--- a/Source/WebKit/android/jni/WebViewCore.h
+++ b/Source/WebKit/android/jni/WebViewCore.h
@@ -527,7 +527,7 @@ namespace android {
// This creates a new BaseLayerAndroid by copying the current m_content
// and doing a copy of the layers. The layers' content may be updated
// as we are calling layersSync().
- BaseLayerAndroid* createBaseLayer();
+ BaseLayerAndroid* createBaseLayer(SkRegion*);
bool updateLayers(LayerAndroid*);
int textWrapWidth() const { return m_textWrapWidth; }
diff --git a/Source/WebKit/android/nav/CacheBuilder.cpp b/Source/WebKit/android/nav/CacheBuilder.cpp
index a4bc758..623d2cb 100644
--- a/Source/WebKit/android/nav/CacheBuilder.cpp
+++ b/Source/WebKit/android/nav/CacheBuilder.cpp
@@ -1406,7 +1406,6 @@ void CacheBuilder::BuildFrame(Frame* root, Frame* frame,
else if (cachedNode.clip(clip) == false)
continue; // skip this node if outside of the clip
}
- cachedNode.setNavableRects();
cachedNode.setColorIndex(colorIndex);
cachedNode.setExport(exported);
cachedNode.setHasCursorRing(hasCursorRing);
@@ -1478,7 +1477,6 @@ bool CacheBuilder::CleanUpContainedNodes(CachedRoot* cachedRoot,
lastNode->hasTagName(HTMLNames::formTag)) {
lastCached->setBounds(IntRect(0, 0, 0, 0));
lastCached->mCursorRing.clear();
- lastCached->setNavableRects();
return false;
}
CachedNode* onlyChildCached = cachedFrame->lastNode();
diff --git a/Source/WebKit/android/nav/CachedNode.cpp b/Source/WebKit/android/nav/CachedNode.cpp
index 86c2a38..e500875 100644
--- a/Source/WebKit/android/nav/CachedNode.cpp
+++ b/Source/WebKit/android/nav/CachedNode.cpp
@@ -92,10 +92,9 @@ void CachedNode::cursorRings(const CachedFrame* frame,
WebCore::IntRect CachedNode::cursorRingBounds(const CachedFrame* frame) const
{
- int partMax = mNavableRects;
- ASSERT(partMax > 0);
- WebCore::IntRect bounds = mCursorRing[0];
- for (int partIndex = 1; partIndex < partMax; partIndex++)
+ int partMax = navableRects();
+ WebCore::IntRect bounds;
+ for (int partIndex = 0; partIndex < partMax; partIndex++)
bounds.unite(mCursorRing[partIndex]);
bounds.inflate(CURSOR_RING_HIT_TEST_RADIUS);
return mIsInLayer ? frame->adjustBounds(this, bounds) : bounds;
@@ -116,7 +115,7 @@ void CachedNode::fixUpCursorRects(const CachedFrame* frame)
mUseHitBounds = true;
return;
}
- if (mNavableRects <= 1)
+ if (navableRects() <= 1)
return;
// if there is more than 1 rect, and the bounds doesn't intersect
// any other cursor ring bounds, use it
@@ -290,8 +289,8 @@ void CachedNode::move(int x, int y)
bool CachedNode::partRectsContains(const CachedNode* other) const
{
int outerIndex = 0;
- int outerMax = mNavableRects;
- int innerMax = other->mNavableRects;
+ int outerMax = navableRects();
+ int innerMax = other->navableRects();
do {
const WebCore::IntRect& outerBounds = mCursorRing[outerIndex];
int innerIndex = 0;
@@ -403,7 +402,7 @@ void CachedNode::Debug::print() const
DUMP_NAV_LOGD("// void* mParentGroup=%p; // (%d) \n", b->mParentGroup, mParentGroupIndex);
DUMP_NAV_LOGD("// int mDataIndex=%d;\n", b->mDataIndex);
DUMP_NAV_LOGD("// int mIndex=%d;\n", b->mIndex);
- DUMP_NAV_LOGD("// int mNavableRects=%d;\n", b->mNavableRects);
+ DUMP_NAV_LOGD("// int navableRects()=%d;\n", b->navableRects());
DUMP_NAV_LOGD("// int mParentIndex=%d;\n", b->mParentIndex);
DUMP_NAV_LOGD("// int mTabIndex=%d;\n", b->mTabIndex);
DUMP_NAV_LOGD("// int mColorIndex=%d;\n", b->mColorIndex);
diff --git a/Source/WebKit/android/nav/CachedNode.h b/Source/WebKit/android/nav/CachedNode.h
index 602dda6..321b7fd 100644
--- a/Source/WebKit/android/nav/CachedNode.h
+++ b/Source/WebKit/android/nav/CachedNode.h
@@ -136,7 +136,7 @@ public:
WebCore::IntRect localHitBounds(const CachedFrame* ) const;
WebCore::IntRect localRing(const CachedFrame* , size_t part) const;
void move(int x, int y);
- int navableRects() const { return mNavableRects; }
+ int navableRects() const { return mCursorRing.size(); }
void* nodePointer() const { return mNode; }
bool noSecondChance() const { return mCondition > SECOND_CHANCE_END; }
const WebCore::IntRect& originalAbsoluteBounds() const {
@@ -169,7 +169,6 @@ public:
void setIsTransparent(bool isTransparent) { mIsTransparent = isTransparent; }
void setIsUnclipped(bool unclipped) { mIsUnclipped = unclipped; }
void setLast() { mLast = true; }
- void setNavableRects() { mNavableRects = mCursorRing.size(); }
void setParentGroup(void* group) { mParentGroup = group; }
void setParentIndex(int parent) { mParentIndex = parent; }
void setSingleImage(bool single) { mSingleImage = single; }
@@ -195,7 +194,6 @@ private:
void* mParentGroup; // WebCore::Node*, only used to match pointers
int mDataIndex; // child frame if a frame; input data index; or -1
int mIndex; // index of itself, to find first in array (document)
- int mNavableRects; // FIXME: could be bitfield once I limit max number of rects
int mParentIndex;
int mTabIndex;
int mColorIndex; // index to ring color and other stylable properties
diff --git a/Source/WebKit/android/nav/WebView.cpp b/Source/WebKit/android/nav/WebView.cpp
index d062db3..0876db6 100644
--- a/Source/WebKit/android/nav/WebView.cpp
+++ b/Source/WebKit/android/nav/WebView.cpp
@@ -570,24 +570,6 @@ bool drawGL(WebCore::IntRect& viewRect, WebCore::IntRect* invalRect, WebCore::In
}
unsigned int pic = m_glWebViewState->currentPictureCounter();
-
- if (extra == &m_ring) {
- if (m_ring.m_isButton || root != m_ring.m_frame) {
- // TODO: Fix the navcache to work with layers correctly
- // In the meantime, this works around the bug. However, the rings
- // it produces are not as nice for some reason, thus we use
- // m_ring.rings() as produced by navcache for the base layer and
- // for layers we generate a new ring set
- m_ring.rings().clear();
- for (size_t i = 0; i < m_ring.m_node->rings().size(); i++) {
- IntRect rect = m_ring.m_node->rings().at(i);
- rect = m_ring.m_frame->adjustBounds(m_ring.m_node, rect);
- if (!m_ring.m_isButton)
- rect.inflate(4);
- m_ring.rings().append(rect);
- }
- }
- }
m_glWebViewState->glExtras()->setDrawExtra(extra);
LayerAndroid* compositeLayer = compositeRoot();
@@ -1934,15 +1916,16 @@ static jint nativeDraw(JNIEnv *env, jobject obj, jobject canv, jint color,
return reinterpret_cast<jint>(GET_NATIVE_VIEW(env, obj)->draw(canvas, color, extras, split));
}
-static jint nativeGetDrawGLFunction(JNIEnv *env, jobject obj, jobject jrect, jobject jviewrect,
- jfloat scale, jint extras) {
+static jint nativeGetDrawGLFunction(JNIEnv *env, jobject obj, jint nativeView,
+ jobject jrect, jobject jviewrect,
+ jfloat scale, jint extras) {
WebCore::IntRect viewRect;
if (jrect == NULL) {
viewRect = WebCore::IntRect();
} else {
viewRect = jrect_to_webrect(env, jrect);
}
- WebView *wvInstance = GET_NATIVE_VIEW(env, obj);
+ WebView *wvInstance = (WebView*) nativeView;
GLDrawFunctor* functor = new GLDrawFunctor(wvInstance, &android::WebView::drawGL,
viewRect, scale, extras);
wvInstance->setFunctor((Functor*) functor);
@@ -1982,10 +1965,10 @@ static void nativeUpdateDrawGLFunction(JNIEnv *env, jobject obj, jobject jrect,
}
}
-static bool nativeEvaluateLayersAnimations(JNIEnv *env, jobject obj)
+static bool nativeEvaluateLayersAnimations(JNIEnv *env, jobject obj, jint nativeView)
{
#if USE(ACCELERATED_COMPOSITING)
- LayerAndroid* root = GET_NATIVE_VIEW(env, obj)->compositeRoot();
+ LayerAndroid* root = ((WebView*)nativeView)->compositeRoot();
if (root)
return root->evaluateAnimations();
#endif
@@ -2303,10 +2286,10 @@ static bool nativeMoveCursor(JNIEnv *env, jobject obj,
return view->moveCursor(key, count, ignoreScroll);
}
-static void nativeRecordButtons(JNIEnv* env, jobject obj, bool hasFocus,
- bool pressed, bool invalidate)
+static void nativeRecordButtons(JNIEnv* env, jobject obj, jint nativeView,
+ bool hasFocus, bool pressed, bool invalidate)
{
- WebView* view = GET_NATIVE_VIEW(env, obj);
+ WebView* view = (WebView*) nativeView;
LOG_ASSERT(view, "view not set in %s", __FUNCTION__);
view->nativeRecordButtons(hasFocus, pressed, invalidate);
}
@@ -2566,10 +2549,10 @@ static jint nativeSelectionY(JNIEnv *env, jobject obj)
return GET_NATIVE_VIEW(env, obj)->selectionY();
}
-static void nativeSetSelectionPointer(JNIEnv *env, jobject obj, jboolean set,
- jfloat scale, jint x, jint y)
+static void nativeSetSelectionPointer(JNIEnv *env, jobject obj, jint nativeView,
+ jboolean set, jfloat scale, jint x, jint y)
{
- GET_NATIVE_VIEW(env, obj)->setSelectionPointer(set, scale, x, y);
+ ((WebView*)nativeView)->setSelectionPointer(set, scale, x, y);
}
static void nativeRegisterPageSwapCallback(JNIEnv *env, jobject obj)
@@ -2809,13 +2792,13 @@ static JNINativeMethod gJavaWebViewMethods[] = {
(void*) nativeDestroy },
{ "nativeDraw", "(Landroid/graphics/Canvas;IIZ)I",
(void*) nativeDraw },
- { "nativeGetDrawGLFunction", "(Landroid/graphics/Rect;Landroid/graphics/Rect;FI)I",
+ { "nativeGetDrawGLFunction", "(ILandroid/graphics/Rect;Landroid/graphics/Rect;FI)I",
(void*) nativeGetDrawGLFunction },
{ "nativeUpdateDrawGLFunction", "(Landroid/graphics/Rect;Landroid/graphics/Rect;)V",
(void*) nativeUpdateDrawGLFunction },
{ "nativeDumpDisplayTree", "(Ljava/lang/String;)V",
(void*) nativeDumpDisplayTree },
- { "nativeEvaluateLayersAnimations", "()Z",
+ { "nativeEvaluateLayersAnimations", "(I)Z",
(void*) nativeEvaluateLayersAnimations },
{ "nativeExtendSelection", "(II)V",
(void*) nativeExtendSelection },
@@ -2893,7 +2876,7 @@ static JNINativeMethod gJavaWebViewMethods[] = {
(void*) nativeMoveSelection },
{ "nativePointInNavCache", "(III)Z",
(void*) nativePointInNavCache },
- { "nativeRecordButtons", "(ZZZ)V",
+ { "nativeRecordButtons", "(IZZZ)V",
(void*) nativeRecordButtons },
{ "nativeResetSelection", "()V",
(void*) nativeResetSelection },
@@ -2929,7 +2912,7 @@ static JNINativeMethod gJavaWebViewMethods[] = {
(void*) nativeCopyBaseContentToPicture },
{ "nativeHasContent", "()Z",
(void*) nativeHasContent },
- { "nativeSetSelectionPointer", "(ZFII)V",
+ { "nativeSetSelectionPointer", "(IZFII)V",
(void*) nativeSetSelectionPointer },
{ "nativeShowCursorTimed", "()V",
(void*) nativeShowCursorTimed },