summaryrefslogtreecommitdiffstats
path: root/Source/WebCore
diff options
context:
space:
mode:
Diffstat (limited to 'Source/WebCore')
-rw-r--r--Source/WebCore/platform/graphics/android/CanvasLayer.cpp6
-rw-r--r--Source/WebCore/platform/graphics/android/DrawQuadData.h172
-rw-r--r--Source/WebCore/platform/graphics/android/GLExtras.cpp10
-rw-r--r--Source/WebCore/platform/graphics/android/GLUtils.cpp1
-rw-r--r--Source/WebCore/platform/graphics/android/MediaTexture.cpp10
-rw-r--r--Source/WebCore/platform/graphics/android/ShaderProgram.cpp111
-rw-r--r--Source/WebCore/platform/graphics/android/ShaderProgram.h45
-rw-r--r--Source/WebCore/platform/graphics/android/Surface.cpp2
-rw-r--r--Source/WebCore/platform/graphics/android/Tile.cpp5
-rw-r--r--Source/WebCore/platform/graphics/android/Tile.h3
-rw-r--r--Source/WebCore/platform/graphics/android/TileGrid.cpp19
-rw-r--r--Source/WebCore/platform/graphics/android/TileTexture.cpp33
-rw-r--r--Source/WebCore/platform/graphics/android/TileTexture.h2
-rw-r--r--Source/WebCore/platform/graphics/android/TransferQueue.cpp8
-rw-r--r--Source/WebCore/platform/graphics/android/VideoLayerAndroid.cpp48
15 files changed, 324 insertions, 151 deletions
diff --git a/Source/WebCore/platform/graphics/android/CanvasLayer.cpp b/Source/WebCore/platform/graphics/android/CanvasLayer.cpp
index 5409fef..1813903 100644
--- a/Source/WebCore/platform/graphics/android/CanvasLayer.cpp
+++ b/Source/WebCore/platform/graphics/android/CanvasLayer.cpp
@@ -33,6 +33,7 @@
#include "AndroidLog.h"
#include "CanvasTexture.h"
+#include "DrawQuadData.h"
#include "Image.h"
#include "ImageBuffer.h"
#include "RenderLayerCompositor.h"
@@ -200,8 +201,9 @@ bool CanvasLayer::drawGL(bool layerTilesDisabled)
SkRect rect = SkRect::MakeXYWH(m_contentRect.x() - m_offsetFromRenderer.width(),
m_contentRect.y() - m_offsetFromRenderer.height(),
m_contentRect.width(), m_contentRect.height());
- TilesManager::instance()->shader()->drawLayerQuad(m_drawTransform, rect,
- m_texture->texture(), 1, true, GL_TEXTURE_EXTERNAL_OES);
+ TextureQuadData data(m_texture->texture(), GL_TEXTURE_EXTERNAL_OES,
+ GL_LINEAR, LayerQuad, &m_drawTransform, &rect);
+ TilesManager::instance()->shader()->drawQuad(&data);
}
return ret;
}
diff --git a/Source/WebCore/platform/graphics/android/DrawQuadData.h b/Source/WebCore/platform/graphics/android/DrawQuadData.h
new file mode 100644
index 0000000..687808d
--- /dev/null
+++ b/Source/WebCore/platform/graphics/android/DrawQuadData.h
@@ -0,0 +1,172 @@
+/*
+ * Copyright 2012, 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 DrawQuadData_h
+#define DrawQuadData_h
+
+#if USE(ACCELERATED_COMPOSITING)
+
+#include "Color.h"
+#include "SkRect.h"
+#include <GLES2/gl2.h>
+
+namespace WebCore {
+
+class TransformationMatrix;
+
+enum DrawQuadType {
+ BaseQuad,
+ LayerQuad,
+ Blit // 1:1 straight pixel blit
+};
+
+// Both PureColorQuadData and TextureQuadData share the data from DrawQuadData.
+class DrawQuadData {
+public:
+ DrawQuadData(DrawQuadType type = BaseQuad,
+ const TransformationMatrix* drawMatrix = 0,
+ const SkRect* geometry = 0,
+ float opacity = 1.0f,
+ bool forceBlending = true)
+ : m_type(type)
+ , m_drawMatrix(drawMatrix)
+ , m_geometry(geometry)
+ , m_opacity(opacity)
+ , m_forceBlending(forceBlending)
+ {
+ }
+
+ DrawQuadData(const DrawQuadData& data)
+ : m_type(data.m_type)
+ , m_drawMatrix(data.m_drawMatrix)
+ , m_geometry(data.m_geometry)
+ , m_opacity(data.m_opacity)
+ , m_forceBlending(data.m_forceBlending)
+ {
+ }
+
+ virtual ~DrawQuadData() {};
+
+ DrawQuadType type() const { return m_type; }
+ const TransformationMatrix* drawMatrix() const { return m_drawMatrix; }
+ const SkRect* geometry() const { return m_geometry; }
+ float opacity() const { return m_opacity; }
+ bool forceBlending() const { return m_forceBlending; }
+
+ void updateDrawMatrix(TransformationMatrix* matrix) { m_drawMatrix = matrix; }
+ void updateGeometry(SkRect* rect) { m_geometry = rect; }
+ void updateOpacity(float opacity) { m_opacity = opacity; }
+
+ virtual bool pureColor() const { return false; }
+
+ virtual Color quadColor() const { return Color(); }
+
+ virtual int textureId() const { return 0; }
+ virtual GLint textureFilter() const { return 0; }
+ virtual GLenum textureTarget() const { return 0; }
+
+private:
+ DrawQuadType m_type;
+ const TransformationMatrix* m_drawMatrix;
+ const SkRect* m_geometry;
+ float m_opacity;
+ bool m_forceBlending;
+};
+
+class PureColorQuadData : public DrawQuadData {
+public:
+ PureColorQuadData(Color color,
+ DrawQuadType type = BaseQuad,
+ const TransformationMatrix* drawMatrix = 0,
+ const SkRect* geometry = 0,
+ float opacity = 1.0f,
+ bool forceBlending = true)
+ : DrawQuadData(type, drawMatrix, geometry, opacity, forceBlending)
+ {
+ m_quadColor = color;
+ }
+
+ PureColorQuadData(const DrawQuadData& data, Color color)
+ : DrawQuadData(data)
+ {
+ m_quadColor = color;
+ }
+
+ virtual ~PureColorQuadData() {};
+ virtual bool pureColor() const { return true; }
+ virtual Color quadColor() const { return m_quadColor; }
+ void updateColor(const Color& color) { m_quadColor = color; }
+
+private:
+ Color m_quadColor;
+};
+
+class TextureQuadData : public DrawQuadData {
+public:
+ TextureQuadData(int textureId,
+ GLenum textureTarget = GL_TEXTURE_2D,
+ GLint textureFilter = GL_LINEAR,
+ DrawQuadType type = BaseQuad,
+ const TransformationMatrix* drawMatrix = 0,
+ const SkRect* geometry = 0,
+ float opacity = 1.0f,
+ bool forceBlending = true)
+ : DrawQuadData(type, drawMatrix, geometry, opacity, forceBlending)
+ {
+ m_textureId = textureId;
+ m_textureTarget = textureTarget;
+ m_textureFilter = textureFilter;
+ }
+
+ TextureQuadData(const DrawQuadData& data,
+ int textureId,
+ GLenum textureTarget = GL_TEXTURE_2D,
+ GLint textureFilter = GL_LINEAR)
+ : DrawQuadData(data)
+ {
+ m_textureId = textureId;
+ m_textureTarget = textureTarget;
+ m_textureFilter = textureFilter;
+ }
+
+ virtual ~TextureQuadData() {};
+ virtual bool pureColor() const { return false; }
+
+ virtual int textureId() const { return m_textureId; }
+ virtual GLint textureFilter() const { return m_textureFilter; }
+ virtual GLenum textureTarget() const { return m_textureTarget; }
+
+ void updateTextureId(int newId) { m_textureId = newId; }
+
+private:
+ int m_textureId;
+ GLint m_textureFilter;
+ GLenum m_textureTarget;
+};
+
+} // namespace WebCore
+
+#endif // USE(ACCELERATED_COMPOSITING)
+#endif // DrawQuadData_h
diff --git a/Source/WebCore/platform/graphics/android/GLExtras.cpp b/Source/WebCore/platform/graphics/android/GLExtras.cpp
index 1b283c2..6498ecf 100644
--- a/Source/WebCore/platform/graphics/android/GLExtras.cpp
+++ b/Source/WebCore/platform/graphics/android/GLExtras.cpp
@@ -30,6 +30,7 @@
#include "AndroidLog.h"
#include "DrawExtra.h"
+#include "DrawQuadData.h"
#include "GLExtras.h"
#include "IntRect.h"
#include "SkPath.h"
@@ -62,11 +63,10 @@ void GLExtras::drawRing(SkRect& srcRect, Color color, const TransformationMatrix
// double applied
Color colorWithoutAlpha(0xFF000000 | color.rgb());
float alpha = color.alpha() / (float) 255;
- if (drawMat) {
- TilesManager::instance()->shader()->drawLayerQuad(*drawMat, srcRect, 0,
- alpha, false, 0, colorWithoutAlpha);
- } else
- TilesManager::instance()->shader()->drawQuad(srcRect, 0, alpha, colorWithoutAlpha);
+
+ PureColorQuadData data(colorWithoutAlpha, drawMat ? LayerQuad : BaseQuad,
+ drawMat, &srcRect, alpha, false);
+ TilesManager::instance()->shader()->drawQuad(&data);
}
void GLExtras::drawRegion(const SkRegion& region, bool fill, bool drawBorder,
diff --git a/Source/WebCore/platform/graphics/android/GLUtils.cpp b/Source/WebCore/platform/graphics/android/GLUtils.cpp
index 1f5a23d..26bd55d 100644
--- a/Source/WebCore/platform/graphics/android/GLUtils.cpp
+++ b/Source/WebCore/platform/graphics/android/GLUtils.cpp
@@ -33,7 +33,6 @@
#include "AndroidLog.h"
#include "BaseRenderer.h"
-#include "ShaderProgram.h"
#include "TextureInfo.h"
#include "Tile.h"
#include "TilesManager.h"
diff --git a/Source/WebCore/platform/graphics/android/MediaTexture.cpp b/Source/WebCore/platform/graphics/android/MediaTexture.cpp
index faa20a1..dffe6c2 100644
--- a/Source/WebCore/platform/graphics/android/MediaTexture.cpp
+++ b/Source/WebCore/platform/graphics/android/MediaTexture.cpp
@@ -21,6 +21,7 @@
#include "MediaTexture.h"
#include "AndroidLog.h"
+#include "DrawQuadData.h"
#include "TilesManager.h"
#include "GLUtils.h"
#include "MediaListener.h"
@@ -176,11 +177,10 @@ void MediaTexture::draw(const TransformationMatrix& contentMatrix,
PIXEL_FORMAT_RGB_888 == f ||
PIXEL_FORMAT_RGB_565 == f);
- TilesManager::instance()->shader()->drawLayerQuad(contentMatrix,
- mediaBounds,
- m_contentTexture->textureId,
- 1.0f, forceAlphaBlending,
- GL_TEXTURE_EXTERNAL_OES);
+ TextureQuadData data(m_contentTexture->textureId, GL_TEXTURE_EXTERNAL_OES,
+ GL_LINEAR, LayerQuad, &contentMatrix, &mediaBounds,
+ 1.0f, forceAlphaBlending);
+ TilesManager::instance()->shader()->drawQuad(&data);
}
ANativeWindow* MediaTexture::requestNativeWindowForVideo()
diff --git a/Source/WebCore/platform/graphics/android/ShaderProgram.cpp b/Source/WebCore/platform/graphics/android/ShaderProgram.cpp
index 257e68f..a0d9e56 100644
--- a/Source/WebCore/platform/graphics/android/ShaderProgram.cpp
+++ b/Source/WebCore/platform/graphics/android/ShaderProgram.cpp
@@ -32,6 +32,7 @@
#if USE(ACCELERATED_COMPOSITING)
#include "AndroidLog.h"
+#include "DrawQuadData.h"
#include "FloatPoint3D.h"
#include "GLUtils.h"
#include "TilesManager.h"
@@ -423,24 +424,6 @@ void ShaderProgram::setupDrawing(const IntRect& viewRect, const SkRect& visibleR
resetBlending();
}
-// Calculate the matrix given the geometry.
-void ShaderProgram::setProjectionMatrix(const SkRect& geometry, GLfloat* mtxPtr)
-{
- TransformationMatrix translate;
- translate.translate3d(geometry.fLeft, geometry.fTop, 0.0);
- TransformationMatrix scale;
- scale.scale3d(geometry.width(), geometry.height(), 1.0);
-
- TransformationMatrix total;
- if (!m_alphaLayer)
- total = m_projectionMatrix * m_repositionMatrix * m_webViewMatrix
- * translate * scale;
- else
- total = m_projectionMatrix * translate * scale;
-
- GLUtils::toGLMatrix(mtxPtr, total);
-}
-
// Calculate the right color value sent into the shader considering the (0,1)
// clamp and alpha blending.
Color ShaderProgram::shaderColor(Color pureColor, float opacity)
@@ -482,33 +465,6 @@ ShaderType ShaderProgram::getTextureShaderType(GLenum textureTarget)
return type;
}
-void ShaderProgram::drawQuad(const SkRect& geometry, int textureId, float opacity,
- Color pureColor, GLenum textureTarget, GLint texFilter)
-{
- ShaderType type = UndefinedShader;
- if (!textureId) {
- pureColor = shaderColor(pureColor, opacity);
- if (pureColor.rgb() == Color::transparent && opacity < 1.0)
- return;
- type = PureColor;
- } else
- type = getTextureShaderType(textureTarget);
-
- if (type != UndefinedShader) {
- // The matrix is either for the transfer queue or the tiles
- GLfloat* finalMatrix = m_transferProjMtx;
- GLfloat projectionMatrix[16];
- if (!geometry.isEmpty()) {
- setProjectionMatrix(geometry, projectionMatrix);
- finalMatrix = projectionMatrix;
- }
- setBlendingState(opacity < 1.0 || pureColor.hasAlpha());
- drawQuadInternal(type, finalMatrix, textureId, opacity, textureTarget,
- texFilter, pureColor);
- }
- GLUtils::checkGlError("drawQuad");
-}
-
// This function transform a clip rect extracted from the current layer
// into a clip rect in screen coordinates -- used by the clipping rects
FloatRect ShaderProgram::rectInScreenCoord(const TransformationMatrix& drawMatrix, const IntSize& size)
@@ -642,16 +598,20 @@ void ShaderProgram::drawQuadInternal(ShaderType type, const GLfloat* matrix,
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
}
-void ShaderProgram::drawLayerQuad(const TransformationMatrix& drawMatrix,
- const SkRect& geometry, int textureId,
- float opacity, bool forceBlending,
- GLenum textureTarget,
- Color pureColor)
+// Calculate the matrix given the geometry.
+GLfloat* ShaderProgram::getProjectionMatrix(const DrawQuadData* data)
{
- TransformationMatrix modifiedDrawMatrix = drawMatrix;
+ DrawQuadType type = data->type();
+ const TransformationMatrix* matrix = data->drawMatrix();
+ const SkRect* geometry = data->geometry();
+ if (type == Blit)
+ return m_transferProjMtx;
+ TransformationMatrix modifiedDrawMatrix;
+ if (type == LayerQuad)
+ modifiedDrawMatrix = *matrix;
// move the drawing depending on where the texture is on the layer
- modifiedDrawMatrix.translate(geometry.fLeft, geometry.fTop);
- modifiedDrawMatrix.scale3d(geometry.width(), geometry.height(), 1);
+ modifiedDrawMatrix.translate(geometry->fLeft, geometry->fTop);
+ modifiedDrawMatrix.scale3d(geometry->width(), geometry->height(), 1);
TransformationMatrix renderMatrix;
if (!m_alphaLayer)
@@ -660,26 +620,39 @@ void ShaderProgram::drawLayerQuad(const TransformationMatrix& drawMatrix,
else
renderMatrix = m_projectionMatrix * modifiedDrawMatrix;
- GLfloat projectionMatrix[16];
- GLUtils::toGLMatrix(projectionMatrix, renderMatrix);
+ GLUtils::toGLMatrix(m_tileProjMatrix, renderMatrix);
+ return m_tileProjMatrix;
+}
+
+void ShaderProgram::drawQuad(const DrawQuadData* data)
+{
+ GLfloat* matrix = getProjectionMatrix(data);
+
+ float opacity = data->opacity();
+ bool forceBlending = data->forceBlending();
bool enableBlending = forceBlending || opacity < 1.0;
- ShaderType type = UndefinedShader;
- if (!textureId) {
- pureColor = shaderColor(pureColor, opacity);
- if (pureColor.rgb() == Color::transparent && enableBlending)
+ ShaderType shaderType = UndefinedShader;
+ int textureId = 0;
+ GLint textureFilter = 0;
+ GLenum textureTarget = 0;
+
+ Color quadColor = data->quadColor();
+ if (data->pureColor()) {
+ shaderType = PureColor;
+ quadColor = shaderColor(quadColor, opacity);
+ enableBlending = enableBlending || quadColor.hasAlpha();
+ if (!quadColor.alpha() && enableBlending)
return;
- type = PureColor;
- } else
- type = getTextureShaderType(textureTarget);
-
- if (type != UndefinedShader) {
- setBlendingState(enableBlending);
- drawQuadInternal(type, projectionMatrix, textureId, opacity,
- textureTarget, GL_LINEAR, pureColor);
+ } else {
+ textureId = data->textureId();
+ textureFilter = data->textureFilter();
+ textureTarget = data->textureTarget();
+ shaderType = getTextureShaderType(textureTarget);
}
-
- GLUtils::checkGlError("drawLayerQuad");
+ setBlendingState(enableBlending);
+ drawQuadInternal(shaderType, matrix, textureId, opacity,
+ textureTarget, textureFilter, quadColor);
}
void ShaderProgram::drawVideoLayerQuad(const TransformationMatrix& drawMatrix,
diff --git a/Source/WebCore/platform/graphics/android/ShaderProgram.h b/Source/WebCore/platform/graphics/android/ShaderProgram.h
index 98d45b5..b233f2b 100644
--- a/Source/WebCore/platform/graphics/android/ShaderProgram.h
+++ b/Source/WebCore/platform/graphics/android/ShaderProgram.h
@@ -30,6 +30,10 @@
namespace WebCore {
+class DrawQuadData;
+class PureColorQuadData;
+class TextureQuadData;
+
enum ShaderType {
UndefinedShader = -1,
PureColor,
@@ -45,14 +49,14 @@ enum ShaderType {
struct ShaderHandles {
ShaderHandles()
- : alphaHandle(-1)
- , contrastHandle(-1)
- , positionHandle(-1)
- , programHandle(-1)
- , projMtxHandle(-1)
- , pureColorHandle(-1)
- , texSamplerHandle(-1)
- , videoMtxHandle(-1)
+ : alphaHandle(-1)
+ , contrastHandle(-1)
+ , positionHandle(-1)
+ , programHandle(-1)
+ , projMtxHandle(-1)
+ , pureColorHandle(-1)
+ , texSamplerHandle(-1)
+ , videoMtxHandle(-1)
{
}
@@ -82,16 +86,16 @@ struct ShaderHandles {
struct ShaderResource {
ShaderResource()
- : program(-1)
- , vertexShader(-1)
- , fragmentShader(-1)
+ : program(-1)
+ , vertexShader(-1)
+ , fragmentShader(-1)
{
};
ShaderResource(GLuint prog, GLuint vertex, GLuint fragment)
- : program(prog)
- , vertexShader(vertex)
- , fragmentShader(fragment)
+ : program(prog)
+ , vertexShader(vertex)
+ , fragmentShader(fragment)
{
};
@@ -118,14 +122,7 @@ public:
// Surface texture in GL_TEXTURE_EXTERNAL_OES target.
// 3) textureId == 0
// No texture needed, just a pureColor quad.
- void drawQuad(const SkRect& geometry, int textureId, float opacity, Color pureColor = Color(),
- GLenum textureTarget = GL_TEXTURE_2D,
- GLint texFilter = GL_LINEAR);
- void drawLayerQuad(const TransformationMatrix& drawMatrix,
- const SkRect& geometry, int textureId, float opacity,
- bool forceBlending = false,
- GLenum textureTarget = GL_TEXTURE_2D,
- Color pureColor = Color());
+ void drawQuad(const DrawQuadData* data);
void drawVideoLayerQuad(const TransformationMatrix& drawMatrix,
float* textureMatrix, SkRect& geometry, int textureId);
FloatRect rectInScreenCoord(const TransformationMatrix& drawMatrix,
@@ -170,7 +167,7 @@ public:
private:
GLuint loadShader(GLenum shaderType, const char* pSource);
GLint createProgram(const char* vertexSource, const char* fragmentSource);
- void setProjectionMatrix(const SkRect& geometry, GLfloat* mtxPtr);
+ GLfloat* getProjectionMatrix(const DrawQuadData* data);
void setBlendingState(bool enableBlending);
void drawQuadInternal(ShaderType type, const GLfloat* matrix, int textureId,
float opacity, GLenum textureTarget, GLenum filter,
@@ -226,6 +223,8 @@ private:
// (-1,1)
GLfloat m_transferProjMtx[16];
+ GLfloat m_tileProjMatrix[16];
+
Vector<ShaderResource> m_resources;
};
diff --git a/Source/WebCore/platform/graphics/android/Surface.cpp b/Source/WebCore/platform/graphics/android/Surface.cpp
index e6d12c1..3ed3aad 100644
--- a/Source/WebCore/platform/graphics/android/Surface.cpp
+++ b/Source/WebCore/platform/graphics/android/Surface.cpp
@@ -167,7 +167,7 @@ IntRect Surface::unclippedArea()
bool Surface::useAggressiveRendering()
{
- // When the background is translucent, 0 < alpha < 255, we had to turn off
+ // When the background is semi-opaque, 0 < alpha < 255, we had to turn off
// low res to avoid artifacts from double drawing.
// TODO: avoid double drawing for low res tiles.
return isBase()
diff --git a/Source/WebCore/platform/graphics/android/Tile.cpp b/Source/WebCore/platform/graphics/android/Tile.cpp
index 0898ca2..35fded1 100644
--- a/Source/WebCore/platform/graphics/android/Tile.cpp
+++ b/Source/WebCore/platform/graphics/android/Tile.cpp
@@ -208,7 +208,8 @@ void Tile::setRepaintPending(bool pending)
}
bool Tile::drawGL(float opacity, const SkRect& rect, float scale,
- const TransformationMatrix* transform)
+ const TransformationMatrix* transform,
+ bool forceBlending)
{
if (m_x < 0 || m_y < 0 || m_scale != scale)
return false;
@@ -218,7 +219,7 @@ bool Tile::drawGL(float opacity, const SkRect& rect, float scale,
if (!m_frontTexture)
return false;
- m_frontTexture->drawGL(isLayerTile(), rect, opacity, transform);
+ m_frontTexture->drawGL(isLayerTile(), rect, opacity, transform, forceBlending);
return true;
}
diff --git a/Source/WebCore/platform/graphics/android/Tile.h b/Source/WebCore/platform/graphics/android/Tile.h
index 9cce2e7..7010301 100644
--- a/Source/WebCore/platform/graphics/android/Tile.h
+++ b/Source/WebCore/platform/graphics/android/Tile.h
@@ -101,7 +101,8 @@ public:
// Return false when real draw didn't happen for any reason.
bool drawGL(float opacity, const SkRect& rect, float scale,
- const TransformationMatrix* transform);
+ const TransformationMatrix* transform,
+ bool forceBlending = false);
// the only thread-safe function called by the background thread
void paintBitmap(TilePainter* painter);
diff --git a/Source/WebCore/platform/graphics/android/TileGrid.cpp b/Source/WebCore/platform/graphics/android/TileGrid.cpp
index 19a1815..0e900a9 100644
--- a/Source/WebCore/platform/graphics/android/TileGrid.cpp
+++ b/Source/WebCore/platform/graphics/android/TileGrid.cpp
@@ -30,6 +30,7 @@
#include "TileGrid.h"
#include "AndroidLog.h"
+#include "DrawQuadData.h"
#include "GLWebViewState.h"
#include "PaintTileOperation.h"
#include "Tile.h"
@@ -283,9 +284,9 @@ void TileGrid::drawGL(const IntRect& visibleArea, float opacity,
int drawn = 0;
SkRegion missingRegion;
- bool translucentBaseSurface =
+ bool semiOpaqueBaseSurface =
background ? (background->hasAlpha() && background->alpha() > 0) : false;
- if (translucentBaseSurface) {
+ if (semiOpaqueBaseSurface) {
SkIRect totalArea = SkIRect::MakeXYWH(m_area.x(), m_area.y(),
m_area.width(), m_area.height());
missingRegion = SkRegion(totalArea);
@@ -305,8 +306,10 @@ void TileGrid::drawGL(const IntRect& visibleArea, float opacity,
tile, tile->isLayerTile(), tile->x(), tile->y(),
tile->scale(), m_scale, tile->isTileReady(), tile->isDirty());
- bool success = tile->drawGL(opacity, rect, m_scale, transform);
- if (translucentBaseSurface && success) {
+ bool forceBaseBlending = background ? background->hasAlpha() : false;
+ bool success = tile->drawGL(opacity, rect, m_scale, transform,
+ forceBaseBlending);
+ if (semiOpaqueBaseSurface && success) {
// Cut the successful drawn tile area from the missing region.
missingRegion.op(SkIRect::MakeXYWH(tile->x(), tile->y(), 1, 1),
SkRegion::kDifference_Op);
@@ -315,12 +318,12 @@ void TileGrid::drawGL(const IntRect& visibleArea, float opacity,
drawn++;
}
- if (translucentBaseSurface)
+ if (semiOpaqueBaseSurface)
TilesManager::instance()->getProfiler()->nextTile(tile, invScale, tileInView);
}
// Draw missing Regions with blend turned on
- if (translucentBaseSurface)
+ if (semiOpaqueBaseSurface)
drawMissingRegion(missingRegion, opacity, background);
ALOGV("TT %p drew %d tiles, scale %f",
@@ -348,7 +351,9 @@ void TileGrid::drawMissingRegion(const SkRegion& region, float opacity,
background->green() * background->alpha() / 255,
background->blue() * background->alpha() / 255,
background->alpha() );
- shader->drawQuad(rect, 0, opacity, postAlpha);
+
+ PureColorQuadData backGroundData(postAlpha, BaseQuad, 0, &rect, opacity);
+ TilesManager::instance()->shader()->drawQuad(&backGroundData);
iterator.next();
}
}
diff --git a/Source/WebCore/platform/graphics/android/TileTexture.cpp b/Source/WebCore/platform/graphics/android/TileTexture.cpp
index 7254149..39effd7 100644
--- a/Source/WebCore/platform/graphics/android/TileTexture.cpp
+++ b/Source/WebCore/platform/graphics/android/TileTexture.cpp
@@ -32,6 +32,7 @@
#include "AndroidLog.h"
#include "Tile.h"
#include "ClassTracker.h"
+#include "DrawQuadData.h"
#include "GLUtils.h"
#include "GLWebViewState.h"
#include "TextureOwner.h"
@@ -118,22 +119,28 @@ void TileTexture::transferComplete()
}
void TileTexture::drawGL(bool isLayer, const SkRect& rect, float opacity,
- const TransformationMatrix* transform)
+ const TransformationMatrix* transform,
+ bool forceBlending)
{
ShaderProgram* shader = TilesManager::instance()->shader();
- if (isLayer && transform) {
- if (isPureColor()) {
- shader->drawLayerQuad(*transform, rect, 0, opacity,
- true, GL_TEXTURE_2D, pureColor());
- } else {
- shader->drawLayerQuad(*transform, rect, m_ownTextureId,
- opacity, true);
- }
+
+ if (isLayer && !transform) {
+ ALOGE("ERROR: Missing tranform for layers!");
+ return;
+ }
+
+ // For base layer, we just follow the forceBlending, otherwise, blending is
+ // always turned on.
+ // TODO: Don't blend tiles if they are fully opaque.
+ forceBlending |= isLayer;
+ DrawQuadData commonData(isLayer ? LayerQuad : BaseQuad, transform, &rect,
+ opacity, forceBlending);
+ if (isPureColor()) {
+ PureColorQuadData data(commonData, pureColor());
+ shader->drawQuad(&data);
} else {
- if (isPureColor())
- shader->drawQuad(rect, 0, opacity, pureColor());
- else
- shader->drawQuad(rect, m_ownTextureId, opacity);
+ TextureQuadData data(commonData, m_ownTextureId, GL_TEXTURE_2D, GL_LINEAR);
+ shader->drawQuad(&data);
}
}
diff --git a/Source/WebCore/platform/graphics/android/TileTexture.h b/Source/WebCore/platform/graphics/android/TileTexture.h
index f1d5f8c..5fe43b0 100644
--- a/Source/WebCore/platform/graphics/android/TileTexture.h
+++ b/Source/WebCore/platform/graphics/android/TileTexture.h
@@ -80,7 +80,7 @@ public:
Color pureColor() { return m_pureColor; }
void drawGL(bool isLayer, const SkRect& rect, float opacity,
- const TransformationMatrix* transform);
+ const TransformationMatrix* transform, bool forceBlending = false);
private:
TextureInfo m_ownTextureInfo;
SkSize m_size;
diff --git a/Source/WebCore/platform/graphics/android/TransferQueue.cpp b/Source/WebCore/platform/graphics/android/TransferQueue.cpp
index 469438f..ff4bc5c 100644
--- a/Source/WebCore/platform/graphics/android/TransferQueue.cpp
+++ b/Source/WebCore/platform/graphics/android/TransferQueue.cpp
@@ -32,8 +32,9 @@
#if USE(ACCELERATED_COMPOSITING)
#include "AndroidLog.h"
-#include "Tile.h"
+#include "DrawQuadData.h"
#include "GLUtils.h"
+#include "Tile.h"
#include "TileTexture.h"
#include "TilesManager.h"
#include <android/native_window.h>
@@ -205,8 +206,9 @@ void TransferQueue::blitTileFromQueue(GLuint fboID, TileTexture* destTex,
// Use empty rect to set up the special matrix to draw.
SkRect rect = SkRect::MakeEmpty();
- TilesManager::instance()->shader()->drawQuad(rect, srcTexId, 1.0,
- srcTexTarget, GL_NEAREST);
+
+ TextureQuadData data(srcTexId, GL_NEAREST, srcTexTarget, Blit, 0, 0, 1.0, false);
+ TilesManager::instance()->shader()->drawQuad(&data);
// To workaround a sync issue on some platforms, we should insert the sync
// here while in the current FBO.
diff --git a/Source/WebCore/platform/graphics/android/VideoLayerAndroid.cpp b/Source/WebCore/platform/graphics/android/VideoLayerAndroid.cpp
index 6669d49..39bbec6 100644
--- a/Source/WebCore/platform/graphics/android/VideoLayerAndroid.cpp
+++ b/Source/WebCore/platform/graphics/android/VideoLayerAndroid.cpp
@@ -30,6 +30,7 @@
#include "VideoLayerAndroid.h"
#include "AndroidLog.h"
+#include "DrawQuadData.h"
#include "ShaderProgram.h"
#include "TilesManager.h"
#include <GLES2/gl2.h>
@@ -75,8 +76,9 @@ void VideoLayerAndroid::showPreparingAnimation(const SkRect& rect,
ShaderProgram* shader = TilesManager::instance()->shader();
VideoLayerManager* manager = TilesManager::instance()->videoLayerManager();
// Paint the video content's background.
- shader->drawLayerQuad(m_drawTransform, rect, 0, 1, true, GL_TEXTURE_2D,
- Color(128, 128, 128, 255));
+ PureColorQuadData backGroundQuadData(Color(128, 128, 128, 255), LayerQuad,
+ &m_drawTransform, &rect);
+ shader->drawQuad(&backGroundQuadData);
TransformationMatrix addReverseRotation;
TransformationMatrix addRotation = m_drawTransform;
@@ -88,14 +90,18 @@ void VideoLayerAndroid::showPreparingAnimation(const SkRect& rect,
addRotation.translate(-halfButtonSize, -halfButtonSize);
SkRect size = SkRect::MakeWH(innerRect.width(), innerRect.height());
- shader->drawLayerQuad(addRotation, size,
- manager->getSpinnerOuterTextureId(), 1, true);
+
+ TextureQuadData spinnerQuadData(manager->getSpinnerOuterTextureId(),
+ GL_TEXTURE_2D, GL_LINEAR,
+ LayerQuad, &addRotation, &size);
+ shader->drawQuad(&spinnerQuadData);
addReverseRotation.rotate(-m_rotateDegree);
addReverseRotation.translate(-halfButtonSize, -halfButtonSize);
- shader->drawLayerQuad(addReverseRotation, size,
- manager->getSpinnerInnerTextureId(), 1, true);
+ spinnerQuadData.updateTextureId(manager->getSpinnerInnerTextureId());
+ spinnerQuadData.updateDrawMatrix(&addReverseRotation);
+ shader->drawQuad(&spinnerQuadData);
m_rotateDegree += ROTATESTEP;
}
@@ -130,11 +136,13 @@ bool VideoLayerAndroid::drawGL(bool layerTilesDisabled)
// Calculate the video rect based on the aspect ratio and the element rect.
SkRect videoRect = calVideoRect(rect);
+ PureColorQuadData pureColorQuadData(Color(0, 0, 0, 255), LayerQuad,
+ &m_drawTransform, &rect);
+
if (videoRect != rect) {
// Paint the whole video element with black color when video content
// can't cover the whole area.
- shader->drawLayerQuad(m_drawTransform, rect, 0, 1, true, GL_TEXTURE_2D,
- Color(0, 0, 0, 255));
+ shader->drawQuad(&pureColorQuadData);
}
// Inner rect is for the progressing / play / pause animation.
@@ -149,7 +157,8 @@ bool VideoLayerAndroid::drawGL(bool layerTilesDisabled)
// When we are drawing the animation of the play/pause button in the
// middle of the video, we need to ask for redraw.
bool needRedraw = false;
-
+ TextureQuadData iconQuadData(0, GL_TEXTURE_2D, GL_LINEAR, LayerQuad,
+ &m_drawTransform, &innerRect);
// Draw the poster image, the progressing image or the Video depending
// on the player's state.
if (m_playerState == PREPARING) {
@@ -170,11 +179,11 @@ bool VideoLayerAndroid::drawGL(bool layerTilesDisabled)
if (scale) {
innerRect.inset(manager->getButtonSize() / 4 * scale,
manager->getButtonSize() / 4 * scale);
- shader->drawLayerQuad(m_drawTransform, innerRect,
- manager->getPlayTextureId(), scale, true);
+ iconQuadData.updateTextureId(manager->getPlayTextureId());
+ iconQuadData.updateOpacity(scale);
+ shader->drawQuad(&iconQuadData);
needRedraw = true;
}
-
} else {
GLuint textureId = manager->getTextureId(uniqueId());
GLfloat* matrix = manager->getMatrix(uniqueId());
@@ -184,10 +193,12 @@ bool VideoLayerAndroid::drawGL(bool layerTilesDisabled)
videoRect, textureId);
} else {
// Show the static poster b/c there is no screen shot available.
- shader->drawLayerQuad(m_drawTransform, rect, 0, 1, true, GL_TEXTURE_2D,
- Color(128, 128, 128, 255));
- shader->drawLayerQuad(m_drawTransform, innerRect,
- manager->getPosterTextureId(), 1, true);
+ pureColorQuadData.updateColor(Color(128, 128, 128, 255));
+ shader->drawQuad(&pureColorQuadData);
+
+ iconQuadData.updateTextureId(manager->getPosterTextureId());
+ iconQuadData.updateOpacity(1.0);
+ shader->drawQuad(&iconQuadData);
}
// Use the scale to control the fading and the sizing during animation.
@@ -195,8 +206,9 @@ bool VideoLayerAndroid::drawGL(bool layerTilesDisabled)
if (scale) {
innerRect.inset(manager->getButtonSize() / 4 * scale,
manager->getButtonSize() / 4 * scale);
- shader->drawLayerQuad(m_drawTransform, innerRect,
- manager->getPauseTextureId(), scale, true);
+ iconQuadData.updateTextureId(manager->getPauseTextureId());
+ iconQuadData.updateOpacity(scale);
+ shader->drawQuad(&iconQuadData);
needRedraw = true;
}