コード例 #1
0
void WebView::paintToCurrentGLContext()
{
    CoordinatedGraphicsScene* scene = coordinatedGraphicsScene();
    if (!scene)
        return;

    // FIXME: We need to clean up this code as it is split over CoordGfx and Page.
    scene->setDrawsBackground(m_page->drawsBackground());
    const FloatRect& viewport = m_userViewportTransform.mapRect(IntRect(IntPoint(), m_size));

    scene->paintToCurrentGLContext(transformToScene().toTransformationMatrix(), m_opacity, viewport);
}
コード例 #2
0
void EwkView::displayTimerFired(Timer<EwkView>*)
{
    Ewk_View_Smart_Data* sd = smartData();

    if (m_pendingSurfaceResize) {
        // Create a GL surface here so that Evas has no chance of painting to an empty GL surface.
        if (!createGLSurface(IntSize(sd->view.w, sd->view.h)))
            return;

        m_pendingSurfaceResize = false;
    }

    evas_gl_make_current(m_evasGL.get(), m_evasGLSurface->surface(), m_evasGLContext->context());

    // We are supposed to clip to the actual viewport, nothing less.
    IntRect viewport(sd->view.x, sd->view.y, sd->view.w, sd->view.h);

    CoordinatedGraphicsScene* scene = coordinatedGraphicsScene();
    if (!scene)
        return;

    scene->setActive(true);
    scene->setDrawsBackground(WKViewGetDrawsBackground(wkView()));

    if (m_isHardwareAccelerated) {
        scene->paintToCurrentGLContext(transformToScene().toTransformationMatrix(), /* opacity */ 1, viewport);
        // sd->image is tied to a native surface. The native surface is in the parent's coordinates,
        // so we need to account for the viewport position when calling evas_object_image_data_update_add.
        evas_object_image_data_update_add(sd->image, viewport.x(), viewport.y(), viewport.width(), viewport.height());
    } else {
        RefPtr<cairo_surface_t> surface = createSurfaceForImage(sd->image);
        if (!surface)
            return;

        RefPtr<cairo_t> graphicsContext = adoptRef(cairo_create(surface.get()));
        cairo_translate(graphicsContext.get(), - pagePosition().x(), - pagePosition().y());
        cairo_scale(graphicsContext.get(), pageScaleFactor(), pageScaleFactor());
        cairo_scale(graphicsContext.get(), deviceScaleFactor(), deviceScaleFactor());
        scene->paintToGraphicsContext(graphicsContext.get());
        evas_object_image_data_update_add(sd->image, 0, 0, viewport.width(), viewport.height());
    }
}