void WebViewEfl::paintToCairoSurface(cairo_surface_t* surface) { CoordinatedGraphicsScene* scene = coordinatedGraphicsScene(); if (!scene) return; PlatformContextCairo context(cairo_create(surface)); const FloatPoint& position = contentPosition(); double effectiveScale = m_page->deviceScaleFactor() * contentScaleFactor(); cairo_matrix_t transform = { effectiveScale, 0, 0, effectiveScale, - position.x() * m_page->deviceScaleFactor(), - position.y() * m_page->deviceScaleFactor() }; cairo_set_matrix(context.cr(), &transform); scene->paintToGraphicsContext(&context, m_page->pageExtendedBackgroundColor(), m_page->drawsBackground()); }
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()); } }