WebKit Bugzilla
New
Browse
Search+
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
[patch]
patch
2012_08_15.diff (text/plain), 115.08 KB, created by
Roland Takacs
on 2012-08-15 12:56:30 PDT
(
hide
)
Description:
patch
Filename:
MIME Type:
Creator:
Roland Takacs
Created:
2012-08-15 12:56:30 PDT
Size:
115.08 KB
patch
obsolete
>diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog >index 6992d8b..4d8d999 100644 >--- a/Source/WebCore/ChangeLog >+++ b/Source/WebCore/ChangeLog >@@ -1,3 +1,266 @@ >+2012-08-12 Helder Correia <helder.correia@nokia.com> >+ >+ [Texmap] Move TextureMapperGL to use GraphicsContext3D >+ https://bugs.webkit.org/show_bug.cgi?id=78672 >+ >+ It is based on a previous patch by Helder Correia. >+ >+ TextureMapperGL (TMGL) includes direct GL calls and >+ GraphicsContext3D (GC3D) offers many conveniences over the >+ former approach: using existing CSS shader code, ANGLE for >+ shader compilation, reusing WebCore::Texture, having shaders and >+ textures that can delete themselves. >+ >+ This patch changes the backend of TMGL to GC3D. It was initially >+ thought to introduce a new backend (say, TextureMapperGC3D), but >+ in the end it was agreed to consolidate it inside TMGL instead, >+ as an additional TextureMapper subclass would get stale very >+ quickly. >+ >+ A GC3D object is created by TMGL with the newly introduced >+ builder createForCurrentGLContext(), which in turn uses >+ the new RenderToCurrentGLContext flag underneath. >+ >+ TMGL's dependency on OpenGLShims.h was completely removed. >+ However, GC3D does not map every single GL constant. Thus, it's >+ important to document the following: >+ - GL_FALSE was mapped to false. >+ - GL_UNPACK_ROW_LENGTH, GL_UNPACK_SKIP_PIXELS, >+ GL_UNPACK_SKIP_ROWS, GL_TEXTURE_RECTANGLE_ARB, and >+ GL_UNSIGNED_INT_8_8_8_8_REV were locally defined in TMGL. >+ >+ The patch was originally developed by Helder Correia and finished >+ by Roland Takacs (rtakacs@inf.u-szeged.hu). >+ >+ No new tests, refactoring. >+ >+ * platform/chromium/support/GraphicsContext3DChromium.cpp: >+ (WebCore::GraphicsContext3D::GraphicsContext3D): >+ * platform/chromium/support/GraphicsContext3DPrivate.cpp: >+ (WebCore::GraphicsContext3DPrivate::createGraphicsContextFromWebContext): >+ * platform/graphics/GraphicsContext3D.h: >+ (GraphicsContext3D): >+ * platform/graphics/blackberry/GraphicsContext3DBlackBerry.cpp: >+ (WebCore::GraphicsContext3D::create): >+ (WebCore::GraphicsContext3D::GraphicsContext3D): >+ * platform/graphics/cairo/GraphicsContext3DCairo.cpp: >+ (WebCore::GraphicsContext3D::create): >+ (WebCore::GraphicsContext3D::GraphicsContext3D): >+ * platform/graphics/clutter/GraphicsContext3DClutter.cpp: >+ (WebCore::GraphicsContext3D::create): >+ (WebCore::GraphicsContext3D::GraphicsContext3D): >+ * platform/graphics/efl/GraphicsContext3DEfl.cpp: >+ (WebCore::GraphicsContext3D::create): >+ (WebCore::GraphicsContext3D::GraphicsContext3D): >+ * platform/graphics/mac/GraphicsContext3DMac.mm: >+ (WebCore::GraphicsContext3D::create): >+ (WebCore::GraphicsContext3D::GraphicsContext3D): >+ * platform/graphics/opengl/GraphicsContext3DOpenGL.cpp: >+ (WebCore::GraphicsContext3D::texImage2D): >+ * platform/graphics/opengl/GraphicsContext3DOpenGLCommon.cpp: >+ (WebCore::GraphicsContext3D::createForCurrentGLContext): >+ (WebCore): >+ (WebCore::GraphicsContext3D::texImage2DDirect): >+ * platform/graphics/opengl/GraphicsContext3DOpenGLES.cpp: >+ (WebCore::GraphicsContext3D::texImage2D): >+ * platform/graphics/qt/GraphicsContext3DQt.cpp: >+ (GraphicsContext3DPrivate): >+ (WebCore::GraphicsContext3DPrivate::GraphicsContext3DPrivate): >+ (WebCore::GraphicsContext3DPrivate::createOffscreenBuffers): >+ (WebCore): >+ (WebCore::GraphicsContext3DPrivate::initializeANGLE): >+ (WebCore::GraphicsContext3DPrivate::~GraphicsContext3DPrivate): >+ (WebCore::GraphicsContext3D::create): >+ (WebCore::GraphicsContext3D::GraphicsContext3D): >+ (WebCore::GraphicsContext3D::makeContextCurrent): >+ * platform/graphics/texmap/TextureMapperGL.cpp: >+ (SharedGLData): >+ (WebCore::TextureMapperGLData::SharedGLData::currentSharedGLData): >+ (WebCore::TextureMapperGLData::SharedGLData::SharedGLData): >+ (WebCore::TextureMapperGLData::sharedGLData): >+ (WebCore::TextureMapperGLData::TextureMapperGLData): >+ (TextureMapperGLData): >+ (WebCore::scissorClip): >+ (WebCore::TextureMapperGL::ClipStack::apply): >+ (WebCore::TextureMapperGLData::initializeStencil): >+ (WebCore::TextureMapperGL::TextureMapperGL): >+ (WebCore::TextureMapperGL::beginPainting): >+ (WebCore::TextureMapperGL::endPainting): >+ (WebCore::TextureMapperGL::drawQuad): >+ (WebCore::TextureMapperGL::drawBorder): >+ (WebCore): >+ (WebCore::TextureMapperGL::drawTextureRectangleARB): >+ (WebCore::TextureMapperGL::drawTexture): >+ (WebCore::viewportMatrix): >+ (WebCore::TextureMapperGL::drawTextureWithAntialiasing): >+ (WebCore::TextureMapperGL::drawTexturedQuadWithProgram): >+ (WebCore::BitmapTextureGL::didReset): >+ (WebCore::BitmapTextureGL::updateContents): >+ (WebCore::TextureMapperGL::drawFiltered): >+ (WebCore::BitmapTextureGL::initializeStencil): >+ (WebCore::BitmapTextureGL::clearIfNeeded): >+ (WebCore::BitmapTextureGL::createFboIfNeeded): >+ (WebCore::BitmapTextureGL::bind): >+ (WebCore::BitmapTextureGL::~BitmapTextureGL): >+ (WebCore::TextureMapperGL::bindDefaultSurface): >+ (WebCore::TextureMapperGL::beginScissorClip): >+ (WebCore::TextureMapperGL::beginClip): >+ (WebCore::TextureMapperGL::endClip): >+ (WebCore::TextureMapperGL::createTexture): >+ * platform/graphics/texmap/TextureMapperGL.h: >+ (WebCore::TextureMapperGL::graphicsContext3D): >+ (TextureMapperGL): >+ (ClipStack): >+ (WebCore::BitmapTextureGL::textureTarget): >+ (BitmapTextureGL): >+ (WebCore::BitmapTextureGL::BitmapTextureGL): >+ * platform/graphics/texmap/TextureMapperShaderManager.cpp: >+ (WebCore): >+ (WebCore::TextureMapperShaderManager::getShaderProgram): >+ (WebCore::TextureMapperShaderProgram::TextureMapperShaderProgram): >+ (WebCore::TextureMapperShaderProgram::initializeProgram): >+ (WebCore::TextureMapperShaderProgram::getUniformLocation): >+ (WebCore::TextureMapperShaderProgram::~TextureMapperShaderProgram): >+ (WebCore::TextureMapperShaderProgramSimple::TextureMapperShaderProgramSimple): >+ (WebCore::TextureMapperShaderProgramSolidColor::TextureMapperShaderProgramSolidColor): >+ (WebCore::TextureMapperShaderProgramRectSimple::TextureMapperShaderProgramRectSimple): >+ (WebCore::TextureMapperShaderProgramOpacityAndMask::TextureMapperShaderProgramOpacityAndMask): >+ (WebCore::TextureMapperShaderProgramRectOpacityAndMask::TextureMapperShaderProgramRectOpacityAndMask): >+ (WebCore::TextureMapperShaderProgramAntialiasingNoMask::TextureMapperShaderProgramAntialiasingNoMask): >+ (WebCore::TextureMapperShaderManager::TextureMapperShaderManager): >+ (WebCore::StandardFilterProgram::~StandardFilterProgram): >+ (WebCore::StandardFilterProgram::StandardFilterProgram): >+ (WebCore::StandardFilterProgram::create): >+ (WebCore::StandardFilterProgram::prepare): >+ (WebCore::TextureMapperShaderManager::getShaderForFilter): >+ * platform/graphics/texmap/TextureMapperShaderManager.h: >+ (WebCore::TextureMapperShaderProgram::id): >+ (WebCore::TextureMapperShaderProgram::vertexAttrib): >+ (TextureMapperShaderProgram): >+ (WebCore::TextureMapperShaderProgram::matrixLocation): >+ (WebCore::TextureMapperShaderProgram::flipLocation): >+ (WebCore::TextureMapperShaderProgram::textureSizeLocation): >+ (WebCore::TextureMapperShaderProgram::sourceTextureLocation): >+ (WebCore::TextureMapperShaderProgram::maskTextureLocation): >+ (WebCore::TextureMapperShaderProgram::opacityLocation): >+ (WebCore::TextureMapperShaderProgram::isValidUniformLocation): >+ (StandardFilterProgram): >+ (WebCore::StandardFilterProgram::vertexAttrib): >+ (WebCore::StandardFilterProgram::texCoordAttrib): >+ (WebCore::StandardFilterProgram::textureUniform): >+ (WebCore::TextureMapperShaderProgramSimple::create): >+ (TextureMapperShaderProgramSimple): >+ (WebCore::TextureMapperShaderProgramRectSimple::create): >+ (TextureMapperShaderProgramRectSimple): >+ (WebCore::TextureMapperShaderProgramOpacityAndMask::create): >+ (TextureMapperShaderProgramOpacityAndMask): >+ (WebCore::TextureMapperShaderProgramRectOpacityAndMask::create): >+ (TextureMapperShaderProgramRectOpacityAndMask): >+ (WebCore::TextureMapperShaderProgramSolidColor::create): >+ (WebCore::TextureMapperShaderProgramSolidColor::colorLocation): >+ (TextureMapperShaderProgramSolidColor): >+ (WebCore::TextureMapperShaderProgramAntialiasingNoMask::create): >+ (WebCore::TextureMapperShaderProgramAntialiasingNoMask::expandedQuadVerticesInTextureCoordinatesLocation): >+ (WebCore::TextureMapperShaderProgramAntialiasingNoMask::expandedQuadEdgesInScreenSpaceLocation): >+ (TextureMapperShaderProgramAntialiasingNoMask): >+ (WebCore::TextureMapperShaderManager::TextureMapperShaderManager): >+ (TextureMapperShaderManager): >+ >+2012-08-12 Helder Correia <helder.correia@nokia.com> >+ >+ [Texmap] Move TextureMapperGL to use GraphicsContext3D >+ https://bugs.webkit.org/show_bug.cgi?id=78672 >+ >+ It is based on a previous patch by Helder Correia. >+ >+ This is part of a several patch-refactoring. >+ >+ Introduce additional logic in GraphicsContext3DQt to support a >+ new RenderToCurrentGLContext RenderStyle. This is necessary to >+ use GC3D for other things than WebGL, like TextureMapper. >+ >+ The GC3D constructor now accepts a RenderStyle instead of the >+ boolean renderDirectlyToHostWindow and thus mimics create()'s >+ signature. This has been changed for all ports in this patch. >+ >+ A new GC3D::createForCurrentGLContext() builder was >+ introduced to better abstract the goal of using GC3D with the >+ current context. >+ >+ The patch was originally developed by Helder Correia and finished >+ by Roland Takacs (rtakacs@inf.u-szeged.hu). >+ >+ No new tests, refactoring. >+ >+ * platform/chromium/support/GraphicsContext3DChromium.cpp: >+ (WebCore::GraphicsContext3D::GraphicsContext3D): >+ * platform/chromium/support/GraphicsContext3DPrivate.cpp: >+ (WebCore::GraphicsContext3DPrivate::createGraphicsContextFromWebContext): >+ * platform/graphics/GraphicsContext3D.h: >+ (GraphicsContext3D): >+ * platform/graphics/blackberry/GraphicsContext3DBlackBerry.cpp: >+ (WebCore::GraphicsContext3D::create): >+ (WebCore::GraphicsContext3D::GraphicsContext3D): >+ * platform/graphics/cairo/GraphicsContext3DCairo.cpp: >+ (WebCore::GraphicsContext3D::create): >+ (WebCore::GraphicsContext3D::GraphicsContext3D): >+ * platform/graphics/clutter/GraphicsContext3DClutter.cpp: >+ (WebCore::GraphicsContext3D::create): >+ (WebCore::GraphicsContext3D::GraphicsContext3D): >+ * platform/graphics/efl/GraphicsContext3DEfl.cpp: >+ (WebCore::GraphicsContext3D::create): >+ (WebCore::GraphicsContext3D::GraphicsContext3D): >+ * platform/graphics/mac/GraphicsContext3DMac.mm: >+ (WebCore::GraphicsContext3D::create): >+ (WebCore::GraphicsContext3D::GraphicsContext3D): >+ * platform/graphics/opengl/GraphicsContext3DOpenGL.cpp: >+ (WebCore::GraphicsContext3D::texImage2D): >+ * platform/graphics/opengl/GraphicsContext3DOpenGLCommon.cpp: >+ (WebCore::GraphicsContext3D::createForCurrentGLContext): >+ (WebCore): >+ (WebCore::GraphicsContext3D::texImage2DDirect): >+ * platform/graphics/opengl/GraphicsContext3DOpenGLES.cpp: >+ (WebCore::GraphicsContext3D::texImage2D): >+ * platform/graphics/qt/GraphicsContext3DQt.cpp: >+ (GraphicsContext3DPrivate): >+ (WebCore::GraphicsContext3DPrivate::GraphicsContext3DPrivate): >+ (WebCore::GraphicsContext3DPrivate::createOffscreenBuffers): >+ (WebCore): >+ (WebCore::GraphicsContext3DPrivate::initializeANGLE): >+ (WebCore::GraphicsContext3DPrivate::~GraphicsContext3DPrivate): >+ (WebCore::GraphicsContext3D::create): >+ (WebCore::GraphicsContext3D::GraphicsContext3D): >+ (WebCore::GraphicsContext3D::makeContextCurrent): >+ >+2012-08-12 Helder Correia <helder.correia@nokia.com> >+ >+ [Texmap] Move TextureMapperGL to use GraphicsContext3D >+ https://bugs.webkit.org/show_bug.cgi?id=78672 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ Introducing a new GraphicsContext3D::texImage2DDirect() to allow >+ initialization of textures without allocation. The existing >+ textImage2D() refuses a null pixel buffer, and >+ texImage2DResourceSafe() allows it but performs memory >+ allocation and zeroes the bits. This was not fast enough for >+ BitmapTextureGL frequent setting up. >+ >+ The patch was originally developed by Helder Correia and finished >+ by Roland Takacs (rtakacs@inf.u-szeged.hu). >+ >+ No new tests (OOPS!). >+ >+ * platform/graphics/GraphicsContext3D.h: >+ (GraphicsContext3D): >+ * platform/graphics/opengl/GraphicsContext3DOpenGL.cpp: >+ (WebCore::GraphicsContext3D::texImage2D): >+ * platform/graphics/opengl/GraphicsContext3DOpenGLCommon.cpp: >+ (WebCore::GraphicsContext3D::texImage2DDirect): >+ (WebCore): >+ * platform/graphics/opengl/GraphicsContext3DOpenGLES.cpp: >+ (WebCore::GraphicsContext3D::texImage2D): >+ > 2012-08-15 Benjamin Poulain <bpoulain@apple.com> > > Use literal initialization for CSS's pseudo types >diff --git a/Source/WebCore/platform/chromium/support/GraphicsContext3DChromium.cpp b/Source/WebCore/platform/chromium/support/GraphicsContext3DChromium.cpp >index 127fcfa..f8e46d8 100644 >--- a/Source/WebCore/platform/chromium/support/GraphicsContext3DChromium.cpp >+++ b/Source/WebCore/platform/chromium/support/GraphicsContext3DChromium.cpp >@@ -43,7 +43,7 @@ > > namespace WebCore { > >-GraphicsContext3D::GraphicsContext3D(GraphicsContext3D::Attributes, HostWindow*, bool) >+GraphicsContext3D::GraphicsContext3D(GraphicsContext3D::Attributes, HostWindow*, GraphicsContext3D::RenderStyle) > { > } > >diff --git a/Source/WebCore/platform/chromium/support/GraphicsContext3DPrivate.cpp b/Source/WebCore/platform/chromium/support/GraphicsContext3DPrivate.cpp >index f6b730d..0d571b4 100644 >--- a/Source/WebCore/platform/chromium/support/GraphicsContext3DPrivate.cpp >+++ b/Source/WebCore/platform/chromium/support/GraphicsContext3DPrivate.cpp >@@ -77,7 +77,7 @@ GraphicsContext3DPrivate::~GraphicsContext3DPrivate() > > PassRefPtr<GraphicsContext3D> GraphicsContext3DPrivate::createGraphicsContextFromWebContext(PassOwnPtr<WebKit::WebGraphicsContext3D> webContext, bool preserveDrawingBuffer) > { >- RefPtr<GraphicsContext3D> context = adoptRef(new GraphicsContext3D(GraphicsContext3D::Attributes(), 0, false /* onscreen */)); >+ RefPtr<GraphicsContext3D> context = adoptRef(new GraphicsContext3D(GraphicsContext3D::Attributes(), 0)); > > OwnPtr<GraphicsContext3DPrivate> priv = adoptPtr(new GraphicsContext3DPrivate(webContext, preserveDrawingBuffer)); > context->m_private = priv.release(); >diff --git a/Source/WebCore/platform/graphics/GraphicsContext3D.h b/Source/WebCore/platform/graphics/GraphicsContext3D.h >index f5e6f1f..b2e6a4d 100644 >--- a/Source/WebCore/platform/graphics/GraphicsContext3D.h >+++ b/Source/WebCore/platform/graphics/GraphicsContext3D.h >@@ -250,6 +250,7 @@ public: > ALPHA = 0x1906, > RGB = 0x1907, > RGBA = 0x1908, >+ BGRA = 0x80E1, > LUMINANCE = 0x1909, > LUMINANCE_ALPHA = 0x190A, > UNSIGNED_SHORT_4_4_4_4 = 0x8033, >@@ -458,7 +459,8 @@ public: > > enum RenderStyle { > RenderOffscreen, >- RenderDirectlyToHostWindow >+ RenderDirectlyToHostWindow, >+ RenderToCurrentGLContext > }; > > class ContextLostCallback { >@@ -477,6 +479,7 @@ public: > void setErrorMessageCallback(PassOwnPtr<ErrorMessageCallback>); > > static PassRefPtr<GraphicsContext3D> create(Attributes, HostWindow*, RenderStyle = RenderOffscreen); >+ static PassRefPtr<GraphicsContext3D> createForCurrentGLContext(); > ~GraphicsContext3D(); > > #if PLATFORM(MAC) >@@ -524,6 +527,9 @@ public: > void prepareTexture(); > #endif > >+ // Equivalent to ::glTexImage2D(). Allows pixels==0 with no allocation. >+ void texImage2DDirect(GC3Denum target, GC3Dint level, GC3Denum internalformat, GC3Dsizei width, GC3Dsizei height, GC3Dint border, GC3Denum format, GC3Denum type, const void* pixels); >+ > // Helper to texImage2D with pixel==0 case: pixels are initialized to 0. > // Return true if no GL error is synthesized. > // By default, alignment is 4, the OpenGL default setting. >@@ -867,7 +873,7 @@ public: > static unsigned getChannelBitsByFormat(GC3Denum); > > private: >- GraphicsContext3D(Attributes attrs, HostWindow* hostWindow, bool renderDirectlyToHostWindow); >+ GraphicsContext3D(Attributes, HostWindow*, RenderStyle = RenderOffscreen); > > // Each platform must provide an implementation of this method. > // >@@ -982,6 +988,7 @@ public: > friend class Extensions3DOpenGLCommon; > > Attributes m_attrs; >+ RenderStyle m_renderStyle; > Vector<Vector<float> > m_vertexArray; > > GC3Duint m_texture; >diff --git a/Source/WebCore/platform/graphics/blackberry/GraphicsContext3DBlackBerry.cpp b/Source/WebCore/platform/graphics/blackberry/GraphicsContext3DBlackBerry.cpp >index f1081ef..d3002cf 100644 >--- a/Source/WebCore/platform/graphics/blackberry/GraphicsContext3DBlackBerry.cpp >+++ b/Source/WebCore/platform/graphics/blackberry/GraphicsContext3DBlackBerry.cpp >@@ -47,10 +47,10 @@ PassRefPtr<GraphicsContext3D> GraphicsContext3D::create(Attributes attribs, Host > if (renderStyle == RenderDirectlyToHostWindow) > return 0; > >- return adoptRef(new GraphicsContext3D(attribs, hostWindow, false)); >+ return adoptRef(new GraphicsContext3D(attribs, hostWindow, renderStyle)); > } > >-GraphicsContext3D::GraphicsContext3D(GraphicsContext3D::Attributes attrs, HostWindow*, bool renderDirectlyToHostWindow) >+GraphicsContext3D::GraphicsContext3D(GraphicsContext3D::Attributes attrs, HostWindow*, GraphicsContext3D::RenderStyle renderStyle) > : m_currentWidth(0) > , m_currentHeight(0) > , m_context(BlackBerry::Platform::Graphics::createWebGLContext()) >@@ -67,7 +67,7 @@ GraphicsContext3D::GraphicsContext3D(GraphicsContext3D::Attributes attrs, HostWi > , m_boundTexture0(0) > , m_isImaginationHardware(0) > { >- if (!renderDirectlyToHostWindow) { >+ if (renderStyle != RenderDirectlyToHostWindow) { > #if USE(ACCELERATED_COMPOSITING) > m_compositingLayer = WebGLLayerWebKitThread::create(); > #endif >diff --git a/Source/WebCore/platform/graphics/cairo/GraphicsContext3DCairo.cpp b/Source/WebCore/platform/graphics/cairo/GraphicsContext3DCairo.cpp >index 9822d4e..64a2faa 100644 >--- a/Source/WebCore/platform/graphics/cairo/GraphicsContext3DCairo.cpp >+++ b/Source/WebCore/platform/graphics/cairo/GraphicsContext3DCairo.cpp >@@ -61,11 +61,11 @@ PassRefPtr<GraphicsContext3D> GraphicsContext3D::create(GraphicsContext3D::Attri > if (!success) > return 0; > >- RefPtr<GraphicsContext3D> context = adoptRef(new GraphicsContext3D(attributes, hostWindow, false)); >+ RefPtr<GraphicsContext3D> context = adoptRef(new GraphicsContext3D(attributes, hostWindow, renderStyle)); > return context.release(); > } > >-GraphicsContext3D::GraphicsContext3D(GraphicsContext3D::Attributes attributes, HostWindow*, bool) >+GraphicsContext3D::GraphicsContext3D(GraphicsContext3D::Attributes attributes, HostWindow*, GraphicsContext3D::RenderStyle) > : m_currentWidth(0) > , m_currentHeight(0) > , m_attrs(attributes) >diff --git a/Source/WebCore/platform/graphics/clutter/GraphicsContext3DClutter.cpp b/Source/WebCore/platform/graphics/clutter/GraphicsContext3DClutter.cpp >index 4b4b0e3..abfbd47 100644 >--- a/Source/WebCore/platform/graphics/clutter/GraphicsContext3DClutter.cpp >+++ b/Source/WebCore/platform/graphics/clutter/GraphicsContext3DClutter.cpp >@@ -42,11 +42,11 @@ namespace WebCore { > > PassRefPtr<GraphicsContext3D> GraphicsContext3D::create(GraphicsContext3D::Attributes attributes, HostWindow* hostWindow, GraphicsContext3D::RenderStyle renderStyle) > { >- RefPtr<GraphicsContext3D> context = adoptRef(new GraphicsContext3D(attributes, hostWindow, false)); >+ RefPtr<GraphicsContext3D> context = adoptRef(new GraphicsContext3D(attributes, hostWindow, renderStyle)); > return context.release(); > } > >-GraphicsContext3D::GraphicsContext3D(GraphicsContext3D::Attributes attributes, HostWindow* hostWindow, bool) >+GraphicsContext3D::GraphicsContext3D(GraphicsContext3D::Attributes attributes, HostWindow* hostWindow, GraphicsContext3D::RenderStyle renderStyle) > { > notImplemented(); > } >diff --git a/Source/WebCore/platform/graphics/efl/GraphicsContext3DEfl.cpp b/Source/WebCore/platform/graphics/efl/GraphicsContext3DEfl.cpp >index efe1a12..721d7c7 100644 >--- a/Source/WebCore/platform/graphics/efl/GraphicsContext3DEfl.cpp >+++ b/Source/WebCore/platform/graphics/efl/GraphicsContext3DEfl.cpp >@@ -36,12 +36,12 @@ PassRefPtr<GraphicsContext3D> GraphicsContext3D::create(GraphicsContext3D::Attri > if (!internal) > return 0; > >- RefPtr<GraphicsContext3D> context = adoptRef(new GraphicsContext3D(attrs, hostWindow, renderDirectlyToEvasGLObject)); >+ RefPtr<GraphicsContext3D> context = adoptRef(new GraphicsContext3D(attrs, hostWindow, renderStyle)); > context->m_private = internal.release(); > return context.release(); > } > >-GraphicsContext3D::GraphicsContext3D(GraphicsContext3D::Attributes attrs, HostWindow* hostWindow, bool renderDirectlyToHostWindow) >+GraphicsContext3D::GraphicsContext3D(GraphicsContext3D::Attributes attrs, HostWindow* hostWindow, GraphicsContext3D::RenderStyle renderStyle) > : m_currentWidth(0) > , m_currentHeight(0) > { >diff --git a/Source/WebCore/platform/graphics/mac/GraphicsContext3DMac.mm b/Source/WebCore/platform/graphics/mac/GraphicsContext3DMac.mm >index d042c66..00e8313 100644 >--- a/Source/WebCore/platform/graphics/mac/GraphicsContext3DMac.mm >+++ b/Source/WebCore/platform/graphics/mac/GraphicsContext3DMac.mm >@@ -98,11 +98,11 @@ PassRefPtr<GraphicsContext3D> GraphicsContext3D::create(GraphicsContext3D::Attri > // This implementation doesn't currently support rendering directly to the HostWindow. > if (renderStyle == RenderDirectlyToHostWindow) > return 0; >- RefPtr<GraphicsContext3D> context = adoptRef(new GraphicsContext3D(attrs, hostWindow, false)); >+ RefPtr<GraphicsContext3D> context = adoptRef(new GraphicsContext3D(attrs, hostWindow, renderStyle)); > return context->m_contextObj ? context.release() : 0; > } > >-GraphicsContext3D::GraphicsContext3D(GraphicsContext3D::Attributes attrs, HostWindow* hostWindow, bool) >+GraphicsContext3D::GraphicsContext3D(GraphicsContext3D::Attributes attrs, HostWindow* hostWindow, GraphicsContext3D::RenderStyle renderStyle) > : m_currentWidth(0) > , m_currentHeight(0) > , m_contextObj(0) >@@ -122,6 +122,7 @@ GraphicsContext3D::GraphicsContext3D(GraphicsContext3D::Attributes attrs, HostWi > , m_private(adoptPtr(new GraphicsContext3DPrivate(this))) > { > UNUSED_PARAM(hostWindow); >+ UNUSED_PARAM(renderStyle); > > Vector<CGLPixelFormatAttribute> attribs; > CGLPixelFormatObj pixelFormatObj = 0; >diff --git a/Source/WebCore/platform/graphics/opengl/GraphicsContext3DOpenGL.cpp b/Source/WebCore/platform/graphics/opengl/GraphicsContext3DOpenGL.cpp >index fd45014..98e1145 100644 >--- a/Source/WebCore/platform/graphics/opengl/GraphicsContext3DOpenGL.cpp >+++ b/Source/WebCore/platform/graphics/opengl/GraphicsContext3DOpenGL.cpp >@@ -256,7 +256,7 @@ bool GraphicsContext3D::texImage2D(GC3Denum target, GC3Dint level, GC3Denum inte > synthesizeGLError(INVALID_VALUE); > return false; > } >- makeContextCurrent(); >+ > GC3Denum openGLInternalFormat = internalformat; > if (type == GL_FLOAT) { > if (format == GL_RGBA) >@@ -265,7 +265,7 @@ bool GraphicsContext3D::texImage2D(GC3Denum target, GC3Dint level, GC3Denum inte > openGLInternalFormat = GL_RGB32F_ARB; > } > >- ::glTexImage2D(target, level, openGLInternalFormat, width, height, border, format, type, pixels); >+ texImage2DDirect(target, level, openGLInternalFormat, width, height, border, format, type, pixels); > return true; > } > >diff --git a/Source/WebCore/platform/graphics/opengl/GraphicsContext3DOpenGLCommon.cpp b/Source/WebCore/platform/graphics/opengl/GraphicsContext3DOpenGLCommon.cpp >index e0c2d6e..772ca81 100644 >--- a/Source/WebCore/platform/graphics/opengl/GraphicsContext3DOpenGLCommon.cpp >+++ b/Source/WebCore/platform/graphics/opengl/GraphicsContext3DOpenGLCommon.cpp >@@ -70,6 +70,12 @@ > > namespace WebCore { > >+PassRefPtr<GraphicsContext3D> GraphicsContext3D::createForCurrentGLContext() >+{ >+ RefPtr<GraphicsContext3D> context = adoptRef(new GraphicsContext3D(Attributes(), 0, GraphicsContext3D::RenderToCurrentGLContext)); >+ return context->m_private ? context.release() : 0; >+} >+ > void GraphicsContext3D::validateDepthStencil(const char* packedDepthStencilExtension) > { > Extensions3D* extensions = getExtensions(); >@@ -1374,6 +1380,12 @@ bool GraphicsContext3D::layerComposited() const > return m_layerComposited; > } > >+void GraphicsContext3D::texImage2DDirect(GC3Denum target, GC3Dint level, GC3Denum internalformat, GC3Dsizei width, GC3Dsizei height, GC3Dint border, GC3Denum format, GC3Denum type, const void* pixels) >+{ >+ makeContextCurrent(); >+ ::glTexImage2D(target, level, internalformat, width, height, border, format, type, pixels); >+} >+ > } > > #endif // USE(3D_GRAPHICS) >diff --git a/Source/WebCore/platform/graphics/opengl/GraphicsContext3DOpenGLES.cpp b/Source/WebCore/platform/graphics/opengl/GraphicsContext3DOpenGLES.cpp >index 9dbb483..4d1530c 100644 >--- a/Source/WebCore/platform/graphics/opengl/GraphicsContext3DOpenGLES.cpp >+++ b/Source/WebCore/platform/graphics/opengl/GraphicsContext3DOpenGLES.cpp >@@ -31,6 +31,7 @@ > #if USE(3D_GRAPHICS) > > #include "GraphicsContext3D.h" >+ > #include "Extensions3DOpenGLES.h" > #include "IntRect.h" > #include "IntSize.h" >@@ -201,8 +202,8 @@ bool GraphicsContext3D::texImage2D(GC3Denum target, GC3Dint level, GC3Denum inte > synthesizeGLError(INVALID_VALUE); > return false; > } >- makeContextCurrent(); >- ::glTexImage2D(target, level, internalformat, width, height, border, format, type, pixels); >+ >+ texImage2DDirect(target, level, internalformat, width, height, border, format, type, pixels); > return true; > } > >diff --git a/Source/WebCore/platform/graphics/qt/GraphicsContext3DQt.cpp b/Source/WebCore/platform/graphics/qt/GraphicsContext3DQt.cpp >index cb824f6..4d69d71 100644 >--- a/Source/WebCore/platform/graphics/qt/GraphicsContext3DQt.cpp >+++ b/Source/WebCore/platform/graphics/qt/GraphicsContext3DQt.cpp >@@ -61,7 +61,7 @@ class GraphicsContext3DPrivate > #endif > { > public: >- GraphicsContext3DPrivate(GraphicsContext3D*, HostWindow*); >+ GraphicsContext3DPrivate(GraphicsContext3D*, HostWindow*, GraphicsContext3D::RenderStyle); > ~GraphicsContext3DPrivate(); > > #if USE(ACCELERATED_COMPOSITING) >@@ -75,6 +75,8 @@ public: > void blitMultisampleFramebuffer() const; > void blitMultisampleFramebufferAndRestoreContext() const; > bool makeCurrentIfNeeded() const; >+ void createOffscreenBuffers(); >+ void initializeANGLE(); > void createGraphicsSurfaces(const IntSize&); > > GraphicsContext3D* m_context; >@@ -104,7 +106,7 @@ void GraphicsContext3D::releaseShaderCompiler() > } > #endif > >-GraphicsContext3DPrivate::GraphicsContext3DPrivate(GraphicsContext3D* context, HostWindow* hostWindow) >+GraphicsContext3DPrivate::GraphicsContext3DPrivate(GraphicsContext3D* context, HostWindow* hostWindow, GraphicsContext3D::RenderStyle renderStyle) > : m_context(context) > , m_hostWindow(hostWindow) > , m_surface(0) >@@ -121,6 +123,12 @@ GraphicsContext3DPrivate::GraphicsContext3DPrivate(GraphicsContext3D* context, H > return; > } > >+ if (renderStyle == GraphicsContext3D::RenderToCurrentGLContext) { >+ m_platformContext = QOpenGLContext::currentContext(); >+ m_surface = m_platformContext->surface(); >+ return; >+ } >+ > #if USE(GRAPHICS_SURFACE) > // FIXME: Find a way to create a QOpenGLContext without creating a QWindow at all. > // We need to create a surface in order to create a QOpenGLContext and make it current. >@@ -146,12 +154,67 @@ GraphicsContext3DPrivate::GraphicsContext3DPrivate(GraphicsContext3D* context, H > #endif > } > >+void GraphicsContext3DPrivate::createOffscreenBuffers() >+{ >+ glGenFramebuffers(/* count */ 1, &m_context->m_fbo); >+ >+ glGenTextures(1, &m_context->m_texture); >+ glBindTexture(GraphicsContext3D::TEXTURE_2D, m_context->m_texture); >+ glTexParameterf(GraphicsContext3D::TEXTURE_2D, GraphicsContext3D::TEXTURE_MAG_FILTER, GraphicsContext3D::LINEAR); >+ glTexParameterf(GraphicsContext3D::TEXTURE_2D, GraphicsContext3D::TEXTURE_MIN_FILTER, GraphicsContext3D::LINEAR); >+ glTexParameteri(GraphicsContext3D::TEXTURE_2D, GraphicsContext3D::TEXTURE_WRAP_S, GraphicsContext3D::CLAMP_TO_EDGE); >+ glTexParameteri(GraphicsContext3D::TEXTURE_2D, GraphicsContext3D::TEXTURE_WRAP_T, GraphicsContext3D::CLAMP_TO_EDGE); >+ glBindTexture(GraphicsContext3D::TEXTURE_2D, 0); >+ >+ // Create a multisample FBO. >+ if (m_context->m_attrs.antialias) { >+ glGenFramebuffers(1, &m_context->m_multisampleFBO); >+ glBindFramebuffer(GraphicsContext3D::FRAMEBUFFER, m_context->m_multisampleFBO); >+ m_context->m_boundFBO = m_context->m_multisampleFBO; >+ glGenRenderbuffers(1, &m_context->m_multisampleColorBuffer); >+ if (m_context->m_attrs.stencil || m_context->m_attrs.depth) >+ glGenRenderbuffers(1, &m_context->m_multisampleDepthStencilBuffer); >+ } else { >+ // Bind canvas FBO. >+ glBindFramebuffer(GraphicsContext3D::FRAMEBUFFER, m_context->m_fbo); >+ m_context->m_boundFBO = m_context->m_fbo; >+#if USE(OPENGL_ES_2) >+ if (m_context->m_attrs.depth) >+ glGenRenderbuffers(1, &m_context->m_depthBuffer); >+ if (m_context->m_attrs.stencil) >+ glGenRenderbuffers(1, &m_context->m_stencilBuffer); >+#endif >+ if (m_context->m_attrs.stencil || m_context->m_attrs.depth) >+ glGenRenderbuffers(1, &m_context->m_depthStencilBuffer); >+ } >+} >+ >+void GraphicsContext3DPrivate::initializeANGLE() >+{ >+ ShBuiltInResources ANGLEResources; >+ ShInitBuiltInResources(&ANGLEResources); >+ >+ m_context->getIntegerv(GraphicsContext3D::MAX_VERTEX_ATTRIBS, &ANGLEResources.MaxVertexAttribs); >+ m_context->getIntegerv(GraphicsContext3D::MAX_VERTEX_UNIFORM_VECTORS, &ANGLEResources.MaxVertexUniformVectors); >+ m_context->getIntegerv(GraphicsContext3D::MAX_VARYING_VECTORS, &ANGLEResources.MaxVaryingVectors); >+ m_context->getIntegerv(GraphicsContext3D::MAX_VERTEX_TEXTURE_IMAGE_UNITS, &ANGLEResources.MaxVertexTextureImageUnits); >+ m_context->getIntegerv(GraphicsContext3D::MAX_COMBINED_TEXTURE_IMAGE_UNITS, &ANGLEResources.MaxCombinedTextureImageUnits); >+ m_context->getIntegerv(GraphicsContext3D::MAX_TEXTURE_IMAGE_UNITS, &ANGLEResources.MaxTextureImageUnits); >+ m_context->getIntegerv(GraphicsContext3D::MAX_FRAGMENT_UNIFORM_VECTORS, &ANGLEResources.MaxFragmentUniformVectors); >+ >+ // Always set to 1 for OpenGL ES. >+ ANGLEResources.MaxDrawBuffers = 1; >+ m_context->m_compiler.setResources(ANGLEResources); >+} >+ > GraphicsContext3DPrivate::~GraphicsContext3DPrivate() > { >- delete m_surface; >- m_surface = 0; >- // Platform context is assumed to be owned by surface. >- m_platformContext = 0; >+ if (m_hostWindow) { >+ delete m_surface; >+ m_surface = 0; >+ // Platform context is assumed to be owned by surface. >+ m_platformContext = 0; >+ } > } > > static inline quint32 swapBgrToRgb(quint32 pixel) >@@ -290,15 +353,16 @@ PassRefPtr<GraphicsContext3D> GraphicsContext3D::create(GraphicsContext3D::Attri > // This implementation doesn't currently support rendering directly to the HostWindow. > if (renderStyle == RenderDirectlyToHostWindow) > return 0; >- RefPtr<GraphicsContext3D> context = adoptRef(new GraphicsContext3D(attrs, hostWindow, false)); >+ RefPtr<GraphicsContext3D> context = adoptRef(new GraphicsContext3D(attrs, hostWindow, renderStyle)); > return context->m_private ? context.release() : 0; > } > >-GraphicsContext3D::GraphicsContext3D(GraphicsContext3D::Attributes attrs, HostWindow* hostWindow, bool) >+GraphicsContext3D::GraphicsContext3D(GraphicsContext3D::Attributes attrs, HostWindow* hostWindow, GraphicsContext3D::RenderStyle renderStyle) > : m_currentWidth(0) > , m_currentHeight(0) > , m_compiler(isGLES2Compliant() ? SH_ESSL_OUTPUT : SH_GLSL_OUTPUT) > , m_attrs(attrs) >+ , m_renderStyle(renderStyle) > , m_texture(0) > , m_compositorTexture(0) > , m_fbo(0) >@@ -315,7 +379,7 @@ GraphicsContext3D::GraphicsContext3D(GraphicsContext3D::Attributes attrs, HostWi > , m_multisampleFBO(0) > , m_multisampleDepthStencilBuffer(0) > , m_multisampleColorBuffer(0) >- , m_private(adoptPtr(new GraphicsContext3DPrivate(this, hostWindow))) >+ , m_private(adoptPtr(new GraphicsContext3DPrivate(this, hostWindow, renderStyle))) > { > validateAttributes(); > >@@ -336,54 +400,10 @@ GraphicsContext3D::GraphicsContext3D(GraphicsContext3D::Attributes attrs, HostWi > return; > } > >- // Create buffers for the canvas FBO. >- glGenFramebuffers(/* count */ 1, &m_fbo); >+ if (renderStyle == RenderOffscreen) >+ m_private->createOffscreenBuffers(); > >- glGenTextures(1, &m_texture); >- glBindTexture(GraphicsContext3D::TEXTURE_2D, m_texture); >- glTexParameterf(GraphicsContext3D::TEXTURE_2D, GraphicsContext3D::TEXTURE_MAG_FILTER, GraphicsContext3D::LINEAR); >- glTexParameterf(GraphicsContext3D::TEXTURE_2D, GraphicsContext3D::TEXTURE_MIN_FILTER, GraphicsContext3D::LINEAR); >- glTexParameteri(GraphicsContext3D::TEXTURE_2D, GraphicsContext3D::TEXTURE_WRAP_S, GraphicsContext3D::CLAMP_TO_EDGE); >- glTexParameteri(GraphicsContext3D::TEXTURE_2D, GraphicsContext3D::TEXTURE_WRAP_T, GraphicsContext3D::CLAMP_TO_EDGE); >- glBindTexture(GraphicsContext3D::TEXTURE_2D, 0); >- >- // Create a multisample FBO. >- if (m_attrs.antialias) { >- glGenFramebuffers(1, &m_multisampleFBO); >- glBindFramebuffer(GraphicsContext3D::FRAMEBUFFER, m_multisampleFBO); >- m_boundFBO = m_multisampleFBO; >- glGenRenderbuffers(1, &m_multisampleColorBuffer); >- if (m_attrs.stencil || m_attrs.depth) >- glGenRenderbuffers(1, &m_multisampleDepthStencilBuffer); >- } else { >- // Bind canvas FBO. >- glBindFramebuffer(GraphicsContext3D::FRAMEBUFFER, m_fbo); >- m_boundFBO = m_fbo; >-#if USE(OPENGL_ES_2) >- if (m_attrs.depth) >- glGenRenderbuffers(1, &m_depthBuffer); >- if (m_attrs.stencil) >- glGenRenderbuffers(1, &m_stencilBuffer); >-#endif >- if (m_attrs.stencil || m_attrs.depth) >- glGenRenderbuffers(1, &m_depthStencilBuffer); >- } >- >- // ANGLE initialization. >- ShBuiltInResources ANGLEResources; >- ShInitBuiltInResources(&ANGLEResources); >- >- getIntegerv(GraphicsContext3D::MAX_VERTEX_ATTRIBS, &ANGLEResources.MaxVertexAttribs); >- getIntegerv(GraphicsContext3D::MAX_VERTEX_UNIFORM_VECTORS, &ANGLEResources.MaxVertexUniformVectors); >- getIntegerv(GraphicsContext3D::MAX_VARYING_VECTORS, &ANGLEResources.MaxVaryingVectors); >- getIntegerv(GraphicsContext3D::MAX_VERTEX_TEXTURE_IMAGE_UNITS, &ANGLEResources.MaxVertexTextureImageUnits); >- getIntegerv(GraphicsContext3D::MAX_COMBINED_TEXTURE_IMAGE_UNITS, &ANGLEResources.MaxCombinedTextureImageUnits); >- getIntegerv(GraphicsContext3D::MAX_TEXTURE_IMAGE_UNITS, &ANGLEResources.MaxTextureImageUnits); >- getIntegerv(GraphicsContext3D::MAX_FRAGMENT_UNIFORM_VECTORS, &ANGLEResources.MaxFragmentUniformVectors); >- >- // Always set to 1 for OpenGL ES. >- ANGLEResources.MaxDrawBuffers = 1; >- m_compiler.setResources(ANGLEResources); >+ m_private->initializeANGLE(); > > #if !USE(OPENGL_ES_2) > glEnable(GL_POINT_SPRITE); >@@ -437,7 +457,7 @@ PlatformLayer* GraphicsContext3D::platformLayer() const > > bool GraphicsContext3D::makeContextCurrent() > { >- if (!m_private) >+ if (!m_private || m_renderStyle == RenderToCurrentGLContext) > return false; > return m_private->makeCurrentIfNeeded(); > } >diff --git a/Source/WebCore/platform/graphics/texmap/TextureMapperGL.cpp b/Source/WebCore/platform/graphics/texmap/TextureMapperGL.cpp >index c6b1e28..b3fac6b 100644 >--- a/Source/WebCore/platform/graphics/texmap/TextureMapperGL.cpp >+++ b/Source/WebCore/platform/graphics/texmap/TextureMapperGL.cpp >@@ -38,13 +38,6 @@ > > #if PLATFORM(QT) > #include "NativeImageQt.h" >-#include <QOpenGLContext> >-#elif OS(WINDOWS) >-#include <windows.h> >-#elif OS(MAC_OS_X) >-#include <AGL/agl.h> >-#elif defined(XP_UNIX) >-#include <GL/glx.h> > #endif > > #if USE(CAIRO) >@@ -53,70 +46,43 @@ > #include <cairo.h> > #endif > >-#define GL_CMD(...) do { __VA_ARGS__; ASSERT_ARG(__VA_ARGS__, !glGetError()); } while (0) >+#if !USE(TEXMAP_OPENGL_ES_2) >+// FIXME: Move to Extensions3D.h. >+#define GL_TEXTURE_RECTANGLE_ARB 0x84F5 >+#define GL_UNSIGNED_INT_8_8_8_8_REV 0x8367 >+#define GL_UNPACK_ROW_LENGTH 0x0CF2 >+#define GL_UNPACK_SKIP_PIXELS 0x0CF4 >+#define GL_UNPACK_SKIP_ROWS 0x0CF3 >+#endif >+ > namespace WebCore { > struct TextureMapperGLData { > struct SharedGLData : public RefCounted<SharedGLData> { >-#if PLATFORM(QT) >- typedef QOpenGLContext* GLContext; >- static GLContext getCurrentGLContext() >- { >- return QOpenGLContext::currentContext(); >- } >-#elif OS(WINDOWS) >- typedef HGLRC GLContext; >- static GLContext getCurrentGLContext() >- { >- return wglGetCurrentContext(); >- } >-#elif OS(MAC_OS_X) >- typedef AGLContext GLContext; >- static GLContext getCurrentGLContext() >- { >- return aglGetCurrentContext(); >- } >-#elif defined(XP_UNIX) >- typedef GLXContext GLContext; >- static GLContext getCurrentGLContext() >- { >- return glXGetCurrentContext(); >- } >-#else >- // Default implementation for unknown opengl. >- // Returns always increasing number and disables GL context data sharing. >- typedef unsigned int GLContext; >- static GLContext getCurrentGLContext() >- { >- static GLContext dummyContextCounter = 0; >- return ++dummyContextCounter; >- } >- >-#endif > >- typedef HashMap<GLContext, SharedGLData*> GLContextDataMap; >+ typedef HashMap<PlatformGraphicsContext3D, SharedGLData*> GLContextDataMap; > static GLContextDataMap& glContextDataMap() > { > static GLContextDataMap map; > return map; > } > >- static PassRefPtr<SharedGLData> currentSharedGLData() >+ static PassRefPtr<SharedGLData> currentSharedGLData(GraphicsContext3D* context) > { >- GLContext currentGLConext = getCurrentGLContext(); >- GLContextDataMap::iterator it = glContextDataMap().find(currentGLConext); >+ GLContextDataMap::iterator it = glContextDataMap().find(context->platformGraphicsContext3D()); > if (it != glContextDataMap().end()) > return it->second; > >- return adoptRef(new SharedGLData(getCurrentGLContext())); >+ return adoptRef(new SharedGLData(context)); > } > > > > TextureMapperShaderManager textureMapperShaderManager; > >- SharedGLData(GLContext glContext) >+ SharedGLData(GraphicsContext3D* context) >+ : textureMapperShaderManager(context) > { >- glContextDataMap().add(glContext, this); >+ glContextDataMap().add(context->platformGraphicsContext3D(), this); > } > > ~SharedGLData() >@@ -135,30 +101,32 @@ struct TextureMapperGLData { > > SharedGLData& sharedGLData() const > { >- return *(m_sharedGLData.get()); >+ return *m_sharedGLData; > } > > void initializeStencil(); > >- TextureMapperGLData() >- : PaintFlags(0) >+ TextureMapperGLData(GraphicsContext3D* context) >+ : context(context) >+ , PaintFlags(0) > , previousProgram(0) > , targetFrameBuffer(0) > , didModifyStencil(false) > , previousScissorState(0) > , previousDepthState(0) >- , m_sharedGLData(TextureMapperGLData::SharedGLData::currentSharedGLData()) >+ , m_sharedGLData(TextureMapperGLData::SharedGLData::currentSharedGLData(this->context)) > { } > >+ GraphicsContext3D* context; > TransformationMatrix projectionMatrix; > TextureMapper::PaintFlags PaintFlags; >- GLint previousProgram; >- GLint targetFrameBuffer; >+ GC3Dint previousProgram; >+ GC3Dint targetFrameBuffer; > bool didModifyStencil; >- GLint previousScissorState; >- GLint previousDepthState; >- GLint viewport[4]; >- GLint previousScissor[4]; >+ GC3Dint previousScissorState; >+ GC3Dint previousDepthState; >+ GC3Dint viewport[4]; >+ GC3Dint previousScissor[4]; > RefPtr<SharedGLData> m_sharedGLData; > RefPtr<BitmapTexture> currentSurface; > }; >@@ -182,25 +150,25 @@ void TextureMapperGL::ClipStack::pop() > clipStack.removeLast(); > } > >-static void scissorClip(const IntRect& rect) >+static void scissorClip(GraphicsContext3D* context, const IntRect& rect) > { > if (rect.isEmpty()) > return; > >- GLint viewport[4]; >- GL_CMD(glGetIntegerv(GL_VIEWPORT, viewport)); >- GL_CMD(glScissor(rect.x(), viewport[3] - rect.maxY(), rect.width(), rect.height())); >+ GC3Dint viewport[4]; >+ context->getIntegerv(GraphicsContext3D::VIEWPORT, viewport); >+ context->scissor(rect.x(), viewport[3] - rect.maxY(), rect.width(), rect.height()); > } > >-void TextureMapperGL::ClipStack::apply() >+void TextureMapperGL::ClipStack::apply(GraphicsContext3D* context) > { >- scissorClip(clipState.scissorBox); >- GL_CMD(glStencilOp(GL_KEEP, GL_KEEP, GL_KEEP)); >- GL_CMD(glStencilFunc(GL_EQUAL, clipState.stencilIndex - 1, clipState.stencilIndex - 1)); >+ scissorClip(context, clipState.scissorBox); >+ context->stencilOp(GraphicsContext3D::KEEP, GraphicsContext3D::KEEP, GraphicsContext3D::KEEP); >+ context->stencilFunc(GraphicsContext3D::EQUAL, clipState.stencilIndex - 1, clipState.stencilIndex - 1); > if (clipState.stencilIndex == 1) >- GL_CMD(glDisable(GL_STENCIL_TEST)); >+ context->disable(GraphicsContext3D::STENCIL_TEST); > else >- GL_CMD(glEnable(GL_STENCIL_TEST)); >+ context->enable(GraphicsContext3D::STENCIL_TEST); > } > > >@@ -214,8 +182,8 @@ void TextureMapperGLData::initializeStencil() > if (didModifyStencil) > return; > >- GL_CMD(glClearStencil(0)); >- GL_CMD(glClear(GL_STENCIL_BUFFER_BIT)); >+ context->clearStencil(0); >+ context->clear(GraphicsContext3D::STENCIL_BUFFER_BIT); > didModifyStencil = true; > } > >@@ -229,10 +197,11 @@ BitmapTextureGL* toBitmapTextureGL(BitmapTexture* texture) > > TextureMapperGL::TextureMapperGL() > : TextureMapper(OpenGLMode) >- , m_data(new TextureMapperGLData) > , m_context(0) > , m_enableEdgeDistanceAntialiasing(false) > { >+ m_context3D = GraphicsContext3D::createForCurrentGLContext(); >+ m_data = new TextureMapperGLData(m_context3D.get()); > } > > TextureMapperGL::ClipStack& TextureMapperGL::clipStack() >@@ -242,15 +211,9 @@ TextureMapperGL::ClipStack& TextureMapperGL::clipStack() > > void TextureMapperGL::beginPainting(PaintFlags flags) > { >- // Make sure that no GL error code stays from previous operations. >- glGetError(); >- >- if (!initializeOpenGLShims()) >- return; >- >- GL_CMD(glGetIntegerv(GL_CURRENT_PROGRAM, &data().previousProgram)); >- data().previousScissorState = glIsEnabled(GL_SCISSOR_TEST); >- data().previousDepthState = glIsEnabled(GL_DEPTH_TEST); >+ m_context3D->getIntegerv(GraphicsContext3D::CURRENT_PROGRAM, &data().previousProgram); >+ data().previousScissorState = m_context3D->isEnabled(GraphicsContext3D::SCISSOR_TEST); >+ data().previousDepthState = m_context3D->isEnabled(GraphicsContext3D::DEPTH_TEST); > #if PLATFORM(QT) > if (m_context) { > QPainter* painter = m_context->platformContext(); >@@ -258,15 +221,15 @@ void TextureMapperGL::beginPainting(PaintFlags flags) > painter->beginNativePainting(); > } > #endif >- glDisable(GL_DEPTH_TEST); >- glEnable(GL_SCISSOR_TEST); >+ m_context3D->disable(GraphicsContext3D::DEPTH_TEST); >+ m_context3D->enable(GraphicsContext3D::SCISSOR_TEST); > data().didModifyStencil = false; >- GL_CMD(glDepthMask(0)); >- GL_CMD(glGetIntegerv(GL_VIEWPORT, data().viewport)); >- GL_CMD(glGetIntegerv(GL_SCISSOR_BOX, data().previousScissor)); >- glGetIntegerv(GL_FRAMEBUFFER_BINDING, &data().targetFrameBuffer); >+ m_context3D->depthMask(0); >+ m_context3D->getIntegerv(GraphicsContext3D::VIEWPORT, data().viewport); >+ m_context3D->getIntegerv(GraphicsContext3D::SCISSOR_BOX, data().previousScissor); >+ m_context3D->getIntegerv(GraphicsContext3D::FRAMEBUFFER_BINDING, &data().targetFrameBuffer); > m_clipStack.init(IntRect(0, 0, data().viewport[2], data().viewport[3])); >- GL_CMD(glGetIntegerv(GL_FRAMEBUFFER_BINDING, &data().targetFrameBuffer)); >+ m_context3D->getIntegerv(GraphicsContext3D::FRAMEBUFFER_BINDING, &data().targetFrameBuffer); > data().PaintFlags = flags; > bindSurface(0); > } >@@ -274,22 +237,22 @@ void TextureMapperGL::beginPainting(PaintFlags flags) > void TextureMapperGL::endPainting() > { > if (data().didModifyStencil) { >- glClearStencil(1); >- glClear(GL_STENCIL_BUFFER_BIT); >+ m_context3D->clearStencil(1); >+ m_context3D->clear(GraphicsContext3D::STENCIL_BUFFER_BIT); > } > >- glUseProgram(data().previousProgram); >+ m_context3D->useProgram(data().previousProgram); > >- glScissor(data().previousScissor[0], data().previousScissor[1], data().previousScissor[2], data().previousScissor[3]); >+ m_context3D->scissor(data().previousScissor[0], data().previousScissor[1], data().previousScissor[2], data().previousScissor[3]); > if (data().previousScissorState) >- glEnable(GL_SCISSOR_TEST); >+ m_context3D->enable(GraphicsContext3D::SCISSOR_TEST); > else >- glDisable(GL_SCISSOR_TEST); >+ m_context3D->disable(GraphicsContext3D::SCISSOR_TEST); > > if (data().previousDepthState) >- glEnable(GL_DEPTH_TEST); >+ m_context3D->enable(GraphicsContext3D::DEPTH_TEST); > else >- glDisable(GL_DEPTH_TEST); >+ m_context3D->disable(GraphicsContext3D::DEPTH_TEST); > > #if PLATFORM(QT) > if (!m_context) >@@ -300,40 +263,40 @@ void TextureMapperGL::endPainting() > #endif > } > >-void TextureMapperGL::drawQuad(const DrawQuad& quadToDraw, const TransformationMatrix& modelViewMatrix, TextureMapperShaderProgram* shaderProgram, GLenum drawingMode, bool needsBlending) >+void TextureMapperGL::drawQuad(const DrawQuad& quadToDraw, const TransformationMatrix& modelViewMatrix, TextureMapperShaderProgram* shaderProgram, GC3Denum drawingMode, bool needsBlending) > { >- GL_CMD(glEnableVertexAttribArray(shaderProgram->vertexAttrib())); >- GL_CMD(glBindBuffer(GL_ARRAY_BUFFER, 0)); >+ m_context3D->enableVertexAttribArray(shaderProgram->vertexAttrib()); >+ m_context3D->bindBuffer(GraphicsContext3D::ARRAY_BUFFER, 0); > >- const GLfloat quad[] = { >+ const GC3Dfloat quad[] = { > quadToDraw.targetRectMappedToUnitSquare.p1().x(), quadToDraw.targetRectMappedToUnitSquare.p1().y(), > quadToDraw.targetRectMappedToUnitSquare.p2().x(), quadToDraw.targetRectMappedToUnitSquare.p2().y(), > quadToDraw.targetRectMappedToUnitSquare.p3().x(), quadToDraw.targetRectMappedToUnitSquare.p3().y(), > quadToDraw.targetRectMappedToUnitSquare.p4().x(), quadToDraw.targetRectMappedToUnitSquare.p4().y() > }; >- GL_CMD(glVertexAttribPointer(shaderProgram->vertexAttrib(), 2, GL_FLOAT, GL_FALSE, 0, quad)); >+ m_context3D->vertexAttribPointer(shaderProgram->vertexAttrib(), 2, GraphicsContext3D::FLOAT, false, 0, GC3Dintptr(quad)); > > TransformationMatrix matrix = TransformationMatrix(data().projectionMatrix).multiply(modelViewMatrix).multiply(TransformationMatrix( > quadToDraw.originalTargetRect.width(), 0, 0, 0, > 0, quadToDraw.originalTargetRect.height(), 0, 0, > 0, 0, 1, 0, > quadToDraw.originalTargetRect.x(), quadToDraw.originalTargetRect.y(), 0, 1)); >- const GLfloat m4[] = { >+ GC3Dfloat m4[] = { > matrix.m11(), matrix.m12(), matrix.m13(), matrix.m14(), > matrix.m21(), matrix.m22(), matrix.m23(), matrix.m24(), > matrix.m31(), matrix.m32(), matrix.m33(), matrix.m34(), > matrix.m41(), matrix.m42(), matrix.m43(), matrix.m44() > }; >- GL_CMD(glUniformMatrix4fv(shaderProgram->matrixLocation(), 1, GL_FALSE, m4)); >+ m_context3D->uniformMatrix4fv(shaderProgram->matrixLocation(), 1, false, m4); > > if (needsBlending) { >- GL_CMD(glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA)); >- GL_CMD(glEnable(GL_BLEND)); >+ m_context3D->blendFunc(GraphicsContext3D::ONE, GraphicsContext3D::ONE_MINUS_SRC_ALPHA); >+ m_context3D->enable(GraphicsContext3D::BLEND); > } else >- GL_CMD(glDisable(GL_BLEND)); >+ m_context3D->disable(GraphicsContext3D::BLEND); > >- GL_CMD(glDrawArrays(drawingMode, 0, 4)); >- GL_CMD(glDisableVertexAttribArray(shaderProgram->vertexAttrib())); >+ m_context3D->drawArrays(drawingMode, 0, 4); >+ m_context3D->disableVertexAttribArray(shaderProgram->vertexAttrib()); > } > > void TextureMapperGL::drawBorder(const Color& color, float width, const FloatRect& targetRect, const TransformationMatrix& modelViewMatrix) >@@ -342,17 +305,17 @@ void TextureMapperGL::drawBorder(const Color& color, float width, const FloatRec > return; > > RefPtr<TextureMapperShaderProgramSolidColor> program = data().sharedGLData().textureMapperShaderManager.solidColorProgram(); >- GL_CMD(glUseProgram(program->id())); >+ m_context3D->useProgram(program->id()); > > float alpha = color.alpha() / 255.0; >- GL_CMD(glUniform4f(program->colorLocation(), >+ m_context3D->uniform4f(program->colorLocation(), > (color.red() / 255.0) * alpha, > (color.green() / 255.0) * alpha, > (color.blue() / 255.0) * alpha, >- alpha)); >- GL_CMD(glLineWidth(width)); >+ alpha); >+ m_context3D->lineWidth(width); > >- drawQuad(targetRect, modelViewMatrix, program.get(), GL_LINE_LOOP, color.hasAlpha()); >+ drawQuad(targetRect, modelViewMatrix, program.get(), GraphicsContext3D::LINE_LOOP, color.hasAlpha()); > } > > void TextureMapperGL::drawRepaintCounter(int value, int pointSize, const FloatPoint& targetPoint, const TransformationMatrix& modelViewMatrix) >@@ -399,7 +362,7 @@ void TextureMapperGL::drawTexture(const BitmapTexture& texture, const FloatRect& > drawTexture(textureGL.id(), textureGL.isOpaque() ? 0 : SupportsBlending, textureGL.size(), targetRect, matrix, opacity, mask, exposedEdges); > } > >-#if defined(GL_ARB_texture_rectangle) >+#if !USE(TEXMAP_OPENGL_ES_2) > void TextureMapperGL::drawTextureRectangleARB(uint32_t texture, Flags flags, const IntSize& textureSize, const FloatRect& targetRect, const TransformationMatrix& modelViewMatrix, float opacity, const BitmapTexture* maskTexture) > { > RefPtr<TextureMapperShaderProgram> program; >@@ -407,36 +370,36 @@ void TextureMapperGL::drawTextureRectangleARB(uint32_t texture, Flags flags, con > program = data().sharedGLData().textureMapperShaderManager.getShaderProgram(TextureMapperShaderManager::RectOpacityAndMask); > else > program = data().sharedGLData().textureMapperShaderManager.getShaderProgram(TextureMapperShaderManager::RectSimple); >- GL_CMD(glUseProgram(program->id())); >+ m_context3D->useProgram(program->id()); > >- GL_CMD(glEnableVertexAttribArray(program->vertexAttrib())); >- GL_CMD(glActiveTexture(GL_TEXTURE0)); >- GL_CMD(glBindTexture(GL_TEXTURE_RECTANGLE_ARB, texture)); >- GL_CMD(glUniform1i(program->sourceTextureLocation(), 0)); >+ m_context3D->enableVertexAttribArray(program->vertexAttrib()); >+ m_context3D->activeTexture(GraphicsContext3D::TEXTURE0); >+ m_context3D->bindTexture(GL_TEXTURE_RECTANGLE_ARB, texture); >+ m_context3D->uniform1i(program->sourceTextureLocation(), 0); > >- GL_CMD(glUniform1f(program->flipLocation(), !!(flags & ShouldFlipTexture))); >- GL_CMD(glUniform2f(program->textureSizeLocation(), textureSize.width(), textureSize.height())); >+ m_context3D->uniform1f(program->flipLocation(), !!(flags & ShouldFlipTexture)); >+ m_context3D->uniform2f(program->textureSizeLocation(), textureSize.width(), textureSize.height()); > > if (TextureMapperShaderProgram::isValidUniformLocation(program->opacityLocation())) >- GL_CMD(glUniform1f(program->opacityLocation(), opacity)); >+ m_context3D->uniform1f(program->opacityLocation(), opacity); > > if (maskTexture && maskTexture->isValid() && TextureMapperShaderProgram::isValidUniformLocation(program->maskTextureLocation())) { > const BitmapTextureGL* maskTextureGL = static_cast<const BitmapTextureGL*>(maskTexture); >- GL_CMD(glActiveTexture(GL_TEXTURE1)); >- GL_CMD(glBindTexture(GL_TEXTURE_2D, maskTextureGL->id())); >- GL_CMD(glUniform1i(program->maskTextureLocation(), 1)); >- GL_CMD(glActiveTexture(GL_TEXTURE0)); >+ m_context3D->activeTexture(GraphicsContext3D::TEXTURE1); >+ m_context3D->bindTexture(GraphicsContext3D::TEXTURE_2D, maskTextureGL->id()); >+ m_context3D->uniform1i(program->maskTextureLocation(), 1); >+ m_context3D->activeTexture(GraphicsContext3D::TEXTURE0); > } > > bool needsBlending = (flags & SupportsBlending) || opacity < 0.99 || maskTexture; >- drawQuad(targetRect, modelViewMatrix, program.get(), GL_TRIANGLE_FAN, needsBlending); >+ drawQuad(targetRect, modelViewMatrix, program.get(), GraphicsContext3D::TRIANGLE_FAN, needsBlending); > } >-#endif // defined(GL_ARB_texture_rectangle) >+#endif // !USE(TEXMAP_OPENGL_ES_2) > > void TextureMapperGL::drawTexture(uint32_t texture, Flags flags, const IntSize& /* textureSize */, const FloatRect& targetRect, const TransformationMatrix& modelViewMatrix, float opacity, const BitmapTexture* maskTexture, unsigned exposedEdges) > { >- bool needsAntiliaing = m_enableEdgeDistanceAntialiasing && !modelViewMatrix.isIntegerTranslation(); >- if (needsAntiliaing && drawTextureWithAntialiasing(texture, flags, targetRect, modelViewMatrix, opacity, maskTexture, exposedEdges)) >+ bool needsAntialiasing = m_enableEdgeDistanceAntialiasing && !modelViewMatrix.isIntegerTranslation(); >+ if (needsAntialiasing && drawTextureWithAntialiasing(texture, flags, targetRect, modelViewMatrix, opacity, maskTexture, exposedEdges)) > return; > > RefPtr<TextureMapperShaderProgram> program; >@@ -444,15 +407,15 @@ void TextureMapperGL::drawTexture(uint32_t texture, Flags flags, const IntSize& > program = data().sharedGLData().textureMapperShaderManager.getShaderProgram(TextureMapperShaderManager::OpacityAndMask); > else > program = data().sharedGLData().textureMapperShaderManager.getShaderProgram(TextureMapperShaderManager::Simple); >- GL_CMD(glUseProgram(program->id())); >+ m_context3D->useProgram(program->id()); > > drawTexturedQuadWithProgram(program.get(), texture, flags, targetRect, modelViewMatrix, opacity, maskTexture); > } > >-static TransformationMatrix viewportMatrix() >+static TransformationMatrix viewportMatrix(GraphicsContext3D* context3D) > { >- GLint viewport[4]; >- GL_CMD(glGetIntegerv(GL_VIEWPORT, viewport)); >+ GC3Dint viewport[4]; >+ context3D->getIntegerv(GraphicsContext3D::VIEWPORT, viewport); > > TransformationMatrix matrix; > matrix.translate3d(viewport[0], viewport[1], 0); >@@ -549,7 +512,7 @@ bool TextureMapperGL::drawTextureWithAntialiasing(uint32_t texture, Flags flags, > // antialiasing. Note here that we are also including the viewport matrix (which > // translates from normalized device coordinates to screen coordinates), because these > // values are consumed in the fragment shader, which works in screen coordinates. >- TransformationMatrix screenSpaceTransform = viewportMatrix().multiply(TransformationMatrix(data().projectionMatrix)).multiply(modelViewMatrix).to2dTransform(); >+ TransformationMatrix screenSpaceTransform = viewportMatrix(m_context3D.get()).multiply(TransformationMatrix(data().projectionMatrix)).multiply(modelViewMatrix).to2dTransform(); > if (!screenSpaceTransform.isInvertible()) > return false; > FloatQuad quadInScreenSpace = screenSpaceTransform.mapQuad(originalTargetRect); >@@ -573,8 +536,8 @@ bool TextureMapperGL::drawTextureWithAntialiasing(uint32_t texture, Flags flags, > quadToEdgeArray(inflateQuad(quadInScreenSpace.boundingBox(), inflationDistance), targetQuadEdges + 12); > > RefPtr<TextureMapperShaderProgramAntialiasingNoMask> program = data().sharedGLData().textureMapperShaderManager.antialiasingNoMaskProgram(); >- GL_CMD(glUseProgram(program->id())); >- GL_CMD(glUniform3fv(program->expandedQuadEdgesInScreenSpaceLocation(), 8, targetQuadEdges)); >+ m_context3D->useProgram(program->id()); >+ m_context3D->uniform3fv(program->expandedQuadEdgesInScreenSpaceLocation(), 8, targetQuadEdges); > > drawTexturedQuadWithProgram(program.get(), texture, flags, DrawQuad(originalTargetRect, expandedQuadInTextureCoordinates), modelViewMatrix, opacity, 0 /* maskTexture */); > return true; >@@ -582,26 +545,26 @@ bool TextureMapperGL::drawTextureWithAntialiasing(uint32_t texture, Flags flags, > > void TextureMapperGL::drawTexturedQuadWithProgram(TextureMapperShaderProgram* program, uint32_t texture, Flags flags, const DrawQuad& quadToDraw, const TransformationMatrix& modelViewMatrix, float opacity, const BitmapTexture* maskTexture) > { >- GL_CMD(glEnableVertexAttribArray(program->vertexAttrib())); >- GL_CMD(glActiveTexture(GL_TEXTURE0)); >- GL_CMD(glBindTexture(GL_TEXTURE_2D, texture)); >- GL_CMD(glUniform1i(program->sourceTextureLocation(), 0)); >+ m_context3D->enableVertexAttribArray(program->vertexAttrib()); >+ m_context3D->activeTexture(GraphicsContext3D::TEXTURE0); >+ m_context3D->bindTexture(GraphicsContext3D::TEXTURE_2D, texture); >+ m_context3D->uniform1i(program->sourceTextureLocation(), 0); > >- GL_CMD(glUniform1f(program->flipLocation(), !!(flags & ShouldFlipTexture))); >+ m_context3D->uniform1f(program->flipLocation(), !!(flags & ShouldFlipTexture)); > > if (TextureMapperShaderProgram::isValidUniformLocation(program->opacityLocation())) >- GL_CMD(glUniform1f(program->opacityLocation(), opacity)); >+ m_context3D->uniform1f(program->opacityLocation(), opacity); > > if (maskTexture && maskTexture->isValid() && TextureMapperShaderProgram::isValidUniformLocation(program->maskTextureLocation())) { > const BitmapTextureGL* maskTextureGL = static_cast<const BitmapTextureGL*>(maskTexture); >- GL_CMD(glActiveTexture(GL_TEXTURE1)); >- GL_CMD(glBindTexture(GL_TEXTURE_2D, maskTextureGL->id())); >- GL_CMD(glUniform1i(program->maskTextureLocation(), 1)); >- GL_CMD(glActiveTexture(GL_TEXTURE0)); >+ m_context3D->activeTexture(GraphicsContext3D::TEXTURE1); >+ m_context3D->bindTexture(GraphicsContext3D::TEXTURE_2D, maskTextureGL->id()); >+ m_context3D->uniform1i(program->maskTextureLocation(), 1); >+ m_context3D->activeTexture(GraphicsContext3D::TEXTURE0); > } > > bool needsBlending = (flags & SupportsBlending) || opacity < 0.99 || maskTexture; >- drawQuad(quadToDraw, modelViewMatrix, program, GL_TRIANGLE_FAN, needsBlending); >+ drawQuad(quadToDraw, modelViewMatrix, program, GraphicsContext3D::TRIANGLE_FAN, needsBlending); > } > > bool BitmapTextureGL::canReuseWith(const IntSize& contentsSize, Flags) >@@ -612,7 +575,7 @@ bool BitmapTextureGL::canReuseWith(const IntSize& contentsSize, Flags) > #if OS(DARWIN) > #define DEFAULT_TEXTURE_PIXEL_TRANSFER_TYPE GL_UNSIGNED_INT_8_8_8_8_REV > #else >-#define DEFAULT_TEXTURE_PIXEL_TRANSFER_TYPE GL_UNSIGNED_BYTE >+#define DEFAULT_TEXTURE_PIXEL_TRANSFER_TYPE GraphicsContext3D::UNSIGNED_BYTE > #endif > > static void swizzleBGRAToRGBA(uint32_t* data, const IntRect& rect, int stride = 0) >@@ -647,38 +610,42 @@ static bool driverSupportsSubImage() > > void BitmapTextureGL::didReset() > { >+ GraphicsContext3D* context3D = m_textureMapper->graphicsContext3D(); >+ > if (!m_id) >- GL_CMD(glGenTextures(1, &m_id)); >+ m_id = context3D->createTexture(); > > m_shouldClear = true; > if (m_textureSize == contentSize()) > return; > >- GLuint format = driverSupportsBGRASwizzling() ? GL_BGRA : GL_RGBA; >+ Platform3DObject format = driverSupportsBGRASwizzling() ? GraphicsContext3D::BGRA : GraphicsContext3D::RGBA; > > 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)); >- GL_CMD(glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE)); >- GL_CMD(glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE)); >- GL_CMD(glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, m_textureSize.width(), m_textureSize.height(), 0, format, DEFAULT_TEXTURE_PIXEL_TRANSFER_TYPE, 0)); >+ context3D->bindTexture(GraphicsContext3D::TEXTURE_2D, m_id); >+ context3D->texParameteri(GraphicsContext3D::TEXTURE_2D, GraphicsContext3D::TEXTURE_MIN_FILTER, GraphicsContext3D::LINEAR); >+ context3D->texParameteri(GraphicsContext3D::TEXTURE_2D, GraphicsContext3D::TEXTURE_MAG_FILTER, GraphicsContext3D::LINEAR); >+ context3D->texParameteri(GraphicsContext3D::TEXTURE_2D, GraphicsContext3D::TEXTURE_WRAP_S, GraphicsContext3D::CLAMP_TO_EDGE); >+ context3D->texParameteri(GraphicsContext3D::TEXTURE_2D, GraphicsContext3D::TEXTURE_WRAP_T, GraphicsContext3D::CLAMP_TO_EDGE); >+ context3D->texImage2DDirect(GraphicsContext3D::TEXTURE_2D, 0, format, m_textureSize.width(), m_textureSize.height(), 0, format, DEFAULT_TEXTURE_PIXEL_TRANSFER_TYPE, 0); > } > > > void BitmapTextureGL::updateContents(const void* data, const IntRect& targetRect, const IntPoint& sourceOffset, int bytesPerLine) > { >- GLuint glFormat = GL_RGBA; >- GL_CMD(glBindTexture(GL_TEXTURE_2D, m_id)); >+ GraphicsContext3D* context3D = m_textureMapper->graphicsContext3D(); >+ >+ Platform3DObject glFormat = GraphicsContext3D::RGBA; >+ context3D->bindTexture(GraphicsContext3D::TEXTURE_2D, m_id); > > const unsigned bytesPerPixel = 4; > if (driverSupportsBGRASwizzling()) >- glFormat = GL_BGRA; >+ glFormat = GraphicsContext3D::BGRA; > else > swizzleBGRAToRGBA(reinterpret_cast<uint32_t*>(const_cast<void*>(data)), IntRect(sourceOffset, targetRect.size()), bytesPerLine / bytesPerPixel); > > if (bytesPerLine == targetRect.width() / 4 && sourceOffset == IntPoint::zero()) { >- GL_CMD(glTexSubImage2D(GL_TEXTURE_2D, 0, targetRect.x(), targetRect.y(), targetRect.width(), targetRect.height(), glFormat, DEFAULT_TEXTURE_PIXEL_TRANSFER_TYPE, (const char*)data)); >+ context3D->texSubImage2D(GraphicsContext3D::TEXTURE_2D, 0, targetRect.x(), targetRect.y(), targetRect.width(), targetRect.height(), glFormat, DEFAULT_TEXTURE_PIXEL_TRANSFER_TYPE, (const char*)data); > return; > } > >@@ -696,19 +663,19 @@ void BitmapTextureGL::updateContents(const void* data, const IntRect& targetRect > dst += targetBytesPerLine; > } > >- GL_CMD(glTexSubImage2D(GL_TEXTURE_2D, 0, targetRect.x(), targetRect.y(), targetRect.width(), targetRect.height(), glFormat, DEFAULT_TEXTURE_PIXEL_TRANSFER_TYPE, temporaryData.data())); >+ context3D->texSubImage2D(GraphicsContext3D::TEXTURE_2D, 0, targetRect.x(), targetRect.y(), targetRect.width(), targetRect.height(), glFormat, DEFAULT_TEXTURE_PIXEL_TRANSFER_TYPE, temporaryData.data()); > return; > } > > #if !defined(TEXMAP_OPENGL_ES_2) > // Use the OpenGL sub-image extension, now that we know it's available. >- GL_CMD(glPixelStorei(GL_UNPACK_ROW_LENGTH, bytesPerLine / bytesPerPixel)); >- GL_CMD(glPixelStorei(GL_UNPACK_SKIP_ROWS, sourceOffset.y())); >- GL_CMD(glPixelStorei(GL_UNPACK_SKIP_PIXELS, sourceOffset.x())); >- GL_CMD(glTexSubImage2D(GL_TEXTURE_2D, 0, targetRect.x(), targetRect.y(), targetRect.width(), targetRect.height(), glFormat, DEFAULT_TEXTURE_PIXEL_TRANSFER_TYPE, (const char*)data)); >- GL_CMD(glPixelStorei(GL_UNPACK_ROW_LENGTH, 0)); >- GL_CMD(glPixelStorei(GL_UNPACK_SKIP_ROWS, 0)); >- GL_CMD(glPixelStorei(GL_UNPACK_SKIP_PIXELS, 0)); >+ context3D->pixelStorei(GL_UNPACK_ROW_LENGTH, bytesPerLine / bytesPerPixel); >+ context3D->pixelStorei(GL_UNPACK_SKIP_ROWS, sourceOffset.y()); >+ context3D->pixelStorei(GL_UNPACK_SKIP_PIXELS, sourceOffset.x()); >+ context3D->texSubImage2D(GraphicsContext3D::TEXTURE_2D, 0, targetRect.x(), targetRect.y(), targetRect.width(), targetRect.height(), glFormat, DEFAULT_TEXTURE_PIXEL_TRANSFER_TYPE, (const char*)data); >+ context3D->pixelStorei(GL_UNPACK_ROW_LENGTH, 0); >+ context3D->pixelStorei(GL_UNPACK_SKIP_ROWS, 0); >+ context3D->pixelStorei(GL_UNPACK_SKIP_PIXELS, 0); > #endif > } > >@@ -744,19 +711,19 @@ void TextureMapperGL::drawFiltered(const BitmapTexture& sourceTexture, const Bit > > program->prepare(filter, pass, sourceTexture.contentSize(), static_cast<const BitmapTextureGL&>(contentTexture).id()); > >- GL_CMD(glEnableVertexAttribArray(program->vertexAttrib())); >- GL_CMD(glEnableVertexAttribArray(program->texCoordAttrib())); >- GL_CMD(glActiveTexture(GL_TEXTURE0)); >- GL_CMD(glBindTexture(GL_TEXTURE_2D, static_cast<const BitmapTextureGL&>(sourceTexture).id())); >- glUniform1i(program->textureUniform(), 0); >- const GLfloat targetVertices[] = {-1, -1, 1, -1, 1, 1, -1, 1}; >- const GLfloat sourceVertices[] = {0, 0, 1, 0, 1, 1, 0, 1}; >- GL_CMD(glVertexAttribPointer(program->vertexAttrib(), 2, GL_FLOAT, GL_FALSE, 0, targetVertices)); >- GL_CMD(glVertexAttribPointer(program->texCoordAttrib(), 2, GL_FLOAT, GL_FALSE, 0, sourceVertices)); >- GL_CMD(glDisable(GL_BLEND)); >- GL_CMD(glDrawArrays(GL_TRIANGLE_FAN, 0, 4)); >- GL_CMD(glDisableVertexAttribArray(program->vertexAttrib())); >- GL_CMD(glDisableVertexAttribArray(program->texCoordAttrib())); >+ m_context3D->enableVertexAttribArray(program->vertexAttrib()); >+ m_context3D->enableVertexAttribArray(program->texCoordAttrib()); >+ m_context3D->activeTexture(GraphicsContext3D::TEXTURE0); >+ m_context3D->bindTexture(GraphicsContext3D::TEXTURE_2D, static_cast<const BitmapTextureGL&>(sourceTexture).id()); >+ m_context3D->uniform1i(program->textureUniform(), 0); >+ const GC3Dfloat targetVertices[] = {-1, -1, 1, -1, 1, 1, -1, 1}; >+ const GC3Dfloat sourceVertices[] = {0, 0, 1, 0, 1, 1, 0, 1}; >+ m_context3D->vertexAttribPointer(program->vertexAttrib(), 2, GraphicsContext3D::FLOAT, false, 0, GC3Dintptr(targetVertices)); >+ m_context3D->vertexAttribPointer(program->texCoordAttrib(), 2, GraphicsContext3D::FLOAT, false, 0, GC3Dintptr(sourceVertices)); >+ m_context3D->disable(GraphicsContext3D::BLEND); >+ m_context3D->drawArrays(GraphicsContext3D::TRIANGLE_FAN, 0, 4); >+ m_context3D->disableVertexAttribArray(program->vertexAttrib()); >+ m_context3D->disableVertexAttribArray(program->texCoordAttrib()); > } > > PassRefPtr<BitmapTexture> BitmapTextureGL::applyFilters(const BitmapTexture& contentTexture, const FilterOperations& filters) >@@ -797,28 +764,32 @@ void BitmapTextureGL::initializeStencil() > { > if (m_rbo) > return; >- GL_CMD(glGenRenderbuffers(1, &m_rbo)); >- GL_CMD(glBindRenderbuffer(GL_RENDERBUFFER, m_rbo)); >+ >+ GraphicsContext3D* context3D = m_textureMapper->graphicsContext3D(); >+ m_rbo = context3D->createRenderbuffer(); >+ context3D->bindRenderbuffer(GraphicsContext3D::RENDERBUFFER, m_rbo); > #ifdef TEXMAP_OPENGL_ES_2 >- GL_CMD(glRenderbufferStorage(GL_RENDERBUFFER, GL_STENCIL_INDEX8, m_textureSize.width(), m_textureSize.height())); >+ context3D->renderbufferStorage(GraphicsContext3D::RENDERBUFFER, GraphicsContext3D::STENCIL_INDEX8, m_textureSize.width(), m_textureSize.height()); > #else >- GL_CMD(glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH_STENCIL, m_textureSize.width(), m_textureSize.height())); >+ context3D->renderbufferStorage(GraphicsContext3D::RENDERBUFFER, GraphicsContext3D::DEPTH_STENCIL, m_textureSize.width(), m_textureSize.height()); > #endif >- GL_CMD(glBindRenderbuffer(GL_RENDERBUFFER, 0)); >- GL_CMD(glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_STENCIL_ATTACHMENT, GL_RENDERBUFFER, m_rbo)); >- GL_CMD(glClearStencil(0)); >- GL_CMD(glClear(GL_STENCIL_BUFFER_BIT)); >+ context3D->bindRenderbuffer(GraphicsContext3D::RENDERBUFFER, 0); >+ context3D->framebufferRenderbuffer(GraphicsContext3D::FRAMEBUFFER, GraphicsContext3D::STENCIL_ATTACHMENT, GraphicsContext3D::RENDERBUFFER, m_rbo); >+ context3D->clearStencil(0); >+ context3D->clear(GraphicsContext3D::STENCIL_BUFFER_BIT); > } > > void BitmapTextureGL::clearIfNeeded() > { >+ GraphicsContext3D* context3D = m_textureMapper->graphicsContext3D(); >+ > if (!m_shouldClear) > return; > > m_clipStack.init(IntRect(IntPoint::zero(), m_textureSize)); >- m_clipStack.apply(); >- GL_CMD(glClearColor(0, 0, 0, 0)); >- GL_CMD(glClear(GL_COLOR_BUFFER_BIT)); >+ m_clipStack.apply(context3D); >+ context3D->clearColor(0, 0, 0, 0); >+ context3D->clear(GraphicsContext3D::COLOR_BUFFER_BIT); > m_shouldClear = false; > } > >@@ -827,33 +798,37 @@ void BitmapTextureGL::createFboIfNeeded() > if (m_fbo) > return; > >- GL_CMD(glGenFramebuffers(1, &m_fbo)); >- GL_CMD(glBindFramebuffer(GL_FRAMEBUFFER, m_fbo)); >- GL_CMD(glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, id(), 0)); >+ GraphicsContext3D* context3D = m_textureMapper->graphicsContext3D(); >+ m_fbo = context3D->createFramebuffer(); >+ context3D->bindFramebuffer(GraphicsContext3D::FRAMEBUFFER, m_fbo); >+ context3D->framebufferTexture2D(GraphicsContext3D::FRAMEBUFFER, GraphicsContext3D::COLOR_ATTACHMENT0, GraphicsContext3D::TEXTURE_2D, id(), 0); > m_shouldClear = true; > } > > void BitmapTextureGL::bind() > { >- GL_CMD(glBindTexture(GL_TEXTURE_2D, 0)); >+ GraphicsContext3D* context3D = m_textureMapper->graphicsContext3D(); >+ context3D->bindTexture(GraphicsContext3D::TEXTURE_2D, 0); > createFboIfNeeded(); >- GL_CMD(glBindFramebuffer(GL_FRAMEBUFFER, m_fbo)); >- GL_CMD(glViewport(0, 0, m_textureSize.width(), m_textureSize.height())); >+ context3D->bindFramebuffer(GraphicsContext3D::FRAMEBUFFER, m_fbo); >+ context3D->viewport(0, 0, m_textureSize.width(), m_textureSize.height()); > clearIfNeeded(); > m_textureMapper->data().projectionMatrix = createProjectionMatrix(m_textureSize, true /* mirrored */); >- m_clipStack.apply(); >+ m_clipStack.apply(context3D); > } > > BitmapTextureGL::~BitmapTextureGL() > { >+ GraphicsContext3D* context3D = m_textureMapper->graphicsContext3D(); >+ > if (m_id) >- GL_CMD(glDeleteTextures(1, &m_id)); >+ context3D->deleteTexture(m_id); > > if (m_fbo) >- GL_CMD(glDeleteFramebuffers(1, &m_fbo)); >+ context3D->deleteFramebuffer(m_fbo); > > if (m_rbo) >- GL_CMD(glDeleteRenderbuffers(1, &m_rbo)); >+ context3D->deleteRenderbuffer(m_rbo); > } > > bool BitmapTextureGL::isValid() const >@@ -873,11 +848,11 @@ TextureMapperGL::~TextureMapperGL() > > void TextureMapperGL::bindDefaultSurface() > { >- GL_CMD(glBindFramebuffer(GL_FRAMEBUFFER, data().targetFrameBuffer)); >+ m_context3D->bindFramebuffer(GraphicsContext3D::FRAMEBUFFER, data().targetFrameBuffer); > IntSize viewportSize(data().viewport[2], data().viewport[3]); > data().projectionMatrix = createProjectionMatrix(viewportSize, data().PaintFlags & PaintingMirrored); >- GL_CMD(glViewport(data().viewport[0], data().viewport[1], viewportSize.width(), viewportSize.height())); >- m_clipStack.apply(); >+ m_context3D->viewport(data().viewport[0], data().viewport[1], viewportSize.width(), viewportSize.height()); >+ m_clipStack.apply(m_context3D.get()); > data().currentSurface.clear(); > } > >@@ -907,7 +882,7 @@ bool TextureMapperGL::beginScissorClip(const TransformationMatrix& modelViewMatr > return false; > > clipStack().current().scissorBox.intersect(rect); >- clipStack().apply(); >+ clipStack().apply(m_context3D.get()); > return true; > } > >@@ -921,10 +896,10 @@ void TextureMapperGL::beginClip(const TransformationMatrix& modelViewMatrix, con > > RefPtr<TextureMapperShaderProgram> program = data().sharedGLData().textureMapperShaderManager.getShaderProgram(TextureMapperShaderManager::Simple); > >- GL_CMD(glUseProgram(program->id())); >- GL_CMD(glEnableVertexAttribArray(program->vertexAttrib())); >- const GLfloat unitRect[] = {0, 0, 1, 0, 1, 1, 0, 1}; >- GL_CMD(glVertexAttribPointer(program->vertexAttrib(), 2, GL_FLOAT, GL_FALSE, 0, unitRect)); >+ m_context3D->useProgram(program->id()); >+ m_context3D->enableVertexAttribArray(program->vertexAttrib()); >+ const GC3Dfloat unitRect[] = {0, 0, 1, 0, 1, 1, 0, 1}; >+ m_context3D->vertexAttribPointer(program->vertexAttrib(), 2, GraphicsContext3D::FLOAT, false, 0, GC3Dintptr(unitRect)); > > TransformationMatrix matrix = TransformationMatrix(data().projectionMatrix) > .multiply(modelViewMatrix) >@@ -933,14 +908,14 @@ void TextureMapperGL::beginClip(const TransformationMatrix& modelViewMatrix, con > 0, 0, 1, 0, > targetRect.x(), targetRect.y(), 0, 1)); > >- const GLfloat m4[] = { >+ const GC3Dfloat m4[] = { > matrix.m11(), matrix.m12(), matrix.m13(), matrix.m14(), > matrix.m21(), matrix.m22(), matrix.m23(), matrix.m24(), > matrix.m31(), matrix.m32(), matrix.m33(), matrix.m34(), > matrix.m41(), matrix.m42(), matrix.m43(), matrix.m44() > }; > >- const GLfloat m4all[] = { >+ const GC3Dfloat m4all[] = { > 2, 0, 0, 0, > 0, 2, 0, 0, > 0, 0, 1, 0, >@@ -949,43 +924,42 @@ void TextureMapperGL::beginClip(const TransformationMatrix& modelViewMatrix, con > > int& stencilIndex = clipStack().current().stencilIndex; > >- GL_CMD(glEnable(GL_STENCIL_TEST)); >+ m_context3D->enable(GraphicsContext3D::STENCIL_TEST); > > // Make sure we don't do any actual drawing. >- GL_CMD(glStencilFunc(GL_NEVER, stencilIndex, stencilIndex)); >+ m_context3D->stencilFunc(GraphicsContext3D::NEVER, stencilIndex, stencilIndex); > > // Operate only on the stencilIndex and above. >- GL_CMD(glStencilMask(0xff & ~(stencilIndex - 1))); >+ m_context3D->stencilMask(0xff & ~(stencilIndex - 1)); > > // First clear the entire buffer at the current index. >- GL_CMD(glUniformMatrix4fv(program->matrixLocation(), 1, GL_FALSE, m4all)); >- GL_CMD(glStencilOp(GL_ZERO, GL_ZERO, GL_ZERO)); >- GL_CMD(glDrawArrays(GL_TRIANGLE_FAN, 0, 4)); >+ m_context3D->uniformMatrix4fv(program->matrixLocation(), 1, false, const_cast<GC3Dfloat*>(m4all)); >+ m_context3D->stencilOp(GraphicsContext3D::ZERO, GraphicsContext3D::ZERO, GraphicsContext3D::ZERO); >+ m_context3D->drawArrays(GraphicsContext3D::TRIANGLE_FAN, 0, 4); > > // Now apply the current index to the new quad. >- GL_CMD(glStencilOp(GL_REPLACE, GL_REPLACE, GL_REPLACE)); >- GL_CMD(glUniformMatrix4fv(program->matrixLocation(), 1, GL_FALSE, m4)); >- GL_CMD(glDrawArrays(GL_TRIANGLE_FAN, 0, 4)); >+ m_context3D->stencilOp(GraphicsContext3D::REPLACE, GraphicsContext3D::REPLACE, GraphicsContext3D::REPLACE); >+ m_context3D->uniformMatrix4fv(program->matrixLocation(), 1, false, const_cast<GC3Dfloat*>(m4)); >+ m_context3D->drawArrays(GraphicsContext3D::TRIANGLE_FAN, 0, 4); > > // Clear the state. >- GL_CMD(glDisableVertexAttribArray(program->vertexAttrib())); >- GL_CMD(glStencilMask(0)); >+ m_context3D->disableVertexAttribArray(program->vertexAttrib()); >+ m_context3D->stencilMask(0); > > // Increase stencilIndex and apply stencil testing. > stencilIndex *= 2; >- clipStack().apply(); >+ clipStack().apply(m_context3D.get()); > } > > void TextureMapperGL::endClip() > { > clipStack().pop(); >- clipStack().apply(); >+ clipStack().apply(m_context3D.get()); > } > > PassRefPtr<BitmapTexture> TextureMapperGL::createTexture() > { >- BitmapTextureGL* texture = new BitmapTextureGL(); >- texture->setTextureMapper(this); >+ BitmapTextureGL* texture = new BitmapTextureGL(this); > return adoptRef(texture); > } > >diff --git a/Source/WebCore/platform/graphics/texmap/TextureMapperGL.h b/Source/WebCore/platform/graphics/texmap/TextureMapperGL.h >index 076e65f..8a72d67 100644 >--- a/Source/WebCore/platform/graphics/texmap/TextureMapperGL.h >+++ b/Source/WebCore/platform/graphics/texmap/TextureMapperGL.h >@@ -23,8 +23,8 @@ > #if USE(ACCELERATED_COMPOSITING) > > #include "FloatQuad.h" >+#include "GraphicsContext3D.h" > #include "IntSize.h" >-#include "OpenGLShims.h" > #include "TextureMapper.h" > #include "TransformationMatrix.h" > >@@ -38,7 +38,6 @@ class TextureMapperShaderProgram; > class TextureMapperGL : public TextureMapper { > public: > static PassOwnPtr<TextureMapperGL> create() { return adoptPtr(new TextureMapperGL); } >- TextureMapperGL(); > virtual ~TextureMapperGL(); > > enum Flag { >@@ -54,7 +53,7 @@ public: > virtual void drawTexture(const BitmapTexture&, const FloatRect&, const TransformationMatrix&, float opacity, const BitmapTexture* maskTexture, unsigned exposedEdges) OVERRIDE; > virtual void drawTexture(uint32_t texture, Flags, const IntSize& textureSize, const FloatRect& targetRect, const TransformationMatrix& modelViewMatrix, float opacity, const BitmapTexture* maskTexture, unsigned exposedEdges = AllEdges); > >-#if defined(GL_ARB_texture_rectangle) >+#if !USE(TEXMAP_OPENGL_ES_2) > virtual void drawTextureRectangleARB(uint32_t texture, Flags, const IntSize& textureSize, const FloatRect& targetRect, const TransformationMatrix& modelViewMatrix, float opacity, const BitmapTexture* maskTexture); > #endif > >@@ -66,6 +65,7 @@ public: > virtual IntSize maxTextureSize() const OVERRIDE { return IntSize(2000, 2000); } > virtual PassRefPtr<BitmapTexture> createTexture() OVERRIDE; > virtual GraphicsContext* graphicsContext() OVERRIDE { return m_context; } >+ inline GraphicsContext3D* graphicsContext3D() const { return m_context3D.get(); } > virtual void setGraphicsContext(GraphicsContext* context) OVERRIDE { m_context = context; } > > #if ENABLE(CSS_FILTERS) >@@ -75,7 +75,6 @@ public: > void setEnableEdgeDistanceAntialiasing(bool enabled) { m_enableEdgeDistanceAntialiasing = enabled; } > > private: >- > struct ClipState { > IntRect scissorBox; > int stencilIndex; >@@ -89,7 +88,7 @@ private: > public: > void push(); > void pop(); >- void apply(); >+ void apply(GraphicsContext3D*); > inline ClipState& current() { return clipState; } > void init(const IntRect&); > >@@ -109,16 +108,19 @@ private: > FloatQuad targetRectMappedToUnitSquare; > }; > >+ TextureMapperGL(); >+ > bool drawTextureWithAntialiasing(uint32_t texture, Flags, const FloatRect& originalTargetRect, const TransformationMatrix& modelViewMatrix, float opacity, const BitmapTexture* maskTexture, unsigned exposedEdges); > void drawTexturedQuadWithProgram(TextureMapperShaderProgram*, uint32_t texture, Flags, const DrawQuad&, const TransformationMatrix& modelViewMatrix, float opacity, const BitmapTexture* maskTexture); >- void drawQuad(const DrawQuad&, const TransformationMatrix& modelViewMatrix, TextureMapperShaderProgram*, GLenum drawingMode, bool needsBlending); >+ void drawQuad(const DrawQuad&, const TransformationMatrix& modelViewMatrix, TextureMapperShaderProgram*, GC3Denum drawingMode, bool needsBlending); > > bool beginScissorClip(const TransformationMatrix&, const FloatRect&); > void bindDefaultSurface(); > ClipStack& clipStack(); > inline TextureMapperGLData& data() { return *m_data; } >- TextureMapperGLData* m_data; > GraphicsContext* m_context; >+ RefPtr<GraphicsContext3D> m_context3D; >+ TextureMapperGLData* m_data; > ClipStack m_clipStack; > bool m_enableEdgeDistanceAntialiasing; > >@@ -135,7 +137,7 @@ public: > void initializeStencil(); > ~BitmapTextureGL(); > virtual uint32_t id() const { return m_id; } >- uint32_t textureTarget() const { return GL_TEXTURE_2D; } >+ uint32_t textureTarget() const { return GraphicsContext3D::TEXTURE_2D; } > IntSize textureSize() const { return m_textureSize; } > void setTextureMapper(TextureMapperGL* texmap) { m_textureMapper = texmap; } > void updateContents(Image*, const IntRect&, const IntPoint&); >@@ -147,20 +149,22 @@ public: > #endif > > private: >- GLuint m_id; >+ Platform3DObject m_id; > IntSize m_textureSize; > IntRect m_dirtyRect; >- GLuint m_fbo; >- GLuint m_rbo; >+ Platform3DObject m_fbo; >+ Platform3DObject m_rbo; > bool m_shouldClear; >- TextureMapperGL* m_textureMapper; > TextureMapperGL::ClipStack m_clipStack; >- BitmapTextureGL() >+ TextureMapperGL* m_textureMapper; >+ >+ BitmapTextureGL(); >+ BitmapTextureGL(TextureMapperGL* textureMapper) > : m_id(0) > , m_fbo(0) > , m_rbo(0) > , m_shouldClear(true) >- , m_textureMapper(0) >+ , m_textureMapper(textureMapper) > { > } > >diff --git a/Source/WebCore/platform/graphics/texmap/TextureMapperShaderManager.cpp b/Source/WebCore/platform/graphics/texmap/TextureMapperShaderManager.cpp >index 0fbdbe9..fa8ac05 100644 >--- a/Source/WebCore/platform/graphics/texmap/TextureMapperShaderManager.cpp >+++ b/Source/WebCore/platform/graphics/texmap/TextureMapperShaderManager.cpp >@@ -30,25 +30,11 @@ > > namespace WebCore { > >-#ifndef TEXMAP_OPENGL_ES_2 >-#define OES2_PRECISION_DEFINITIONS \ >- "#define lowp\n#define highp\n" >-#define OES2_FRAGMENT_SHADER_DEFAULT_PRECISION >-#else >-#define OES2_PRECISION_DEFINITIONS >-#define OES2_FRAGMENT_SHADER_DEFAULT_PRECISION \ >- "precision mediump float; \n" >-#endif >- >-#define STRINGIFY_VAL(src...) #src >-#define VERTEX_SHADER(src...) OES2_PRECISION_DEFINITIONS\ >- STRINGIFY_VAL(src) >-#define FRAGMENT_SHADER(src...) OES2_PRECISION_DEFINITIONS\ >- OES2_FRAGMENT_SHADER_DEFAULT_PRECISION\ >- STRINGIFY_VAL(src) >+#define STRINGIFY(src...) #src > > static const char* fragmentShaderSourceOpacityAndMask = >- FRAGMENT_SHADER( >+ STRINGIFY( >+ precision mediump float; > uniform sampler2D s_source; > uniform sampler2D s_mask; > uniform lowp float u_opacity; >@@ -64,7 +50,8 @@ static const char* fragmentShaderSourceOpacityAndMask = > ); > > static const char* fragmentShaderSourceRectOpacityAndMask = >- FRAGMENT_SHADER( >+ STRINGIFY( >+ precision mediump float; > uniform sampler2DRect s_source; > uniform sampler2DRect s_mask; > uniform lowp float u_opacity; >@@ -80,7 +67,7 @@ static const char* fragmentShaderSourceRectOpacityAndMask = > ); > > static const char* vertexShaderSourceOpacityAndMask = >- VERTEX_SHADER( >+ STRINGIFY( > uniform mat4 u_matrix; > uniform lowp float u_flip; > attribute vec4 a_vertex; >@@ -95,7 +82,8 @@ static const char* vertexShaderSourceOpacityAndMask = > ); > > static const char* fragmentShaderSourceSimple = >- FRAGMENT_SHADER( >+ STRINGIFY( >+ precision mediump float; > uniform sampler2D s_source; > uniform lowp float u_opacity; > varying highp vec2 v_sourceTexCoord; >@@ -107,7 +95,8 @@ static const char* fragmentShaderSourceSimple = > ); > > static const char* fragmentShaderSourceAntialiasingNoMask = >- FRAGMENT_SHADER( >+ STRINGIFY( >+ precision mediump float; > uniform sampler2D s_source; > varying highp vec2 v_sourceTexCoord; > uniform lowp float u_opacity; >@@ -145,7 +134,8 @@ static const char* fragmentShaderSourceAntialiasingNoMask = > ); > > static const char* fragmentShaderSourceRectSimple = >- FRAGMENT_SHADER( >+ STRINGIFY( >+ precision mediump float; > uniform sampler2DRect s_source; > uniform lowp vec2 u_textureSize; > uniform lowp float u_opacity; >@@ -158,7 +148,7 @@ static const char* fragmentShaderSourceRectSimple = > ); > > static const char* vertexShaderSourceSimple = >- VERTEX_SHADER( >+ STRINGIFY( > uniform mat4 u_matrix; > uniform lowp float u_flip; > attribute vec4 a_vertex; >@@ -171,7 +161,7 @@ static const char* vertexShaderSourceSimple = > ); > > static const char* vertexShaderSourceSolidColor = >- VERTEX_SHADER( >+ STRINGIFY( > uniform mat4 u_matrix; > attribute vec4 a_vertex; > void main(void) >@@ -182,7 +172,8 @@ static const char* vertexShaderSourceSolidColor = > > > static const char* fragmentShaderSourceSolidColor = >- VERTEX_SHADER( >+ STRINGIFY( >+ precision mediump float; > uniform vec4 u_color; > void main(void) > { >@@ -212,22 +203,22 @@ PassRefPtr<TextureMapperShaderProgram> TextureMapperShaderManager::getShaderProg > > switch (shaderType) { > case Simple: >- program = TextureMapperShaderProgramSimple::create(); >+ program = TextureMapperShaderProgramSimple::create(m_context); > break; > case RectSimple: >- program = TextureMapperShaderProgramRectSimple::create(); >+ program = TextureMapperShaderProgramRectSimple::create(m_context); > break; > case AntialiasingNoMask: >- program = TextureMapperShaderProgramAntialiasingNoMask::create(); >+ program = TextureMapperShaderProgramAntialiasingNoMask::create(m_context); > break; > case OpacityAndMask: >- program = TextureMapperShaderProgramOpacityAndMask::create(); >+ program = TextureMapperShaderProgramOpacityAndMask::create(m_context); > break; > case RectOpacityAndMask: >- program = TextureMapperShaderProgramRectOpacityAndMask::create(); >+ program = TextureMapperShaderProgramRectOpacityAndMask::create(m_context); > break; > case SolidColor: >- program = TextureMapperShaderProgramSolidColor::create(); >+ program = TextureMapperShaderProgramSolidColor::create(m_context); > break; > case Invalid: > ASSERT_NOT_REACHED(); >@@ -236,8 +227,9 @@ PassRefPtr<TextureMapperShaderProgram> TextureMapperShaderManager::getShaderProg > return program; > } > >-TextureMapperShaderProgram::TextureMapperShaderProgram(const char* vertexShaderSource, const char* fragmentShaderSource) >- : m_id(0) >+TextureMapperShaderProgram::TextureMapperShaderProgram(GraphicsContext3D* context, const char* vertexShaderSource, const char* fragmentShaderSource) >+ : m_context(context) >+ , m_id(0) > , m_vertexAttrib(0) > , m_vertexShader(0) > , m_fragmentShader(0) >@@ -256,46 +248,46 @@ void TextureMapperShaderProgram::initializeProgram() > { > const char* vertexShaderSourceProgram = vertexShaderSource(); > const char* fragmentShaderSourceProgram = fragmentShaderSource(); >- GLuint vertexShader = glCreateShader(GL_VERTEX_SHADER); >- GLuint fragmentShader = glCreateShader(GL_FRAGMENT_SHADER); >- glShaderSource(vertexShader, 1, &vertexShaderSourceProgram, 0); >- glShaderSource(fragmentShader, 1, &fragmentShaderSourceProgram, 0); >- GLuint programID = glCreateProgram(); >- glCompileShader(vertexShader); >- glCompileShader(fragmentShader); >+ Platform3DObject vertexShader = m_context->createShader(GraphicsContext3D::VERTEX_SHADER); >+ Platform3DObject fragmentShader = m_context->createShader(GraphicsContext3D::FRAGMENT_SHADER); >+ m_context->shaderSource(vertexShader, vertexShaderSourceProgram); >+ m_context->shaderSource(fragmentShader, fragmentShaderSourceProgram); >+ Platform3DObject programID = m_context->createProgram(); >+ m_context->compileShader(vertexShader); >+ m_context->compileShader(fragmentShader); > >- glAttachShader(programID, vertexShader); >- glAttachShader(programID, fragmentShader); >- glLinkProgram(programID); >+ m_context->attachShader(programID, vertexShader); >+ m_context->attachShader(programID, fragmentShader); >+ m_context->linkProgram(programID); > >- m_vertexAttrib = glGetAttribLocation(programID, "a_vertex"); >+ m_vertexAttrib = m_context->getAttribLocation(programID, "a_vertex"); > > m_id = programID; > m_vertexShader = vertexShader; > m_fragmentShader = fragmentShader; > } > >-void TextureMapperShaderProgram::getUniformLocation(GLint &variable, const char* name) >+void TextureMapperShaderProgram::getUniformLocation(GC3Dint &variable, const char* name) > { >- variable = glGetUniformLocation(m_id, name); >+ variable = m_context->getUniformLocation(m_id, name); > ASSERT(variable >= 0); > } > > TextureMapperShaderProgram::~TextureMapperShaderProgram() > { >- GLuint programID = m_id; >+ Platform3DObject programID = m_id; > if (!programID) > return; > >- glDetachShader(programID, m_vertexShader); >- glDeleteShader(m_vertexShader); >- glDetachShader(programID, m_fragmentShader); >- glDeleteShader(m_fragmentShader); >- glDeleteProgram(programID); >+ m_context->detachShader(programID, m_vertexShader); >+ m_context->deleteShader(m_vertexShader); >+ m_context->detachShader(programID, m_fragmentShader); >+ m_context->deleteShader(m_fragmentShader); >+ m_context->deleteProgram(programID); > } > >-TextureMapperShaderProgramSimple::TextureMapperShaderProgramSimple() >- : TextureMapperShaderProgram(vertexShaderSourceSimple, fragmentShaderSourceSimple) >+TextureMapperShaderProgramSimple::TextureMapperShaderProgramSimple(GraphicsContext3D* context) >+ : TextureMapperShaderProgram(context, vertexShaderSourceSimple, fragmentShaderSourceSimple) > { > initializeProgram(); > getUniformLocation(m_flipLocation, "u_flip"); >@@ -304,16 +296,16 @@ TextureMapperShaderProgramSimple::TextureMapperShaderProgramSimple() > getUniformLocation(m_opacityLocation, "u_opacity"); > } > >-TextureMapperShaderProgramSolidColor::TextureMapperShaderProgramSolidColor() >- : TextureMapperShaderProgram(vertexShaderSourceSolidColor, fragmentShaderSourceSolidColor) >+TextureMapperShaderProgramSolidColor::TextureMapperShaderProgramSolidColor(GraphicsContext3D* context) >+ : TextureMapperShaderProgram(context, vertexShaderSourceSolidColor, fragmentShaderSourceSolidColor) > { > initializeProgram(); > getUniformLocation(m_matrixLocation, "u_matrix"); > getUniformLocation(m_colorLocation, "u_color"); > } > >-TextureMapperShaderProgramRectSimple::TextureMapperShaderProgramRectSimple() >- : TextureMapperShaderProgram(vertexShaderSourceSimple, fragmentShaderSourceRectSimple) >+TextureMapperShaderProgramRectSimple::TextureMapperShaderProgramRectSimple(GraphicsContext3D* context) >+ : TextureMapperShaderProgram(context, vertexShaderSourceSimple, fragmentShaderSourceRectSimple) > { > initializeProgram(); > getUniformLocation(m_matrixLocation, "u_matrix"); >@@ -323,8 +315,8 @@ TextureMapperShaderProgramRectSimple::TextureMapperShaderProgramRectSimple() > getUniformLocation(m_opacityLocation, "u_opacity"); > } > >-TextureMapperShaderProgramOpacityAndMask::TextureMapperShaderProgramOpacityAndMask() >- : TextureMapperShaderProgram(vertexShaderSourceOpacityAndMask, fragmentShaderSourceOpacityAndMask) >+TextureMapperShaderProgramOpacityAndMask::TextureMapperShaderProgramOpacityAndMask(GraphicsContext3D* context) >+ : TextureMapperShaderProgram(context, vertexShaderSourceOpacityAndMask, fragmentShaderSourceOpacityAndMask) > { > initializeProgram(); > getUniformLocation(m_matrixLocation, "u_matrix"); >@@ -334,8 +326,8 @@ TextureMapperShaderProgramOpacityAndMask::TextureMapperShaderProgramOpacityAndMa > getUniformLocation(m_opacityLocation, "u_opacity"); > } > >-TextureMapperShaderProgramRectOpacityAndMask::TextureMapperShaderProgramRectOpacityAndMask() >- : TextureMapperShaderProgram(vertexShaderSourceOpacityAndMask, fragmentShaderSourceRectOpacityAndMask) >+TextureMapperShaderProgramRectOpacityAndMask::TextureMapperShaderProgramRectOpacityAndMask(GraphicsContext3D* context) >+ : TextureMapperShaderProgram(context, vertexShaderSourceOpacityAndMask, fragmentShaderSourceRectOpacityAndMask) > { > initializeProgram(); > getUniformLocation(m_matrixLocation, "u_matrix"); >@@ -345,8 +337,8 @@ TextureMapperShaderProgramRectOpacityAndMask::TextureMapperShaderProgramRectOpac > getUniformLocation(m_opacityLocation, "u_opacity"); > } > >-TextureMapperShaderProgramAntialiasingNoMask::TextureMapperShaderProgramAntialiasingNoMask() >- : TextureMapperShaderProgram(vertexShaderSourceSimple, fragmentShaderSourceAntialiasingNoMask) >+TextureMapperShaderProgramAntialiasingNoMask::TextureMapperShaderProgramAntialiasingNoMask(GraphicsContext3D* context) >+ : TextureMapperShaderProgram(context, vertexShaderSourceSimple, fragmentShaderSourceAntialiasingNoMask) > { > initializeProgram(); > getUniformLocation(m_matrixLocation, "u_matrix"); >@@ -356,9 +348,9 @@ TextureMapperShaderProgramAntialiasingNoMask::TextureMapperShaderProgramAntialia > getUniformLocation(m_flipLocation, "u_flip"); > } > >-TextureMapperShaderManager::TextureMapperShaderManager() >+TextureMapperShaderManager::TextureMapperShaderManager(GraphicsContext3D* context) >+ : m_context(context) > { >- ASSERT(initializeOpenGLShims()); > } > > TextureMapperShaderManager::~TextureMapperShaderManager() >@@ -373,18 +365,19 @@ TextureMapperShaderManager::~TextureMapperShaderManager() > > StandardFilterProgram::~StandardFilterProgram() > { >- glDetachShader(m_id, m_vertexShader); >- glDeleteShader(m_vertexShader); >- glDetachShader(m_id, m_fragmentShader); >- glDeleteShader(m_fragmentShader); >- glDeleteProgram(m_id); >+ m_context->detachShader(m_id, m_vertexShader); >+ m_context->deleteShader(m_vertexShader); >+ m_context->detachShader(m_id, m_fragmentShader); >+ m_context->deleteShader(m_fragmentShader); >+ m_context->deleteProgram(m_id); > } > >-StandardFilterProgram::StandardFilterProgram(FilterOperation::OperationType type, unsigned pass) >- : m_id(0) >+StandardFilterProgram::StandardFilterProgram(GraphicsContext3D* context, FilterOperation::OperationType type, unsigned pass) >+ : m_context(context) >+ , m_id(0) > { > const char* vertexShaderSource = >- VERTEX_SHADER( >+ STRINGIFY( > attribute vec4 a_vertex; > attribute vec4 a_texCoord; > varying highp vec2 v_texCoord; >@@ -396,8 +389,7 @@ StandardFilterProgram::StandardFilterProgram(FilterOperation::OperationType type > ); > > #define STANDARD_FILTER(x...) \ >- OES2_PRECISION_DEFINITIONS\ >- OES2_FRAGMENT_SHADER_DEFAULT_PRECISION\ >+ "precision mediump float;\n"\ > "varying highp vec2 v_texCoord;\n"\ > "uniform highp float u_amount;\n"\ > "uniform sampler2D u_texture;\n"\ >@@ -490,7 +482,8 @@ StandardFilterProgram::StandardFilterProgram(FilterOperation::OperationType type > ); > break; > case FilterOperation::BLUR: >- fragmentShaderSource = FRAGMENT_SHADER( >+ fragmentShaderSource = STRINGIFY( >+ precision mediump float; > varying highp vec2 v_texCoord; > uniform lowp vec2 u_blurRadius; > uniform sampler2D u_texture; >@@ -523,7 +516,8 @@ StandardFilterProgram::StandardFilterProgram(FilterOperation::OperationType type > switch (pass) { > case 0: { > // First pass: horizontal alpha blur. >- fragmentShaderSource = FRAGMENT_SHADER( >+ fragmentShaderSource = STRINGIFY( >+ precision mediump float; > varying highp vec2 v_texCoord; > uniform lowp float u_shadowBlurRadius; > uniform lowp vec2 u_shadowOffset; >@@ -556,7 +550,8 @@ StandardFilterProgram::StandardFilterProgram(FilterOperation::OperationType type > } > case 1: { > // Second pass: vertical alpha blur and composite with origin. >- fragmentShaderSource = FRAGMENT_SHADER( >+ fragmentShaderSource = STRINGIFY( >+ precision mediump float; > varying highp vec2 v_texCoord; > uniform lowp float u_shadowBlurRadius; > uniform lowp vec4 u_shadowColor; >@@ -602,26 +597,25 @@ StandardFilterProgram::StandardFilterProgram(FilterOperation::OperationType type > > if (!fragmentShaderSource) > return; >- GLuint vertexShader = glCreateShader(GL_VERTEX_SHADER); >- GLuint fragmentShader = glCreateShader(GL_FRAGMENT_SHADER); >- glShaderSource(vertexShader, 1, &vertexShaderSource, 0); >- glShaderSource(fragmentShader, 1, &fragmentShaderSource, 0); >- GLuint programID = glCreateProgram(); >- glCompileShader(vertexShader); >- glCompileShader(fragmentShader); >+ Platform3DObject vertexShader = m_context->createShader(GraphicsContext3D::VERTEX_SHADER); >+ Platform3DObject fragmentShader = m_context->createShader(GraphicsContext3D::FRAGMENT_SHADER); >+ m_context->shaderSource(vertexShader, vertexShaderSource); >+ m_context->shaderSource(fragmentShader, fragmentShaderSource); >+ Platform3DObject programID = m_context->createProgram(); >+ m_context->compileShader(vertexShader); >+ m_context->compileShader(fragmentShader); > #if !LOG_DISABLED >- GLchar log[100]; >- GLint len; >- glGetShaderInfoLog(fragmentShader, 100, &len, log); >+ String log; >+ m_context->getShaderInfoLog(fragmentShader); > WTFLog(&LogCompositing, "%s\n", log); > #endif >- glAttachShader(programID, vertexShader); >- glAttachShader(programID, fragmentShader); >- glLinkProgram(programID); >+ m_context->attachShader(programID, vertexShader); >+ m_context->attachShader(programID, fragmentShader); >+ m_context->linkProgram(programID); > >- m_vertexAttrib = glGetAttribLocation(programID, "a_vertex"); >- m_texCoordAttrib = glGetAttribLocation(programID, "a_texCoord"); >- m_textureUniformLocation = glGetUniformLocation(programID, "u_texture"); >+ m_vertexAttrib = m_context->getAttribLocation(programID, "a_vertex"); >+ m_texCoordAttrib = m_context->getAttribLocation(programID, "a_texCoord"); >+ m_textureUniformLocation = m_context->getUniformLocation(programID, "u_texture"); > switch (type) { > case FilterOperation::GRAYSCALE: > case FilterOperation::SEPIA: >@@ -631,21 +625,21 @@ StandardFilterProgram::StandardFilterProgram(FilterOperation::OperationType type > case FilterOperation::BRIGHTNESS: > case FilterOperation::CONTRAST: > case FilterOperation::OPACITY: >- m_uniformLocations.amount = glGetUniformLocation(programID, "u_amount"); >+ m_uniformLocations.amount = m_context->getUniformLocation(programID, "u_amount"); > break; > case FilterOperation::BLUR: >- m_uniformLocations.blur.radius = glGetUniformLocation(programID, "u_blurRadius"); >- m_uniformLocations.blur.gaussianKernel = glGetUniformLocation(programID, "u_gaussianKernel"); >+ m_uniformLocations.blur.radius = m_context->getUniformLocation(programID, "u_blurRadius"); >+ m_uniformLocations.blur.gaussianKernel = m_context->getUniformLocation(programID, "u_gaussianKernel"); > break; > case FilterOperation::DROP_SHADOW: >- m_uniformLocations.shadow.blurRadius = glGetUniformLocation(programID, "u_shadowBlurRadius"); >- m_uniformLocations.shadow.gaussianKernel = glGetUniformLocation(programID, "u_gaussianKernel"); >+ m_uniformLocations.shadow.blurRadius = m_context->getUniformLocation(programID, "u_shadowBlurRadius"); >+ m_uniformLocations.shadow.gaussianKernel = m_context->getUniformLocation(programID, "u_gaussianKernel"); > if (!pass) >- m_uniformLocations.shadow.offset = glGetUniformLocation(programID, "u_shadowOffset"); >+ m_uniformLocations.shadow.offset = m_context->getUniformLocation(programID, "u_shadowOffset"); > else { > // We only need the color and the content texture in the second pass, the first pass is only a horizontal alpha blur. >- m_uniformLocations.shadow.color = glGetUniformLocation(programID, "u_shadowColor"); >- m_uniformLocations.shadow.contentTexture = glGetUniformLocation(programID, "u_contentTexture"); >+ m_uniformLocations.shadow.color = m_context->getUniformLocation(programID, "u_shadowColor"); >+ m_uniformLocations.shadow.contentTexture = m_context->getUniformLocation(programID, "u_contentTexture"); > } > break; > default: >@@ -656,9 +650,9 @@ StandardFilterProgram::StandardFilterProgram(FilterOperation::OperationType type > m_fragmentShader = fragmentShader; > } > >-PassRefPtr<StandardFilterProgram> StandardFilterProgram::create(FilterOperation::OperationType type, unsigned pass) >+PassRefPtr<StandardFilterProgram> StandardFilterProgram::create(GraphicsContext3D* context, FilterOperation::OperationType type, unsigned pass) > { >- RefPtr<StandardFilterProgram> program = adoptRef(new StandardFilterProgram(type, pass)); >+ RefPtr<StandardFilterProgram> program = adoptRef(new StandardFilterProgram(context, type, pass)); > if (!program->m_id) > return 0; > >@@ -694,21 +688,21 @@ static float* gaussianKernel() > return kernel; > } > >-void StandardFilterProgram::prepare(const FilterOperation& operation, unsigned pass, const IntSize& size, GLuint contentTexture) >+void StandardFilterProgram::prepare(const FilterOperation& operation, unsigned pass, const IntSize& size, GC3Duint contentTexture) > { >- glUseProgram(m_id); >+ m_context->useProgram(m_id); > switch (operation.getOperationType()) { > case FilterOperation::GRAYSCALE: > case FilterOperation::SEPIA: > case FilterOperation::SATURATE: > case FilterOperation::HUE_ROTATE: >- glUniform1f(m_uniformLocations.amount, static_cast<const BasicColorMatrixFilterOperation&>(operation).amount()); >+ m_context->uniform1f(m_uniformLocations.amount, static_cast<const BasicColorMatrixFilterOperation&>(operation).amount()); > break; > case FilterOperation::INVERT: > case FilterOperation::BRIGHTNESS: > case FilterOperation::CONTRAST: > case FilterOperation::OPACITY: >- glUniform1f(m_uniformLocations.amount, static_cast<const BasicComponentTransferFilterOperation&>(operation).amount()); >+ m_context->uniform1f(m_uniformLocations.amount, static_cast<const BasicComponentTransferFilterOperation&>(operation).amount()); > break; > case FilterOperation::BLUR: { > const BlurFilterOperation& blur = static_cast<const BlurFilterOperation&>(operation); >@@ -720,8 +714,8 @@ void StandardFilterProgram::prepare(const FilterOperation& operation, unsigned p > else > radius.setWidth(floatValueForLength(blur.stdDeviation(), size.width()) / size.width()); > >- glUniform2f(m_uniformLocations.blur.radius, radius.width(), radius.height()); >- glUniform1fv(m_uniformLocations.blur.gaussianKernel, GAUSSIAN_KERNEL_HALF_WIDTH, gaussianKernel()); >+ m_context->uniform2f(m_uniformLocations.blur.radius, radius.width(), radius.height()); >+ m_context->uniform1fv(m_uniformLocations.blur.gaussianKernel, GAUSSIAN_KERNEL_HALF_WIDTH, gaussianKernel()); > break; > } > case FilterOperation::DROP_SHADOW: { >@@ -729,20 +723,20 @@ void StandardFilterProgram::prepare(const FilterOperation& operation, unsigned p > switch (pass) { > case 0: > // First pass: vertical alpha blur. >- glUniform2f(m_uniformLocations.shadow.offset, float(shadow.location().x()) / float(size.width()), float(shadow.location().y()) / float(size.height())); >- glUniform1f(m_uniformLocations.shadow.blurRadius, shadow.stdDeviation() / float(size.width())); >- glUniform1fv(m_uniformLocations.shadow.gaussianKernel, GAUSSIAN_KERNEL_HALF_WIDTH, gaussianKernel()); >+ m_context->uniform2f(m_uniformLocations.shadow.offset, float(shadow.location().x()) / float(size.width()), float(shadow.location().y()) / float(size.height())); >+ m_context->uniform1f(m_uniformLocations.shadow.blurRadius, shadow.stdDeviation() / float(size.width())); >+ m_context->uniform1fv(m_uniformLocations.shadow.gaussianKernel, GAUSSIAN_KERNEL_HALF_WIDTH, gaussianKernel()); > break; > case 1: > // Second pass: we need the shadow color and the content texture for compositing. >- glUniform1f(m_uniformLocations.shadow.blurRadius, shadow.stdDeviation() / float(size.height())); >- glUniform1fv(m_uniformLocations.shadow.gaussianKernel, GAUSSIAN_KERNEL_HALF_WIDTH, gaussianKernel()); >- glActiveTexture(GL_TEXTURE1); >- glBindTexture(GL_TEXTURE_2D, contentTexture); >- glUniform1i(m_uniformLocations.shadow.contentTexture, 1); >+ m_context->uniform1f(m_uniformLocations.shadow.blurRadius, shadow.stdDeviation() / float(size.height())); >+ m_context->uniform1fv(m_uniformLocations.shadow.gaussianKernel, GAUSSIAN_KERNEL_HALF_WIDTH, gaussianKernel()); >+ m_context->activeTexture(GraphicsContext3D::TEXTURE1); >+ m_context->bindTexture(GraphicsContext3D::TEXTURE_2D, contentTexture); >+ m_context->uniform1i(m_uniformLocations.shadow.contentTexture, 1); > float r, g, b, a; > shadow.color().getRGBA(r, g, b, a); >- glUniform4f(m_uniformLocations.shadow.color, r, g, b, a); >+ m_context->uniform4f(m_uniformLocations.shadow.color, r, g, b, a); > break; > } > break; >@@ -759,7 +753,7 @@ PassRefPtr<StandardFilterProgram> TextureMapperShaderManager::getShaderForFilter > int key = int(type) | (pass << 16); > FilterMap::iterator iterator = m_filterMap.find(key); > if (iterator == m_filterMap.end()) { >- program = StandardFilterProgram::create(type, pass); >+ program = StandardFilterProgram::create(m_context, type, pass); > if (!program) > return 0; > >diff --git a/Source/WebCore/platform/graphics/texmap/TextureMapperShaderManager.h b/Source/WebCore/platform/graphics/texmap/TextureMapperShaderManager.h >index 785498e..be45c5d 100644 >--- a/Source/WebCore/platform/graphics/texmap/TextureMapperShaderManager.h >+++ b/Source/WebCore/platform/graphics/texmap/TextureMapperShaderManager.h >@@ -24,9 +24,9 @@ > #if USE(ACCELERATED_COMPOSITING) && USE(TEXTURE_MAPPER) > > #include "FloatQuad.h" >+#include "GraphicsContext3D.h" > #include "IntSize.h" >-#include "OpenGLShims.h" >-#include "TextureMapper.h" >+#include "TextureMapperGL.h" > #include "TransformationMatrix.h" > #include <wtf/HashMap.h> > #include <wtf/PassRefPtr.h> >@@ -44,39 +44,40 @@ class TextureMapperShaderManager; > > class TextureMapperShaderProgram : public RefCounted<TextureMapperShaderProgram> { > public: >- GLuint id() { return m_id; } >- GLuint vertexAttrib() { return m_vertexAttrib; } >+ Platform3DObject id() { return m_id; } >+ GC3Duint vertexAttrib() { return m_vertexAttrib; } > >- TextureMapperShaderProgram(const char* vertexShaderSource, const char* fragmentShaderSource); >+ TextureMapperShaderProgram(GraphicsContext3D*, const char* vertexShaderSource, const char* fragmentShaderSource); > virtual ~TextureMapperShaderProgram(); > > virtual void prepare(float opacity, const BitmapTexture*) { } >- GLint matrixLocation() const { return m_matrixLocation; } >- GLint flipLocation() const { return m_flipLocation; } >- GLint textureSizeLocation() const { return m_textureSizeLocation; } >- GLint sourceTextureLocation() const { return m_sourceTextureLocation; } >- GLint maskTextureLocation() const { return m_maskTextureLocation; } >- GLint opacityLocation() const { return m_opacityLocation; } >+ GC3Dint matrixLocation() const { return m_matrixLocation; } >+ GC3Dint flipLocation() const { return m_flipLocation; } >+ GC3Dint textureSizeLocation() const { return m_textureSizeLocation; } >+ GC3Dint sourceTextureLocation() const { return m_sourceTextureLocation; } >+ GC3Dint maskTextureLocation() const { return m_maskTextureLocation; } >+ GC3Dint opacityLocation() const { return m_opacityLocation; } > >- static bool isValidUniformLocation(GLint location) { return location >= 0; } >+ static bool isValidUniformLocation(GC3Dint location) { return location >= 0; } > > protected: >- void getUniformLocation(GLint& var, const char* name); >+ void getUniformLocation(GC3Dint& var, const char* name); > void initializeProgram(); > virtual void initialize() { } > const char* vertexShaderSource() const { return m_vertexShaderSource.data(); } > const char* fragmentShaderSource() const { return m_fragmentShaderSource.data(); } > >- GLuint m_id; >- GLuint m_vertexAttrib; >- GLuint m_vertexShader; >- GLuint m_fragmentShader; >- GLint m_matrixLocation; >- GLint m_flipLocation; >- GLint m_textureSizeLocation; >- GLint m_sourceTextureLocation; >- GLint m_opacityLocation; >- GLint m_maskTextureLocation; >+ GraphicsContext3D* m_context; >+ Platform3DObject m_id; >+ GC3Duint m_vertexAttrib; >+ Platform3DObject m_vertexShader; >+ Platform3DObject m_fragmentShader; >+ GC3Dint m_matrixLocation; >+ GC3Dint m_flipLocation; >+ GC3Dint m_textureSizeLocation; >+ GC3Dint m_sourceTextureLocation; >+ GC3Dint m_opacityLocation; >+ GC3Dint m_maskTextureLocation; > > private: > CString m_vertexShaderSource; >@@ -87,33 +88,36 @@ private: > class StandardFilterProgram : public RefCounted<StandardFilterProgram> { > public: > virtual ~StandardFilterProgram(); >- virtual void prepare(const FilterOperation&, unsigned pass, const IntSize&, GLuint contentTexture); >- static PassRefPtr<StandardFilterProgram> create(FilterOperation::OperationType, unsigned pass); >- GLuint vertexAttrib() const { return m_vertexAttrib; } >- GLuint texCoordAttrib() const { return m_texCoordAttrib; } >- GLuint textureUniform() const { return m_textureUniformLocation; } >+ virtual void prepare(const FilterOperation&, unsigned pass, const IntSize&, GC3Duint contentTexture); >+ static PassRefPtr<StandardFilterProgram> create(GraphicsContext3D*, FilterOperation::OperationType, unsigned pass); >+ GC3Duint vertexAttrib() const { return m_vertexAttrib; } >+ GC3Duint texCoordAttrib() const { return m_texCoordAttrib; } >+ GC3Duint textureUniform() const { return m_textureUniformLocation; } >+protected: >+ GraphicsContext3D* m_context; > private: >- StandardFilterProgram(FilterOperation::OperationType, unsigned pass); >- GLuint m_id; >- GLuint m_vertexShader; >- GLuint m_fragmentShader; >- GLuint m_vertexAttrib; >- GLuint m_texCoordAttrib; >- GLuint m_textureUniformLocation; >+ StandardFilterProgram(); >+ StandardFilterProgram(GraphicsContext3D*, FilterOperation::OperationType, unsigned pass); >+ Platform3DObject m_id; >+ Platform3DObject m_vertexShader; >+ Platform3DObject m_fragmentShader; >+ GC3Duint m_vertexAttrib; >+ GC3Duint m_texCoordAttrib; >+ GC3Duint m_textureUniformLocation; > union { >- GLuint amount; >+ GC3Duint amount; > > struct { >- GLuint radius; >- GLuint gaussianKernel; >+ GC3Duint radius; >+ GC3Duint gaussianKernel; > } blur; > > struct { >- GLuint blurRadius; >- GLuint color; >- GLuint offset; >- GLuint contentTexture; >- GLuint gaussianKernel; >+ GC3Duint blurRadius; >+ GC3Duint color; >+ GC3Duint offset; >+ GC3Duint contentTexture; >+ GC3Duint gaussianKernel; > } shadow; > } m_uniformLocations; > }; >@@ -121,77 +125,89 @@ private: > > class TextureMapperShaderProgramSimple : public TextureMapperShaderProgram { > public: >- static PassRefPtr<TextureMapperShaderProgramSimple> create() >+ static PassRefPtr<TextureMapperShaderProgramSimple> create(GraphicsContext3D* context) > { >- return adoptRef(new TextureMapperShaderProgramSimple()); >+ return adoptRef(new TextureMapperShaderProgramSimple(context)); > } > > protected: >+ TextureMapperShaderProgramSimple(GraphicsContext3D*); >+private: > TextureMapperShaderProgramSimple(); > }; > > class TextureMapperShaderProgramRectSimple : public TextureMapperShaderProgram { > public: >- static PassRefPtr<TextureMapperShaderProgramRectSimple> create() >+ static PassRefPtr<TextureMapperShaderProgramRectSimple> create(GraphicsContext3D* context) > { >- return adoptRef(new TextureMapperShaderProgramRectSimple()); >+ return adoptRef(new TextureMapperShaderProgramRectSimple(context)); > } > >+protected: >+ TextureMapperShaderProgramRectSimple(GraphicsContext3D*); > private: > TextureMapperShaderProgramRectSimple(); > }; > > class TextureMapperShaderProgramOpacityAndMask : public TextureMapperShaderProgram { > public: >- static PassRefPtr<TextureMapperShaderProgramOpacityAndMask> create() >+ static PassRefPtr<TextureMapperShaderProgramOpacityAndMask> create(GraphicsContext3D* context) > { >- return adoptRef(new TextureMapperShaderProgramOpacityAndMask()); >+ return adoptRef(new TextureMapperShaderProgramOpacityAndMask(context)); > } > >+protected: >+ TextureMapperShaderProgramOpacityAndMask(GraphicsContext3D*); > private: > TextureMapperShaderProgramOpacityAndMask(); > }; > > class TextureMapperShaderProgramRectOpacityAndMask : public TextureMapperShaderProgram { > public: >- static PassRefPtr<TextureMapperShaderProgramRectOpacityAndMask> create() >+ static PassRefPtr<TextureMapperShaderProgramRectOpacityAndMask> create(GraphicsContext3D* context) > { >- return adoptRef(new TextureMapperShaderProgramRectOpacityAndMask()); >+ return adoptRef(new TextureMapperShaderProgramRectOpacityAndMask(context)); > } > >+protected: >+ TextureMapperShaderProgramRectOpacityAndMask(GraphicsContext3D*); > private: > TextureMapperShaderProgramRectOpacityAndMask(); > }; > > class TextureMapperShaderProgramSolidColor : public TextureMapperShaderProgram { > public: >- static PassRefPtr<TextureMapperShaderProgramSolidColor> create() >+ static PassRefPtr<TextureMapperShaderProgramSolidColor> create(GraphicsContext3D* context) > { >- return adoptRef(new TextureMapperShaderProgramSolidColor()); >+ return adoptRef(new TextureMapperShaderProgramSolidColor(context)); > } > >- GLint colorLocation() const { return m_colorLocation; } >+ GC3Dint colorLocation() const { return m_colorLocation; } > >+protected: >+ TextureMapperShaderProgramSolidColor(GraphicsContext3D*); > private: > TextureMapperShaderProgramSolidColor(); >- GLint m_colorLocation; >+ GC3Dint m_colorLocation; > }; > > class TextureMapperShaderProgramAntialiasingNoMask : public TextureMapperShaderProgram { > public: >- static PassRefPtr<TextureMapperShaderProgramAntialiasingNoMask> create() >+ static PassRefPtr<TextureMapperShaderProgramAntialiasingNoMask> create(GraphicsContext3D* context) > { >- return adoptRef(new TextureMapperShaderProgramAntialiasingNoMask()); >+ return adoptRef(new TextureMapperShaderProgramAntialiasingNoMask(context)); > } > >- GLint expandedQuadVerticesInTextureCoordinatesLocation() { return m_expandedQuadVerticesInTextureCordinatesLocation; } >- GLint expandedQuadEdgesInScreenSpaceLocation() { return m_expandedQuadEdgesInScreenSpaceLocation; } >+ GC3Dint expandedQuadVerticesInTextureCoordinatesLocation() { return m_expandedQuadVerticesInTextureCordinatesLocation; } >+ GC3Dint expandedQuadEdgesInScreenSpaceLocation() { return m_expandedQuadEdgesInScreenSpaceLocation; } > >+protected: >+ TextureMapperShaderProgramAntialiasingNoMask(GraphicsContext3D*); > private: > TextureMapperShaderProgramAntialiasingNoMask(); > >- GLint m_expandedQuadVerticesInTextureCordinatesLocation; >- GLint m_expandedQuadEdgesInScreenSpaceLocation; >+ GC3Dint m_expandedQuadVerticesInTextureCordinatesLocation; >+ GC3Dint m_expandedQuadEdgesInScreenSpaceLocation; > }; > > class TextureMapperShaderManager { >@@ -206,7 +222,8 @@ public: > SolidColor > }; > >- TextureMapperShaderManager(); >+ TextureMapperShaderManager() { }; >+ TextureMapperShaderManager(GraphicsContext3D*); > virtual ~TextureMapperShaderManager(); > > #if ENABLE(CSS_FILTERS) >@@ -221,12 +238,12 @@ public: > private: > typedef HashMap<ShaderType, RefPtr<TextureMapperShaderProgram>, DefaultHash<int>::Hash, HashTraits<int> > TextureMapperShaderProgramMap; > TextureMapperShaderProgramMap m_textureMapperShaderProgramMap; >+ GraphicsContext3D* m_context; > > #if ENABLE(CSS_FILTERS) > typedef HashMap<int, RefPtr<StandardFilterProgram> > FilterMap; > FilterMap m_filterMap; > #endif >- > }; > > }
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Formatted Diff
|
Diff
Attachments on
bug 78672
:
153650
|
153653
|
153657
|
153684
|
153896
|
153906
|
153909
|
154580
|
154582
|
154725
|
154727
|
154777
|
154782
|
154783
|
154787
|
154818
|
154819
|
157911
|
158621
|
159896
|
160499
|
160508
|
160511
|
160535
|
160559
|
160567
|
160989