Beispiel #1
0
void WebGLLayerChromium::updateCompositorResources(GraphicsContext3D* rendererContext, CCTextureUpdater&)
{
    if (!drawsContent())
        return;

    if (m_dirtyRect.isEmpty())
        return;

    if (m_textureChanged) {
        rendererContext->bindTexture(GraphicsContext3D::TEXTURE_2D, m_textureId);
        // Set the min-mag filters to linear and wrap modes to GL_CLAMP_TO_EDGE
        // to get around NPOT texture limitations of GLES.
        rendererContext->texParameteri(GraphicsContext3D::TEXTURE_2D, GraphicsContext3D::TEXTURE_MIN_FILTER, GraphicsContext3D::LINEAR);
        rendererContext->texParameteri(GraphicsContext3D::TEXTURE_2D, GraphicsContext3D::TEXTURE_MAG_FILTER, GraphicsContext3D::LINEAR);
        rendererContext->texParameteri(GraphicsContext3D::TEXTURE_2D, GraphicsContext3D::TEXTURE_WRAP_S, GraphicsContext3D::CLAMP_TO_EDGE);
        rendererContext->texParameteri(GraphicsContext3D::TEXTURE_2D, GraphicsContext3D::TEXTURE_WRAP_T, GraphicsContext3D::CLAMP_TO_EDGE);
        m_textureChanged = false;
    }
    // Update the contents of the texture used by the compositor.
    if (!m_dirtyRect.isEmpty() && m_textureUpdated) {
        // publishToPlatformLayer prepares the contents of the off-screen render target for use by the compositor.
        drawingBuffer()->publishToPlatformLayer();
        context()->markLayerComposited();
        m_updateRect = FloatRect(FloatPoint(), bounds());
        resetNeedsDisplay();
        m_textureUpdated = false;
    }
}
void ContentLayerChromium::paintContentsIfDirty()
{
    ASSERT(drawsContent());

    updateTileSizeAndTilingOption();

    const IntRect& layerRect = visibleLayerRect();
    if (layerRect.isEmpty())
        return;

    IntRect dirty = enclosingIntRect(m_dirtyRect);
    dirty.intersect(IntRect(IntPoint(), contentBounds()));
    invalidateRect(dirty);

    if (!drawsContent())
        return;

    prepareToUpdate(layerRect);
    resetNeedsDisplay();
}