[SCM] WebKit Debian packaging branch, debian/experimental, updated. upstream/1.3.3-9427-gc2be6fc
commit-queue at webkit.org
commit-queue at webkit.org
Wed Dec 22 14:16:19 UTC 2010
The following commit has been merged in the debian/experimental branch:
commit 5569fb150e74585561de708d48e6798cf89f20dc
Author: commit-queue at webkit.org <commit-queue at webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date: Wed Oct 6 03:41:47 2010 +0000
2010-10-05 W. James MacLean <wjmaclean at chromium.org>
Reviewed by James Robinson.
[chromium] Add mipmap support for ImageLayerChromium
https://bugs.webkit.org/show_bug.cgi?id=46493
Mipmap behaviour can be tested with existing tests.
Tests in LayoutTests/compositing/images/ will detect if
mipmaps fail.
* platform/graphics/chromium/ContentLayerChromium.cpp:
(WebCore::ContentLayerChromium::SharedValues::SharedValues):
(WebCore::isPowerOfTwo):
(WebCore::ContentLayerChromium::updateTextureRect):
* platform/graphics/chromium/ContentLayerChromium.h:
(WebCore::ContentLayerChromium::SharedValues::npotSupported):
* platform/graphics/chromium/ImageLayerChromium.cpp:
(WebCore::ImageLayerChromium::updateContents):
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@69172 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/WebCore/ChangeLog b/WebCore/ChangeLog
index 7967095..c6afca8 100644
--- a/WebCore/ChangeLog
+++ b/WebCore/ChangeLog
@@ -1,3 +1,23 @@
+2010-10-05 W. James MacLean <wjmaclean at chromium.org>
+
+ Reviewed by James Robinson.
+
+ [chromium] Add mipmap support for ImageLayerChromium
+ https://bugs.webkit.org/show_bug.cgi?id=46493
+
+ Mipmap behaviour can be tested with existing tests.
+ Tests in LayoutTests/compositing/images/ will detect if
+ mipmaps fail.
+
+ * platform/graphics/chromium/ContentLayerChromium.cpp:
+ (WebCore::ContentLayerChromium::SharedValues::SharedValues):
+ (WebCore::isPowerOfTwo):
+ (WebCore::ContentLayerChromium::updateTextureRect):
+ * platform/graphics/chromium/ContentLayerChromium.h:
+ (WebCore::ContentLayerChromium::SharedValues::npotSupported):
+ * platform/graphics/chromium/ImageLayerChromium.cpp:
+ (WebCore::ImageLayerChromium::updateContents):
+
2010-10-05 Adam Barth <abarth at webkit.org>
Reviewed by Darin Adler.
diff --git a/WebCore/platform/graphics/chromium/ContentLayerChromium.cpp b/WebCore/platform/graphics/chromium/ContentLayerChromium.cpp
index 635e6d8..20a2d70 100644
--- a/WebCore/platform/graphics/chromium/ContentLayerChromium.cpp
+++ b/WebCore/platform/graphics/chromium/ContentLayerChromium.cpp
@@ -57,6 +57,7 @@ ContentLayerChromium::SharedValues::SharedValues(GraphicsContext3D* context)
, m_shaderMatrixLocation(-1)
, m_shaderAlphaLocation(-1)
, m_initialized(false)
+ , m_npotSupported(false)
{
// Shaders for drawing the layer contents.
char vertexShaderString[] =
@@ -103,6 +104,8 @@ ContentLayerChromium::SharedValues::SharedValues(GraphicsContext3D* context)
ASSERT(m_shaderMatrixLocation != -1);
ASSERT(m_shaderAlphaLocation != -1);
+ m_npotSupported = GLC(context, context->getString(GraphicsContext3D::EXTENSIONS).contains("GL_OES_texture_npot"));
+
m_initialized = true;
}
@@ -239,7 +242,14 @@ void ContentLayerChromium::updateContents()
updateTextureRect(pixels, bitmapSize, requiredTextureSize, dirtyRect, textureId);
}
-void ContentLayerChromium::updateTextureRect(void* pixels, const IntSize& bitmapSize, const IntSize& requiredTextureSize, const IntRect& updateRect, unsigned textureId)
+static inline bool isPowerOfTwo(int x)
+{
+ ASSERT(x >= 0);
+ return !(x & (x-1));
+}
+
+void ContentLayerChromium::updateTextureRect(void* pixels, const IntSize& bitmapSize,
+ const IntSize& requiredTextureSize, const IntRect& updateRect, unsigned textureId, MipmapUse requestMipmap)
{
if (!pixels)
return;
@@ -247,11 +257,26 @@ void ContentLayerChromium::updateTextureRect(void* pixels, const IntSize& bitmap
GraphicsContext3D* context = layerRendererContext();
context->bindTexture(GraphicsContext3D::TEXTURE_2D, textureId);
+ bool generateMipmap = (requestMipmap == useMipmap)
+ && (layerRenderer()->contentLayerSharedValues()->npotSupported()
+ || (isPowerOfTwo(updateRect.width()) && isPowerOfTwo(updateRect.height())));
+
// If the texture id or size changed since last time then we need to tell GL
// to re-allocate a texture.
if (m_contentsTexture != textureId || requiredTextureSize != m_allocatedTextureSize) {
ASSERT(bitmapSize == requiredTextureSize);
GLC(context, context->texImage2D(GraphicsContext3D::TEXTURE_2D, 0, GraphicsContext3D::RGBA, requiredTextureSize.width(), requiredTextureSize.height(), 0, GraphicsContext3D::RGBA, GraphicsContext3D::UNSIGNED_BYTE, pixels));
+ if (generateMipmap) {
+ GLC(context, context->texParameteri(GraphicsContext3D::TEXTURE_2D, GraphicsContext3D::TEXTURE_MIN_FILTER,
+ GraphicsContext3D::LINEAR_MIPMAP_LINEAR));
+ GLC(context, context->texParameteri(GraphicsContext3D::TEXTURE_2D, GraphicsContext3D::TEXTURE_MAG_FILTER,
+ GraphicsContext3D::LINEAR));
+ } else {
+ GLC(context, context->texParameteri(GraphicsContext3D::TEXTURE_2D, GraphicsContext3D::TEXTURE_MIN_FILTER,
+ GraphicsContext3D::LINEAR));
+ GLC(context, context->texParameteri(GraphicsContext3D::TEXTURE_2D, GraphicsContext3D::TEXTURE_MAG_FILTER,
+ GraphicsContext3D::LINEAR));
+ }
m_contentsTexture = textureId;
m_allocatedTextureSize = requiredTextureSize;
@@ -261,6 +286,9 @@ void ContentLayerChromium::updateTextureRect(void* pixels, const IntSize& bitmap
GLC(context, context->texSubImage2D(GraphicsContext3D::TEXTURE_2D, 0, updateRect.x(), updateRect.y(), updateRect.width(), updateRect.height(), GraphicsContext3D::RGBA, GraphicsContext3D::UNSIGNED_BYTE, pixels));
}
+ if (generateMipmap)
+ GLC(context, context->generateMipmap(GraphicsContext3D::TEXTURE_2D));
+
m_dirtyRect.setSize(FloatSize());
m_contentsDirty = false;
}
diff --git a/WebCore/platform/graphics/chromium/ContentLayerChromium.h b/WebCore/platform/graphics/chromium/ContentLayerChromium.h
index 7f302fc..d325dfb 100644
--- a/WebCore/platform/graphics/chromium/ContentLayerChromium.h
+++ b/WebCore/platform/graphics/chromium/ContentLayerChromium.h
@@ -63,6 +63,7 @@ public:
int shaderMatrixLocation() const { return m_shaderMatrixLocation; }
int shaderAlphaLocation() const { return m_shaderAlphaLocation; }
int initialized() const { return m_initialized; }
+ bool npotSupported() const { return m_npotSupported; }
private:
GraphicsContext3D* m_context;
@@ -71,13 +72,16 @@ public:
int m_shaderMatrixLocation;
int m_shaderAlphaLocation;
int m_initialized;
+ bool m_npotSupported;
};
protected:
ContentLayerChromium(GraphicsLayerChromium* owner);
+ enum MipmapUse {noMipmap, useMipmap};
+
void updateTextureRect(void* pixels, const IntSize& bitmapSize, const IntSize& requiredTextureSize,
- const IntRect& updateRect, unsigned textureId);
+ const IntRect& updateRect, unsigned textureId, MipmapUse generateMipmap = noMipmap);
virtual void cleanupResources();
diff --git a/WebCore/platform/graphics/chromium/ImageLayerChromium.cpp b/WebCore/platform/graphics/chromium/ImageLayerChromium.cpp
index c97be82..42bc1ff 100644
--- a/WebCore/platform/graphics/chromium/ImageLayerChromium.cpp
+++ b/WebCore/platform/graphics/chromium/ImageLayerChromium.cpp
@@ -152,7 +152,7 @@ void ImageLayerChromium::updateContents()
dirtyRect.intersect(IntRect(IntPoint(0, 0), bitmapSize));
if (pixels)
- updateTextureRect(pixels, bitmapSize, requiredTextureSize, dirtyRect, textureId);
+ updateTextureRect(pixels, bitmapSize, requiredTextureSize, dirtyRect, textureId, useMipmap);
}
}
--
WebKit Debian packaging
More information about the Pkg-webkit-commits
mailing list