summaryrefslogtreecommitdiffstats
path: root/Source/WebCore
diff options
context:
space:
mode:
Diffstat (limited to 'Source/WebCore')
-rw-r--r--Source/WebCore/platform/graphics/android/GLWebViewState.cpp2
-rw-r--r--Source/WebCore/platform/graphics/android/GraphicsLayerAndroid.cpp22
-rw-r--r--Source/WebCore/platform/graphics/android/GraphicsLayerAndroid.h1
-rw-r--r--Source/WebCore/platform/graphics/android/LayerAndroid.cpp24
-rw-r--r--Source/WebCore/platform/graphics/android/LayerAndroid.h2
-rw-r--r--Source/WebCore/platform/graphics/android/ScrollableLayerAndroid.h2
-rw-r--r--Source/WebCore/platform/graphics/android/ShaderProgram.cpp60
-rw-r--r--Source/WebCore/platform/graphics/android/ShaderProgram.h21
8 files changed, 89 insertions, 45 deletions
diff --git a/Source/WebCore/platform/graphics/android/GLWebViewState.cpp b/Source/WebCore/platform/graphics/android/GLWebViewState.cpp
index 8ced8dc..9f266d2 100644
--- a/Source/WebCore/platform/graphics/android/GLWebViewState.cpp
+++ b/Source/WebCore/platform/graphics/android/GLWebViewState.cpp
@@ -371,8 +371,6 @@ double GLWebViewState::setupDrawing(IntRect& viewRect, SkRect& visibleRect,
XLOG("Reinit shader");
shader->init();
}
- glUseProgram(shader->program());
- glUniform1i(shader->textureSampler(), 0);
shader->setViewRect(viewRect);
shader->setViewport(visibleRect);
shader->setWebViewRect(webViewRect);
diff --git a/Source/WebCore/platform/graphics/android/GraphicsLayerAndroid.cpp b/Source/WebCore/platform/graphics/android/GraphicsLayerAndroid.cpp
index 09a4bc6..eadac6b 100644
--- a/Source/WebCore/platform/graphics/android/GraphicsLayerAndroid.cpp
+++ b/Source/WebCore/platform/graphics/android/GraphicsLayerAndroid.cpp
@@ -120,7 +120,6 @@ GraphicsLayerAndroid::GraphicsLayerAndroid(GraphicsLayerClient* client) :
m_haveContents(false),
m_haveImage(false),
m_newImage(false),
- m_imageRef(0),
m_foregroundLayer(0),
m_foregroundClipLayer(0)
{
@@ -387,6 +386,7 @@ void GraphicsLayerAndroid::setDrawsContent(bool drawsContent)
if (drawsContent == m_drawsContent)
return;
GraphicsLayer::setDrawsContent(drawsContent);
+ m_contentLayer->setVisible(drawsContent);
if (m_drawsContent) {
m_haveContents = true;
setNeedsDisplay();
@@ -836,22 +836,14 @@ void GraphicsLayerAndroid::setContentsToImage(Image* image)
if (image) {
m_haveContents = true;
m_haveImage = true;
- // Only pass the new image if it's a different one
- if (image->nativeImageForCurrentFrame() != m_imageRef) {
- m_newImage = true;
- m_contentLayer->setContentsImage(image->nativeImageForCurrentFrame());
- // remember the passed image.
- m_imageRef = image->nativeImageForCurrentFrame();
- setNeedsDisplay();
- askForSync();
- }
+ m_newImage = true;
+ m_contentLayer->setContentsImage(image->nativeImageForCurrentFrame());
}
- if (m_haveImage && !image) {
+ if (m_haveImage && !image)
m_contentLayer->setContentsImage(0);
- m_imageRef = 0;
- setNeedsDisplay();
- askForSync();
- }
+
+ setNeedsDisplay();
+ askForSync();
}
void GraphicsLayerAndroid::setContentsToMedia(PlatformLayer* mediaLayer)
diff --git a/Source/WebCore/platform/graphics/android/GraphicsLayerAndroid.h b/Source/WebCore/platform/graphics/android/GraphicsLayerAndroid.h
index a693de3..af8d7ce 100644
--- a/Source/WebCore/platform/graphics/android/GraphicsLayerAndroid.h
+++ b/Source/WebCore/platform/graphics/android/GraphicsLayerAndroid.h
@@ -147,7 +147,6 @@ private:
bool m_haveContents;
bool m_haveImage;
bool m_newImage;
- SkBitmapRef* m_imageRef; // only used to remember previously passed images
SkRegion m_dirtyRegion;
diff --git a/Source/WebCore/platform/graphics/android/LayerAndroid.cpp b/Source/WebCore/platform/graphics/android/LayerAndroid.cpp
index 4e00a4b..91c44c6 100644
--- a/Source/WebCore/platform/graphics/android/LayerAndroid.cpp
+++ b/Source/WebCore/platform/graphics/android/LayerAndroid.cpp
@@ -778,6 +778,9 @@ bool LayerAndroid::updateWithTree(LayerAndroid* newTree)
return needsRepaint;
}
+// Return true to indicate to WebViewCore that the updates
+// are too complicated to be fully handled and we need a full
+// call to webkit (e.g. handle repaints)
bool LayerAndroid::updateWithLayer(LayerAndroid* layer)
{
if (!layer)
@@ -790,6 +793,9 @@ bool LayerAndroid::updateWithLayer(LayerAndroid* layer)
m_opacity = layer->m_opacity;
m_transform = layer->m_transform;
+ if (m_imageRef != layer->m_imageRef)
+ m_visible = false;
+
if ((m_recordingPicture != layer->m_recordingPicture)
|| (m_imageRef != layer->m_imageRef))
return true;
@@ -879,28 +885,28 @@ bool LayerAndroid::drawGL(GLWebViewState* glWebViewState, SkMatrix& matrix)
if (!m_visible)
return false;
- bool askPaint = false;
+ bool askScreenUpdate = false;
if (m_texture)
- askPaint |= m_texture->draw();
+ askScreenUpdate |= m_texture->draw();
if (m_imageTexture)
m_imageTexture->draw(this);
// When the layer is dirty, the UI thread should be notified to redraw.
- askPaint |= drawChildrenGL(glWebViewState, matrix);
+ askScreenUpdate |= drawChildrenGL(glWebViewState, matrix);
m_atomicSync.lock();
- askPaint |= m_dirty;
- if (askPaint || m_hasRunningAnimations || m_drawTransform.hasPerspective())
+ askScreenUpdate |= m_dirty;
+ if (askScreenUpdate || m_hasRunningAnimations || m_drawTransform.hasPerspective())
addDirtyArea(glWebViewState);
m_atomicSync.unlock();
- return askPaint;
+ return askScreenUpdate;
}
bool LayerAndroid::drawChildrenGL(GLWebViewState* glWebViewState, SkMatrix& matrix)
{
- bool askPaint = false;
+ bool askScreenUpdate = false;
int count = this->countChildren();
if (count > 0) {
Vector <LayerAndroid*> sublayers;
@@ -911,11 +917,11 @@ bool LayerAndroid::drawChildrenGL(GLWebViewState* glWebViewState, SkMatrix& matr
std::stable_sort(sublayers.begin(), sublayers.end(), compareLayerZ);
for (int i = 0; i < count; i++) {
LayerAndroid* layer = sublayers[i];
- askPaint |= layer->drawGL(glWebViewState, matrix);
+ askScreenUpdate |= layer->drawGL(glWebViewState, matrix);
}
}
- return askPaint;
+ return askScreenUpdate;
}
void LayerAndroid::extraDraw(SkCanvas* canvas)
diff --git a/Source/WebCore/platform/graphics/android/LayerAndroid.h b/Source/WebCore/platform/graphics/android/LayerAndroid.h
index cd52937..4458a2c 100644
--- a/Source/WebCore/platform/graphics/android/LayerAndroid.h
+++ b/Source/WebCore/platform/graphics/android/LayerAndroid.h
@@ -280,7 +280,7 @@ public:
// such as the position, the transform. Return true if anything more
// complex is needed.
bool updateWithTree(LayerAndroid*);
- bool updateWithLayer(LayerAndroid*);
+ virtual bool updateWithLayer(LayerAndroid*);
SkBitmapRef* imageRef() { return m_imageRef; }
ImageTexture* imageTexture() { return m_imageTexture; }
diff --git a/Source/WebCore/platform/graphics/android/ScrollableLayerAndroid.h b/Source/WebCore/platform/graphics/android/ScrollableLayerAndroid.h
index a2486a5..5cba5d9 100644
--- a/Source/WebCore/platform/graphics/android/ScrollableLayerAndroid.h
+++ b/Source/WebCore/platform/graphics/android/ScrollableLayerAndroid.h
@@ -42,6 +42,8 @@ public:
virtual LayerAndroid* copy() const { return new ScrollableLayerAndroid(*this); }
+ virtual bool updateWithLayer(LayerAndroid*) { return true; }
+
// Scrolls to the given position in the layer.
// Returns whether or not any scrolling was required.
bool scrollTo(int x, int y);
diff --git a/Source/WebCore/platform/graphics/android/ShaderProgram.cpp b/Source/WebCore/platform/graphics/android/ShaderProgram.cpp
index 857623a..797da52 100644
--- a/Source/WebCore/platform/graphics/android/ShaderProgram.cpp
+++ b/Source/WebCore/platform/graphics/android/ShaderProgram.cpp
@@ -62,6 +62,22 @@ static const char gFragmentShader[] =
" gl_FragColor *= alpha; "
"}\n";
+static const char gFragmentShaderInverted[] =
+ "precision mediump float;\n"
+ "varying vec2 v_texCoord; \n"
+ "uniform float alpha; \n"
+ "uniform float contrast; \n"
+ "uniform sampler2D s_texture; \n"
+ "void main() {\n"
+ " vec4 pixel = texture2D(s_texture, v_texCoord); \n"
+ " float a = pixel.a; \n"
+ " float color = a - (0.2989 * pixel.r + 0.5866 * pixel.g + 0.1145 * pixel.b);\n"
+ " color = ((color - a/2.0) * contrast) + a/2.0; \n"
+ " pixel.rgb = vec3(color, color, color); \n "
+ " gl_FragColor = pixel; \n"
+ " gl_FragColor *= alpha; \n"
+ "}\n";
+
static const char gVideoVertexShader[] =
"attribute vec4 vPosition;\n"
"uniform mat4 textureMatrix;\n"
@@ -186,6 +202,7 @@ ShaderProgram::ShaderProgram()
void ShaderProgram::init()
{
m_program = createProgram(gVertexShader, gFragmentShader);
+ m_programInverted = createProgram(gVertexShader, gFragmentShaderInverted);
m_videoProgram = createProgram(gVideoVertexShader, gVideoFragmentShader);
m_surfTexOESProgram =
createProgram(gVertexShader, gSurfaceTextureOESFragmentShader);
@@ -193,6 +210,7 @@ void ShaderProgram::init()
createProgram(gVertexShader, gSurfaceTextureOESFragmentShaderInverted);
if (m_program == -1
+ || m_programInverted == -1
|| m_videoProgram == -1
|| m_surfTexOESProgram == -1
|| m_surfTexOESProgramInverted == -1)
@@ -203,6 +221,12 @@ void ShaderProgram::init()
m_hTexSampler = glGetUniformLocation(m_program, "s_texture");
m_hPosition = glGetAttribLocation(m_program, "vPosition");
+ m_hProjectionMatrixInverted = glGetUniformLocation(m_programInverted, "projectionMatrix");
+ m_hAlphaInverted = glGetUniformLocation(m_programInverted, "alpha");
+ m_hContrastInverted = glGetUniformLocation(m_surfTexOESProgramInverted, "contrast");
+ m_hTexSamplerInverted = glGetUniformLocation(m_programInverted, "s_texture");
+ m_hPositionInverted = glGetAttribLocation(m_programInverted, "vPosition");
+
m_hVideoProjectionMatrix =
glGetUniformLocation(m_videoProgram, "projectionMatrix");
m_hVideoTextureMatrix = glGetUniformLocation(m_videoProgram, "textureMatrix");
@@ -334,10 +358,22 @@ void ShaderProgram::drawQuad(SkRect& geometry, int textureId, float opacity,
GLenum textureTarget, GLint texFilter)
{
if (textureTarget == GL_TEXTURE_2D) {
- drawQuadInternal(geometry, textureId, opacity, m_program,
- m_hProjectionMatrix,
- m_hTexSampler, GL_TEXTURE_2D,
- m_hPosition, alpha(), texFilter);
+ if (!TilesManager::instance()->invertedScreen()) {
+ drawQuadInternal(geometry, textureId, opacity, m_program,
+ m_hProjectionMatrix,
+ m_hTexSampler, GL_TEXTURE_2D,
+ m_hPosition, m_hAlpha, texFilter);
+ } else {
+ // With the new GPU texture upload path, we do not use an FBO
+ // to blit the texture we receive from the TexturesGenerator thread.
+ // To implement inverted rendering, we thus have to do the rendering
+ // live, by using a different shader.
+ drawQuadInternal(geometry, textureId, opacity, m_programInverted,
+ m_hProjectionMatrixInverted,
+ m_hTexSamplerInverted, GL_TEXTURE_2D,
+ m_hPositionInverted, m_hAlphaInverted, texFilter,
+ m_hContrastInverted);
+ }
} else if (textureTarget == GL_TEXTURE_EXTERNAL_OES
&& !TilesManager::instance()->invertedScreen()) {
drawQuadInternal(geometry, textureId, opacity, m_surfTexOESProgram,
@@ -520,10 +556,18 @@ void ShaderProgram::drawLayerQuad(const TransformationMatrix& drawMatrix,
GLfloat projectionMatrix[16];
GLUtils::toGLMatrix(projectionMatrix, renderMatrix);
if (textureTarget == GL_TEXTURE_2D) {
- drawLayerQuadInternal(projectionMatrix, textureId, opacity,
- GL_TEXTURE_2D, m_program,
- m_hProjectionMatrix, m_hTexSampler,
- m_hPosition, alpha());
+ if (!TilesManager::instance()->invertedScreen()) {
+ drawLayerQuadInternal(projectionMatrix, textureId, opacity,
+ GL_TEXTURE_2D, m_program,
+ m_hProjectionMatrix, m_hTexSampler,
+ m_hPosition, m_hAlpha);
+ } else {
+ drawLayerQuadInternal(projectionMatrix, textureId, opacity,
+ GL_TEXTURE_2D, m_programInverted,
+ m_hProjectionMatrixInverted, m_hTexSamplerInverted,
+ m_hPositionInverted, m_hAlphaInverted,
+ m_hContrastInverted);
+ }
} else if (textureTarget == GL_TEXTURE_EXTERNAL_OES
&& !TilesManager::instance()->invertedScreen()) {
drawLayerQuadInternal(projectionMatrix, textureId, opacity,
diff --git a/Source/WebCore/platform/graphics/android/ShaderProgram.h b/Source/WebCore/platform/graphics/android/ShaderProgram.h
index 5f5ce9f..bfb1fb6 100644
--- a/Source/WebCore/platform/graphics/android/ShaderProgram.h
+++ b/Source/WebCore/platform/graphics/android/ShaderProgram.h
@@ -33,9 +33,6 @@ class ShaderProgram {
public:
ShaderProgram();
void init();
- int projectionMatrix() { return m_hProjectionMatrix; }
- int alpha() { return m_hAlpha; }
- int textureSampler() { return m_hTexSampler; }
int program() { return m_program; }
// Drawing
@@ -111,6 +108,7 @@ private:
bool m_blendingEnabled;
int m_program;
+ int m_programInverted;
int m_videoProgram;
int m_surfTexOESProgram;
int m_surfTexOESProgramInverted;
@@ -128,12 +126,16 @@ private:
IntRect m_webViewRect;
// uniforms
- int m_hProjectionMatrix;
- int m_hAlpha;
- int m_hTexSampler;
- int m_hVideoProjectionMatrix;
- int m_hVideoTextureMatrix;
- int m_hVideoTexSampler;
+ GLint m_hProjectionMatrix;
+ GLint m_hAlpha;
+ GLint m_hTexSampler;
+ GLint m_hProjectionMatrixInverted;
+ GLint m_hAlphaInverted;
+ GLint m_hContrastInverted;
+ GLint m_hTexSamplerInverted;
+ GLint m_hVideoProjectionMatrix;
+ GLint m_hVideoTextureMatrix;
+ GLint m_hVideoTexSampler;
GLint m_hSTOESProjectionMatrix;
GLint m_hSTOESAlpha;
@@ -150,6 +152,7 @@ private:
// attribs
GLint m_hPosition;
+ GLint m_hPositionInverted;
GLint m_hVideoPosition;
};