Modified: trunk/Source/WebCore/platform/graphics/cairo/GraphicsContext3DCairo.cpp (127043 => 127044)
--- trunk/Source/WebCore/platform/graphics/cairo/GraphicsContext3DCairo.cpp 2012-08-29 20:40:38 UTC (rev 127043)
+++ trunk/Source/WebCore/platform/graphics/cairo/GraphicsContext3DCairo.cpp 2012-08-29 20:41:03 UTC (rev 127044)
@@ -65,7 +65,7 @@
return context.release();
}
-GraphicsContext3D::GraphicsContext3D(GraphicsContext3D::Attributes attributes, HostWindow*, GraphicsContext3D::RenderStyle)
+GraphicsContext3D::GraphicsContext3D(GraphicsContext3D::Attributes attributes, HostWindow*, GraphicsContext3D::RenderStyle renderStyle)
: m_currentWidth(0)
, m_currentHeight(0)
, m_attrs(attributes)
@@ -78,37 +78,39 @@
, m_multisampleFBO(0)
, m_multisampleDepthStencilBuffer(0)
, m_multisampleColorBuffer(0)
- , m_private(GraphicsContext3DPrivate::create(this))
+ , m_private(GraphicsContext3DPrivate::create(this, renderStyle))
{
makeContextCurrent();
validateAttributes();
- // Create a texture to render into.
- ::glGenTextures(1, &m_texture);
- ::glBindTexture(GL_TEXTURE_2D, m_texture);
- ::glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
- ::glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
- ::glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP);
- ::glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP);
- ::glBindTexture(GL_TEXTURE_2D, 0);
+ if (renderStyle == RenderOffscreen) {
+ // Create a texture to render into.
+ ::glGenTextures(1, &m_texture);
+ ::glBindTexture(GL_TEXTURE_2D, m_texture);
+ ::glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
+ ::glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
+ ::glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP);
+ ::glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP);
+ ::glBindTexture(GL_TEXTURE_2D, 0);
- // Create an FBO.
- ::glGenFramebuffersEXT(1, &m_fbo);
- ::glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, m_fbo);
+ // Create an FBO.
+ ::glGenFramebuffersEXT(1, &m_fbo);
+ ::glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, m_fbo);
- m_boundFBO = m_fbo;
- if (!m_attrs.antialias && (m_attrs.stencil || m_attrs.depth))
- ::glGenRenderbuffersEXT(1, &m_depthStencilBuffer);
-
- // Create a multisample FBO.
- if (m_attrs.antialias) {
- ::glGenFramebuffersEXT(1, &m_multisampleFBO);
- ::glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, m_multisampleFBO);
- m_boundFBO = m_multisampleFBO;
- ::glGenRenderbuffersEXT(1, &m_multisampleColorBuffer);
- if (m_attrs.stencil || m_attrs.depth)
- ::glGenRenderbuffersEXT(1, &m_multisampleDepthStencilBuffer);
+ m_boundFBO = m_fbo;
+ if (!m_attrs.antialias && (m_attrs.stencil || m_attrs.depth))
+ ::glGenRenderbuffersEXT(1, &m_depthStencilBuffer);
+
+ // Create a multisample FBO.
+ if (m_attrs.antialias) {
+ ::glGenFramebuffersEXT(1, &m_multisampleFBO);
+ ::glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, m_multisampleFBO);
+ m_boundFBO = m_multisampleFBO;
+ ::glGenRenderbuffersEXT(1, &m_multisampleColorBuffer);
+ if (m_attrs.stencil || m_attrs.depth)
+ ::glGenRenderbuffersEXT(1, &m_multisampleDepthStencilBuffer);
+ }
}
// ANGLE initialization.
@@ -134,6 +136,9 @@
GraphicsContext3D::~GraphicsContext3D()
{
+ if (m_private->renderStyle() == RenderToCurrentGLContext)
+ return;
+
makeContextCurrent();
::glDeleteTextures(1, &m_texture);
if (m_attrs.antialias) {
Modified: trunk/Source/WebCore/platform/graphics/cairo/GraphicsContext3DPrivate.cpp (127043 => 127044)
--- trunk/Source/WebCore/platform/graphics/cairo/GraphicsContext3DPrivate.cpp 2012-08-29 20:40:38 UTC (rev 127043)
+++ trunk/Source/WebCore/platform/graphics/cairo/GraphicsContext3DPrivate.cpp 2012-08-29 20:41:03 UTC (rev 127044)
@@ -36,15 +36,25 @@
namespace WebCore {
-PassOwnPtr<GraphicsContext3DPrivate> GraphicsContext3DPrivate::create(GraphicsContext3D* context)
+PassOwnPtr<GraphicsContext3DPrivate> GraphicsContext3DPrivate::create(GraphicsContext3D* context, GraphicsContext3D::RenderStyle renderStyle)
{
- return adoptPtr(new GraphicsContext3DPrivate(context));
+ return adoptPtr(new GraphicsContext3DPrivate(context, renderStyle));
}
-GraphicsContext3DPrivate::GraphicsContext3DPrivate(GraphicsContext3D* context)
+GraphicsContext3DPrivate::GraphicsContext3DPrivate(GraphicsContext3D* context, GraphicsContext3D::RenderStyle renderStyle)
: m_context(context)
- , m_glContext(GLContext::createOffscreenContext(GLContext::sharingContext()))
+ , m_renderStyle(renderStyle)
{
+ switch (renderStyle) {
+ case GraphicsContext3D::RenderOffscreen:
+ m_glContext = GLContext::createOffscreenContext(GLContext::sharingContext());
+ break;
+ case GraphicsContext3D::RenderToCurrentGLContext:
+ break;
+ case GraphicsContext3D::RenderDirectlyToHostWindow:
+ ASSERT_NOT_REACHED();
+ break;
+ }
}
GraphicsContext3DPrivate::~GraphicsContext3DPrivate()
@@ -67,6 +77,8 @@
if (!m_glContext)
return;
+ ASSERT(m_renderStyle == GraphicsContext3D::RenderOffscreen);
+
// FIXME: We do not support mask for the moment with TextureMapperImageBuffer.
if (textureMapper->accelerationMode() != TextureMapper::OpenGLMode) {
GraphicsContext* context = textureMapper->graphicsContext();
Modified: trunk/Source/WebCore/platform/graphics/cairo/GraphicsContext3DPrivate.h (127043 => 127044)
--- trunk/Source/WebCore/platform/graphics/cairo/GraphicsContext3DPrivate.h 2012-08-29 20:40:38 UTC (rev 127043)
+++ trunk/Source/WebCore/platform/graphics/cairo/GraphicsContext3DPrivate.h 2012-08-29 20:41:03 UTC (rev 127044)
@@ -36,20 +36,23 @@
#endif
{
public:
- static PassOwnPtr<GraphicsContext3DPrivate> create(GraphicsContext3D*);
+ static PassOwnPtr<GraphicsContext3DPrivate> create(GraphicsContext3D*, GraphicsContext3D::RenderStyle);
~GraphicsContext3DPrivate();
bool makeContextCurrent();
PlatformGraphicsContext3D platformContext();
+ GraphicsContext3D::RenderStyle renderStyle() { return m_renderStyle; }
+
#if USE(ACCELERATED_COMPOSITING) && USE(TEXTURE_MAPPER)
virtual void paintToTextureMapper(TextureMapper*, const FloatRect& target, const TransformationMatrix&, float opacity, BitmapTexture* mask);
#endif
private:
- GraphicsContext3DPrivate(GraphicsContext3D*);
+ GraphicsContext3DPrivate(GraphicsContext3D*, GraphicsContext3D::RenderStyle);
GraphicsContext3D* m_context;
OwnPtr<GLContext> m_glContext;
+ GraphicsContext3D::RenderStyle m_renderStyle;
};
}