コード例 #1
0
PassRefPtr<BitmapContext> createBitmapContextFromWebView(bool, bool, bool, bool drawSelectionRect)
{
    Ewk_View_Smart_Data* smartData = static_cast<Ewk_View_Smart_Data*>(evas_object_smart_data_get(browser->mainView()));
    Ewk_View_Private_Data* privateData = static_cast<Ewk_View_Private_Data*>(smartData->_priv);
    const Evas_Object* mainFrame = browser->mainFrame();

    int x, y, width, height;
    if (!ewk_frame_visible_content_geometry_get(mainFrame, EINA_TRUE, &x, &y, &width, &height))
        return 0;

    RefPtr<cairo_surface_t> surface = adoptRef(cairo_image_surface_create(CAIRO_FORMAT_ARGB32, width, height));
    RefPtr<cairo_t> context = adoptRef(cairo_create(surface.get()));

    const Eina_Rectangle rect = { x, y, width, height };
    if (!ewk_view_paint(privateData, context.get(), &rect))
        return 0;

    if (DumpRenderTreeSupportEfl::isTrackingRepaints(mainFrame)) {
        cairo_push_group(context.get());

        // Paint the gray mask over the original image.
        cairo_set_source_rgba(context.get(), 0, 0, 0, 0.66);
        cairo_paint(context.get());

        // Paint transparent rectangles over the mask to show the repainted regions.
        cairo_set_source_rgba(context.get(), 0, 0, 0, 0);
        cairo_set_operator(context.get(), CAIRO_OPERATOR_SOURCE);

        Eina_List* repaintRects = DumpRenderTreeSupportEfl::trackedRepaintRects(mainFrame);
        void* iter = 0;
        EINA_LIST_FREE(repaintRects, iter) {
            Eina_Rectangle* rect = static_cast<Eina_Rectangle*>(iter);

            cairo_rectangle(context.get(), rect->x, rect->y, rect->w, rect->h);
            cairo_fill(context.get());

            eina_rectangle_free(rect);
        }

        cairo_pop_group_to_source(context.get());
        cairo_paint(context.get());
    }
コード例 #2
0
static Eina_Bool _ewk_view_single_smart_repaints_process(Ewk_View_Smart_Data* smartData)
{
    if (smartData->animated_zoom.zoom.current < 0.00001) {
        Evas_Object* clip = evas_object_clip_get(smartData->backing_store);

        // reset effects of zoom_weak_set()
        evas_object_image_fill_set(smartData->backing_store, 0, 0, smartData->view.w, smartData->view.h);
        evas_object_move(clip, smartData->view.x, smartData->view.y);

        Evas_Coord width = smartData->view.w;
        Evas_Coord height = smartData->view.h;

        Evas_Coord centerWidth, centerHeight;
        ewk_frame_contents_size_get(smartData->main_frame, &centerWidth, &centerHeight);
        if (width > centerWidth)
            width = centerWidth;

        if (height > centerHeight)
            height = centerHeight;

        evas_object_resize(clip, width, height);
    }

    Evas_Coord imageWidth, imageHeight;
    evas_object_image_size_get(smartData->backing_store, &imageWidth, &imageHeight);

    Eina_Tiler* tiler = eina_tiler_new(imageWidth, imageHeight);
    if (!tiler) {
        ERR("could not create tiler %dx%d", imageWidth, imageHeight);
        return false;
    }

    ewk_view_layout_if_needed_recursive(smartData->_priv);

    size_t count;
    const Eina_Rectangle* paintRequest = ewk_view_repaints_pop(smartData->_priv, &count);
    const Eina_Rectangle* paintRequestEnd = paintRequest + count;
    for (; paintRequest < paintRequestEnd; paintRequest++)
        eina_tiler_rect_add(tiler, paintRequest);

    Eina_Iterator* iterator = eina_tiler_iterator_new(tiler);
    if (!iterator) {
        ERR("could not get iterator for tiler");
        eina_tiler_free(tiler);
        return false;
    }

#if USE(TILED_BACKING_STORE)
    WebCore::Frame* mainFrame = EWKPrivate::coreFrame(smartData->main_frame);
    if (mainFrame && mainFrame->tiledBackingStore())
        mainFrame->tiledBackingStore()->coverWithTilesIfNeeded();
#endif

    Ewk_Paint_Context* context = ewk_paint_context_from_image_new(smartData->backing_store);
    ewk_paint_context_save(context);

    Eina_Rectangle* rect;
    EINA_ITERATOR_FOREACH(iterator, rect) {
        ewk_view_paint(smartData->_priv, context, rect);
        evas_object_image_data_update_add(smartData->backing_store, rect->x, rect->y, rect->w, rect->h);
    }