Beispiel #1
0
void DrawingBuffer::initialize(const IntSize& size)
{
    ASSERT(m_context);
    m_attributes = m_context->getContextAttributes();

    if (m_attributes.alpha) {
        m_internalColorFormat = GraphicsContext3D::RGBA;
        m_colorFormat = GraphicsContext3D::RGBA;
        m_internalRenderbufferFormat = Extensions3D::RGBA8_OES;
    } else {
        m_internalColorFormat = GraphicsContext3D::RGB;
        m_colorFormat = GraphicsContext3D::RGB;
        m_internalRenderbufferFormat = Extensions3D::RGB8_OES;
    }

    m_context->getIntegerv(GraphicsContext3D::MAX_TEXTURE_SIZE, &m_maxTextureSize);

    m_fbo = m_context->createFramebuffer();

    if (m_separateFrontTexture)
        m_frontColorBuffer = createColorTexture();

    m_context->bindFramebuffer(GraphicsContext3D::FRAMEBUFFER, m_fbo);
    m_colorBuffer = createColorTexture();
    m_context->framebufferTexture2D(GraphicsContext3D::FRAMEBUFFER, GraphicsContext3D::COLOR_ATTACHMENT0, GraphicsContext3D::TEXTURE_2D, m_colorBuffer, 0);
    createSecondaryBuffers();
    reset(size);
#if ENABLE(CANVAS_USES_MAILBOX)
    m_lastColorBuffer = createNewMailbox(m_colorBuffer);
#endif // ENABLE(CANVAS_USES_MAILBOX)
}
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(0)
    , m_colorBuffer(0)
    , m_depthStencilBuffer(0)
    , m_depthBuffer(0)
    , m_stencilBuffer(0)
    , m_multisampleFBO(0)
    , m_multisampleColorBuffer(0)
    , m_internal(new DrawingBufferInternal)
{
    if (!m_context->getExtensions()->supports("GL_CHROMIUM_copy_texture_to_parent_texture")) {
        m_context.clear();
        return;
    }
    m_fbo = context->createFramebuffer();
    context->bindFramebuffer(GraphicsContext3D::FRAMEBUFFER, m_fbo);
    m_colorBuffer = generateColorTexture(context, size);
    createSecondaryBuffers();
    reset(size);
}
Beispiel #3
0
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);
}
Beispiel #4
0
DrawingBuffer::DrawingBuffer(GraphicsContext3D* context,
                             const IntSize& size,
                             bool multisampleExtensionSupported,
                             bool packedDepthStencilExtensionSupported)
    : m_context(context)
    , 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)
{
#if 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);

    // Create the FBO
    m_fbo = context->createFramebuffer();
    ASSERT(m_fbo);
    if (!m_fbo) {
        clear();
        return;
    }

    createSecondaryBuffers();
    reset(size);
#endif	
}
DrawingBuffer::DrawingBuffer(GraphicsContext3D* context,
                             const IntSize& size,
                             bool multisampleExtensionSupported,
                             bool packedDepthStencilExtensionSupported,
                             bool separateBackingTexture)
    : m_separateBackingTexture(separateBackingTexture)
    , m_scissorEnabled(false)
    , m_texture2DBinding(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_depthStencilBuffer(0)
    , m_depthBuffer(0)
    , m_stencilBuffer(0)
    , m_multisampleFBO(0)
    , m_multisampleColorBuffer(0)
{
    // Support for a separate backing texture has only been enabled for
    // the chromium port.
    ASSERT(!m_separateBackingTexture);
    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);
}
Beispiel #6
0
void DrawingBuffer::initialize(const IntSize& size)
{
    ASSERT(m_context);
    m_attributes = m_context->getContextAttributes();
    Extensions3DUtil extensionsUtil(m_context);

    if (m_attributes.alpha) {
        m_internalColorFormat = GL_RGBA;
        m_colorFormat = GL_RGBA;
        m_internalRenderbufferFormat = GL_RGBA8_OES;
    } else {
        m_internalColorFormat = GL_RGB;
        m_colorFormat = GL_RGB;
        m_internalRenderbufferFormat = GL_RGB8_OES;
    }

    m_context->getIntegerv(GL_MAX_TEXTURE_SIZE, &m_maxTextureSize);

    int maxSampleCount = 0;
    m_multisampleMode = None;
    if (m_attributes.antialias && m_multisampleExtensionSupported) {
        m_context->getIntegerv(GL_MAX_SAMPLES_ANGLE, &maxSampleCount);
        m_multisampleMode = ExplicitResolve;
        if (extensionsUtil.supportsExtension("GL_EXT_multisampled_render_to_texture"))
            m_multisampleMode = ImplicitResolve;
    }
    m_sampleCount = std::min(4, maxSampleCount);

    m_fbo = m_context->createFramebuffer();

    m_context->bindFramebuffer(GL_FRAMEBUFFER, m_fbo);
    m_colorBuffer = createColorTexture();
    if (m_multisampleMode == ImplicitResolve)
        m_context->framebufferTexture2DMultisampleEXT(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, m_colorBuffer, 0, m_sampleCount);
    else
        m_context->framebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, m_colorBuffer, 0);
    createSecondaryBuffers();
    reset(size);
}