Ejemplo n.º 1
0
void WKCACFLayerRenderer::setNeedsDisplay(bool sync)
{
    if (!m_syncLayerChanges && sync)
        m_syncLayerChanges = true;

    ASSERT(m_rootLayer);
    m_rootLayer->setNeedsDisplay(0);
    renderSoon();
}
Ejemplo n.º 2
0
void LegacyCACFLayerTreeHost::paint()
{
    createRenderer();
    if (!m_d3dDevice) {
        if (m_mightBeAbleToCreateDeviceLater)
            renderSoon();
        return;
    }

    CACFLayerTreeHost::paint();
}
Ejemplo n.º 3
0
void WKCACFLayerRenderer::paint()
{
    createRenderer();
    if (!m_d3dDevice) {
        if (m_mightBeAbleToCreateDeviceLater)
            renderSoon();
        return;
    }

    if (m_backingStoreDirty) {
        // If the backing store is still dirty when we are about to draw the
        // composited content, we need to force the window to paint into the
        // backing store. The paint will only paint the dirty region that
        // if being tracked in WebView.
        UpdateWindow(m_hostWindow);
        return;
    }

    Vector<CGRect> dirtyRects;
    getDirtyRects(m_hostWindow, dirtyRects);
    render(dirtyRects);
}
Ejemplo n.º 4
0
void LegacyCACFLayerTreeHost::contextDidChange()
{
    renderSoon();
    CACFLayerTreeHost::contextDidChange();
}
Ejemplo n.º 5
0
void LegacyCACFLayerTreeHost::render(const Vector<CGRect>& windowDirtyRects)
{
    ASSERT(m_d3dDevice);

    if (m_mustResetLostDeviceBeforeRendering && !resetDevice(LostDevice)) {
        // We can't reset the device right now. Try again soon.
        renderSoon();
        return;
    }

    CGRect bounds = this->bounds();

    // Give the renderer some space to use. This needs to be valid until the
    // wkCACFContextFinishUpdate() call below.
    char space[4096];
    if (!wkCACFContextBeginUpdate(m_context, space, sizeof(space), CACurrentMediaTime(), bounds, windowDirtyRects.data(), windowDirtyRects.size()))
        return;

    HRESULT err = S_OK;
    CFTimeInterval timeToNextRender = numeric_limits<CFTimeInterval>::infinity();

    do {
        // FIXME: don't need to clear dirty region if layer tree is opaque.

        WKCACFUpdateRectEnumerator* e = wkCACFContextCopyUpdateRectEnumerator(m_context);
        if (!e)
            break;

        Vector<D3DRECT, 64> rects;
        for (const CGRect* r = wkCACFUpdateRectEnumeratorNextRect(e); r; r = wkCACFUpdateRectEnumeratorNextRect(e)) {
            D3DRECT rect;
            rect.x1 = r->origin.x;
            rect.x2 = rect.x1 + r->size.width;
            rect.y1 = bounds.origin.y + bounds.size.height - (r->origin.y + r->size.height);
            rect.y2 = rect.y1 + r->size.height;

            rects.append(rect);
        }
        wkCACFUpdateRectEnumeratorRelease(e);

        timeToNextRender = wkCACFContextGetNextUpdateTime(m_context);

        if (rects.isEmpty())
            break;

        m_d3dDevice->Clear(rects.size(), rects.data(), D3DCLEAR_TARGET, 0, 1.0f, 0);

        m_d3dDevice->BeginScene();
        wkCACFContextRenderUpdate(m_context);
        m_d3dDevice->EndScene();

        err = m_d3dDevice->Present(0, 0, 0, 0);

        if (err == D3DERR_DEVICELOST) {
            wkCACFContextAddUpdateRect(m_context, bounds);
            if (!resetDevice(LostDevice)) {
                // We can't reset the device right now. Try again soon.
                renderSoon();
                return;
            }
        }
    } while (err == D3DERR_DEVICELOST);

    wkCACFContextFinishUpdate(m_context);

#ifndef NDEBUG
    if (m_printTree)
        rootLayer()->printTree();
#endif

    // If timeToNextRender is not infinity, it means animations are running, so queue up to render again
    if (timeToNextRender != numeric_limits<CFTimeInterval>::infinity())
        renderSoon();
}
Ejemplo n.º 6
0
void WKCACFLayerRenderer::render(const Vector<CGRect>& dirtyRects)
{
    ASSERT(m_d3dDevice);

    if (m_mustResetLostDeviceBeforeRendering && !resetDevice(LostDevice)) {
        // We can't reset the device right now. Try again soon.
        renderSoon();
        return;
    }

    if (m_client && !m_client->shouldRender()) {
        renderSoon();
        return;
    }

    // Flush the root layer to the render tree.
    WKCACFContextFlusher::shared().flushAllContexts();

    CGRect bounds = this->bounds();

    CFTimeInterval t = CACurrentMediaTime();

    // Give the renderer some space to use. This needs to be valid until the
    // CARenderUpdateFinish() call below.
    char space[4096];
    CARenderUpdate* u = CARenderUpdateBegin(space, sizeof(space), t, 0, 0, &bounds);
    if (!u)
        return;

    CARenderContextLock(m_renderContext);
    CARenderUpdateAddContext(u, m_renderContext);
    CARenderContextUnlock(m_renderContext);

    for (size_t i = 0; i < dirtyRects.size(); ++i)
        CARenderUpdateAddRect(u, &dirtyRects[i]);

    HRESULT err = S_OK;
    do {
        CGSRegionObj rgn = CARenderUpdateCopyRegion(u);

        if (!rgn)
            break;

        // FIXME: don't need to clear dirty region if layer tree is opaque.

        Vector<D3DRECT, 64> rects;
        CGSRegionEnumeratorObj e = CGSRegionEnumerator(rgn);
        for (const CGRect* r = CGSNextRect(e); r; r = CGSNextRect(e)) {
            D3DRECT rect;
            rect.x1 = r->origin.x;
            rect.x2 = rect.x1 + r->size.width;
            rect.y1 = bounds.origin.y + bounds.size.height - (r->origin.y + r->size.height);
            rect.y2 = rect.y1 + r->size.height;

            rects.append(rect);
        }
        CGSReleaseRegionEnumerator(e);
        CGSReleaseRegion(rgn);

        if (rects.isEmpty())
            break;

        m_d3dDevice->Clear(rects.size(), rects.data(), D3DCLEAR_TARGET, 0, 1.0f, 0);

        m_d3dDevice->BeginScene();
        CARenderOGLRender(m_renderer, u);
        m_d3dDevice->EndScene();

        err = m_d3dDevice->Present(0, 0, 0, 0);

        if (err == D3DERR_DEVICELOST) {
            CARenderUpdateAddRect(u, &bounds);
            if (!resetDevice(LostDevice)) {
                // We can't reset the device right now. Try again soon.
                renderSoon();
                return;
            }
        }
    } while (err == D3DERR_DEVICELOST);

    CARenderUpdateFinish(u);

#ifndef NDEBUG
    if (m_printTree)
        m_rootLayer->printTree();
#endif
}
Ejemplo n.º 7
0
void WKCACFLayerRenderer::setNeedsDisplay()
{
    ASSERT(m_rootLayer);
    m_rootLayer->setNeedsDisplay(0);
    renderSoon();
}
Ejemplo n.º 8
0
void WKCACFLayerRenderer::layerTreeDidChange()
{
    WKCACFContextFlusher::shared().addContext(m_context.get());
    renderSoon();
}
Ejemplo n.º 9
0
void WKCACFLayerRenderer::setRootContents(CGImageRef image)
{
    ASSERT(m_rootLayer);
    m_rootLayer->setContents(image);
    renderSoon();
}
Ejemplo n.º 10
0
void WKCACFLayerRenderer::render(const Vector<CGRect>& windowDirtyRects)
{
    ASSERT(m_d3dDevice);

    if (m_mustResetLostDeviceBeforeRendering && !resetDevice(LostDevice)) {
        // We can't reset the device right now. Try again soon.
        renderSoon();
        return;
    }

    if (m_client && !m_client->shouldRender()) {
        renderSoon();
        return;
    }

    // Sync the layer if needed
    if (m_syncLayerChanges) {
        m_client->syncCompositingState();
        m_syncLayerChanges = false;
    }

    // Flush the root layer to the render tree.
    wkCACFContextFlush(m_context);

    // All pending animations will have been started with the flush. Fire the animationStarted calls
    double currentTime = WTF::currentTime();
    double currentMediaTime = CACurrentMediaTime();
    double t = currentTime + wkCACFContextGetLastCommitTime(m_context) - currentMediaTime;
    ASSERT(t <= currentTime);

    HashSet<RefPtr<PlatformCALayer> >::iterator end = m_pendingAnimatedLayers.end();
    for (HashSet<RefPtr<PlatformCALayer> >::iterator it = m_pendingAnimatedLayers.begin(); it != end; ++it) {
        PlatformCALayerClient* owner = (*it)->owner();
        owner->platformCALayerAnimationStarted(t);
    }

    m_pendingAnimatedLayers.clear();

    CGRect bounds = this->bounds();

    // Give the renderer some space to use. This needs to be valid until the
    // wkCACFContextFinishUpdate() call below.
    char space[4096];
    if (!wkCACFContextBeginUpdate(m_context, space, sizeof(space), currentMediaTime, bounds, windowDirtyRects.data(), windowDirtyRects.size()))
        return;

    HRESULT err = S_OK;
    CFTimeInterval timeToNextRender = numeric_limits<CFTimeInterval>::infinity();

    do {
        // FIXME: don't need to clear dirty region if layer tree is opaque.

        WKCACFUpdateRectEnumerator* e = wkCACFContextCopyUpdateRectEnumerator(m_context);
        if (!e)
            break;

        Vector<D3DRECT, 64> rects;
        for (const CGRect* r = wkCACFUpdateRectEnumeratorNextRect(e); r; r = wkCACFUpdateRectEnumeratorNextRect(e)) {
            D3DRECT rect;
            rect.x1 = r->origin.x;
            rect.x2 = rect.x1 + r->size.width;
            rect.y1 = bounds.origin.y + bounds.size.height - (r->origin.y + r->size.height);
            rect.y2 = rect.y1 + r->size.height;

            rects.append(rect);
        }
        wkCACFUpdateRectEnumeratorRelease(e);

        timeToNextRender = wkCACFContextGetNextUpdateTime(m_context);

        if (rects.isEmpty())
            break;

        m_d3dDevice->Clear(rects.size(), rects.data(), D3DCLEAR_TARGET, 0, 1.0f, 0);

        m_d3dDevice->BeginScene();
        wkCACFContextRenderUpdate(m_context);
        m_d3dDevice->EndScene();

        err = m_d3dDevice->Present(0, 0, 0, 0);

        if (err == D3DERR_DEVICELOST) {
            wkCACFContextAddUpdateRect(m_context, bounds);
            if (!resetDevice(LostDevice)) {
                // We can't reset the device right now. Try again soon.
                renderSoon();
                return;
            }
        }
    } while (err == D3DERR_DEVICELOST);

    wkCACFContextFinishUpdate(m_context);

#ifndef NDEBUG
    if (m_printTree)
        m_rootLayer->printTree();
#endif

    // If timeToNextRender is not infinity, it means animations are running, so queue up to render again
    if (timeToNextRender != numeric_limits<CFTimeInterval>::infinity())
        renderSoon();
}