diff options
author | Ben Murdoch <benm@google.com> | 2011-05-16 16:25:10 +0100 |
---|---|---|
committer | Ben Murdoch <benm@google.com> | 2011-05-23 18:54:14 +0100 |
commit | ab9e7a118cf1ea2e3a93dce683b2ded3e7291ddb (patch) | |
tree | db769fadd053248f85db67434a5b275224defef7 /Source/WebCore/platform/graphics/gpu | |
parent | 52e2557aeb8477967e97fd24f20f8f407a10fa15 (diff) | |
download | external_webkit-ab9e7a118cf1ea2e3a93dce683b2ded3e7291ddb.zip external_webkit-ab9e7a118cf1ea2e3a93dce683b2ded3e7291ddb.tar.gz external_webkit-ab9e7a118cf1ea2e3a93dce683b2ded3e7291ddb.tar.bz2 |
Merge WebKit at r76408: Initial merge by git.
Change-Id: I5b91decbd693ccbf5c1b8354b37cd68cc9a1ea53
Diffstat (limited to 'Source/WebCore/platform/graphics/gpu')
12 files changed, 96 insertions, 59 deletions
diff --git a/Source/WebCore/platform/graphics/gpu/DrawingBuffer.cpp b/Source/WebCore/platform/graphics/gpu/DrawingBuffer.cpp index c283068..dae83a2 100644 --- a/Source/WebCore/platform/graphics/gpu/DrawingBuffer.cpp +++ b/Source/WebCore/platform/graphics/gpu/DrawingBuffer.cpp @@ -67,16 +67,21 @@ void DrawingBuffer::clear() m_multisampleColorBuffer = 0; } - if (m_multisampleDepthStencilBuffer) { - m_context->deleteRenderbuffer(m_multisampleDepthStencilBuffer); - m_multisampleDepthStencilBuffer = 0; - } - if (m_depthStencilBuffer) { m_context->deleteRenderbuffer(m_depthStencilBuffer); m_depthStencilBuffer = 0; } + if (m_depthBuffer) { + m_context->deleteRenderbuffer(m_depthBuffer); + m_depthBuffer = 0; + } + + if (m_stencilBuffer) { + m_context->deleteRenderbuffer(m_stencilBuffer); + m_stencilBuffer = 0; + } + if (m_multisampleFBO) { m_context->bindFramebuffer(GraphicsContext3D::FRAMEBUFFER, m_multisampleFBO); m_context->deleteFramebuffer(m_multisampleFBO); @@ -92,22 +97,52 @@ void DrawingBuffer::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::resizeDepthStencil(int sampleCount) +{ + const GraphicsContext3D::Attributes& attributes = m_context->getContextAttributes(); + if (attributes.depth && attributes.stencil && m_packedDepthStencilExtensionSupported) { + if (!m_depthStencilBuffer) + m_depthStencilBuffer = m_context->createRenderbuffer(); + m_context->bindRenderbuffer(GraphicsContext3D::RENDERBUFFER, m_depthStencilBuffer); + if (multisample()) + m_context->getExtensions()->renderbufferStorageMultisample(GraphicsContext3D::RENDERBUFFER, sampleCount, Extensions3D::DEPTH24_STENCIL8, m_size.width(), m_size.height()); + else + m_context->renderbufferStorage(GraphicsContext3D::RENDERBUFFER, Extensions3D::DEPTH24_STENCIL8, m_size.width(), m_size.height()); + m_context->framebufferRenderbuffer(GraphicsContext3D::FRAMEBUFFER, GraphicsContext3D::STENCIL_ATTACHMENT, GraphicsContext3D::RENDERBUFFER, m_depthStencilBuffer); + m_context->framebufferRenderbuffer(GraphicsContext3D::FRAMEBUFFER, GraphicsContext3D::DEPTH_ATTACHMENT, GraphicsContext3D::RENDERBUFFER, m_depthStencilBuffer); + } else { + if (attributes.depth) { + if (!m_depthBuffer) + m_depthBuffer = m_context->createRenderbuffer(); + m_context->bindRenderbuffer(GraphicsContext3D::RENDERBUFFER, m_depthBuffer); + if (multisample()) + m_context->getExtensions()->renderbufferStorageMultisample(GraphicsContext3D::RENDERBUFFER, sampleCount, GraphicsContext3D::DEPTH_COMPONENT16, m_size.width(), m_size.height()); + else + m_context->renderbufferStorage(GraphicsContext3D::RENDERBUFFER, GraphicsContext3D::DEPTH_COMPONENT16, m_size.width(), m_size.height()); + m_context->framebufferRenderbuffer(GraphicsContext3D::FRAMEBUFFER, GraphicsContext3D::DEPTH_ATTACHMENT, GraphicsContext3D::RENDERBUFFER, m_depthBuffer); + } + if (attributes.stencil) { + if (!m_stencilBuffer) + m_stencilBuffer = m_context->createRenderbuffer(); + m_context->bindRenderbuffer(GraphicsContext3D::RENDERBUFFER, m_stencilBuffer); + if (multisample()) + m_context->getExtensions()->renderbufferStorageMultisample(GraphicsContext3D::RENDERBUFFER, sampleCount, GraphicsContext3D::STENCIL_INDEX8, m_size.width(), m_size.height()); + else + m_context->renderbufferStorage(GraphicsContext3D::RENDERBUFFER, GraphicsContext3D::STENCIL_INDEX8, m_size.width(), m_size.height()); + m_context->framebufferRenderbuffer(GraphicsContext3D::FRAMEBUFFER, GraphicsContext3D::STENCIL_ATTACHMENT, GraphicsContext3D::RENDERBUFFER, m_stencilBuffer); + } + } + m_context->bindRenderbuffer(GraphicsContext3D::RENDERBUFFER, 0); +} + void DrawingBuffer::reset(const IntSize& newSize) { if (m_size == newSize) @@ -120,7 +155,7 @@ void DrawingBuffer::reset(const IntSize& newSize) m_context->makeContextCurrent(); const GraphicsContext3D::Attributes& attributes = m_context->getContextAttributes(); - unsigned long internalColorFormat, colorFormat, internalDepthStencilFormat = 0; + unsigned long internalColorFormat, colorFormat; if (attributes.alpha) { internalColorFormat = GraphicsContext3D::RGBA; colorFormat = GraphicsContext3D::RGBA; @@ -128,17 +163,7 @@ void DrawingBuffer::reset(const IntSize& newSize) internalColorFormat = GraphicsContext3D::RGB; colorFormat = GraphicsContext3D::RGB; } - if (attributes.stencil || attributes.depth) { - // We don't allow the logic where stencil is required and depth is not. - // See GraphicsContext3D constructor. - // 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_COMPONENT16; - } // resize multisample FBO if (multisample()) { @@ -152,15 +177,7 @@ void DrawingBuffer::reset(const IntSize& newSize) m_context->bindRenderbuffer(GraphicsContext3D::RENDERBUFFER, m_multisampleColorBuffer); m_context->getExtensions()->renderbufferStorageMultisample(GraphicsContext3D::RENDERBUFFER, sampleCount, internalColorFormat, m_size.width(), m_size.height()); m_context->framebufferRenderbuffer(GraphicsContext3D::FRAMEBUFFER, GraphicsContext3D::COLOR_ATTACHMENT0, GraphicsContext3D::RENDERBUFFER, m_multisampleColorBuffer); - if (attributes.stencil || attributes.depth) { - m_context->bindRenderbuffer(GraphicsContext3D::RENDERBUFFER, m_multisampleDepthStencilBuffer); - m_context->getExtensions()->renderbufferStorageMultisample(GraphicsContext3D::RENDERBUFFER, sampleCount, internalDepthStencilFormat, m_size.width(), m_size.height()); - if (attributes.stencil) - m_context->framebufferRenderbuffer(GraphicsContext3D::FRAMEBUFFER, GraphicsContext3D::STENCIL_ATTACHMENT, GraphicsContext3D::RENDERBUFFER, m_multisampleDepthStencilBuffer); - if (attributes.depth) - m_context->framebufferRenderbuffer(GraphicsContext3D::FRAMEBUFFER, GraphicsContext3D::DEPTH_ATTACHMENT, GraphicsContext3D::RENDERBUFFER, m_multisampleDepthStencilBuffer); - } - m_context->bindRenderbuffer(GraphicsContext3D::RENDERBUFFER, 0); + resizeDepthStencil(sampleCount); if (m_context->checkFramebufferStatus(GraphicsContext3D::FRAMEBUFFER) != GraphicsContext3D::FRAMEBUFFER_COMPLETE) { // Cleanup clear(); @@ -175,15 +192,7 @@ void DrawingBuffer::reset(const IntSize& newSize) 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_2D, m_colorBuffer, 0); m_context->bindTexture(GraphicsContext3D::TEXTURE_2D, 0); - if (!multisample() && (attributes.stencil || attributes.depth)) { - m_context->bindRenderbuffer(GraphicsContext3D::RENDERBUFFER, m_depthStencilBuffer); - m_context->renderbufferStorage(GraphicsContext3D::RENDERBUFFER, internalDepthStencilFormat, m_size.width(), m_size.height()); - if (attributes.stencil) - m_context->framebufferRenderbuffer(GraphicsContext3D::FRAMEBUFFER, GraphicsContext3D::STENCIL_ATTACHMENT, GraphicsContext3D::RENDERBUFFER, m_depthStencilBuffer); - if (attributes.depth) - m_context->framebufferRenderbuffer(GraphicsContext3D::FRAMEBUFFER, GraphicsContext3D::DEPTH_ATTACHMENT, GraphicsContext3D::RENDERBUFFER, m_depthStencilBuffer); - m_context->bindRenderbuffer(GraphicsContext3D::RENDERBUFFER, 0); - } + resizeDepthStencil(0); if (m_context->checkFramebufferStatus(GraphicsContext3D::FRAMEBUFFER) != GraphicsContext3D::FRAMEBUFFER_COMPLETE) { // Cleanup clear(); diff --git a/Source/WebCore/platform/graphics/gpu/DrawingBuffer.h b/Source/WebCore/platform/graphics/gpu/DrawingBuffer.h index e0e0ee1..49ae114 100644 --- a/Source/WebCore/platform/graphics/gpu/DrawingBuffer.h +++ b/Source/WebCore/platform/graphics/gpu/DrawingBuffer.h @@ -67,6 +67,8 @@ public: // Create the depth/stencil and multisample buffers, if needed. void createSecondaryBuffers(); + void resizeDepthStencil(int sampleCount); + // 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); @@ -80,8 +82,10 @@ public: #endif #if PLATFORM(CHROMIUM) - class WillPublishCallback : public Noncopyable { + class WillPublishCallback { + WTF_MAKE_NONCOPYABLE(WillPublishCallback); public: + WillPublishCallback() { } virtual ~WillPublishCallback() { } virtual void willPublish() = 0; @@ -106,13 +110,18 @@ private: bool m_packedDepthStencilExtensionSupported; Platform3DObject m_fbo; Platform3DObject m_colorBuffer; + + // This is used when we have OES_packed_depth_stencil. Platform3DObject m_depthStencilBuffer; + // These are used when we don't. + Platform3DObject m_depthBuffer; + Platform3DObject m_stencilBuffer; + // For multisampling Platform3DObject m_multisampleFBO; Platform3DObject m_multisampleColorBuffer; - Platform3DObject m_multisampleDepthStencilBuffer; - + #if PLATFORM(CHROMIUM) OwnPtr<WillPublishCallback> m_callback; OwnPtr<DrawingBufferInternal> m_internal; diff --git a/Source/WebCore/platform/graphics/gpu/LoopBlinnClassifier.h b/Source/WebCore/platform/graphics/gpu/LoopBlinnClassifier.h index c665844..1bd67b8 100644 --- a/Source/WebCore/platform/graphics/gpu/LoopBlinnClassifier.h +++ b/Source/WebCore/platform/graphics/gpu/LoopBlinnClassifier.h @@ -30,14 +30,14 @@ #ifndef LoopBlinnClassifier_h #define LoopBlinnClassifier_h -#include <wtf/Noncopyable.h> namespace WebCore { class FloatPoint; // Classifies cubic curves into specific types. -class LoopBlinnClassifier : public Noncopyable { +class LoopBlinnClassifier { + WTF_MAKE_NONCOPYABLE(LoopBlinnClassifier); public: // The types of cubic curves. enum CurveType { diff --git a/Source/WebCore/platform/graphics/gpu/LoopBlinnLocalTriangulator.h b/Source/WebCore/platform/graphics/gpu/LoopBlinnLocalTriangulator.h index ea3d7e3..d01e6c9 100644 --- a/Source/WebCore/platform/graphics/gpu/LoopBlinnLocalTriangulator.h +++ b/Source/WebCore/platform/graphics/gpu/LoopBlinnLocalTriangulator.h @@ -30,19 +30,20 @@ #include "FloatPoint3D.h" #include "LoopBlinnConstants.h" #include <wtf/Assertions.h> -#include <wtf/Noncopyable.h> namespace WebCore { // Performs a localized triangulation of the triangle mesh // corresponding to the four control point vertices of a cubic curve // segment. -class LoopBlinnLocalTriangulator : public Noncopyable { +class LoopBlinnLocalTriangulator { + WTF_MAKE_NONCOPYABLE(LoopBlinnLocalTriangulator); public: // The vertices that the triangulator operates upon, containing both // the position information as well as the cubic texture // coordinates. - class Vertex : public Noncopyable { + class Vertex { + WTF_MAKE_NONCOPYABLE(Vertex); public: Vertex() { diff --git a/Source/WebCore/platform/graphics/gpu/PODArena.h b/Source/WebCore/platform/graphics/gpu/PODArena.h index f68baef..6edc1db 100644 --- a/Source/WebCore/platform/graphics/gpu/PODArena.h +++ b/Source/WebCore/platform/graphics/gpu/PODArena.h @@ -158,7 +158,8 @@ private: } // Manages a chunk of memory and individual allocations out of it. - class Chunk : public Noncopyable { + class Chunk { + WTF_MAKE_NONCOPYABLE(Chunk); public: // Allocates a block of memory of the given size from the passed // Allocator. diff --git a/Source/WebCore/platform/graphics/gpu/PODIntervalTree.h b/Source/WebCore/platform/graphics/gpu/PODIntervalTree.h index 320ce60..5bf3de0 100644 --- a/Source/WebCore/platform/graphics/gpu/PODIntervalTree.h +++ b/Source/WebCore/platform/graphics/gpu/PODIntervalTree.h @@ -44,8 +44,8 @@ struct ValueToString; // supports efficient (O(lg n)) insertion, removal and querying of // intervals in the tree. template<class T, class UserData = void*> -class PODIntervalTree : public Noncopyable, - public PODRedBlackTree<PODInterval<T, UserData> > { +class PODIntervalTree : public PODRedBlackTree<PODInterval<T, UserData> > { + WTF_MAKE_NONCOPYABLE(PODIntervalTree); public: // Typedef to reduce typing when declaring intervals to be stored in // this tree. diff --git a/Source/WebCore/platform/graphics/gpu/PODRedBlackTree.h b/Source/WebCore/platform/graphics/gpu/PODRedBlackTree.h index 6d5954c..bd08988 100644 --- a/Source/WebCore/platform/graphics/gpu/PODRedBlackTree.h +++ b/Source/WebCore/platform/graphics/gpu/PODRedBlackTree.h @@ -198,7 +198,8 @@ protected: // The base Node class which is stored in the tree. Nodes are only // an internal concept; users of the tree deal only with the data // they store in it. - class Node : public Noncopyable { + class Node { + WTF_MAKE_NONCOPYABLE(Node); public: // Constructor. Newly-created nodes are colored red. explicit Node(const T& data) @@ -659,7 +660,8 @@ private: // Helper class for size() // A Visitor which simply counts the number of visited elements. - class Counter : public Visitor, public Noncopyable { + class Counter : public Visitor { + WTF_MAKE_NONCOPYABLE(Counter); public: Counter() : m_count(0) { } diff --git a/Source/WebCore/platform/graphics/gpu/Shader.h b/Source/WebCore/platform/graphics/gpu/Shader.h index e5bd8de..4f62ca9 100644 --- a/Source/WebCore/platform/graphics/gpu/Shader.h +++ b/Source/WebCore/platform/graphics/gpu/Shader.h @@ -40,7 +40,8 @@ class AffineTransform; class GraphicsContext3D; class Color; -class Shader : public Noncopyable { +class Shader { + WTF_MAKE_NONCOPYABLE(Shader); protected: Shader(GraphicsContext3D*, unsigned program); ~Shader(); diff --git a/Source/WebCore/platform/graphics/gpu/SharedGraphicsContext3D.cpp b/Source/WebCore/platform/graphics/gpu/SharedGraphicsContext3D.cpp index 9d1298f..9c59077 100644 --- a/Source/WebCore/platform/graphics/gpu/SharedGraphicsContext3D.cpp +++ b/Source/WebCore/platform/graphics/gpu/SharedGraphicsContext3D.cpp @@ -51,6 +51,9 @@ namespace WebCore { PassRefPtr<SharedGraphicsContext3D> SharedGraphicsContext3D::create(HostWindow* hostWindow) { GraphicsContext3D::Attributes attr; + attr.depth = false; + attr.stencil = true; + attr.antialias = false; attr.canRecoverFromContextLoss = false; // Canvas contexts can not handle lost contexts. RefPtr<GraphicsContext3D> context = GraphicsContext3D::create(attr, hostWindow); if (!context) @@ -293,6 +296,14 @@ void SharedGraphicsContext3D::applyCompositeOperator(CompositeOperator op) } } +void SharedGraphicsContext3D::enableStencil(bool enable) +{ + if (enable) + m_context->enable(GraphicsContext3D::STENCIL_TEST); + else + m_context->disable(GraphicsContext3D::STENCIL_TEST); +} + void SharedGraphicsContext3D::useQuadVertices() { if (!m_quadVertices) { diff --git a/Source/WebCore/platform/graphics/gpu/SharedGraphicsContext3D.h b/Source/WebCore/platform/graphics/gpu/SharedGraphicsContext3D.h index ea1810d..1e032d7 100644 --- a/Source/WebCore/platform/graphics/gpu/SharedGraphicsContext3D.h +++ b/Source/WebCore/platform/graphics/gpu/SharedGraphicsContext3D.h @@ -90,6 +90,7 @@ public: // Shared logic for canvas 2d void applyCompositeOperator(CompositeOperator); + void enableStencil(bool enable); void useQuadVertices(); void useFillSolidProgram(const AffineTransform&, const Color&); diff --git a/Source/WebCore/platform/graphics/gpu/TilingData.h b/Source/WebCore/platform/graphics/gpu/TilingData.h index 1bdc51a..d1140bd 100644 --- a/Source/WebCore/platform/graphics/gpu/TilingData.h +++ b/Source/WebCore/platform/graphics/gpu/TilingData.h @@ -38,7 +38,8 @@ namespace WebCore { class FloatRect; class IntRect; -class TilingData : public Noncopyable { +class TilingData { + WTF_MAKE_NONCOPYABLE(TilingData); public: TilingData(int maxTextureSize, int totalSizeX, int totalSizeY, bool hasBorderTexels); int maxTextureSize() const { return m_maxTextureSize; } diff --git a/Source/WebCore/platform/graphics/gpu/mac/DrawingBufferMac.mm b/Source/WebCore/platform/graphics/gpu/mac/DrawingBufferMac.mm index 601454e..e6dfdb8 100644 --- a/Source/WebCore/platform/graphics/gpu/mac/DrawingBufferMac.mm +++ b/Source/WebCore/platform/graphics/gpu/mac/DrawingBufferMac.mm @@ -41,15 +41,16 @@ DrawingBuffer::DrawingBuffer(GraphicsContext3D* context, bool multisampleExtensionSupported, bool packedDepthStencilExtensionSupported) : m_context(context) - , m_size(size) + , m_size(-1, -1) , m_multisampleExtensionSupported(multisampleExtensionSupported) , m_packedDepthStencilExtensionSupported(packedDepthStencilExtensionSupported) , m_fbo(context->createFramebuffer()) , m_colorBuffer(0) , m_depthStencilBuffer(0) + , m_depthBuffer(0) + , m_stencilBuffer(0) , m_multisampleFBO(0) , m_multisampleColorBuffer(0) - , m_multisampleDepthStencilBuffer(0) { ASSERT(m_fbo); if (!m_fbo) { |