Diff
Modified: trunk/Source/WebCore/ChangeLog (100046 => 100047)
--- trunk/Source/WebCore/ChangeLog 2011-11-12 00:34:57 UTC (rev 100046)
+++ trunk/Source/WebCore/ChangeLog 2011-11-12 00:57:48 UTC (rev 100047)
@@ -1,3 +1,32 @@
+2011-11-11 Antoine Labour <[email protected]>
+
+ [chromium] Add translation/scaling to WebExternalTextureLayer
+ https://bugs.webkit.org/show_bug.cgi?id=72087
+
+ Reviewed by James Robinson.
+
+ Covered by WebLayerTest.
+
+ * platform/graphics/chromium/PluginLayerChromium.cpp:
+ (WebCore::PluginLayerChromium::PluginLayerChromium):
+ (WebCore::PluginLayerChromium::setUVRect):
+ (WebCore::PluginLayerChromium::pushPropertiesTo):
+ * platform/graphics/chromium/PluginLayerChromium.h:
+ (WebCore::PluginLayerChromium::uvRect):
+ * platform/graphics/chromium/ShaderChromium.cpp:
+ (WebCore::VertexShaderPosTexStretch::VertexShaderPosTexStretch):
+ (WebCore::VertexShaderPosTexStretch::init):
+ (WebCore::VertexShaderPosTexStretch::getShaderString):
+ * platform/graphics/chromium/ShaderChromium.h:
+ (WebCore::VertexShaderPosTexStretch::matrixLocation):
+ (WebCore::VertexShaderPosTexStretch::offsetLocation):
+ (WebCore::VertexShaderPosTexStretch::scaleLocation):
+ * platform/graphics/chromium/cc/CCPluginLayerImpl.cpp:
+ (WebCore::CCPluginLayerImpl::CCPluginLayerImpl):
+ (WebCore::CCPluginLayerImpl::draw):
+ * platform/graphics/chromium/cc/CCPluginLayerImpl.h:
+ (WebCore::CCPluginLayerImpl::setUVRect):
+
2011-11-11 Stephen Chenney <[email protected]>
Null deref when no use element exists for SVG element instance
Modified: trunk/Source/WebCore/platform/graphics/chromium/PluginLayerChromium.cpp (100046 => 100047)
--- trunk/Source/WebCore/platform/graphics/chromium/PluginLayerChromium.cpp 2011-11-12 00:34:57 UTC (rev 100046)
+++ trunk/Source/WebCore/platform/graphics/chromium/PluginLayerChromium.cpp 2011-11-12 00:57:48 UTC (rev 100047)
@@ -45,6 +45,7 @@
: LayerChromium(delegate)
, m_textureId(0)
, m_flipped(true)
+ , m_uvRect(0, 0, 1, 1)
{
}
@@ -65,6 +66,12 @@
setNeedsCommit();
}
+void PluginLayerChromium::setUVRect(const FloatRect& rect)
+{
+ m_uvRect = rect;
+ setNeedsCommit();
+}
+
void PluginLayerChromium::pushPropertiesTo(CCLayerImpl* layer)
{
LayerChromium::pushPropertiesTo(layer);
@@ -72,6 +79,7 @@
CCPluginLayerImpl* pluginLayer = static_cast<CCPluginLayerImpl*>(layer);
pluginLayer->setTextureId(m_textureId);
pluginLayer->setFlipped(m_flipped);
+ pluginLayer->setUVRect(m_uvRect);
}
}
Modified: trunk/Source/WebCore/platform/graphics/chromium/PluginLayerChromium.h (100046 => 100047)
--- trunk/Source/WebCore/platform/graphics/chromium/PluginLayerChromium.h 2011-11-12 00:34:57 UTC (rev 100046)
+++ trunk/Source/WebCore/platform/graphics/chromium/PluginLayerChromium.h 2011-11-12 00:57:48 UTC (rev 100047)
@@ -45,6 +45,8 @@
unsigned textureId() const { return m_textureId; }
void setFlipped(bool);
bool flipped() const { return m_flipped; }
+ void setUVRect(const FloatRect&);
+ const FloatRect& uvRect() const { return m_uvRect; }
virtual void pushPropertiesTo(CCLayerImpl*);
@@ -54,6 +56,7 @@
private:
unsigned m_textureId;
bool m_flipped;
+ FloatRect m_uvRect;
};
}
Modified: trunk/Source/WebCore/platform/graphics/chromium/ShaderChromium.cpp (100046 => 100047)
--- trunk/Source/WebCore/platform/graphics/chromium/ShaderChromium.cpp 2011-11-12 00:34:57 UTC (rev 100046)
+++ trunk/Source/WebCore/platform/graphics/chromium/ShaderChromium.cpp 2011-11-12 00:57:48 UTC (rev 100047)
@@ -63,6 +63,38 @@
);
}
+VertexShaderPosTexStretch::VertexShaderPosTexStretch()
+ : m_matrixLocation(-1)
+ , m_offsetLocation(-1)
+ , m_scaleLocation(-1)
+{
+}
+
+void VertexShaderPosTexStretch::init(GraphicsContext3D* context, unsigned program)
+{
+ m_matrixLocation = context->getUniformLocation(program, "matrix");
+ m_offsetLocation = context->getUniformLocation(program, "offset");
+ m_scaleLocation = context->getUniformLocation(program, "scale");
+ ASSERT(m_matrixLocation != -1 && m_offsetLocation != -1 && m_scaleLocation != -1);
+}
+
+String VertexShaderPosTexStretch::getShaderString() const
+{
+ return SHADER(
+ attribute vec4 a_position;
+ attribute vec2 a_texCoord;
+ uniform mat4 matrix;
+ uniform vec2 offset;
+ uniform vec2 scale;
+ varying vec2 v_texCoord;
+ void main()
+ {
+ gl_Position = matrix * a_position;
+ v_texCoord = scale * a_texCoord + offset;
+ }
+ );
+}
+
VertexShaderPosTexYUVStretch::VertexShaderPosTexYUVStretch()
: m_matrixLocation(-1)
, m_yWidthScaleFactorLocation(-1)
Modified: trunk/Source/WebCore/platform/graphics/chromium/ShaderChromium.h (100046 => 100047)
--- trunk/Source/WebCore/platform/graphics/chromium/ShaderChromium.h 2011-11-12 00:34:57 UTC (rev 100046)
+++ trunk/Source/WebCore/platform/graphics/chromium/ShaderChromium.h 2011-11-12 00:57:48 UTC (rev 100047)
@@ -51,6 +51,23 @@
int m_matrixLocation;
};
+class VertexShaderPosTexStretch {
+public:
+ VertexShaderPosTexStretch();
+
+ void init(GraphicsContext3D*, unsigned program);
+ String getShaderString() const;
+
+ int matrixLocation() const { return m_matrixLocation; }
+ int offsetLocation() const { return m_offsetLocation; }
+ int scaleLocation() const { return m_scaleLocation; }
+
+private:
+ int m_matrixLocation;
+ int m_offsetLocation;
+ int m_scaleLocation;
+};
+
class VertexShaderPosTexYUVStretch {
public:
VertexShaderPosTexYUVStretch();
Modified: trunk/Source/WebCore/platform/graphics/chromium/cc/CCPluginLayerImpl.cpp (100046 => 100047)
--- trunk/Source/WebCore/platform/graphics/chromium/cc/CCPluginLayerImpl.cpp 2011-11-12 00:34:57 UTC (rev 100046)
+++ trunk/Source/WebCore/platform/graphics/chromium/cc/CCPluginLayerImpl.cpp 2011-11-12 00:57:48 UTC (rev 100047)
@@ -43,11 +43,15 @@
programId = program->program();
samplerLocation = program->fragmentShader().samplerLocation();
matrixLocation = program->vertexShader().matrixLocation();
+ offsetLocation = program->vertexShader().offsetLocation();
+ scaleLocation = program->vertexShader().scaleLocation();
alphaLocation = program->fragmentShader().alphaLocation();
}
int programId;
int samplerLocation;
int matrixLocation;
+ int offsetLocation;
+ int scaleLocation;
int alphaLocation;
};
@@ -59,6 +63,7 @@
: CCLayerImpl(id)
, m_textureId(0)
, m_flipped(true)
+ , m_uvRect(0, 0, 1, 1)
{
}
@@ -88,6 +93,8 @@
GLC(context, context->useProgram(binding.programId));
GLC(context, context->uniform1i(binding.samplerLocation, 0));
+ GLC(context, context->uniform2f(binding.offsetLocation, m_uvRect.x(), m_uvRect.y()));
+ GLC(context, context->uniform2f(binding.scaleLocation, m_uvRect.width(), m_uvRect.height()));
layerRenderer->drawTexturedQuad(drawTransform(), bounds().width(), bounds().height(), drawOpacity(), layerRenderer->sharedGeometryQuad(),
binding.matrixLocation,
binding.alphaLocation,
Modified: trunk/Source/WebCore/platform/graphics/chromium/cc/CCPluginLayerImpl.h (100046 => 100047)
--- trunk/Source/WebCore/platform/graphics/chromium/cc/CCPluginLayerImpl.h 2011-11-12 00:34:57 UTC (rev 100046)
+++ trunk/Source/WebCore/platform/graphics/chromium/cc/CCPluginLayerImpl.h 2011-11-12 00:57:48 UTC (rev 100047)
@@ -26,6 +26,7 @@
#ifndef CCPluginLayerImpl_h
#define CCPluginLayerImpl_h
+#include "FloatRect.h"
#include "ProgramBinding.h"
#include "ShaderChromium.h"
#include "cc/CCLayerImpl.h"
@@ -40,8 +41,8 @@
}
virtual ~CCPluginLayerImpl();
- typedef ProgramBinding<VertexShaderPosTex, FragmentShaderRGBATexAlpha> Program;
- typedef ProgramBinding<VertexShaderPosTex, FragmentShaderRGBATexFlipAlpha> ProgramFlip;
+ typedef ProgramBinding<VertexShaderPosTexStretch, FragmentShaderRGBATexAlpha> Program;
+ typedef ProgramBinding<VertexShaderPosTexStretch, FragmentShaderRGBATexFlipAlpha> ProgramFlip;
virtual void draw(LayerRendererChromium*);
@@ -49,6 +50,7 @@
void setTextureId(unsigned id) { m_textureId = id; }
void setFlipped(bool flipped) { m_flipped = flipped; }
+ void setUVRect(const FloatRect& rect) { m_uvRect = rect; }
private:
explicit CCPluginLayerImpl(int);
@@ -57,6 +59,7 @@
unsigned m_textureId;
bool m_flipped;
+ FloatRect m_uvRect;
};
}
Modified: trunk/Source/WebKit/chromium/ChangeLog (100046 => 100047)
--- trunk/Source/WebKit/chromium/ChangeLog 2011-11-12 00:34:57 UTC (rev 100046)
+++ trunk/Source/WebKit/chromium/ChangeLog 2011-11-12 00:57:48 UTC (rev 100047)
@@ -1,3 +1,15 @@
+2011-11-11 Antoine Labour <[email protected]>
+
+ [chromium] Add translation/scaling to WebExternalTextureLayer
+ https://bugs.webkit.org/show_bug.cgi?id=72087
+
+ Reviewed by James Robinson.
+
+ * public/WebExternalTextureLayer.h:
+ * src/WebExternalTextureLayer.cpp:
+ (WebKit::WebExternalTextureLayer::setUVRect):
+ (WebKit::WebExternalTextureLayer::uvRect):
+
2011-11-11 Adam Klein <[email protected]>
Remove no-op StorageNamespace::unlock method
Modified: trunk/Source/WebKit/chromium/public/WebExternalTextureLayer.h (100046 => 100047)
--- trunk/Source/WebKit/chromium/public/WebExternalTextureLayer.h 2011-11-12 00:34:57 UTC (rev 100046)
+++ trunk/Source/WebKit/chromium/public/WebExternalTextureLayer.h 2011-11-12 00:57:48 UTC (rev 100047)
@@ -27,6 +27,7 @@
#define WebExternalTextureLayer_h
#include "WebCommon.h"
+#include "WebFloatRect.h"
#include "WebLayer.h"
namespace WebKit {
@@ -62,6 +63,11 @@
WEBKIT_EXPORT void setFlipped(bool);
WEBKIT_EXPORT bool flipped() const;
+ // Sets the rect in UV space of the texture that is mapped to the layer
+ // bounds.
+ WEBKIT_EXPORT void setUVRect(const WebFloatRect&);
+ WEBKIT_EXPORT WebFloatRect uvRect() const;
+
#if WEBKIT_IMPLEMENTATION
WebExternalTextureLayer(const WTF::PassRefPtr<WebExternalTextureLayerImpl>&);
WebExternalTextureLayer& operator=(const WTF::PassRefPtr<WebExternalTextureLayerImpl>&);
Modified: trunk/Source/WebKit/chromium/src/WebExternalTextureLayer.cpp (100046 => 100047)
--- trunk/Source/WebKit/chromium/src/WebExternalTextureLayer.cpp 2011-11-12 00:34:57 UTC (rev 100046)
+++ trunk/Source/WebKit/chromium/src/WebExternalTextureLayer.cpp 2011-11-12 00:57:48 UTC (rev 100047)
@@ -56,6 +56,16 @@
return constUnwrap<WebExternalTextureLayerImpl>()->flipped();
}
+void WebExternalTextureLayer::setUVRect(const WebFloatRect& rect)
+{
+ unwrap<WebExternalTextureLayerImpl>()->setUVRect(rect);
+}
+
+WebFloatRect WebExternalTextureLayer::uvRect() const
+{
+ return WebFloatRect(constUnwrap<WebExternalTextureLayerImpl>()->uvRect());
+}
+
WebExternalTextureLayer::WebExternalTextureLayer(const PassRefPtr<WebExternalTextureLayerImpl>& node)
: WebLayer(node)
{
Modified: trunk/Source/WebKit/chromium/tests/WebLayerTest.cpp (100046 => 100047)
--- trunk/Source/WebKit/chromium/tests/WebLayerTest.cpp 2011-11-12 00:34:57 UTC (rev 100046)
+++ trunk/Source/WebKit/chromium/tests/WebLayerTest.cpp 2011-11-12 00:57:48 UTC (rev 100047)
@@ -29,6 +29,7 @@
#include "WebContentLayerClient.h"
#include "WebExternalTextureLayer.h"
#include "WebFloatPoint.h"
+#include "WebFloatRect.h"
#include "WebLayerClient.h"
#include "WebRect.h"
#include "WebSize.h"
@@ -127,7 +128,13 @@
Mock::VerifyAndClearExpectations(&client);
EXPECT_TRUE(textureLayer.flipped());
+ EXPECT_CALL(client, notifyNeedsComposite()).Times(AtLeast(1));
+ WebFloatRect uvRect(0.1, 0.1, 0.9, 0.9);
+ textureLayer.setUVRect(uvRect);
+ Mock::VerifyAndClearExpectations(&client);
+ EXPECT_TRUE(textureLayer.flipped());
+
// Content layer.
MockWebContentLayerClient contentClient;
EXPECT_CALL(contentClient, paintContents(_, _)).Times(AnyNumber());