summaryrefslogtreecommitdiffstats
path: root/WebCore/platform
diff options
context:
space:
mode:
Diffstat (limited to 'WebCore/platform')
-rw-r--r--WebCore/platform/android/RenderThemeAndroid.cpp12
-rw-r--r--WebCore/platform/graphics/android/BaseLayerAndroid.cpp17
-rw-r--r--WebCore/platform/graphics/android/BaseLayerAndroid.h2
-rw-r--r--WebCore/platform/graphics/android/BaseTile.cpp24
-rw-r--r--WebCore/platform/graphics/android/GLWebViewState.cpp9
-rw-r--r--WebCore/platform/graphics/android/GLWebViewState.h4
-rw-r--r--WebCore/platform/graphics/android/GraphicsLayerAndroid.cpp130
-rw-r--r--WebCore/platform/graphics/android/GraphicsLayerAndroid.h1
-rw-r--r--WebCore/platform/graphics/android/LayerAndroid.cpp52
-rw-r--r--WebCore/platform/graphics/android/LayerAndroid.h6
-rw-r--r--WebCore/platform/graphics/android/MediaLayer.cpp27
-rw-r--r--WebCore/platform/graphics/android/ShaderProgram.cpp29
-rw-r--r--WebCore/platform/graphics/android/ShaderProgram.h9
-rw-r--r--WebCore/platform/graphics/android/TiledPage.cpp4
-rw-r--r--WebCore/platform/graphics/android/TilesManager.cpp11
-rw-r--r--WebCore/platform/graphics/android/TilesManager.h11
-rw-r--r--WebCore/platform/graphics/android/android_graphics.cpp21
-rw-r--r--WebCore/platform/graphics/android/android_graphics.h1
18 files changed, 258 insertions, 112 deletions
diff --git a/WebCore/platform/android/RenderThemeAndroid.cpp b/WebCore/platform/android/RenderThemeAndroid.cpp
index b43e0e6..66f034d 100644
--- a/WebCore/platform/android/RenderThemeAndroid.cpp
+++ b/WebCore/platform/android/RenderThemeAndroid.cpp
@@ -52,9 +52,15 @@ namespace WebCore {
// dropdowns, we want a much smaller height, which encompasses the text.
const int listboxPadding = 5;
-// This is the color of selection in a textfield. It was obtained by checking
-// the color of selection in TextViews in the system.
-const RGBA32 selectionColor = makeRGB(255, 146, 0);
+// This is the color of selection in a textfield. It was computed from
+// frameworks/base/core/res/res/values/colors.xml, which uses #9983CC39
+// (decimal a = 153, r = 131, g = 204, b = 57)
+// for all four highlighted text values. Blending this with white yields:
+// R = (131 * 153 + 255 * (255 - 153)) / 255 -> 180.6
+// G = (204 * 153 + 255 * (255 - 153)) / 255 -> 224.4
+// B = ( 57 * 153 + 255 * (255 - 153)) / 255 -> 136.2
+
+const RGBA32 selectionColor = makeRGB(181, 224, 136);
static SkCanvas* getCanvasFromInfo(const PaintInfo& info)
{
diff --git a/WebCore/platform/graphics/android/BaseLayerAndroid.cpp b/WebCore/platform/graphics/android/BaseLayerAndroid.cpp
index 2f0e999..d2c41dc 100644
--- a/WebCore/platform/graphics/android/BaseLayerAndroid.cpp
+++ b/WebCore/platform/graphics/android/BaseLayerAndroid.cpp
@@ -116,12 +116,11 @@ void BaseLayerAndroid::drawCanvas(SkCanvas* canvas)
}
#if USE(ACCELERATED_COMPOSITING)
-bool BaseLayerAndroid::drawBasePictureInGL(SkRect& viewport, float scale)
+bool BaseLayerAndroid::drawBasePictureInGL(SkRect& viewport, float scale, double currentTime)
{
if (!m_glWebViewState)
return false;
- double currentTime = WTF::currentTime();
bool goingDown = m_previousVisible.fTop - viewport.fTop <= 0;
bool goingLeft = m_previousVisible.fLeft - viewport.fLeft >= 0;
@@ -268,8 +267,6 @@ bool BaseLayerAndroid::drawGL(IntRect& viewRect, SkRect& visibleRect,
(float)m_color.green() / 255.0,
(float)m_color.blue() / 255.0, 1);
glClear(GL_COLOR_BUFFER_BIT);
- glEnable(GL_BLEND);
- glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
glViewport(left, top, width, height);
ShaderProgram* shader = TilesManager::instance()->shader();
@@ -281,8 +278,10 @@ bool BaseLayerAndroid::drawGL(IntRect& viewRect, SkRect& visibleRect,
glUniform1i(shader->textureSampler(), 0);
shader->setViewRect(viewRect);
shader->setViewport(visibleRect);
+ shader->resetBlending();
- ret = drawBasePictureInGL(visibleRect, scale);
+ double currentTime = WTF::currentTime();
+ ret = drawBasePictureInGL(visibleRect, scale, currentTime);
if (countChildren() >= 1) {
LayerAndroid* compositedRoot = static_cast<LayerAndroid*>(getChild(0));
@@ -311,7 +310,7 @@ bool BaseLayerAndroid::drawGL(IntRect& viewRect, SkRect& visibleRect,
scale = m_glWebViewState->futureScale();
}
compositedRoot->setScale(scale);
- compositedRoot->computeTextureSize();
+ compositedRoot->computeTextureSize(currentTime);
compositedRoot->reserveGLTextures();
#ifdef DEBUG
@@ -337,12 +336,6 @@ bool BaseLayerAndroid::drawGL(IntRect& viewRect, SkRect& visibleRect,
glBindBuffer(GL_ARRAY_BUFFER, 0);
m_previousVisible = visibleRect;
-#ifdef DEBUG_COUNT
- XLOG("GLWebViewState(%d) DoubleBufferedTexture(%d) BaseTile(%d) TileSet(%d) TiledPage(%d)",
- GLWebViewState::count(), DoubleBufferedTexture::count(),
- BaseTile::count(), TileSet::count(), TiledPage::count());
-#endif // DEBUG_COUNT
-
#endif // USE(ACCELERATED_COMPOSITING)
#ifdef DEBUG
ClassTracker::instance()->show();
diff --git a/WebCore/platform/graphics/android/BaseLayerAndroid.h b/WebCore/platform/graphics/android/BaseLayerAndroid.h
index c57b13d..cb1caef 100644
--- a/WebCore/platform/graphics/android/BaseLayerAndroid.h
+++ b/WebCore/platform/graphics/android/BaseLayerAndroid.h
@@ -59,7 +59,7 @@ public:
void swapExtra(BaseLayerAndroid* base) { m_extra.swap(base->m_extra); }
private:
#if USE(ACCELERATED_COMPOSITING)
- bool drawBasePictureInGL(SkRect& viewport, float scale);
+ bool drawBasePictureInGL(SkRect& viewport, float scale, double currentTime);
GLWebViewState* m_glWebViewState;
android::Mutex m_drawLock;
diff --git a/WebCore/platform/graphics/android/BaseTile.cpp b/WebCore/platform/graphics/android/BaseTile.cpp
index e5275c6..a69e6f9 100644
--- a/WebCore/platform/graphics/android/BaseTile.cpp
+++ b/WebCore/platform/graphics/android/BaseTile.cpp
@@ -265,18 +265,18 @@ void BaseTile::paintBitmap()
canvas->restore();
-#ifdef DEBUG
- SkPaint paint;
- paint.setARGB(128, 255, 0, 0);
- paint.setStrokeWidth(3);
- canvas->drawLine(0, 0, tileWidth, tileHeight, paint);
- paint.setARGB(128, 0, 255, 0);
- canvas->drawLine(0, tileHeight, tileWidth, 0, paint);
- paint.setARGB(128, 0, 0, 255);
- canvas->drawLine(0, 0, tileWidth, 0, paint);
- canvas->drawLine(tileWidth, 0, tileWidth, tileHeight, paint);
- drawTileInfo(canvas, texture, x, y, scale);
-#endif
+ if (TilesManager::instance()->getShowVisualIndicator()) {
+ SkPaint paint;
+ paint.setARGB(128, 255, 0, 0);
+ paint.setStrokeWidth(3);
+ canvas->drawLine(0, 0, tileWidth, tileHeight, paint);
+ paint.setARGB(128, 0, 255, 0);
+ canvas->drawLine(0, tileHeight, tileWidth, 0, paint);
+ paint.setARGB(128, 0, 0, 255);
+ canvas->drawLine(0, 0, tileWidth, 0, paint);
+ canvas->drawLine(tileWidth, 0, tileWidth, tileHeight, paint);
+ drawTileInfo(canvas, texture, x, y, scale);
+ }
texture->setTile(x, y);
texture->producerUpdate(textureInfo);
diff --git a/WebCore/platform/graphics/android/GLWebViewState.cpp b/WebCore/platform/graphics/android/GLWebViewState.cpp
index 5ba094b..71f3fe5 100644
--- a/WebCore/platform/graphics/android/GLWebViewState.cpp
+++ b/WebCore/platform/graphics/android/GLWebViewState.cpp
@@ -92,7 +92,8 @@ GLWebViewState::~GLWebViewState()
#endif
}
-void GLWebViewState::setBaseLayer(BaseLayerAndroid* layer, const IntRect& rect)
+void GLWebViewState::setBaseLayer(BaseLayerAndroid* layer, const IntRect& rect,
+ bool showVisualIndicator)
{
android::Mutex::Autolock lock(m_baseLayerLock);
if (!layer) {
@@ -113,6 +114,8 @@ void GLWebViewState::setBaseLayer(BaseLayerAndroid* layer, const IntRect& rect)
m_currentBaseLayer = layer;
}
inval(rect);
+
+ TilesManager::instance()->setShowVisualIndicator(showVisualIndicator);
}
void GLWebViewState::unlockBaseLayerUpdate() {
@@ -127,7 +130,7 @@ void GLWebViewState::unlockBaseLayerUpdate() {
}
void GLWebViewState::setExtra(BaseLayerAndroid* layer, SkPicture& picture,
- const IntRect& rect)
+ const IntRect& rect, bool allowSame)
{
android::Mutex::Autolock lock(m_baseLayerLock);
if (!m_baseLayerUpdate)
@@ -135,7 +138,7 @@ void GLWebViewState::setExtra(BaseLayerAndroid* layer, SkPicture& picture,
layer->setExtra(picture);
- if (m_lastInval == rect)
+ if (!allowSame && m_lastInval == rect)
return;
if (!rect.isEmpty())
diff --git a/WebCore/platform/graphics/android/GLWebViewState.h b/WebCore/platform/graphics/android/GLWebViewState.h
index 2082f2c..91bb2d7 100644
--- a/WebCore/platform/graphics/android/GLWebViewState.h
+++ b/WebCore/platform/graphics/android/GLWebViewState.h
@@ -168,8 +168,8 @@ public:
void resetTransitionTime() { m_transitionTime = -1; }
unsigned int paintBaseLayerContent(SkCanvas* canvas);
- void setBaseLayer(BaseLayerAndroid* layer, const IntRect& rect);
- void setExtra(BaseLayerAndroid*, SkPicture&, const IntRect&);
+ void setBaseLayer(BaseLayerAndroid* layer, const IntRect& rect, bool showVisualIndicator);
+ void setExtra(BaseLayerAndroid*, SkPicture&, const IntRect&, bool allowSame);
void scheduleUpdate(const double& currentTime, const SkIRect& viewport, float scale);
TiledPage* sibling(TiledPage* page);
diff --git a/WebCore/platform/graphics/android/GraphicsLayerAndroid.cpp b/WebCore/platform/graphics/android/GraphicsLayerAndroid.cpp
index e887964..ccc872a 100644
--- a/WebCore/platform/graphics/android/GraphicsLayerAndroid.cpp
+++ b/WebCore/platform/graphics/android/GraphicsLayerAndroid.cpp
@@ -271,7 +271,17 @@ void GraphicsLayerAndroid::setPosition(const FloatPoint& point)
if (point == m_position)
return;
- GraphicsLayer::setPosition(point);
+ FloatPoint pos(point);
+#if ENABLE(ANDROID_OVERFLOW_SCROLL)
+ // Add the scroll position back in. When scrolling a layer, all the children
+ // are positioned based on the content scroll. Adding the scroll position
+ // back in allows the children to draw based on 0,0.
+ RenderLayer* layer = renderLayerFromClient(m_client);
+ if (layer && layer->parent() && layer->parent()->hasOverflowScroll())
+ pos += layer->parent()->scrolledContentOffset();
+#endif
+
+ GraphicsLayer::setPosition(pos);
#ifdef LAYER_DEBUG_2
LOG("(%x) setPosition(%.2f,%.2f) pos(%.2f, %.2f) anchor(%.2f,%.2f) size(%.2f, %.2f)",
@@ -279,7 +289,7 @@ void GraphicsLayerAndroid::setPosition(const FloatPoint& point)
m_anchorPoint.x(), m_anchorPoint.y(), m_size.width(), m_size.height());
#endif
updateFixedPosition();
- m_contentLayer->setPosition(point.x(), point.y());
+ m_contentLayer->setPosition(pos.x(), pos.y());
askForSync();
}
@@ -368,31 +378,6 @@ void GraphicsLayerAndroid::setDrawsContent(bool drawsContent)
if (m_contentLayer->isRootLayer())
return;
if (m_drawsContent) {
-#if ENABLE(ANDROID_OVERFLOW_SCROLL)
- RenderLayer* layer = renderLayerFromClient(m_client);
- if (layer) {
- if (layer->hasOverflowScroll() && !m_foregroundLayer) {
- m_foregroundLayer = new ScrollableLayerAndroid();
- m_foregroundClipLayer = new LayerAndroid(false);
- m_foregroundClipLayer->setMasksToBounds(true);
-
- m_foregroundClipLayer->addChild(m_foregroundLayer);
- m_contentLayer->addChild(m_foregroundClipLayer);
- } else if (layer->isRootLayer()
- && layer->renderer()->frame()->ownerRenderer()) {
- // We have to do another check for scrollable content since an
- // iframe might be compositing for other reasons.
- FrameView* view = layer->renderer()->frame()->view();
- if (view->hasOverflowScroll()) {
- // Replace the content layer with a scrollable layer.
- LayerAndroid* layer = new ScrollableLayerAndroid(*m_contentLayer);
- m_contentLayer->unref();
- m_contentLayer = layer;
- }
- }
- }
-#endif
-
m_haveContents = true;
setNeedsDisplay();
}
@@ -478,6 +463,77 @@ private:
GraphicsLayerPaintingPhase m_originalPhase;
};
+void GraphicsLayerAndroid::updateScrollingLayers()
+{
+#if ENABLE(ANDROID_OVERFLOW_SCROLL)
+ RenderLayer* layer = renderLayerFromClient(m_client);
+ if (!layer || !m_haveContents)
+ return;
+ bool hasOverflowScroll = m_foregroundLayer || m_contentLayer->contentIsScrollable();
+ bool layerNeedsOverflow = layer->hasOverflowScroll();
+ bool iframeNeedsOverflow = layer->isRootLayer() &&
+ layer->renderer()->frame()->ownerRenderer() &&
+ layer->renderer()->frame()->view()->hasOverflowScroll();
+
+ if (hasOverflowScroll && (layerNeedsOverflow || iframeNeedsOverflow)) {
+ // Already has overflow layers.
+ return;
+ }
+ if (!hasOverflowScroll && !layerNeedsOverflow && !iframeNeedsOverflow) {
+ // Does not need overflow layers.
+ return;
+ }
+ if (layerNeedsOverflow || iframeNeedsOverflow) {
+ ASSERT(!hasOverflowScroll);
+ if (layerNeedsOverflow) {
+ ASSERT(!m_foregroundLayer && !m_foregroundClipLayer);
+ m_foregroundLayer = new ScrollableLayerAndroid();
+ m_foregroundClipLayer = new LayerAndroid(false);
+ m_foregroundClipLayer->setMasksToBounds(true);
+ m_foregroundClipLayer->addChild(m_foregroundLayer);
+ m_contentLayer->addChild(m_foregroundClipLayer);
+ } else {
+ ASSERT(iframeNeedsOverflow && !m_contentLayer->contentIsScrollable());
+ // No need to copy the children as they will be removed and synced.
+ m_contentLayer->removeChildren();
+ // Replace the content layer with a scrollable layer.
+ LayerAndroid* layer = new ScrollableLayerAndroid(*m_contentLayer);
+ m_contentLayer->unref();
+ m_contentLayer = layer;
+ if (m_parent) {
+ // The content layer has changed so the parent needs to sync
+ // children.
+ static_cast<GraphicsLayerAndroid*>(m_parent)->m_needsSyncChildren = true;
+ }
+ }
+ // Need to rebuild our children based on the new structure.
+ m_needsSyncChildren = true;
+ } else {
+ ASSERT(hasOverflowScroll && !layerNeedsOverflow && !iframeNeedsOverflow);
+ ASSERT(m_contentLayer);
+ // Remove the foreground layers.
+ if (m_foregroundLayer) {
+ m_foregroundLayer->unref();
+ m_foregroundLayer = 0;
+ m_foregroundClipLayer->unref();
+ m_foregroundClipLayer = 0;
+ }
+ // No need to copy over children.
+ m_contentLayer->removeChildren();
+ LayerAndroid* layer = new LayerAndroid(*m_contentLayer);
+ m_contentLayer->unref();
+ m_contentLayer = layer;
+ if (m_parent) {
+ // The content layer has changed so the parent needs to sync
+ // children.
+ static_cast<GraphicsLayerAndroid*>(m_parent)->m_needsSyncChildren = true;
+ }
+ // Children are all re-parented.
+ m_needsSyncChildren = true;
+ }
+#endif
+}
+
bool GraphicsLayerAndroid::repaint()
{
LOG("(%x) repaint(), gPaused(%d) m_needsRepaint(%d) m_haveContents(%d) ",
@@ -506,8 +562,13 @@ bool GraphicsLayerAndroid::repaint()
m_foregroundLayer->setSize(contentsRect.width(), contentsRect.height());
// Paint everything else into the main recording canvas.
phase.clear(GraphicsLayerPaintBackground);
- if (!paintContext(m_foregroundLayer->recordContext(), contentsRect))
- return false;
+
+ // Paint at 0,0.
+ IntSize scroll = layer->scrolledContentOffset();
+ layer->scrollToOffset(0, 0, true, false);
+ // At this point, it doesn't matter if painting failed.
+ (void) paintContext(m_foregroundLayer->recordContext(), contentsRect);
+ layer->scrollToOffset(scroll.width(), scroll.height(), true, false);
// Construct the clip layer for masking the contents.
IntRect clip = layer->renderer()->absoluteBoundingBoxRect();
@@ -830,10 +891,16 @@ void GraphicsLayerAndroid::syncChildren()
{
if (m_needsSyncChildren) {
m_contentLayer->removeChildren();
- if (m_foregroundClipLayer)
+ LayerAndroid* layer = m_contentLayer;
+ if (m_foregroundClipLayer) {
m_contentLayer->addChild(m_foregroundClipLayer);
+ // Use the scrollable content layer as the parent of the children so
+ // that they move with the content.
+ layer = m_foregroundLayer;
+ layer->removeChildren();
+ }
for (unsigned int i = 0; i < m_children.size(); i++)
- m_contentLayer->addChild(m_children[i]->platformLayer());
+ layer->addChild(m_children[i]->platformLayer());
m_needsSyncChildren = false;
}
}
@@ -857,6 +924,7 @@ void GraphicsLayerAndroid::syncCompositingState()
for (unsigned int i = 0; i < m_children.size(); i++)
m_children[i]->syncCompositingState();
+ updateScrollingLayers();
syncChildren();
syncMask();
diff --git a/WebCore/platform/graphics/android/GraphicsLayerAndroid.h b/WebCore/platform/graphics/android/GraphicsLayerAndroid.h
index ce6bac1..da247ca 100644
--- a/WebCore/platform/graphics/android/GraphicsLayerAndroid.h
+++ b/WebCore/platform/graphics/android/GraphicsLayerAndroid.h
@@ -127,6 +127,7 @@ private:
void syncMask();
void updateFixedPosition();
+ void updateScrollingLayers();
// with SkPicture, we always repaint the entire layer's content.
bool repaint();
diff --git a/WebCore/platform/graphics/android/LayerAndroid.cpp b/WebCore/platform/graphics/android/LayerAndroid.cpp
index bee423c..35979f6 100644
--- a/WebCore/platform/graphics/android/LayerAndroid.cpp
+++ b/WebCore/platform/graphics/android/LayerAndroid.cpp
@@ -75,7 +75,8 @@ LayerAndroid::LayerAndroid(bool isRootLayer) : SkLayer(),
m_reservedTexture(0),
m_pictureUsed(0),
m_requestSent(false),
- m_scale(1)
+ m_scale(1),
+ m_lastComputeTextureSize(0)
{
m_backgroundColor = 0;
@@ -123,6 +124,7 @@ LayerAndroid::LayerAndroid(const LayerAndroid& layer) : SkLayer(layer),
m_dirty = layer.m_dirty;
m_pictureUsed = layer.m_pictureUsed;
m_scale = layer.m_scale;
+ m_lastComputeTextureSize = 0;
for (int i = 0; i < layer.countChildren(); i++)
addChild(layer.getChild(i)->copy())->unref();
@@ -147,7 +149,8 @@ LayerAndroid::LayerAndroid(SkPicture* picture) : SkLayer(),
m_drawingTexture(0),
m_reservedTexture(0),
m_requestSent(false),
- m_scale(1)
+ m_scale(1),
+ m_lastComputeTextureSize(0)
{
m_backgroundColor = 0;
m_dirty = false;
@@ -651,8 +654,12 @@ static inline bool compareLayerFullSize(const LayerAndroid* a, const LayerAndroi
return sizeA > sizeB;
}
-void LayerAndroid::computeTextureSize()
+void LayerAndroid::computeTextureSize(double time)
{
+ if (m_lastComputeTextureSize + s_computeTextureDelay > time)
+ return;
+ m_lastComputeTextureSize = time;
+
// First, we collect the layers, computing m_layerTextureRect
// as being clipped against the viewport
Vector <LayerAndroid*> layers;
@@ -861,9 +868,10 @@ bool LayerAndroid::drawGL(SkMatrix& matrix)
uniqueId(), this, getWidth(), getHeight(),
m_drawingTexture, textureRect.x(), textureRect.y(),
textureRect.width(), textureRect.height());
+ //TODO determine when drawing if the alpha value is used.
TilesManager::instance()->shader()->drawLayerQuad(m, bounds,
textureInfo->m_textureId,
- m_drawOpacity);
+ m_drawOpacity, true);
}
m_drawingTexture->consumerRelease();
}
@@ -984,25 +992,25 @@ void LayerAndroid::contentDraw(SkCanvas* canvas)
canvas->drawPicture(*m_extra);
m_atomicSync.unlock();
-#ifdef LAYER_DEBUG
- float w = getSize().width();
- float h = getSize().height();
- SkPaint paint;
- paint.setARGB(128, 255, 0, 0);
- canvas->drawLine(0, 0, w, h, paint);
- canvas->drawLine(0, h, w, 0, paint);
- paint.setARGB(128, 0, 255, 0);
- canvas->drawLine(0, 0, 0, h, paint);
- canvas->drawLine(0, h, w, h, paint);
- canvas->drawLine(w, h, w, 0, paint);
- canvas->drawLine(w, 0, 0, 0, paint);
-
- if (m_isFixed) {
- SkPaint paint;
- paint.setARGB(80, 255, 0, 0);
- canvas->drawRect(m_fixedRect, paint);
+ if (TilesManager::instance()->getShowVisualIndicator()) {
+ float w = getSize().width();
+ float h = getSize().height();
+ SkPaint paint;
+ paint.setARGB(128, 255, 0, 0);
+ canvas->drawLine(0, 0, w, h, paint);
+ canvas->drawLine(0, h, w, 0, paint);
+ paint.setARGB(128, 0, 255, 0);
+ canvas->drawLine(0, 0, 0, h, paint);
+ canvas->drawLine(0, h, w, h, paint);
+ canvas->drawLine(w, h, w, 0, paint);
+ canvas->drawLine(w, 0, 0, 0, paint);
+
+ if (m_isFixed) {
+ SkPaint paint;
+ paint.setARGB(80, 255, 0, 0);
+ canvas->drawRect(m_fixedRect, paint);
+ }
}
-#endif
}
void LayerAndroid::onDraw(SkCanvas* canvas, SkScalar opacity)
diff --git a/WebCore/platform/graphics/android/LayerAndroid.h b/WebCore/platform/graphics/android/LayerAndroid.h
index 2cb56c1..0d5a878 100644
--- a/WebCore/platform/graphics/android/LayerAndroid.h
+++ b/WebCore/platform/graphics/android/LayerAndroid.h
@@ -111,7 +111,7 @@ public:
void showLayers(int indent = 0);
// Texture size functions
- void computeTextureSize();
+ void computeTextureSize(double time);
void collect(Vector<LayerAndroid*>& layers,
int& size);
int clippedTextureSize() const;
@@ -325,6 +325,10 @@ private:
float m_scale;
+ // We try to not always compute the texture size, as this is quite heavy
+ static const double s_computeTextureDelay = 0.2; // 200 ms
+ double m_lastComputeTextureSize;
+
// This mutex serves two purposes. (1) It ensures that certain operations
// happen atomically and (2) it makes sure those operations are synchronized
// across all threads and cores.
diff --git a/WebCore/platform/graphics/android/MediaLayer.cpp b/WebCore/platform/graphics/android/MediaLayer.cpp
index 7a4c02d..ad4fc76 100644
--- a/WebCore/platform/graphics/android/MediaLayer.cpp
+++ b/WebCore/platform/graphics/android/MediaLayer.cpp
@@ -84,19 +84,26 @@ bool MediaLayer::drawGL(SkMatrix& matrix)
if (m_bufferedTexture) {
TextureInfo* textureInfo = m_bufferedTexture->consumerLock();
if (textureInfo) {
- // the layer's shader draws the content inverted so we must undo
- // that change in the transformation matrix
- TransformationMatrix m = drawTransform();
- if (!m_isContentInverted) {
- m.flipY();
- m.translate(0, -getSize().height());
- }
SkRect rect;
rect.set(0, 0, getSize().width(), getSize().height());
- TilesManager::instance()->shader()->drawLayerQuad(m, rect,
- textureInfo->m_textureId,
- 1.0f); //TODO fix this m_drawOpacity
+
+ if (textureInfo->m_width != 0 && textureInfo->m_height != 0) {
+ // the layer's shader draws the content inverted so we must undo
+ // that change in the transformation matrix
+ TransformationMatrix m = drawTransform();
+ if (!m_isContentInverted) {
+ m.flipY();
+ m.translate(0, -getSize().height());
+ }
+
+ bool forceBlending = textureInfo->m_internalFormat == GL_RGBA ||
+ textureInfo->m_internalFormat == GL_ALPHA;
+ TilesManager::instance()->shader()->drawLayerQuad(m, rect,
+ textureInfo->m_textureId,
+ 1.0f, forceBlending);
+ }
+
if (!rect.isEmpty())
needsInval = false;
}
diff --git a/WebCore/platform/graphics/android/ShaderProgram.cpp b/WebCore/platform/graphics/android/ShaderProgram.cpp
index c4129f1..828cc37 100644
--- a/WebCore/platform/graphics/android/ShaderProgram.cpp
+++ b/WebCore/platform/graphics/android/ShaderProgram.cpp
@@ -146,6 +146,7 @@ GLuint ShaderProgram::createProgram(const char* pVertexSource, const char* pFrag
}
ShaderProgram::ShaderProgram()
+ : m_blendingEnabled(false)
{
init();
}
@@ -181,6 +182,27 @@ void ShaderProgram::init()
glBufferData(GL_ARRAY_BUFFER, 2 * 4 * sizeof(GLfloat), coord, GL_STATIC_DRAW);
}
+void ShaderProgram::resetBlending()
+{
+ glDisable(GL_BLEND);
+ glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
+ glBlendEquation(GL_FUNC_ADD);
+ m_blendingEnabled = false;
+}
+
+void ShaderProgram::setBlendingState(bool enableBlending)
+{
+ if (enableBlending == m_blendingEnabled)
+ return;
+
+ if (enableBlending)
+ glEnable(GL_BLEND);
+ else
+ glDisable(GL_BLEND);
+
+ m_blendingEnabled = enableBlending;
+}
+
/////////////////////////////////////////////////////////////////////////////////////////
// Drawing
/////////////////////////////////////////////////////////////////////////////////////////
@@ -222,6 +244,7 @@ void ShaderProgram::drawQuad(SkRect& geometry, int textureId, float opacity)
glVertexAttribPointer(m_hPosition, 2, GL_FLOAT, GL_FALSE, 0, 0);
glUniform1f(alpha(), opacity);
+ setBlendingState(opacity < 1.0);
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
GLUtils::checkGlError("drawQuad");
@@ -278,7 +301,8 @@ IntRect ShaderProgram::clippedRectWithViewport(const IntRect& rect, int margin)
}
void ShaderProgram::drawLayerQuad(const TransformationMatrix& drawMatrix,
- SkRect& geometry, int textureId, float opacity)
+ SkRect& geometry, int textureId, float opacity,
+ bool forceBlending)
{
TransformationMatrix renderMatrix = drawMatrix;
@@ -297,6 +321,7 @@ void ShaderProgram::drawLayerQuad(const TransformationMatrix& drawMatrix,
glVertexAttribPointer(m_hPosition, 2, GL_FLOAT, GL_FALSE, 0, 0);
glUniform1f(alpha(), opacity);
+ setBlendingState(forceBlending || opacity < 1.0);
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
}
@@ -317,12 +342,14 @@ void ShaderProgram::drawVideoLayerQuad(const TransformationMatrix& drawMatrix,
glUniformMatrix4fv(m_hVideoProjectionMatrix, 1, GL_FALSE, projectionMatrix);
glUniformMatrix4fv(m_hVideoTextureMatrix, 1, GL_FALSE, textureMatrix);
+ glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_EXTERNAL_OES, textureId);
glBindBuffer(GL_ARRAY_BUFFER, m_textureBuffer[0]);
glEnableVertexAttribArray(m_hVideoPosition);
glVertexAttribPointer(m_hVideoPosition, 2, GL_FLOAT, GL_FALSE, 0, 0);
+ setBlendingState(false);
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
// switch back to our normal rendering program
diff --git a/WebCore/platform/graphics/android/ShaderProgram.h b/WebCore/platform/graphics/android/ShaderProgram.h
index 5e2045c..9419511 100644
--- a/WebCore/platform/graphics/android/ShaderProgram.h
+++ b/WebCore/platform/graphics/android/ShaderProgram.h
@@ -40,7 +40,8 @@ class ShaderProgram {
void setViewport(SkRect& viewport);
void drawQuad(SkRect& geometry, int textureId, float opacity);
void drawLayerQuad(const TransformationMatrix& drawMatrix,
- SkRect& geometry, int textureId, float opacity);
+ SkRect& geometry, int textureId, float opacity,
+ bool forceBlending = false);
void drawVideoLayerQuad(const TransformationMatrix& drawMatrix,
float* textureMatrix, SkRect& geometry, int textureId);
void setViewRect(const IntRect& viewRect);
@@ -49,11 +50,17 @@ class ShaderProgram {
void clip(const FloatRect& rect);
IntRect clippedRectWithViewport(const IntRect& rect, int margin = 0);
+ void resetBlending();
+
private:
GLuint loadShader(GLenum shaderType, const char* pSource);
GLuint createProgram(const char* vertexSource, const char* fragmentSource);
void setProjectionMatrix(SkRect& geometry);
+ void setBlendingState(bool enableBlending);
+
+ bool m_blendingEnabled;
+
int m_program;
int m_videoProgram;
diff --git a/WebCore/platform/graphics/android/TiledPage.cpp b/WebCore/platform/graphics/android/TiledPage.cpp
index 620aa6f..36988dd 100644
--- a/WebCore/platform/graphics/android/TiledPage.cpp
+++ b/WebCore/platform/graphics/android/TiledPage.cpp
@@ -49,8 +49,6 @@
#endif // DEBUG
-#define MAX_TILES 256
-
namespace WebCore {
using namespace android;
@@ -65,7 +63,7 @@ TiledPage::TiledPage(int id, GLWebViewState* state)
, m_latestPictureInval(0)
, m_prepare(false)
{
- m_baseTiles = new BaseTile[MAX_TILES];
+ m_baseTiles = new BaseTile[TilesManager::getMaxTextureAllocation() + 1];
#ifdef DEBUG_COUNT
ClassTracker::instance()->increment("TiledPage");
#endif
diff --git a/WebCore/platform/graphics/android/TilesManager.cpp b/WebCore/platform/graphics/android/TilesManager.cpp
index 571d9cc..a15e862 100644
--- a/WebCore/platform/graphics/android/TilesManager.cpp
+++ b/WebCore/platform/graphics/android/TilesManager.cpp
@@ -58,7 +58,7 @@
// at least 5 * 3 = 15 textures. We can also enable offscreen textures
#define EXPANDED_TILE_BOUNDS_X 1
#define EXPANDED_TILE_BOUNDS_Y 4
-#define MAX_TEXTURE_ALLOCATION (5+EXPANDED_TILE_BOUNDS_X*2)*(3+EXPANDED_TILE_BOUNDS_Y*2)*2
+#define MAX_TEXTURE_ALLOCATION (5+1+EXPANDED_TILE_BOUNDS_X*2)*(3+1+EXPANDED_TILE_BOUNDS_Y*2)*2
#define TILE_WIDTH 300
#define TILE_HEIGHT 300
@@ -78,11 +78,17 @@ GLint TilesManager::getMaxTextureSize()
return maxTextureSize;
}
+int TilesManager::getMaxTextureAllocation()
+{
+ return MAX_TEXTURE_ALLOCATION;
+}
+
TilesManager::TilesManager()
: m_layersMemoryUsage(0)
, m_maxTextureCount(0)
, m_expandedTileBounds(false)
, m_generatorReady(false)
+ , m_showVisualIndicator(false)
{
XLOG("TilesManager ctor");
m_textures.reserveCapacity(MAX_TEXTURE_ALLOCATION);
@@ -369,7 +375,8 @@ int TilesManager::maxTextureCount()
void TilesManager::setMaxTextureCount(int max)
{
XLOG("setMaxTextureCount: %d", max);
- if (m_maxTextureCount >= max && m_maxTextureCount)
+ if (max > MAX_TEXTURE_ALLOCATION ||
+ (m_maxTextureCount >= max && m_maxTextureCount))
return;
android::Mutex::Autolock lock(m_texturesLock);
diff --git a/WebCore/platform/graphics/android/TilesManager.h b/WebCore/platform/graphics/android/TilesManager.h
index eeb38fe..107b121 100644
--- a/WebCore/platform/graphics/android/TilesManager.h
+++ b/WebCore/platform/graphics/android/TilesManager.h
@@ -45,6 +45,7 @@ class TilesManager {
public:
static TilesManager* instance();
static GLint getMaxTextureSize();
+ static int getMaxTextureAllocation();
static bool hardwareAccelerationEnabled()
{
@@ -107,6 +108,14 @@ public:
m_expandedTileBounds = enabled;
}
+ bool getShowVisualIndicator() {
+ return m_showVisualIndicator;
+ }
+
+ void setShowVisualIndicator(bool showVisualIndicator) {
+ m_showVisualIndicator = showVisualIndicator;
+ }
+
private:
TilesManager();
@@ -128,6 +137,8 @@ private:
bool m_generatorReady;
+ bool m_showVisualIndicator;
+
sp<TexturesGenerator> m_pixmapsGenerationThread;
android::Mutex m_texturesLock;
diff --git a/WebCore/platform/graphics/android/android_graphics.cpp b/WebCore/platform/graphics/android/android_graphics.cpp
index c046858..e50cfec 100644
--- a/WebCore/platform/graphics/android/android_graphics.cpp
+++ b/WebCore/platform/graphics/android/android_graphics.cpp
@@ -109,14 +109,8 @@ void CursorRing::draw(SkCanvas* canvas, LayerAndroid* layer, IntRect* inval)
inval->unite(m_lastBounds);
}
-bool CursorRing::setup()
+void CursorRing::setIsButton(const CachedNode* node)
{
- m_node->localCursorRings(m_frame, &m_rings);
- if (!m_rings.size()) {
- DBG_NAV_LOG("!rings.size()");
- m_viewImpl->m_hasCursorBounds = false;
- return false;
- }
m_isButton = false;
m_viewImpl->gButtonMutex.lock();
// If this is a button drawn by us (rather than webkit) do not draw the
@@ -124,7 +118,7 @@ bool CursorRing::setup()
// Should be in sync with recordButtons, since that will be called
// before this.
if (m_viewImpl->m_buttons.size() > 0) {
- WebCore::Node* cursorPointer = (WebCore::Node*) m_node->nodePointer();
+ WebCore::Node* cursorPointer = (WebCore::Node*) node->nodePointer();
Container* end = m_viewImpl->m_buttons.end();
for (Container* ptr = m_viewImpl->m_buttons.begin(); ptr != end; ptr++) {
if (ptr->matches(cursorPointer)) {
@@ -134,6 +128,17 @@ bool CursorRing::setup()
}
}
m_viewImpl->gButtonMutex.unlock();
+}
+
+bool CursorRing::setup()
+{
+ m_node->localCursorRings(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_viewImpl->updateCursorBounds(m_root, m_frame, m_node);
diff --git a/WebCore/platform/graphics/android/android_graphics.h b/WebCore/platform/graphics/android/android_graphics.h
index 9f52a27..be309a6 100644
--- a/WebCore/platform/graphics/android/android_graphics.h
+++ b/WebCore/platform/graphics/android/android_graphics.h
@@ -54,6 +54,7 @@ public:
CursorRing(WebViewCore* core) : m_viewImpl(core) {}
virtual ~CursorRing() {}
virtual void draw(SkCanvas* , LayerAndroid* , IntRect* );
+ void setIsButton(const CachedNode* );
bool setup();
private:
friend class WebView;