summaryrefslogtreecommitdiffstats
path: root/Source/WebCore/platform/graphics
diff options
context:
space:
mode:
authorNicolas Roard <nicolasroard@google.com>2011-10-14 14:36:56 -0700
committerNicolas Roard <nicolasroard@google.com>2011-10-14 15:16:33 -0700
commit7eb15a6b569f79bfddb934615640fd6275218377 (patch)
tree24fe93822190ec16b84a6c5dd689012b6a6706bc /Source/WebCore/platform/graphics
parent4520f40c217eca38e19654c0d5e7c987ab07bb9a (diff)
downloadexternal_webkit-7eb15a6b569f79bfddb934615640fd6275218377.zip
external_webkit-7eb15a6b569f79bfddb934615640fd6275218377.tar.gz
external_webkit-7eb15a6b569f79bfddb934615640fd6275218377.tar.bz2
Improve performances / fixes some glitches
- no layout / bgd color check if no inval on the base layer - throttle the number of ImageTexture uploaded per draw call - disable fast layer position update for now bug:5297559 bug:5421309 bug:5218173 Change-Id: I9ff9867dd3cfc2e0805e378d75ea75667fef8673
Diffstat (limited to 'Source/WebCore/platform/graphics')
-rw-r--r--Source/WebCore/platform/graphics/android/GLWebViewState.cpp8
-rw-r--r--Source/WebCore/platform/graphics/android/ImageTexture.cpp9
-rw-r--r--Source/WebCore/platform/graphics/android/ImageTexture.h1
-rw-r--r--Source/WebCore/platform/graphics/android/ImagesManager.cpp21
-rw-r--r--Source/WebCore/platform/graphics/android/ImagesManager.h4
-rw-r--r--Source/WebCore/platform/graphics/android/LayerAndroid.cpp5
6 files changed, 47 insertions, 1 deletions
diff --git a/Source/WebCore/platform/graphics/android/GLWebViewState.cpp b/Source/WebCore/platform/graphics/android/GLWebViewState.cpp
index 66c0370..2d7b177 100644
--- a/Source/WebCore/platform/graphics/android/GLWebViewState.cpp
+++ b/Source/WebCore/platform/graphics/android/GLWebViewState.cpp
@@ -31,6 +31,7 @@
#include "BaseLayerAndroid.h"
#include "ClassTracker.h"
#include "GLUtils.h"
+#include "ImagesManager.h"
#include "LayerAndroid.h"
#include "SkPath.h"
#include "TilesManager.h"
@@ -447,6 +448,11 @@ bool GLWebViewState::drawGL(IntRect& rect, SkRect& viewport, IntRect* invalRect,
// the BaseTiles' texture.
TilesManager::instance()->transferQueue()->updateDirtyBaseTiles();
+ // Upload any pending ImageTexture
+ // Return true if we still have some images to upload.
+ // TODO: upload as many textures as possible within a certain time limit
+ bool ret = ImagesManager::instance()->uploadTextures();
+
if (scale < MIN_SCALE_WARNING || scale > MAX_SCALE_WARNING)
XLOGC("WARNING, scale seems corrupted after update: %e", scale);
@@ -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);
diff --git a/Source/WebCore/platform/graphics/android/ImageTexture.cpp b/Source/WebCore/platform/graphics/android/ImageTexture.cpp
index 814373c..96f7713 100644
--- a/Source/WebCore/platform/graphics/android/ImageTexture.cpp
+++ b/Source/WebCore/platform/graphics/android/ImageTexture.cpp
@@ -26,6 +26,7 @@
#include "config.h"
#include "ImageTexture.h"
+#include "ImagesManager.h"
#include "SkDevice.h"
#include "TilesManager.h"
@@ -92,6 +93,14 @@ void ImageTexture::prepareGL()
if (m_textureId)
return;
+ ImagesManager::instance()->scheduleTextureUpload(this);
+}
+
+void ImageTexture::uploadGLTexture()
+{
+ if (m_textureId)
+ return;
+
glGenTextures(1, &m_textureId);
GLUtils::createTextureWithBitmap(m_textureId, *m_image);
}
diff --git a/Source/WebCore/platform/graphics/android/ImageTexture.h b/Source/WebCore/platform/graphics/android/ImageTexture.h
index 18ff7ef..7f35f06 100644
--- a/Source/WebCore/platform/graphics/android/ImageTexture.h
+++ b/Source/WebCore/platform/graphics/android/ImageTexture.h
@@ -64,6 +64,7 @@ public:
virtual ~ImageTexture();
void prepareGL();
+ void uploadGLTexture();
void drawGL(LayerAndroid* painter);
void drawCanvas(SkCanvas*, SkRect&);
void retain() { m_refCount++; }
diff --git a/Source/WebCore/platform/graphics/android/ImagesManager.cpp b/Source/WebCore/platform/graphics/android/ImagesManager.cpp
index 3518832..21f9fe9 100644
--- a/Source/WebCore/platform/graphics/android/ImagesManager.cpp
+++ b/Source/WebCore/platform/graphics/android/ImagesManager.cpp
@@ -105,4 +105,25 @@ ImageTexture* ImagesManager::getTextureForImage(SkBitmapRef* img, bool retain)
return image;
}
+void ImagesManager::scheduleTextureUpload(ImageTexture* texture)
+{
+ if (m_imagesToUpload.contains(texture))
+ return;
+
+ texture->retain();
+ m_imagesToUpload.append(texture);
+}
+
+bool ImagesManager::uploadTextures()
+{
+ // scheduleUpload and uploadTextures are called on the same thread
+ if (!m_imagesToUpload.size())
+ return false;
+ ImageTexture* texture = m_imagesToUpload.last();
+ texture->uploadGLTexture();
+ m_imagesToUpload.removeLast();
+ removeImage(texture->imageRef());
+ return m_imagesToUpload.size();
+}
+
} // namespace WebCore
diff --git a/Source/WebCore/platform/graphics/android/ImagesManager.h b/Source/WebCore/platform/graphics/android/ImagesManager.h
index 1b5d322..2fcb9fd 100644
--- a/Source/WebCore/platform/graphics/android/ImagesManager.h
+++ b/Source/WebCore/platform/graphics/android/ImagesManager.h
@@ -30,6 +30,7 @@
#include "SkBitmap.h"
#include "SkBitmapRef.h"
#include "SkRefCnt.h"
+#include "Vector.h"
namespace WebCore {
@@ -43,6 +44,8 @@ public:
void removeImage(SkBitmapRef* img);
ImageTexture* getTextureForImage(SkBitmapRef* img, bool retain = true);
void showImages();
+ void scheduleTextureUpload(ImageTexture* texture);
+ bool uploadTextures();
private:
ImagesManager() {}
@@ -51,6 +54,7 @@ private:
android::Mutex m_imagesLock;
HashMap<SkBitmapRef*, ImageTexture*> m_images;
+ Vector<ImageTexture*> m_imagesToUpload;
};
} // namespace WebCore
diff --git a/Source/WebCore/platform/graphics/android/LayerAndroid.cpp b/Source/WebCore/platform/graphics/android/LayerAndroid.cpp
index 4162e0b..4a0e2bb 100644
--- a/Source/WebCore/platform/graphics/android/LayerAndroid.cpp
+++ b/Source/WebCore/platform/graphics/android/LayerAndroid.cpp
@@ -768,6 +768,8 @@ void LayerAndroid::assignTextureTo(LayerAndroid* newTree)
bool LayerAndroid::updateWithTree(LayerAndroid* newTree)
{
+// Disable fast update for now
+#if (0)
bool needsRepaint = false;
int count = this->countChildren();
for (int i = 0; i < count; i++)
@@ -778,6 +780,9 @@ bool LayerAndroid::updateWithTree(LayerAndroid* newTree)
needsRepaint |= updateWithLayer(newLayer);
}
return needsRepaint;
+#else
+ return true;
+#endif
}
// Return true to indicate to WebViewCore that the updates