diff options
Diffstat (limited to 'Source/WebCore/platform/graphics/gpu')
-rw-r--r-- | Source/WebCore/platform/graphics/gpu/DrawingBuffer.cpp | 466 | ||||
-rw-r--r-- | Source/WebCore/platform/graphics/gpu/DrawingBuffer.h | 173 | ||||
-rw-r--r-- | Source/WebCore/platform/graphics/gpu/Texture.cpp | 10 | ||||
-rw-r--r-- | Source/WebCore/platform/graphics/gpu/Texture.h | 6 | ||||
-rw-r--r-- | Source/WebCore/platform/graphics/gpu/TilingData.cpp | 4 |
5 files changed, 7 insertions, 652 deletions
diff --git a/Source/WebCore/platform/graphics/gpu/DrawingBuffer.cpp b/Source/WebCore/platform/graphics/gpu/DrawingBuffer.cpp deleted file mode 100644 index 2b96cb594..000000000 --- a/Source/WebCore/platform/graphics/gpu/DrawingBuffer.cpp +++ /dev/null @@ -1,466 +0,0 @@ -/* - * Copyright (c) 2010, Google Inc. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following disclaimer - * in the documentation and/or other materials provided with the - * distribution. - * * Neither the name of Google Inc. nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include "config.h" - -#if ENABLE(ACCELERATED_2D_CANVAS) || USE(3D_GRAPHICS) - -#include "DrawingBuffer.h" - -#include "Extensions3D.h" -#include "GraphicsContext3D.h" - -namespace WebCore { - -#if PLATFORM(WIN) || USE(CAIRO) -DrawingBuffer::DrawingBuffer(GraphicsContext3D* context, const IntSize& size, bool multisampleExtensionSupported, bool packedDepthStencilExtensionSupported, PreserveDrawingBuffer preserveDrawingBuffer, AlphaRequirement alpha) - : m_preserveDrawingBuffer(preserveDrawingBuffer) - , m_alpha(alpha) - , m_scissorEnabled(false) - , m_texture2DBinding(0) - , m_framebufferBinding(0) - , m_activeTextureUnit(GraphicsContext3D::TEXTURE0) - , m_context(context) - , m_size(-1, -1) - , m_multisampleExtensionSupported(multisampleExtensionSupported) - , m_packedDepthStencilExtensionSupported(packedDepthStencilExtensionSupported) - , m_fbo(context->createFramebuffer()) - , m_colorBuffer(0) - , m_frontColorBuffer(0) - , m_separateFrontTexture(false) - , m_depthStencilBuffer(0) - , m_depthBuffer(0) - , m_stencilBuffer(0) - , m_multisampleFBO(0) - , m_multisampleColorBuffer(0) -{ - ASSERT(m_fbo); - if (!m_fbo) { - clear(); - return; - } - - // create a texture to render into - m_colorBuffer = context->createTexture(); - context->bindTexture(GraphicsContext3D::TEXTURE_2D, m_colorBuffer); - context->texParameterf(GraphicsContext3D::TEXTURE_2D, GraphicsContext3D::TEXTURE_MAG_FILTER, GraphicsContext3D::LINEAR); - context->texParameterf(GraphicsContext3D::TEXTURE_2D, GraphicsContext3D::TEXTURE_MIN_FILTER, GraphicsContext3D::LINEAR); - context->texParameteri(GraphicsContext3D::TEXTURE_2D, GraphicsContext3D::TEXTURE_WRAP_S, GraphicsContext3D::CLAMP_TO_EDGE); - context->texParameteri(GraphicsContext3D::TEXTURE_2D, GraphicsContext3D::TEXTURE_WRAP_T, GraphicsContext3D::CLAMP_TO_EDGE); - context->bindTexture(GraphicsContext3D::TEXTURE_2D, 0); - - createSecondaryBuffers(); - reset(size); -} - -DrawingBuffer::~DrawingBuffer() -{ - clear(); -} -#endif - -// Global resource ceiling (expressed in terms of pixels) for DrawingBuffer creation and resize. -// When this limit is set, DrawingBuffer::create() and DrawingBuffer::reset() calls that would -// exceed the global cap will instead clear the buffer. -static int s_maximumResourceUsePixels = 0; -static int s_currentResourceUsePixels = 0; -static const float s_resourceAdjustedRatio = 0.5; - -PassRefPtr<DrawingBuffer> DrawingBuffer::create(GraphicsContext3D* context, const IntSize& size, PreserveDrawingBuffer preserve, AlphaRequirement alpha) -{ - Extensions3D* extensions = context->getExtensions(); - bool multisampleSupported = extensions->maySupportMultisampling() - && extensions->supports("GL_ANGLE_framebuffer_blit") - && extensions->supports("GL_ANGLE_framebuffer_multisample") - && extensions->supports("GL_OES_rgb8_rgba8"); - if (multisampleSupported) { - extensions->ensureEnabled("GL_ANGLE_framebuffer_blit"); - extensions->ensureEnabled("GL_ANGLE_framebuffer_multisample"); - extensions->ensureEnabled("GL_OES_rgb8_rgba8"); - } - 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, preserve, alpha)); - return (drawingBuffer->m_context) ? drawingBuffer.release() : 0; -} - -void DrawingBuffer::clear() -{ - if (!m_context) - return; - - m_context->makeContextCurrent(); - - if (!m_size.isEmpty()) { - s_currentResourceUsePixels -= m_size.width() * m_size.height(); - m_size = IntSize(); - } - - if (m_colorBuffer) { - m_context->deleteTexture(m_colorBuffer); - m_colorBuffer = 0; - } - - if (m_frontColorBuffer) { - m_context->deleteTexture(m_frontColorBuffer); - m_frontColorBuffer = 0; - } - - if (m_multisampleColorBuffer) { - m_context->deleteRenderbuffer(m_multisampleColorBuffer); - m_multisampleColorBuffer = 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->deleteFramebuffer(m_multisampleFBO); - m_multisampleFBO = 0; - } - - if (m_fbo) { - m_context->deleteFramebuffer(m_fbo); - m_fbo = 0; - } -} - -void DrawingBuffer::createSecondaryBuffers() -{ - // create a multisample FBO - if (multisample()) { - m_multisampleFBO = m_context->createFramebuffer(); - m_context->bindFramebuffer(GraphicsContext3D::FRAMEBUFFER, m_multisampleFBO); - m_multisampleColorBuffer = 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::clearFramebuffers(GC3Dbitfield clearMask) -{ - m_context->bindFramebuffer(GraphicsContext3D::FRAMEBUFFER, m_multisampleFBO ? m_multisampleFBO : m_fbo); - - m_context->clear(clearMask); - - // The multisample fbo was just cleared, but we also need to clear the non-multisampled buffer too. - if (m_multisampleFBO) { - m_context->bindFramebuffer(GraphicsContext3D::FRAMEBUFFER, m_fbo); - m_context->clear(GraphicsContext3D::COLOR_BUFFER_BIT); - m_context->bindFramebuffer(GraphicsContext3D::FRAMEBUFFER, m_multisampleFBO); - } -} - -// Only way to ensure that we're not getting a bad framebuffer on some AMD/OSX devices. -// FIXME: This can be removed once renderbufferStorageMultisample starts reporting GL_OUT_OF_MEMORY properly. -bool DrawingBuffer::checkBufferIntegrity() -{ - if (!m_multisampleFBO) - return true; - - if (m_scissorEnabled) - m_context->disable(GraphicsContext3D::SCISSOR_TEST); - - m_context->colorMask(true, true, true, true); - - m_context->bindFramebuffer(GraphicsContext3D::FRAMEBUFFER, m_multisampleFBO); - m_context->clearColor(1.0f, 0.0f, 1.0f, 1.0f); - m_context->clear(GraphicsContext3D::COLOR_BUFFER_BIT); - - commit(0, 0, 1, 1); - - unsigned char pixel[4] = {0, 0, 0, 0}; - m_context->readPixels(0, 0, 1, 1, GraphicsContext3D::RGBA, GraphicsContext3D::UNSIGNED_BYTE, &pixel); - - if (m_scissorEnabled) - m_context->enable(GraphicsContext3D::SCISSOR_TEST); - - return (pixel[0] == 0xFF && pixel[1] == 0x00 && pixel[2] == 0xFF && pixel[3] == 0xFF); -} - -bool DrawingBuffer::reset(const IntSize& newSize) -{ - if (!m_context) - return false; - - m_context->makeContextCurrent(); - - int maxTextureSize = 0; - m_context->getIntegerv(GraphicsContext3D::MAX_TEXTURE_SIZE, &maxTextureSize); - if (newSize.height() > maxTextureSize || newSize.width() > maxTextureSize) { - clear(); - return false; - } - - int pixelDelta = newSize.width() * newSize.height(); - int oldSize = 0; - if (!m_size.isEmpty()) { - oldSize = m_size.width() * m_size.height(); - pixelDelta -= oldSize; - } - - IntSize adjustedSize = newSize; - if (s_maximumResourceUsePixels) { - while ((s_currentResourceUsePixels + pixelDelta) > s_maximumResourceUsePixels) { - adjustedSize.scale(s_resourceAdjustedRatio); - if (adjustedSize.isEmpty()) { - clear(); - return false; - } - pixelDelta = adjustedSize.width() * adjustedSize.height(); - pixelDelta -= oldSize; - } - } - - const GraphicsContext3D::Attributes& attributes = m_context->getContextAttributes(); - - if (adjustedSize != m_size) { - - unsigned internalColorFormat, colorFormat, internalRenderbufferFormat; - if (attributes.alpha) { - internalColorFormat = GraphicsContext3D::RGBA; - colorFormat = GraphicsContext3D::RGBA; - internalRenderbufferFormat = Extensions3D::RGBA8_OES; - } else { - internalColorFormat = GraphicsContext3D::RGB; - colorFormat = GraphicsContext3D::RGB; - internalRenderbufferFormat = Extensions3D::RGB8_OES; - } - - do { - m_size = adjustedSize; - // resize multisample FBO - if (multisample()) { - int maxSampleCount = 0; - - m_context->getIntegerv(Extensions3D::MAX_SAMPLES, &maxSampleCount); - int sampleCount = std::min(4, maxSampleCount); - - m_context->bindFramebuffer(GraphicsContext3D::FRAMEBUFFER, m_multisampleFBO); - - m_context->bindRenderbuffer(GraphicsContext3D::RENDERBUFFER, m_multisampleColorBuffer); - m_context->getExtensions()->renderbufferStorageMultisample(GraphicsContext3D::RENDERBUFFER, sampleCount, internalRenderbufferFormat, m_size.width(), m_size.height()); - - if (m_context->getError() == GraphicsContext3D::OUT_OF_MEMORY) { - adjustedSize.scale(s_resourceAdjustedRatio); - continue; - } - - m_context->framebufferRenderbuffer(GraphicsContext3D::FRAMEBUFFER, GraphicsContext3D::COLOR_ATTACHMENT0, GraphicsContext3D::RENDERBUFFER, m_multisampleColorBuffer); - resizeDepthStencil(sampleCount); - if (m_context->checkFramebufferStatus(GraphicsContext3D::FRAMEBUFFER) != GraphicsContext3D::FRAMEBUFFER_COMPLETE) { - adjustedSize.scale(s_resourceAdjustedRatio); - continue; - } - } - - // resize regular FBO - m_context->bindFramebuffer(GraphicsContext3D::FRAMEBUFFER, m_fbo); - - m_context->bindTexture(GraphicsContext3D::TEXTURE_2D, m_colorBuffer); - m_context->texImage2D(GraphicsContext3D::TEXTURE_2D, 0, internalColorFormat, m_size.width(), m_size.height(), 0, colorFormat, GraphicsContext3D::UNSIGNED_BYTE, 0); - - m_context->framebufferTexture2D(GraphicsContext3D::FRAMEBUFFER, GraphicsContext3D::COLOR_ATTACHMENT0, GraphicsContext3D::TEXTURE_2D, m_colorBuffer, 0); - - // resize the front color buffer - if (m_separateFrontTexture) { - m_context->bindTexture(GraphicsContext3D::TEXTURE_2D, m_frontColorBuffer); - m_context->texImage2D(GraphicsContext3D::TEXTURE_2D, 0, internalColorFormat, m_size.width(), m_size.height(), 0, colorFormat, GraphicsContext3D::UNSIGNED_BYTE, 0); - } - - m_context->bindTexture(GraphicsContext3D::TEXTURE_2D, 0); - - if (!multisample()) - resizeDepthStencil(0); - if (m_context->checkFramebufferStatus(GraphicsContext3D::FRAMEBUFFER) != GraphicsContext3D::FRAMEBUFFER_COMPLETE) { - adjustedSize.scale(s_resourceAdjustedRatio); - continue; - } - -#if OS(DARWIN) - // FIXME: This can be removed once renderbufferStorageMultisample starts reporting GL_OUT_OF_MEMORY properly on OSX. - if (!checkBufferIntegrity()) { - adjustedSize.scale(s_resourceAdjustedRatio); - continue; - } -#endif - - break; - - } while (!adjustedSize.isEmpty()); - - pixelDelta = m_size.width() * m_size.height(); - pixelDelta -= oldSize; - s_currentResourceUsePixels += pixelDelta; - - if (!newSize.isEmpty() && adjustedSize.isEmpty()) { - clear(); - return false; - } - } - - m_context->disable(GraphicsContext3D::SCISSOR_TEST); - m_context->clearColor(0, 0, 0, 0); - m_context->colorMask(true, true, true, true); - - GC3Dbitfield clearMask = GraphicsContext3D::COLOR_BUFFER_BIT; - if (attributes.depth) { - m_context->clearDepth(1.0f); - clearMask |= GraphicsContext3D::DEPTH_BUFFER_BIT; - m_context->depthMask(true); - } - if (attributes.stencil) { - m_context->clearStencil(0); - clearMask |= GraphicsContext3D::STENCIL_BUFFER_BIT; - m_context->stencilMaskSeparate(GraphicsContext3D::FRONT, 0xFFFFFFFF); - } - - clearFramebuffers(clearMask); - - return true; -} - -void DrawingBuffer::commit(long x, long y, long width, long height) -{ - if (!m_context) - return; - - if (width < 0) - width = m_size.width(); - if (height < 0) - height = m_size.height(); - - m_context->makeContextCurrent(); - - if (m_multisampleFBO) { - m_context->bindFramebuffer(Extensions3D::READ_FRAMEBUFFER, m_multisampleFBO); - m_context->bindFramebuffer(Extensions3D::DRAW_FRAMEBUFFER, m_fbo); - - if (m_scissorEnabled) - m_context->disable(GraphicsContext3D::SCISSOR_TEST); - - // Use NEAREST, because there is no scale performed during the blit. - m_context->getExtensions()->blitFramebuffer(x, y, width, height, x, y, width, height, GraphicsContext3D::COLOR_BUFFER_BIT, GraphicsContext3D::NEAREST); - - if (m_scissorEnabled) - m_context->enable(GraphicsContext3D::SCISSOR_TEST); - } - - m_context->bindFramebuffer(GraphicsContext3D::FRAMEBUFFER, m_fbo); -} - -void DrawingBuffer::restoreFramebufferBinding() -{ - if (!m_context || !m_framebufferBinding) - return; - - m_context->bindFramebuffer(GraphicsContext3D::FRAMEBUFFER, m_framebufferBinding); -} - -bool DrawingBuffer::multisample() const -{ - return m_context && m_context->getContextAttributes().antialias && m_multisampleExtensionSupported; -} - -void DrawingBuffer::discardResources() -{ - m_colorBuffer = 0; - m_frontColorBuffer = 0; - m_multisampleColorBuffer = 0; - - m_depthStencilBuffer = 0; - m_depthBuffer = 0; - - m_stencilBuffer = 0; - - m_multisampleFBO = 0; - m_fbo = 0; -} - -void DrawingBuffer::bind() -{ - if (!m_context) - return; - - m_context->bindFramebuffer(GraphicsContext3D::FRAMEBUFFER, m_multisampleFBO ? m_multisampleFBO : m_fbo); -} - -} // namespace WebCore - -#endif diff --git a/Source/WebCore/platform/graphics/gpu/DrawingBuffer.h b/Source/WebCore/platform/graphics/gpu/DrawingBuffer.h deleted file mode 100644 index e234e420c..000000000 --- a/Source/WebCore/platform/graphics/gpu/DrawingBuffer.h +++ /dev/null @@ -1,173 +0,0 @@ -/* - * Copyright (c) 2010, Google Inc. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following disclaimer - * in the documentation and/or other materials provided with the - * distribution. - * * Neither the name of Google Inc. nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef DrawingBuffer_h -#define DrawingBuffer_h - -#include "GraphicsContext3D.h" -#include "GraphicsTypes3D.h" -#include "IntSize.h" -#include "PlatformLayer.h" - -#include <wtf/Noncopyable.h> -#include <wtf/OwnPtr.h> -#include <wtf/PassOwnPtr.h> -#if PLATFORM(MAC) -#include <wtf/RetainPtr.h> -#endif - -namespace WebCore { -class GraphicsContext3D; - -// Manages a rendering target (framebuffer + attachment) for a canvas. Can publish its rendering -// results to a PlatformLayer for compositing. -class DrawingBuffer : public RefCounted<DrawingBuffer> { -public: - enum PreserveDrawingBuffer { - Preserve, - Discard - }; - - enum AlphaRequirement { - Alpha, - Opaque - }; - - static PassRefPtr<DrawingBuffer> create(GraphicsContext3D*, const IntSize&, PreserveDrawingBuffer, AlphaRequirement); - friend class GraphicsContext3D; - - ~DrawingBuffer(); - - // Issues a glClear() on all framebuffers associated with this DrawingBuffer. The caller is responsible for - // making the context current and setting the clear values and masks. Modifies the framebuffer binding. - void clearFramebuffers(GC3Dbitfield clearMask); - - // Returns true if the buffer was successfully resized. - bool reset(const IntSize&); - void bind(); - IntSize size() const { return m_size; } - Platform3DObject colorBuffer() const { return m_colorBuffer; } - - // 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(); - - 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); - - // commit should copy the full multisample buffer, and not respect the - // current scissor bounds. Track the state of the scissor test so that it - // can be disabled during calls to commit. - void setScissorEnabled(bool scissorEnabled) { m_scissorEnabled = scissorEnabled; } - - // The DrawingBuffer needs to track the texture bound to texture unit 0. - // The bound texture is tracked to avoid costly queries during rendering. - void setTexture2DBinding(Platform3DObject texture) { m_texture2DBinding = texture; } - - // The DrawingBuffer needs to track the currently bound framebuffer so it - // restore the binding when needed. - void setFramebufferBinding(Platform3DObject fbo) { m_framebufferBinding = fbo; } - - // Bind to the m_framebufferBinding if it's not 0. - void restoreFramebufferBinding(); - - // Track the currently active texture unit. Texture unit 0 is used as host for a scratch - // texture. - void setActiveTextureUnit(GC3Dint textureUnit) { m_activeTextureUnit = textureUnit; } - - bool multisample() const; - - Platform3DObject framebuffer() const; - - // Immediately releases ownership of all resources. Call upon loss of the - // graphics context to prevent freeing invalid resources. - void discardResources(); - - void markContentsChanged() { m_contentsChanged = true; } - -#if USE(ACCELERATED_COMPOSITING) - PlatformLayer* platformLayer(); - unsigned frontColorBuffer() const; - void paintCompositedResultsToCanvas(ImageBuffer*); -#endif - - GraphicsContext3D* graphicsContext3D() const { return m_context.get(); } - -private: - DrawingBuffer(GraphicsContext3D*, const IntSize&, bool multisampleExtensionSupported, - bool packedDepthStencilExtensionSupported, PreserveDrawingBuffer, AlphaRequirement); - - void initialize(const IntSize&); - - bool checkBufferIntegrity(); - - PreserveDrawingBuffer m_preserveDrawingBuffer; - AlphaRequirement m_alpha; - bool m_scissorEnabled; - Platform3DObject m_texture2DBinding; - Platform3DObject m_framebufferBinding; - GC3Denum m_activeTextureUnit; - - RefPtr<GraphicsContext3D> m_context; - IntSize m_size; - bool m_multisampleExtensionSupported; - bool m_packedDepthStencilExtensionSupported; - Platform3DObject m_fbo; - Platform3DObject m_colorBuffer; - Platform3DObject m_frontColorBuffer; - bool m_separateFrontTexture; - - // 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; - - // True if our contents have been modified since the last presentation of this buffer. - bool m_contentsChanged; - -#if PLATFORM(MAC) - RetainPtr<WebGLLayer> m_platformLayer; -#endif -}; - -} // namespace WebCore - -#endif // DrawingBuffer_h diff --git a/Source/WebCore/platform/graphics/gpu/Texture.cpp b/Source/WebCore/platform/graphics/gpu/Texture.cpp index 31aaa63ee..aad13f34d 100644 --- a/Source/WebCore/platform/graphics/gpu/Texture.cpp +++ b/Source/WebCore/platform/graphics/gpu/Texture.cpp @@ -43,11 +43,11 @@ namespace WebCore { -Texture::Texture(GraphicsContext3D* context, PassOwnPtr<Vector<unsigned int>> tileTextureIds, Format format, int width, int height, int maxTextureSize) +Texture::Texture(GraphicsContext3D* context, std::unique_ptr<Vector<unsigned>> tileTextureIds, Format format, int width, int height, int maxTextureSize) : m_context(context) , m_format(format) , m_tiles(IntSize(maxTextureSize, maxTextureSize), IntSize(width, height), true) - , m_tileTextureIds(tileTextureIds) + , m_tileTextureIds(WTFMove(tileTextureIds)) { } @@ -66,7 +66,7 @@ static void convertFormat(GraphicsContext3D* context, Texture::Format format, un *glType = GraphicsContext3D::UNSIGNED_BYTE; break; case Texture::BGRA8: - if (context->getExtensions()->supports("GL_EXT_texture_format_BGRA8888")) { + if (context->getExtensions().supports("GL_EXT_texture_format_BGRA8888")) { *glFormat = Extensions3D::BGRA_EXT; *glType = GraphicsContext3D::UNSIGNED_BYTE; } else { @@ -94,7 +94,7 @@ PassRefPtr<Texture> Texture::create(GraphicsContext3D* context, Format format, i numTiles = 0; } - OwnPtr<Vector<unsigned int>> textureIds = adoptPtr(new Vector<unsigned int>(numTiles)); + auto textureIds = std::make_unique<Vector<unsigned>>(numTiles); textureIds->fill(0, numTiles); for (int i = 0; i < numTiles; i++) { @@ -120,7 +120,7 @@ PassRefPtr<Texture> Texture::create(GraphicsContext3D* context, Format format, i tileBoundsWithBorder.height(), 0, glFormat, glType); } - return adoptRef(new Texture(context, textureIds.release(), format, width, height, maxTextureSize)); + return adoptRef(new Texture(context, WTFMove(textureIds), format, width, height, maxTextureSize)); } template <bool swizzle> diff --git a/Source/WebCore/platform/graphics/gpu/Texture.h b/Source/WebCore/platform/graphics/gpu/Texture.h index 6e93b91c2..3aa55f821 100644 --- a/Source/WebCore/platform/graphics/gpu/Texture.h +++ b/Source/WebCore/platform/graphics/gpu/Texture.h @@ -32,8 +32,6 @@ #define Texture_h #include "TilingData.h" -#include <wtf/OwnPtr.h> -#include <wtf/PassOwnPtr.h> #include <wtf/RefCounted.h> #include <wtf/RefPtr.h> #include <wtf/Vector.h> @@ -54,11 +52,11 @@ public: Format format() const { return m_format; } const TilingData& tiles() const { return m_tiles; } private: - Texture(GraphicsContext3D*, PassOwnPtr<Vector<unsigned int>> tileTextureIds, Format format, int width, int height, int maxTextureSize); + Texture(GraphicsContext3D*, std::unique_ptr<Vector<unsigned>> tileTextureIds, Format, int width, int height, int maxTextureSize); GraphicsContext3D* m_context; Format m_format; TilingData m_tiles; - OwnPtr<Vector<unsigned int>> m_tileTextureIds; + std::unique_ptr<Vector<unsigned>> m_tileTextureIds; }; } diff --git a/Source/WebCore/platform/graphics/gpu/TilingData.cpp b/Source/WebCore/platform/graphics/gpu/TilingData.cpp index 23df37da0..6a3d04c4d 100644 --- a/Source/WebCore/platform/graphics/gpu/TilingData.cpp +++ b/Source/WebCore/platform/graphics/gpu/TilingData.cpp @@ -30,8 +30,6 @@ #include "config.h" -#if USE(ACCELERATED_COMPOSITING) || ENABLE(ACCELERATED_2D_CANVAS) - #include "TilingData.h" #include "FloatRect.h" @@ -203,5 +201,3 @@ void TilingData::recomputeNumTiles() } } - -#endif |