summaryrefslogtreecommitdiffstats
path: root/Source/WebCore/platform/graphics/gpu
diff options
context:
space:
mode:
authorBen Murdoch <benm@google.com>2011-05-13 16:23:25 +0100
committerBen Murdoch <benm@google.com>2011-05-16 11:35:02 +0100
commit65f03d4f644ce73618e5f4f50dd694b26f55ae12 (patch)
treef478babb801e720de7bfaee23443ffe029f58731 /Source/WebCore/platform/graphics/gpu
parent47de4a2fb7262c7ebdb9cd133ad2c54c187454d0 (diff)
downloadexternal_webkit-65f03d4f644ce73618e5f4f50dd694b26f55ae12.zip
external_webkit-65f03d4f644ce73618e5f4f50dd694b26f55ae12.tar.gz
external_webkit-65f03d4f644ce73618e5f4f50dd694b26f55ae12.tar.bz2
Merge WebKit at r75993: Initial merge by git.
Change-Id: I602bbdc3974787a3b0450456a30a7868286921c3
Diffstat (limited to 'Source/WebCore/platform/graphics/gpu')
-rw-r--r--Source/WebCore/platform/graphics/gpu/DrawingBuffer.cpp35
-rw-r--r--Source/WebCore/platform/graphics/gpu/DrawingBuffer.h6
-rw-r--r--Source/WebCore/platform/graphics/gpu/mac/DrawingBufferMac.mm23
3 files changed, 41 insertions, 23 deletions
diff --git a/Source/WebCore/platform/graphics/gpu/DrawingBuffer.cpp b/Source/WebCore/platform/graphics/gpu/DrawingBuffer.cpp
index d2415ca..c283068 100644
--- a/Source/WebCore/platform/graphics/gpu/DrawingBuffer.cpp
+++ b/Source/WebCore/platform/graphics/gpu/DrawingBuffer.cpp
@@ -40,14 +40,16 @@ namespace WebCore {
PassRefPtr<DrawingBuffer> DrawingBuffer::create(GraphicsContext3D* context, const IntSize& size)
{
- RefPtr<DrawingBuffer> drawingBuffer = adoptRef(new DrawingBuffer(context, size));
Extensions3D* extensions = context->getExtensions();
bool multisampleSupported = extensions->supports("GL_ANGLE_framebuffer_blit") && extensions->supports("GL_ANGLE_framebuffer_multisample");
if (multisampleSupported) {
extensions->ensureEnabled("GL_ANGLE_framebuffer_blit");
extensions->ensureEnabled("GL_ANGLE_framebuffer_multisample");
}
- drawingBuffer->m_multisampleExtensionSupported = multisampleSupported;
+ bool packedDepthStencilSupported = extensions->supports("GL_OES_packed_depth_stencil");
+ if (packedDepthStencilSupported)
+ extensions->ensureEnabled("GL_OES_packed_depth_stencil");
+ RefPtr<DrawingBuffer> drawingBuffer = adoptRef(new DrawingBuffer(context, size, multisampleSupported, packedDepthStencilSupported));
return (drawingBuffer->m_context) ? drawingBuffer.release() : 0;
}
@@ -88,6 +90,24 @@ void DrawingBuffer::clear()
m_context.clear();
}
+void DrawingBuffer::createSecondaryBuffers()
+{
+ const GraphicsContext3D::Attributes& attributes = m_context->getContextAttributes();
+
+ // Create the stencil and depth buffer if needed
+ if (!multisample() && (attributes.stencil || attributes.depth))
+ m_depthStencilBuffer = m_context->createRenderbuffer();
+
+ // create a multisample FBO
+ if (multisample()) {
+ m_multisampleFBO = m_context->createFramebuffer();
+ m_context->bindFramebuffer(GraphicsContext3D::FRAMEBUFFER, m_multisampleFBO);
+ m_multisampleColorBuffer = m_context->createRenderbuffer();
+ if (attributes.stencil || attributes.depth)
+ m_multisampleDepthStencilBuffer = m_context->createRenderbuffer();
+ }
+}
+
void DrawingBuffer::reset(const IntSize& newSize)
{
if (m_size == newSize)
@@ -111,10 +131,13 @@ void DrawingBuffer::reset(const IntSize& newSize)
if (attributes.stencil || attributes.depth) {
// We don't allow the logic where stencil is required and depth is not.
// See GraphicsContext3D constructor.
- if (attributes.stencil && attributes.depth)
- internalDepthStencilFormat = GraphicsContext3D::DEPTH_STENCIL;
+
+ // FIXME: If packed depth/stencil is not supported, we should
+ // create separate renderbuffers for depth and stencil.
+ if (attributes.stencil && attributes.depth && m_packedDepthStencilExtensionSupported)
+ internalDepthStencilFormat = Extensions3D::DEPTH24_STENCIL8;
else
- internalDepthStencilFormat = GraphicsContext3D::DEPTH_COMPONENT;
+ internalDepthStencilFormat = GraphicsContext3D::DEPTH_COMPONENT16;
}
// resize multisample FBO
@@ -150,7 +173,7 @@ void DrawingBuffer::reset(const IntSize& newSize)
m_context->bindTexture(GraphicsContext3D::TEXTURE_2D, m_colorBuffer);
m_context->texImage2DResourceSafe(GraphicsContext3D::TEXTURE_2D, 0, internalColorFormat, m_size.width(), m_size.height(), 0, colorFormat, GraphicsContext3D::UNSIGNED_BYTE);
- m_context->framebufferTexture2D(GraphicsContext3D::FRAMEBUFFER, GraphicsContext3D::COLOR_ATTACHMENT0, GraphicsContext3D::TEXTURE, m_colorBuffer, 0);
+ m_context->framebufferTexture2D(GraphicsContext3D::FRAMEBUFFER, GraphicsContext3D::COLOR_ATTACHMENT0, GraphicsContext3D::TEXTURE_2D, m_colorBuffer, 0);
m_context->bindTexture(GraphicsContext3D::TEXTURE_2D, 0);
if (!multisample() && (attributes.stencil || attributes.depth)) {
m_context->bindRenderbuffer(GraphicsContext3D::RENDERBUFFER, m_depthStencilBuffer);
diff --git a/Source/WebCore/platform/graphics/gpu/DrawingBuffer.h b/Source/WebCore/platform/graphics/gpu/DrawingBuffer.h
index 9f79889..e0e0ee1 100644
--- a/Source/WebCore/platform/graphics/gpu/DrawingBuffer.h
+++ b/Source/WebCore/platform/graphics/gpu/DrawingBuffer.h
@@ -63,6 +63,9 @@ public:
// Clear all resources from this object, as well as context. Called when context is destroyed
// to prevent invalid accesses to the resources.
void clear();
+
+ // Create the depth/stencil and multisample buffers, if needed.
+ void createSecondaryBuffers();
// Copies the multisample color buffer to the normal color buffer and leaves m_fbo bound
void commit(long x = 0, long y = 0, long width = -1, long height = -1);
@@ -92,7 +95,7 @@ public:
private:
static PassRefPtr<DrawingBuffer> create(GraphicsContext3D*, const IntSize&);
- DrawingBuffer(GraphicsContext3D*, const IntSize&);
+ DrawingBuffer(GraphicsContext3D*, const IntSize&, bool multisampleExtensionSupported, bool packedDepthStencilExtensionSupported);
// Platform specific function called after reset() so each platform can do extra work if needed
void didReset();
@@ -100,6 +103,7 @@ private:
RefPtr<GraphicsContext3D> m_context;
IntSize m_size;
bool m_multisampleExtensionSupported;
+ bool m_packedDepthStencilExtensionSupported;
Platform3DObject m_fbo;
Platform3DObject m_colorBuffer;
Platform3DObject m_depthStencilBuffer;
diff --git a/Source/WebCore/platform/graphics/gpu/mac/DrawingBufferMac.mm b/Source/WebCore/platform/graphics/gpu/mac/DrawingBufferMac.mm
index 89dcb9c..601454e 100644
--- a/Source/WebCore/platform/graphics/gpu/mac/DrawingBufferMac.mm
+++ b/Source/WebCore/platform/graphics/gpu/mac/DrawingBufferMac.mm
@@ -36,9 +36,14 @@
namespace WebCore {
-DrawingBuffer::DrawingBuffer(GraphicsContext3D* context, const IntSize& size)
+DrawingBuffer::DrawingBuffer(GraphicsContext3D* context,
+ const IntSize& size,
+ bool multisampleExtensionSupported,
+ bool packedDepthStencilExtensionSupported)
: m_context(context)
, m_size(size)
+ , m_multisampleExtensionSupported(multisampleExtensionSupported)
+ , m_packedDepthStencilExtensionSupported(packedDepthStencilExtensionSupported)
, m_fbo(context->createFramebuffer())
, m_colorBuffer(0)
, m_depthStencilBuffer(0)
@@ -77,21 +82,7 @@ DrawingBuffer::DrawingBuffer(GraphicsContext3D* context, const IntSize& size)
return;
}
- const GraphicsContext3D::Attributes& attributes = context->getContextAttributes();
-
- // Create the stencil and depth buffer if needed
- if (!multisample() && (attributes.stencil || attributes.depth))
- m_depthStencilBuffer = context->createRenderbuffer();
-
- // create a multisample FBO
- if (multisample()) {
- m_multisampleFBO = context->createFramebuffer();
- context->bindFramebuffer(GraphicsContext3D::FRAMEBUFFER, m_multisampleFBO);
- m_multisampleColorBuffer = context->createRenderbuffer();
- if (attributes.stencil || attributes.depth)
- m_multisampleDepthStencilBuffer = context->createRenderbuffer();
- }
-
+ createSecondaryBuffers();
reset(size);
}