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.cpp4
-rw-r--r--WebCore/platform/graphics/android/BaseTile.cpp26
-rw-r--r--WebCore/platform/graphics/android/GLWebViewState.cpp6
-rw-r--r--WebCore/platform/graphics/android/GLWebViewState.h7
-rw-r--r--WebCore/platform/graphics/android/GraphicsLayerAndroid.cpp4
-rw-r--r--WebCore/platform/graphics/android/LayerAndroid.cpp39
-rw-r--r--WebCore/platform/graphics/android/MediaLayer.cpp32
-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/TilesManager.cpp21
-rw-r--r--WebCore/platform/graphics/android/TilesManager.h10
12 files changed, 134 insertions, 65 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 35c3b36..584add1 100644
--- a/WebCore/platform/graphics/android/BaseLayerAndroid.cpp
+++ b/WebCore/platform/graphics/android/BaseLayerAndroid.cpp
@@ -263,12 +263,11 @@ bool BaseLayerAndroid::drawGL(IntRect& viewRect, SkRect& visibleRect,
XLOG("drawBasePicture drawGL() viewRect: %d, %d, %d, %d",
left, top, width, height);
+ m_glWebViewState->setBackgroundColor(color);
glClearColor((float)m_color.red() / 255.0,
(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();
@@ -280,6 +279,7 @@ bool BaseLayerAndroid::drawGL(IntRect& viewRect, SkRect& visibleRect,
glUniform1i(shader->textureSampler(), 0);
shader->setViewRect(viewRect);
shader->setViewport(visibleRect);
+ shader->resetBlending();
double currentTime = WTF::currentTime();
ret = drawBasePictureInGL(visibleRect, scale, currentTime);
diff --git a/WebCore/platform/graphics/android/BaseTile.cpp b/WebCore/platform/graphics/android/BaseTile.cpp
index e5275c6..bfd5118 100644
--- a/WebCore/platform/graphics/android/BaseTile.cpp
+++ b/WebCore/platform/graphics/android/BaseTile.cpp
@@ -257,7 +257,7 @@ void BaseTile::paintBitmap()
SkCanvas* canvas = texture->canvas();
canvas->save();
- canvas->drawARGB(0, 0, 0, 0, SkXfermode::kClear_Mode);
+ canvas->drawColor(tiledPage->glWebViewState()->getBackgroundColor());
canvas->scale(scale, scale);
canvas->translate(-x * w, -y * h);
@@ -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 53d5c5e..3d2f6c8 100644
--- a/WebCore/platform/graphics/android/GLWebViewState.cpp
+++ b/WebCore/platform/graphics/android/GLWebViewState.cpp
@@ -68,6 +68,7 @@ GLWebViewState::GLWebViewState(android::Mutex* buttonMutex)
, m_usePageA(true)
, m_globalButtonMutex(buttonMutex)
, m_baseLayerUpdate(true)
+ , m_backgroundColor(SK_ColorWHITE)
{
m_viewport.setEmpty();
m_previousViewport.setEmpty();
@@ -92,7 +93,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 +115,8 @@ void GLWebViewState::setBaseLayer(BaseLayerAndroid* layer, const IntRect& rect)
m_currentBaseLayer = layer;
}
inval(rect);
+
+ TilesManager::instance()->setShowVisualIndicator(showVisualIndicator);
}
void GLWebViewState::unlockBaseLayerUpdate() {
diff --git a/WebCore/platform/graphics/android/GLWebViewState.h b/WebCore/platform/graphics/android/GLWebViewState.h
index d28c16a..d265b41 100644
--- a/WebCore/platform/graphics/android/GLWebViewState.h
+++ b/WebCore/platform/graphics/android/GLWebViewState.h
@@ -168,7 +168,7 @@ public:
void resetTransitionTime() { m_transitionTime = -1; }
unsigned int paintBaseLayerContent(SkCanvas* canvas);
- void setBaseLayer(BaseLayerAndroid* layer, const IntRect& rect);
+ 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);
@@ -208,6 +208,9 @@ public:
bool drawGL(IntRect& rect, SkRect& viewport,
float scale, SkColor color = SK_ColorWHITE);
+ void setBackgroundColor(SkColor color) { m_backgroundColor = color; }
+ SkColor getBackgroundColor() { return m_backgroundColor; }
+
private:
void inval(const IntRect& rect); // caller must hold m_baseLayerLock
@@ -247,6 +250,8 @@ private:
bool m_baseLayerUpdate;
IntRect m_invalidateRect;
+
+ SkColor m_backgroundColor;
};
} // namespace WebCore
diff --git a/WebCore/platform/graphics/android/GraphicsLayerAndroid.cpp b/WebCore/platform/graphics/android/GraphicsLayerAndroid.cpp
index 49f20ab..ccc872a 100644
--- a/WebCore/platform/graphics/android/GraphicsLayerAndroid.cpp
+++ b/WebCore/platform/graphics/android/GraphicsLayerAndroid.cpp
@@ -467,7 +467,7 @@ void GraphicsLayerAndroid::updateScrollingLayers()
{
#if ENABLE(ANDROID_OVERFLOW_SCROLL)
RenderLayer* layer = renderLayerFromClient(m_client);
- if (!layer)
+ if (!layer || !m_haveContents)
return;
bool hasOverflowScroll = m_foregroundLayer || m_contentLayer->contentIsScrollable();
bool layerNeedsOverflow = layer->hasOverflowScroll();
@@ -508,7 +508,6 @@ void GraphicsLayerAndroid::updateScrollingLayers()
}
// Need to rebuild our children based on the new structure.
m_needsSyncChildren = true;
- askForSync();
} else {
ASSERT(hasOverflowScroll && !layerNeedsOverflow && !iframeNeedsOverflow);
ASSERT(m_contentLayer);
@@ -531,7 +530,6 @@ void GraphicsLayerAndroid::updateScrollingLayers()
}
// Children are all re-parented.
m_needsSyncChildren = true;
- askForSync();
}
#endif
}
diff --git a/WebCore/platform/graphics/android/LayerAndroid.cpp b/WebCore/platform/graphics/android/LayerAndroid.cpp
index 7375cba..35979f6 100644
--- a/WebCore/platform/graphics/android/LayerAndroid.cpp
+++ b/WebCore/platform/graphics/android/LayerAndroid.cpp
@@ -868,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();
}
@@ -991,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/MediaLayer.cpp b/WebCore/platform/graphics/android/MediaLayer.cpp
index 7a4c02d..d8bbefc 100644
--- a/WebCore/platform/graphics/android/MediaLayer.cpp
+++ b/WebCore/platform/graphics/android/MediaLayer.cpp
@@ -78,32 +78,34 @@ bool MediaLayer::drawGL(SkMatrix& matrix)
// draw any video content if present
m_videoTexture->drawVideo(drawTransform());
- bool needsInval = true;
-
// draw the primary content
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 (!rect.isEmpty())
- needsInval = false;
+
+ 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);
+ }
}
m_bufferedTexture->consumerRelease();
}
- return drawChildrenGL(matrix) || needsInval;
+ return drawChildrenGL(matrix);
}
ANativeWindow* MediaLayer::acquireNativeWindowForVideo()
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/TilesManager.cpp b/WebCore/platform/graphics/android/TilesManager.cpp
index 0fb3b1b..16fb782 100644
--- a/WebCore/platform/graphics/android/TilesManager.cpp
+++ b/WebCore/platform/graphics/android/TilesManager.cpp
@@ -55,10 +55,11 @@
// We need n textures for one TiledPage, and another n textures for the
// second page used when scaling.
// In our case, we use 300x300 textures. On the tablet, this equates to
-// at least 5 * 3 = 15 textures. We can also enable offscreen textures
+// at least 5 * 3 = 15 textures. We also enable offscreen textures to a maximum
+// of 154 textures used (i.e. ~106Mb max, accounting for the double buffer textures)
#define EXPANDED_TILE_BOUNDS_X 1
#define EXPANDED_TILE_BOUNDS_Y 4
-#define MAX_TEXTURE_ALLOCATION (5+1+EXPANDED_TILE_BOUNDS_X*2)*(3+1+EXPANDED_TILE_BOUNDS_Y*2)*2
+#define MAX_TEXTURE_ALLOCATION (5+EXPANDED_TILE_BOUNDS_X*2)*(3+EXPANDED_TILE_BOUNDS_Y*2)*2
#define TILE_WIDTH 300
#define TILE_HEIGHT 300
@@ -88,6 +89,7 @@ TilesManager::TilesManager()
, m_maxTextureCount(0)
, m_expandedTileBounds(false)
, m_generatorReady(false)
+ , m_showVisualIndicator(false)
{
XLOG("TilesManager ctor");
m_textures.reserveCapacity(MAX_TEXTURE_ALLOCATION);
@@ -373,13 +375,20 @@ int TilesManager::maxTextureCount()
void TilesManager::setMaxTextureCount(int max)
{
- XLOG("setMaxTextureCount: %d", max);
- if (max > MAX_TEXTURE_ALLOCATION ||
- (m_maxTextureCount >= max && m_maxTextureCount))
+ XLOG("setMaxTextureCount: %d (current: %d, total:%d)",
+ max, m_maxTextureCount, MAX_TEXTURE_ALLOCATION);
+ if (m_maxTextureCount &&
+ (max > MAX_TEXTURE_ALLOCATION ||
+ max <= m_maxTextureCount))
return;
android::Mutex::Autolock lock(m_texturesLock);
- m_maxTextureCount = max;
+
+ if (max < MAX_TEXTURE_ALLOCATION)
+ m_maxTextureCount = max;
+ else
+ m_maxTextureCount = MAX_TEXTURE_ALLOCATION;
+
allocateTiles();
}
diff --git a/WebCore/platform/graphics/android/TilesManager.h b/WebCore/platform/graphics/android/TilesManager.h
index 29b7fc1..107b121 100644
--- a/WebCore/platform/graphics/android/TilesManager.h
+++ b/WebCore/platform/graphics/android/TilesManager.h
@@ -108,6 +108,14 @@ public:
m_expandedTileBounds = enabled;
}
+ bool getShowVisualIndicator() {
+ return m_showVisualIndicator;
+ }
+
+ void setShowVisualIndicator(bool showVisualIndicator) {
+ m_showVisualIndicator = showVisualIndicator;
+ }
+
private:
TilesManager();
@@ -129,6 +137,8 @@ private:
bool m_generatorReady;
+ bool m_showVisualIndicator;
+
sp<TexturesGenerator> m_pixmapsGenerationThread;
android::Mutex m_texturesLock;