Diff
Modified: trunk/Source/WebCore/ChangeLog (110437 => 110438)
--- trunk/Source/WebCore/ChangeLog 2012-03-12 17:06:44 UTC (rev 110437)
+++ trunk/Source/WebCore/ChangeLog 2012-03-12 17:08:18 UTC (rev 110438)
@@ -1,5 +1,37 @@
2012-03-12 Jocelyn Turcotte <[email protected]>
+ [TexMapGL] Use textures sized exactly to their contents.
+ https://bugs.webkit.org/show_bug.cgi?id=80845
+
+ Reviewed by Noam Rosenthal.
+
+ This fixes a regression introduced in r108273 as well as the bug it fixed.
+ The regressing behavior was that textures were rendered shrunk by 1 pixel
+ and thus would appear blurry on the screen.
+ The original problem was that garbage contents would appear on filtered
+ textures since we would reuse textures of different sizes by giving them
+ a slightly bigger size.
+
+ This patch will reuse the texture only if the size matches exactly to allow
+ edge clamping to work properly when redering with linear filtering.
+ Reusing textures would only saves us the allocation of graphic memory
+ anyway, which is negligeable compared to texture upload.
+
+ * platform/graphics/qt/GraphicsContext3DQt.cpp:
+ (WebCore::GraphicsContext3DPrivate::paintToTextureMapper):
+ * platform/graphics/texmap/TextureMapperGL.cpp:
+ (WebCore::TextureMapperGL::drawTexture):
+ (WebCore::BitmapTextureGL::didReset):
+ * platform/graphics/texmap/TextureMapperGL.h:
+ (BitmapTextureGL):
+ * platform/graphics/texmap/TextureMapperShaderManager.cpp:
+ (WebCore::TextureMapperShaderProgramOpacityAndMask::TextureMapperShaderProgramOpacityAndMask):
+ (WebCore::TextureMapperShaderProgramOpacityAndMask::prepare):
+ * platform/graphics/texmap/TextureMapperShaderManager.h:
+ (TextureMapperShaderProgramOpacityAndMask):
+
+2012-03-12 Jocelyn Turcotte <[email protected]>
+
[TexMap] Remove BitmapTexture::destroy.
https://bugs.webkit.org/show_bug.cgi?id=80844
Modified: trunk/Source/WebCore/platform/graphics/qt/GraphicsContext3DQt.cpp (110437 => 110438)
--- trunk/Source/WebCore/platform/graphics/qt/GraphicsContext3DQt.cpp 2012-03-12 17:06:44 UTC (rev 110437)
+++ trunk/Source/WebCore/platform/graphics/qt/GraphicsContext3DQt.cpp 2012-03-12 17:08:18 UTC (rev 110438)
@@ -124,7 +124,7 @@
if (textureMapper->accelerationMode() == TextureMapper::OpenGLMode) {
TextureMapperGL* texmapGL = static_cast<TextureMapperGL*>(textureMapper);
TextureMapperGL::Flags flags = TextureMapperGL::ShouldFlipTexture | (m_context->m_attrs.alpha ? TextureMapperGL::SupportsBlending : 0);
- texmapGL->drawTexture(m_context->m_texture, flags, FloatSize(1, 1), targetRect, matrix, opacity, mask);
+ texmapGL->drawTexture(m_context->m_texture, flags, targetRect, matrix, opacity, mask);
return;
}
Modified: trunk/Source/WebCore/platform/graphics/texmap/TextureMapperGL.cpp (110437 => 110438)
--- trunk/Source/WebCore/platform/graphics/texmap/TextureMapperGL.cpp 2012-03-12 17:06:44 UTC (rev 110437)
+++ trunk/Source/WebCore/platform/graphics/texmap/TextureMapperGL.cpp 2012-03-12 17:08:18 UTC (rev 110438)
@@ -313,10 +313,10 @@
return;
const BitmapTextureGL& textureGL = static_cast<const BitmapTextureGL&>(texture);
- drawTexture(textureGL.id(), textureGL.isOpaque() ? 0 : SupportsBlending, textureGL.relativeSize(), targetRect, matrix, opacity, mask);
+ drawTexture(textureGL.id(), textureGL.isOpaque() ? 0 : SupportsBlending, targetRect, matrix, opacity, mask);
}
-void TextureMapperGL::drawTexture(uint32_t texture, Flags flags, const FloatSize& relativeSize, const FloatRect& targetRect, const TransformationMatrix& modelViewMatrix, float opacity, const BitmapTexture* maskTexture)
+void TextureMapperGL::drawTexture(uint32_t texture, Flags flags, const FloatRect& targetRect, const TransformationMatrix& modelViewMatrix, float opacity, const BitmapTexture* maskTexture)
{
RefPtr<TextureMapperShaderProgram> shaderInfo;
if (maskTexture)
@@ -344,11 +344,13 @@
matrix.m31(), matrix.m32(), matrix.m33(), matrix.m34(),
matrix.m41(), matrix.m42(), matrix.m43(), matrix.m44()
};
- const GLfloat m4src[] = {relativeSize.width(), 0, 0, 0,
- 0, relativeSize.height() * ((flags & ShouldFlipTexture) ? -1 : 1), 0, 0,
- 0, 0, 1, 0,
- 0, (flags & ShouldFlipTexture) ? relativeSize.height() : 0, 0, 1};
+ const GLfloat m4src[] = {
+ 1, 0, 0, 0,
+ 0, (flags & ShouldFlipTexture) ? -1 : 1, 0, 0,
+ 0, 0, 1, 0,
+ 0, (flags & ShouldFlipTexture) ? 1 : 0, 0, 1};
+
GL_CMD(glUniformMatrix4fv(shaderInfo->matrixVariable(), 1, GL_FALSE, m4))
GL_CMD(glUniformMatrix4fv(shaderInfo->sourceMatrixVariable(), 1, GL_FALSE, m4src))
GL_CMD(glUniform1i(shaderInfo->sourceTextureVariable(), 0))
@@ -374,15 +376,11 @@
void BitmapTextureGL::didReset()
{
- IntSize newTextureSize = nextPowerOfTwo(contentSize());
- bool justCreated = false;
- if (!m_id) {
+ if (!m_id)
GL_CMD(glGenTextures(1, &m_id))
- justCreated = true;
- }
- if (justCreated || newTextureSize.width() > m_textureSize.width() || newTextureSize.height() > m_textureSize.height()) {
- m_textureSize = newTextureSize;
+ if (m_textureSize != contentSize()) {
+ m_textureSize = contentSize();
GL_CMD(glBindTexture(GL_TEXTURE_2D, m_id))
GL_CMD(glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR))
GL_CMD(glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR))
@@ -391,8 +389,6 @@
GL_CMD(glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, m_textureSize.width(), m_textureSize.height(), 0, GL_RGBA, GL_UNSIGNED_BYTE, 0))
}
- // We decrease the size by one, since this is used as rectangle coordinates and not as size.
- m_relativeSize = FloatSize(float(contentSize().width() - 1) / m_textureSize.width(), float(contentSize().height() - 1) / m_textureSize.height());
m_surfaceNeedsReset = true;
}
Modified: trunk/Source/WebCore/platform/graphics/texmap/TextureMapperGL.h (110437 => 110438)
--- trunk/Source/WebCore/platform/graphics/texmap/TextureMapperGL.h 2012-03-12 17:06:44 UTC (rev 110437)
+++ trunk/Source/WebCore/platform/graphics/texmap/TextureMapperGL.h 2012-03-12 17:08:18 UTC (rev 110438)
@@ -49,7 +49,7 @@
// reimps from TextureMapper
virtual void drawTexture(const BitmapTexture&, const FloatRect&, const TransformationMatrix&, float opacity, const BitmapTexture* maskTexture);
- virtual void drawTexture(uint32_t texture, Flags, const FloatSize&, const FloatRect&, const TransformationMatrix&, float opacity, const BitmapTexture* maskTexture);
+ virtual void drawTexture(uint32_t texture, Flags, const FloatRect&, const TransformationMatrix&, float opacity, const BitmapTexture* maskTexture);
virtual void bindSurface(BitmapTexture* surface);
virtual void beginClip(const TransformationMatrix&, const FloatRect&);
virtual void beginPainting();
@@ -82,14 +82,12 @@
void initializeStencil();
~BitmapTextureGL();
virtual uint32_t id() const { return m_id; }
- inline FloatSize relativeSize() const { return m_relativeSize; }
void setTextureMapper(TextureMapperGL* texmap) { m_textureMapper = texmap; }
void updateContents(Image*, const IntRect&, const IntRect&, PixelFormat);
void updateContents(const void*, const IntRect&);
private:
GLuint m_id;
- FloatSize m_relativeSize;
IntSize m_textureSize;
IntRect m_dirtyRect;
GLuint m_fbo;
@@ -108,23 +106,6 @@
friend class TextureMapperGL;
};
-// An offscreen buffer to be rendered by software.
-static inline int nextPowerOfTwo(int num)
-{
- for (int i = 0x10000000; i > 0; i >>= 1) {
- if (num == i)
- return num;
- if (num & i)
- return (i << 1);
- }
- return 1;
-}
-
-static inline IntSize nextPowerOfTwo(const IntSize& size)
-{
- return IntSize(nextPowerOfTwo(size.width()), nextPowerOfTwo(size.height()));
-}
-
typedef uint64_t ImageUID;
ImageUID uidForImage(Image*);
Modified: trunk/Source/WebCore/platform/graphics/texmap/TextureMapperShaderManager.cpp (110437 => 110438)
--- trunk/Source/WebCore/platform/graphics/texmap/TextureMapperShaderManager.cpp 2012-03-12 17:06:44 UTC (rev 110437)
+++ trunk/Source/WebCore/platform/graphics/texmap/TextureMapperShaderManager.cpp 2012-03-12 17:08:18 UTC (rev 110438)
@@ -57,13 +57,13 @@
static const char* vertexShaderSourceOpacityAndMask =
VERTEX_SHADER(
- uniform mat4 InMatrix, InSourceMatrix, InMaskMatrix;
+ uniform mat4 InMatrix, InSourceMatrix;
attribute vec4 InVertex;
varying highp vec2 OutTexCoordSource, OutTexCoordMask;
void main(void)
{
OutTexCoordSource = vec2(InSourceMatrix * InVertex);
- OutTexCoordMask = vec2(InMaskMatrix * InVertex);
+ OutTexCoordMask = vec2(InVertex);
gl_Position = InMatrix * InVertex;
}
);
@@ -171,7 +171,6 @@
initializeProgram();
getUniformLocation(m_matrixVariable, "InMatrix");
getUniformLocation(m_sourceMatrixVariable, "InSourceMatrix");
- getUniformLocation(m_maskMatrixVariable, "InMaskMatrix");
getUniformLocation(m_sourceTextureVariable, "SourceTexture");
getUniformLocation(m_maskTextureVariable, "MaskTexture");
getUniformLocation(m_opacityVariable, "Opacity");
@@ -196,11 +195,6 @@
const BitmapTextureGL* maskTextureGL = static_cast<const BitmapTextureGL*>(maskTexture);
glActiveTexture(GL_TEXTURE1);
glBindTexture(GL_TEXTURE_2D, maskTextureGL->id());
- const GLfloat m4mask[] = {maskTextureGL->relativeSize().width(), 0, 0, 0,
- 0, maskTextureGL->relativeSize().height(), 0, 0,
- 0, 0, 1, 0,
- 0, 0, 0, 1};
- glUniformMatrix4fv(m_maskMatrixVariable, 1, GL_FALSE, m4mask);
glUniform1i(m_maskTextureVariable, 1);
glActiveTexture(GL_TEXTURE0);
}
Modified: trunk/Source/WebCore/platform/graphics/texmap/TextureMapperShaderManager.h (110437 => 110438)
--- trunk/Source/WebCore/platform/graphics/texmap/TextureMapperShaderManager.h 2012-03-12 17:06:44 UTC (rev 110437)
+++ trunk/Source/WebCore/platform/graphics/texmap/TextureMapperShaderManager.h 2012-03-12 17:08:18 UTC (rev 110438)
@@ -89,7 +89,6 @@
public:
static PassRefPtr<TextureMapperShaderProgramOpacityAndMask> create();
virtual void prepare(float opacity, const BitmapTexture*);
- GLint maskMatrixVariable() const { return m_maskMatrixVariable; }
GLint maskTextureVariable() const { return m_maskTextureVariable; }
private:
@@ -97,7 +96,6 @@
virtual const char* vertexShaderSource() const;
virtual const char* fragmentShaderSource() const;
TextureMapperShaderProgramOpacityAndMask();
- GLint m_maskMatrixVariable;
GLint m_maskTextureVariable;
};