[TexMap] Add TextureMapperContextAttributes
authorzandobersek@gmail.com <zandobersek@gmail.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 8 Aug 2017 07:46:42 +0000 (07:46 +0000)
committerzandobersek@gmail.com <zandobersek@gmail.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 8 Aug 2017 07:46:42 +0000 (07:46 +0000)
https://bugs.webkit.org/show_bug.cgi?id=175311

Reviewed by Carlos Garcia Campos.

Add and use TextureMapperContextAttributes, a slim struct that holds
information about the type and extensions supported by the OpenGL
context that's being used for one specific TextureMapperGL instance.

This struct is initialized in the TextureMapperGL constructor for the
OpenGL context that's been made current on that thread, and that will
be used for that TextureMapperGL instance through its lifetime. The
struct is then also copied into any BitmapTextureGL objects that have
been created through this TextureMapperGL (or its texture pool).

The struct is initialized with information about GLES2 support (which
is at this point done through the USE_OPENGL_ES_2 macro) and about
specific OpenGL extensions that are supported. These are then used in
TextureMapperGL (NPOT textures) and BitmapTextureGL (BGRA support,
sub-image unpacking) to deploy specific optimizations or workarounds.

This ultimately serves as a replacement for clunky static functions
that need to operate on GraphicsContext3D objects to retrieve this
information.

No new tests -- no change in behavior.

* platform/TextureMapper.cmake:
* platform/graphics/texmap/BitmapTextureGL.cpp:
(WebCore::BitmapTextureGL::BitmapTextureGL):
(WebCore::BitmapTextureGL::updateContentsNoSwizzle):
(WebCore::BitmapTextureGL::updateContents):
(WebCore::driverSupportsSubImage): Deleted.
* platform/graphics/texmap/BitmapTextureGL.h:
(WebCore::BitmapTextureGL::create):
* platform/graphics/texmap/BitmapTexturePool.cpp:
(WebCore::BitmapTexturePool::BitmapTexturePool):
(WebCore::BitmapTexturePool::createTexture):
* platform/graphics/texmap/BitmapTexturePool.h:
* platform/graphics/texmap/TextureMapperContextAttributes.cpp: Added.
(WebCore::TextureMapperContextAttributes::initialize):
* platform/graphics/texmap/TextureMapperContextAttributes.h: Added.
* platform/graphics/texmap/TextureMapperGL.cpp:
(WebCore::TextureMapperGL::TextureMapperGL):
(WebCore::TextureMapperGL::drawTexture):
(WebCore::TextureMapperGL::drawTexturedQuadWithProgram):
(WebCore::TextureMapperGL::createTexture):
(WebCore::driverSupportsNPOTTextures): Deleted.
* platform/graphics/texmap/TextureMapperGL.h:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@220392 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebCore/ChangeLog
Source/WebCore/platform/TextureMapper.cmake
Source/WebCore/platform/graphics/texmap/BitmapTextureGL.cpp
Source/WebCore/platform/graphics/texmap/BitmapTextureGL.h
Source/WebCore/platform/graphics/texmap/BitmapTexturePool.cpp
Source/WebCore/platform/graphics/texmap/BitmapTexturePool.h
Source/WebCore/platform/graphics/texmap/TextureMapperContextAttributes.cpp [new file with mode: 0644]
Source/WebCore/platform/graphics/texmap/TextureMapperContextAttributes.h [new file with mode: 0644]
Source/WebCore/platform/graphics/texmap/TextureMapperGL.cpp
Source/WebCore/platform/graphics/texmap/TextureMapperGL.h

index f3d471a..13d6118 100644 (file)
@@ -1,5 +1,57 @@
 2017-08-08  Zan Dobersek  <zdobersek@igalia.com>
 
+        [TexMap] Add TextureMapperContextAttributes
+        https://bugs.webkit.org/show_bug.cgi?id=175311
+
+        Reviewed by Carlos Garcia Campos.
+
+        Add and use TextureMapperContextAttributes, a slim struct that holds
+        information about the type and extensions supported by the OpenGL
+        context that's being used for one specific TextureMapperGL instance.
+
+        This struct is initialized in the TextureMapperGL constructor for the
+        OpenGL context that's been made current on that thread, and that will
+        be used for that TextureMapperGL instance through its lifetime. The
+        struct is then also copied into any BitmapTextureGL objects that have
+        been created through this TextureMapperGL (or its texture pool).
+
+        The struct is initialized with information about GLES2 support (which
+        is at this point done through the USE_OPENGL_ES_2 macro) and about
+        specific OpenGL extensions that are supported. These are then used in
+        TextureMapperGL (NPOT textures) and BitmapTextureGL (BGRA support,
+        sub-image unpacking) to deploy specific optimizations or workarounds.
+
+        This ultimately serves as a replacement for clunky static functions
+        that need to operate on GraphicsContext3D objects to retrieve this
+        information.
+
+        No new tests -- no change in behavior.
+
+        * platform/TextureMapper.cmake:
+        * platform/graphics/texmap/BitmapTextureGL.cpp:
+        (WebCore::BitmapTextureGL::BitmapTextureGL):
+        (WebCore::BitmapTextureGL::updateContentsNoSwizzle):
+        (WebCore::BitmapTextureGL::updateContents):
+        (WebCore::driverSupportsSubImage): Deleted.
+        * platform/graphics/texmap/BitmapTextureGL.h:
+        (WebCore::BitmapTextureGL::create):
+        * platform/graphics/texmap/BitmapTexturePool.cpp:
+        (WebCore::BitmapTexturePool::BitmapTexturePool):
+        (WebCore::BitmapTexturePool::createTexture):
+        * platform/graphics/texmap/BitmapTexturePool.h:
+        * platform/graphics/texmap/TextureMapperContextAttributes.cpp: Added.
+        (WebCore::TextureMapperContextAttributes::initialize):
+        * platform/graphics/texmap/TextureMapperContextAttributes.h: Added.
+        * platform/graphics/texmap/TextureMapperGL.cpp:
+        (WebCore::TextureMapperGL::TextureMapperGL):
+        (WebCore::TextureMapperGL::drawTexture):
+        (WebCore::TextureMapperGL::drawTexturedQuadWithProgram):
+        (WebCore::TextureMapperGL::createTexture):
+        (WebCore::driverSupportsNPOTTextures): Deleted.
+        * platform/graphics/texmap/TextureMapperGL.h:
+
+2017-08-08  Zan Dobersek  <zdobersek@igalia.com>
+
         [TexMap] Don't expose GraphicsContext3D object
         https://bugs.webkit.org/show_bug.cgi?id=175310
 
index 41ffe8f..75e4106 100644 (file)
@@ -17,6 +17,7 @@ if (USE_TEXTURE_MAPPER_GL)
     list(APPEND WebCore_SOURCES
         platform/graphics/texmap/BitmapTextureGL.cpp
         platform/graphics/texmap/ClipStack.cpp
+        platform/graphics/texmap/TextureMapperContextAttributes.cpp
         platform/graphics/texmap/TextureMapperGL.cpp
         platform/graphics/texmap/TextureMapperShaderProgram.cpp
     )
index f2ed01b..cf56eb2 100644 (file)
@@ -57,8 +57,9 @@ BitmapTextureGL* toBitmapTextureGL(BitmapTexture* texture)
     return static_cast<BitmapTextureGL*>(texture);
 }
 
-BitmapTextureGL::BitmapTextureGL(RefPtr<GraphicsContext3D>&& context3D, const Flags flags, GC3Dint internalFormat)
-    : m_context3D(WTFMove(context3D))
+BitmapTextureGL::BitmapTextureGL(const TextureMapperContextAttributes& contextAttributes, RefPtr<GraphicsContext3D>&& context3D, const Flags flags, GC3Dint internalFormat)
+    : m_contextAttributes(contextAttributes)
+    , m_context3D(WTFMove(context3D))
 {
     if (internalFormat != GraphicsContext3D::DONT_CARE) {
         m_internalFormat = m_format = internalFormat;
@@ -72,8 +73,8 @@ BitmapTextureGL::BitmapTextureGL(RefPtr<GraphicsContext3D>&& context3D, const Fl
         // internal and external formats need to be BGRA
         m_internalFormat = GraphicsContext3D::RGBA;
         m_format = GraphicsContext3D::BGRA;
-        if (m_context3D->isGLES2Compliant()) {
-            if (m_context3D->getExtensions().supports("GL_EXT_texture_format_BGRA8888"))
+        if (m_contextAttributes.isGLES2Compliant) {
+            if (m_contextAttributes.supportsBGRA8888)
                 m_internalFormat = GraphicsContext3D::BGRA;
             else
                 m_format = GraphicsContext3D::RGBA;
@@ -91,16 +92,6 @@ static void swizzleBGRAToRGBA(uint32_t* data, const IntRect& rect, int stride =
     }
 }
 
-static bool driverSupportsSubImage(GraphicsContext3D* context)
-{
-    if (context->isGLES2Compliant()) {
-        static bool supportsSubImage = context->getExtensions().supports("GL_EXT_unpack_subimage");
-        return supportsSubImage;
-    }
-
-    return true;
-}
-
 void BitmapTextureGL::didReset()
 {
     if (!m_id)
@@ -122,9 +113,12 @@ void BitmapTextureGL::didReset()
 
 void BitmapTextureGL::updateContentsNoSwizzle(const void* srcData, const IntRect& targetRect, const IntPoint& sourceOffset, int bytesPerLine, unsigned bytesPerPixel, Platform3DObject glFormat)
 {
-    m_context3D->bindTexture(GraphicsContext3D::TEXTURE_2D, m_id);
     // For ES drivers that don't support sub-images.
-    if (driverSupportsSubImage(m_context3D.get())) {
+    bool contextSupportsUnpackSubimage = m_contextAttributes.supportsUnpackSubimage;
+
+    m_context3D->bindTexture(GraphicsContext3D::TEXTURE_2D, m_id);
+
+    if (contextSupportsUnpackSubimage) {
         // Use the OpenGL sub-image extension, now that we know it's available.
         m_context3D->pixelStorei(GraphicsContext3D::UNPACK_ROW_LENGTH, bytesPerLine / bytesPerPixel);
         m_context3D->pixelStorei(GraphicsContext3D::UNPACK_SKIP_ROWS, sourceOffset.y());
@@ -133,8 +127,7 @@ void BitmapTextureGL::updateContentsNoSwizzle(const void* srcData, const IntRect
 
     m_context3D->texSubImage2D(GraphicsContext3D::TEXTURE_2D, 0, targetRect.x(), targetRect.y(), targetRect.width(), targetRect.height(), glFormat, m_type, srcData);
 
-    // For ES drivers that don't support sub-images.
-    if (driverSupportsSubImage(m_context3D.get())) {
+    if (contextSupportsUnpackSubimage) {
         m_context3D->pixelStorei(GraphicsContext3D::UNPACK_ROW_LENGTH, 0);
         m_context3D->pixelStorei(GraphicsContext3D::UNPACK_SKIP_ROWS, 0);
         m_context3D->pixelStorei(GraphicsContext3D::UNPACK_SKIP_PIXELS, 0);
@@ -151,7 +144,7 @@ void BitmapTextureGL::updateContents(const void* srcData, const IntRect& targetR
     IntPoint adjustedSourceOffset = sourceOffset;
 
     // Texture upload requires subimage buffer if driver doesn't support subimage and we don't have full image upload.
-    bool requireSubImageBuffer = !driverSupportsSubImage(m_context3D.get())
+    bool requireSubImageBuffer = !m_contextAttributes.supportsUnpackSubimage
         && !(bytesPerLine == static_cast<int>(targetRect.width() * bytesPerPixel) && adjustedSourceOffset == IntPoint::zero());
 
     // prepare temporaryData if necessary
index abbfbde..3eb48a3 100644 (file)
@@ -28,6 +28,7 @@
 #include "FilterOperation.h"
 #include "GraphicsContext3D.h"
 #include "IntSize.h"
+#include "TextureMapperContextAttributes.h"
 #include "TextureMapperGL.h"
 
 namespace WebCore {
@@ -38,9 +39,9 @@ class FilterOperation;
 
 class BitmapTextureGL : public BitmapTexture {
 public:
-    static Ref<BitmapTexture> create(Ref<GraphicsContext3D>&& context3D, const Flags flags = NoFlag, GC3Dint internalFormat = GraphicsContext3D::DONT_CARE)
+    static Ref<BitmapTexture> create(const TextureMapperContextAttributes& contextAttributes, Ref<GraphicsContext3D>&& context3D, const Flags flags = NoFlag, GC3Dint internalFormat = GraphicsContext3D::DONT_CARE)
     {
-        return adoptRef(*new BitmapTextureGL(WTFMove(context3D), flags, internalFormat));
+        return adoptRef(*new BitmapTextureGL(contextAttributes, WTFMove(context3D), flags, internalFormat));
     }
 
     virtual ~BitmapTextureGL();
@@ -79,7 +80,7 @@ public:
     void copyFromExternalTexture(Platform3DObject textureID);
 
 private:
-    BitmapTextureGL(RefPtr<GraphicsContext3D>&&, const Flags, GC3Dint internalFormat);
+    BitmapTextureGL(const TextureMapperContextAttributes&, RefPtr<GraphicsContext3D>&&, const Flags, GC3Dint internalFormat);
 
     Platform3DObject m_id { 0 };
     IntSize m_textureSize;
@@ -89,6 +90,7 @@ private:
     Platform3DObject m_depthBufferObject { 0 };
     bool m_shouldClear { true };
     ClipStack m_clipStack;
+    TextureMapperContextAttributes m_contextAttributes;
     RefPtr<GraphicsContext3D> m_context3D;
 
     void clearIfNeeded();
index c19f31b..b8a1e54 100644 (file)
@@ -37,8 +37,9 @@ static const double releaseUnusedSecondsTolerance = 3;
 static const Seconds releaseUnusedTexturesTimerInterval { 500_ms };
 
 #if USE(TEXTURE_MAPPER_GL)
-BitmapTexturePool::BitmapTexturePool(RefPtr<GraphicsContext3D>&& context3D)
-    : m_context3D(WTFMove(context3D))
+BitmapTexturePool::BitmapTexturePool(const TextureMapperContextAttributes& contextAttributes, RefPtr<GraphicsContext3D>&& context3D)
+    : m_contextAttributes(contextAttributes)
+    , m_context3D(WTFMove(context3D))
     , m_releaseUnusedTexturesTimer(RunLoop::current(), this, &BitmapTexturePool::releaseUnusedTexturesTimerFired)
 {
 }
@@ -93,7 +94,7 @@ void BitmapTexturePool::releaseUnusedTexturesTimerFired()
 RefPtr<BitmapTexture> BitmapTexturePool::createTexture(const BitmapTexture::Flags flags)
 {
 #if USE(TEXTURE_MAPPER_GL)
-    return BitmapTextureGL::create(*m_context3D, flags);
+    return BitmapTextureGL::create(m_contextAttributes, *m_context3D, flags);
 #else
     UNUSED_PARAM(flags);
     return nullptr;
index e2e11f1..897f5c2 100644 (file)
@@ -28,6 +28,7 @@
 #define BitmapTexturePool_h
 
 #include "BitmapTexture.h"
+#include "TextureMapperContextAttributes.h"
 #include <wtf/CurrentTime.h>
 #include <wtf/RunLoop.h>
 
@@ -45,7 +46,7 @@ class BitmapTexturePool {
     WTF_MAKE_FAST_ALLOCATED;
 public:
 #if USE(TEXTURE_MAPPER_GL)
-    explicit BitmapTexturePool(RefPtr<GraphicsContext3D>&&);
+    explicit BitmapTexturePool(const TextureMapperContextAttributes&, RefPtr<GraphicsContext3D>&&);
 #endif
 
     RefPtr<BitmapTexture> acquireTexture(const IntSize&, const BitmapTexture::Flags);
@@ -68,6 +69,7 @@ private:
     RefPtr<BitmapTexture> createTexture(const BitmapTexture::Flags);
 
 #if USE(TEXTURE_MAPPER_GL)
+    TextureMapperContextAttributes m_contextAttributes;
     RefPtr<GraphicsContext3D> m_context3D;
 #endif
 
diff --git a/Source/WebCore/platform/graphics/texmap/TextureMapperContextAttributes.cpp b/Source/WebCore/platform/graphics/texmap/TextureMapperContextAttributes.cpp
new file mode 100644 (file)
index 0000000..214cf0d
--- /dev/null
@@ -0,0 +1,58 @@
+/*
+ * Copyright (C) 2017 Igalia S.L.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. 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 APPLE INC. AND ITS CONTRIBUTORS ``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 APPLE INC. OR ITS 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.
+ */
+
+#include "config.h"
+#include "TextureMapperContextAttributes.h"
+
+#if USE(TEXTURE_MAPPER_GL)
+
+#include <wtf/text/WTFString.h>
+
+#if USE(LIBEPOXY)
+#include <epoxy/gl.h>
+#elif USE(OPENGL_ES_2)
+#include <GLES2/gl2.h>
+#else
+#include "OpenGLShims.h"
+#endif
+
+namespace WebCore {
+
+void TextureMapperContextAttributes::initialize()
+{
+#if USE(OPENGL_ES_2)
+    isGLES2Compliant = true;
+#endif
+
+    String extensionsString(reinterpret_cast<const char*>(glGetString(GL_EXTENSIONS)));
+
+    supportsNPOTTextures = !isGLES2Compliant || extensionsString.contains(ASCIILiteral("GL_OES_texture_npot"));
+    supportsBGRA8888 = extensionsString.contains(ASCIILiteral("GL_EXT_texture_format_BGRA8888"));
+    supportsUnpackSubimage = !isGLES2Compliant || extensionsString.contains(ASCIILiteral("GL_EXT_unpack_subimage"));
+}
+
+} // namespace WebCore
+
+#endif // USE(TEXTURE_MAPPER_GL)
diff --git a/Source/WebCore/platform/graphics/texmap/TextureMapperContextAttributes.h b/Source/WebCore/platform/graphics/texmap/TextureMapperContextAttributes.h
new file mode 100644 (file)
index 0000000..00c7b99
--- /dev/null
@@ -0,0 +1,44 @@
+/*
+ * Copyright (C) 2017 Igalia S.L.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. 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 APPLE INC. AND ITS CONTRIBUTORS ``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 APPLE INC. OR ITS 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.
+ */
+
+#pragma once
+
+#if USE(TEXTURE_MAPPER_GL)
+
+namespace WebCore {
+
+struct TextureMapperContextAttributes {
+    void initialize();
+
+    bool isGLES2Compliant { false };
+
+    bool supportsNPOTTextures { false };
+    bool supportsBGRA8888 { false };
+    bool supportsUnpackSubimage { false };
+};
+
+} // namespace WebCore
+
+#endif // USE(TEXTURE_MAPPER_GL)
index e0b7a70..39a747b 100644 (file)
@@ -165,12 +165,14 @@ Ref<TextureMapperShaderProgram> TextureMapperGLData::getShaderProgram(TextureMap
 TextureMapperGL::TextureMapperGL()
     : m_enableEdgeDistanceAntialiasing(false)
 {
+    m_contextAttributes.initialize();
+
     m_context3D = GraphicsContext3D::createForCurrentGLContext();
     ASSERT(m_context3D);
 
     m_data = new TextureMapperGLData(*m_context3D);
 #if USE(TEXTURE_MAPPER_GL)
-    m_texturePool = std::make_unique<BitmapTexturePool>(m_context3D.copyRef());
+    m_texturePool = std::make_unique<BitmapTexturePool>(m_contextAttributes, m_context3D.copyRef());
 #endif
 }
 
@@ -436,16 +438,6 @@ void TextureMapperGL::drawTexture(const BitmapTexture& texture, const FloatRect&
     drawTexture(textureGL.id(), textureGL.isOpaque() ? 0 : ShouldBlend, textureGL.size(), targetRect, matrix, opacity, exposedEdges);
 }
 
-static bool driverSupportsNPOTTextures(GraphicsContext3D& context)
-{
-    if (context.isGLES2Compliant()) {
-        static bool supportsNPOTTextures = context.getExtensions().supports("GL_OES_texture_npot");
-        return supportsNPOTTextures;
-    }
-
-    return true;
-}
-
 void TextureMapperGL::drawTexture(Platform3DObject texture, Flags flags, const IntSize& textureSize, const FloatRect& targetRect, const TransformationMatrix& modelViewMatrix, float opacity, unsigned exposedEdges)
 {
     bool useRect = flags & ShouldUseARBTextureRect;
@@ -462,7 +454,7 @@ void TextureMapperGL::drawTexture(Platform3DObject texture, Flags flags, const I
         options |= TextureMapperShaderProgram::Antialiasing;
         flags |= ShouldAntialias;
     }
-    if (wrapMode() == RepeatWrap && !driverSupportsNPOTTextures(*m_context3D))
+    if (wrapMode() == RepeatWrap && !m_contextAttributes.supportsNPOTTextures)
         options |= TextureMapperShaderProgram::ManualRepeat;
 
     RefPtr<FilterOperation> filter = data().filterInfo ? data().filterInfo->filter: 0;
@@ -591,7 +583,7 @@ void TextureMapperGL::drawTexturedQuadWithProgram(TextureMapperShaderProgram& pr
     GC3Denum target = flags & ShouldUseARBTextureRect ? GC3Denum(Extensions3D::TEXTURE_RECTANGLE_ARB) : GC3Denum(GraphicsContext3D::TEXTURE_2D);
     m_context3D->bindTexture(target, texture);
     m_context3D->uniform1i(program.samplerLocation(), 0);
-    if (wrapMode() == RepeatWrap && driverSupportsNPOTTextures(*m_context3D)) {
+    if (wrapMode() == RepeatWrap && m_contextAttributes.supportsNPOTTextures) {
         m_context3D->texParameteri(GraphicsContext3D::TEXTURE_2D, GraphicsContext3D::TEXTURE_WRAP_S, GraphicsContext3D::REPEAT);
         m_context3D->texParameteri(GraphicsContext3D::TEXTURE_2D, GraphicsContext3D::TEXTURE_WRAP_T, GraphicsContext3D::REPEAT);
     }
@@ -768,7 +760,7 @@ IntRect TextureMapperGL::clipBounds()
 
 Ref<BitmapTexture> TextureMapperGL::createTexture(GC3Dint internalFormat)
 {
-    return BitmapTextureGL::create(*m_context3D, internalFormat);
+    return BitmapTextureGL::create(m_contextAttributes, *m_context3D, internalFormat);
 }
 
 std::unique_ptr<TextureMapper> TextureMapper::platformCreateAccelerated()
index 1a52a44..1c88996 100644 (file)
@@ -28,6 +28,7 @@
 #include "GraphicsContext3D.h"
 #include "IntSize.h"
 #include "TextureMapper.h"
+#include "TextureMapperContextAttributes.h"
 #include "TransformationMatrix.h"
 
 namespace WebCore {
@@ -90,6 +91,8 @@ private:
     void bindDefaultSurface();
     ClipStack& clipStack();
     inline TextureMapperGLData& data() { return *m_data; }
+
+    TextureMapperContextAttributes m_contextAttributes;
     RefPtr<GraphicsContext3D> m_context3D;
     TextureMapperGLData* m_data;
     ClipStack m_clipStack;