static void _e_icon_obj_prepare(Evas_Object *obj, E_Smart_Data *sd) { if (!sd->obj) return; if (sd->edje) { Evas_Object *pclip; pclip = evas_object_clip_get(sd->obj); evas_object_del(sd->obj); #ifdef USE_ICON_CACHE sd->ci = NULL; eina_stringshare_replace(&sd->file, NULL); #endif sd->obj = evas_object_image_add(evas_object_evas_get(obj)); if (!sd->animated) evas_object_image_scale_hint_set(sd->obj, EVAS_IMAGE_SCALE_HINT_STATIC); evas_object_smart_member_add(sd->obj, obj); evas_object_event_callback_add(sd->obj, EVAS_CALLBACK_IMAGE_PRELOADED, _e_icon_preloaded, obj); evas_object_clip_set(sd->obj, pclip); } }
static void _emotion_aspect_borders_apply(Evas_Object *obj, Smart_Data *sd, int w, int h, int iw, int ih) { int x, y; evas_object_geometry_get(obj, &x, &y, NULL, NULL); /* applying calculated borders */ if (sd->crop.l == 0 && sd->crop.r == 0 && sd->crop.t == 0 && sd->crop.b == 0) { Evas_Object *old_clipper; if (sd->crop.clipper) { old_clipper = evas_object_clip_get(sd->crop.clipper); evas_object_clip_unset(sd->obj); evas_object_clip_set(sd->obj, old_clipper); evas_object_del(sd->crop.clipper); sd->crop.clipper = NULL; } } else { if (!sd->crop.clipper) { Evas_Object *old_clipper; sd->crop.clipper = evas_object_rectangle_add( evas_object_evas_get(obj)); evas_object_color_set(sd->crop.clipper, 255, 255, 255, 255); evas_object_smart_member_add(sd->crop.clipper, obj); old_clipper = evas_object_clip_get(sd->obj); evas_object_clip_set(sd->obj, sd->crop.clipper); evas_object_clip_set(sd->crop.clipper, old_clipper); if (evas_object_visible_get(sd->obj)) evas_object_show(sd->crop.clipper); } } _clipper_position_size_update(obj, x, y, w, h, iw, ih); }
static void _ewk_view_single_smart_resize(Evas_Object *o, Evas_Coord w, Evas_Coord h) { Ewk_View_Smart_Data *sd = (Ewk_View_Smart_Data*)evas_object_smart_data_get(o); _parent_sc.sc.resize(o, w, h); // these should be queued and processed in calculate as well! evas_object_image_size_set(sd->backing_store, w, h); if (sd->animated_zoom.zoom.current < 0.00001) { Evas_Object *clip = evas_object_clip_get(sd->backing_store); Evas_Coord x, y, cw, ch; evas_object_image_fill_set(sd->backing_store, 0, 0, w, h); evas_object_geometry_get(sd->backing_store, &x, &y, 0, 0); evas_object_move(clip, x, y); ewk_frame_contents_size_get(sd->main_frame, &cw, &ch); if (w > cw) w = cw; if (h > ch) h = ch; evas_object_resize(clip, w, h); } }
static void _ewk_view_single_smart_resize(Evas_Object* ewkView, Evas_Coord width, Evas_Coord height) { Ewk_View_Smart_Data* smartData = static_cast<Ewk_View_Smart_Data*>(evas_object_smart_data_get(ewkView)); _parent_sc.sc.resize(ewkView, width, height); if (!smartData) return; // these should be queued and processed in calculate as well! evas_object_image_size_set(smartData->backing_store, width, height); if (smartData->animated_zoom.zoom.current < 0.00001) { Evas_Object* clip = evas_object_clip_get(smartData->backing_store); Evas_Coord x, y, cw, ch; evas_object_image_fill_set(smartData->backing_store, 0, 0, width, height); evas_object_geometry_get(smartData->backing_store, &x, &y, 0, 0); evas_object_move(clip, x, y); ewk_frame_contents_size_get(smartData->main_frame, &cw, &ch); if (width > cw) width = cw; if (height > ch) height = ch; evas_object_resize(clip, width, height); } }
static Eina_Bool _ewk_view_single_smart_zoom_weak_set(Ewk_View_Smart_Data *sd, float zoom, Evas_Coord cx, Evas_Coord cy) { // TODO: review float scale = zoom / sd->animated_zoom.zoom.start; Evas_Coord w = sd->view.w * scale; Evas_Coord h = sd->view.h * scale; Evas_Coord dx, dy, cw, ch; Evas_Object *clip = evas_object_clip_get(sd->backing_store); ewk_frame_contents_size_get(sd->main_frame, &cw, &ch); if (sd->view.w > 0 && sd->view.h > 0) { dx = (w * (sd->view.w - cx)) / sd->view.w; dy = (h * (sd->view.h - cy)) / sd->view.h; } else { dx = 0; dy = 0; } evas_object_image_fill_set(sd->backing_store, cx + dx, cy + dy, w, h); if (sd->view.w > 0 && sd->view.h > 0) { dx = ((sd->view.w - w) * cx) / sd->view.w; dy = ((sd->view.h - h) * cy) / sd->view.h; } else { dx = 0; dy = 0; } evas_object_move(clip, sd->view.x + dx, sd->view.y + dy); if (cw < sd->view.w) w = cw * scale; if (ch < sd->view.h) h = ch * scale; evas_object_resize(clip, w, h); return EINA_TRUE; }
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, ¢erWidth, ¢erHeight); 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); }
Object* Object::getClip() const { return objectLink( evas_object_clip_get( o ) ); }
static Eina_Bool _ewk_view_single_smart_repaints_process(Ewk_View_Smart_Data *sd) { Ewk_View_Paint_Context *ctxt; Evas_Coord ow, oh; void *pixels; Eina_Rectangle r = {0, 0, 0, 0}; const Eina_Rectangle *pr; const Eina_Rectangle *pr_end; Eina_Tiler *tiler; Eina_Iterator *itr; cairo_status_t status; cairo_surface_t *surface; cairo_format_t format; cairo_t *cairo; size_t count; Eina_Bool ret = EINA_TRUE; if (sd->animated_zoom.zoom.current < 0.00001) { Evas_Object *clip = evas_object_clip_get(sd->backing_store); Evas_Coord w, h, cw, ch; // reset effects of zoom_weak_set() evas_object_image_fill_set (sd->backing_store, 0, 0, sd->view.w, sd->view.h); evas_object_move(clip, sd->view.x, sd->view.y); w = sd->view.w; h = sd->view.h; ewk_frame_contents_size_get(sd->main_frame, &cw, &ch); if (w > cw) w = cw; if (h > ch) h = ch; evas_object_resize(clip, w, h); } pixels = evas_object_image_data_get(sd->backing_store, 1); evas_object_image_size_get(sd->backing_store, &ow, &oh); if (sd->bg_color.a < 255) format = CAIRO_FORMAT_ARGB32; else format = CAIRO_FORMAT_RGB24; surface = cairo_image_surface_create_for_data ((unsigned char*)pixels, format, ow, oh, ow * 4); status = cairo_surface_status(surface); if (status != CAIRO_STATUS_SUCCESS) { ERR("could not create surface from data %dx%d: %s", ow, oh, cairo_status_to_string(status)); ret = EINA_FALSE; goto error_cairo_surface; } cairo = cairo_create(surface); status = cairo_status(cairo); if (status != CAIRO_STATUS_SUCCESS) { ERR("could not create cairo from surface %dx%d: %s", ow, oh, cairo_status_to_string(status)); ret = EINA_FALSE; goto error_cairo; } ctxt = ewk_view_paint_context_new(sd->_priv, cairo); if (!ctxt) { ERR("could not create paint context"); ret = EINA_FALSE; goto error_paint_context; } tiler = eina_tiler_new(ow, oh); if (!tiler) { ERR("could not create tiler %dx%d", ow, oh); ret = EINA_FALSE; goto error_tiler; } pr = ewk_view_repaints_get(sd->_priv, &count); pr_end = pr + count; for (; pr < pr_end; pr++) eina_tiler_rect_add(tiler, pr); itr = eina_tiler_iterator_new(tiler); if (!itr) { ERR("could not get iterator for tiler"); ret = EINA_FALSE; goto error_iterator; } int sx, sy; ewk_frame_scroll_pos_get(sd->main_frame, &sx, &sy); EINA_ITERATOR_FOREACH(itr, r) { Eina_Rectangle scrolled_rect = { r.x + sx, r.y + sy, r.w, r.h }; ewk_view_paint_context_save(ctxt); if ((sx) || (sy)) ewk_view_paint_context_translate(ctxt, -sx, -sy); ewk_view_paint_context_clip(ctxt, &scrolled_rect); ewk_view_paint_context_paint_contents(ctxt, &scrolled_rect); ewk_view_paint_context_restore(ctxt); evas_object_image_data_update_add (sd->backing_store, r.x, r.y, r.w, r.h); }
static Eina_Bool _ewk_view_single_smart_repaints_process(Ewk_View_Smart_Data* smartData) { Ewk_View_Paint_Context* context; Evas_Coord ow, oh; void* pixels; Eina_Rectangle* rect; const Eina_Rectangle* pr; const Eina_Rectangle* pr_end; Eina_Tiler* tiler; Eina_Iterator* iterator; cairo_status_t status; cairo_surface_t* surface; cairo_format_t format; cairo_t* cairo; size_t count; Eina_Bool result = true; if (smartData->animated_zoom.zoom.current < 0.00001) { Evas_Object* clip = evas_object_clip_get(smartData->backing_store); Evas_Coord width, height, centerWidth, centerHeight; // 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); width = smartData->view.w; height = smartData->view.h; ewk_frame_contents_size_get(smartData->main_frame, ¢erWidth, ¢erHeight); if (width > centerWidth) width = centerWidth; if (height > centerHeight) height = centerHeight; evas_object_resize(clip, width, height); } pixels = evas_object_image_data_get(smartData->backing_store, 1); evas_object_image_size_get(smartData->backing_store, &ow, &oh); format = CAIRO_FORMAT_ARGB32; surface = cairo_image_surface_create_for_data (static_cast<unsigned char*>(pixels), format, ow, oh, ow * 4); status = cairo_surface_status(surface); if (status != CAIRO_STATUS_SUCCESS) { ERR("could not create surface from data %dx%d: %s", ow, oh, cairo_status_to_string(status)); result = false; goto error_cairo_surface; } cairo = cairo_create(surface); status = cairo_status(cairo); if (status != CAIRO_STATUS_SUCCESS) { ERR("could not create cairo from surface %dx%d: %s", ow, oh, cairo_status_to_string(status)); result = false; goto error_cairo; } context = ewk_view_paint_context_new(smartData->_priv, cairo); if (!context) { ERR("could not create paint context"); result = false; goto error_paint_context; } tiler = eina_tiler_new(ow, oh); if (!tiler) { ERR("could not create tiler %dx%d", ow, oh); result = false; goto error_tiler; } ewk_view_layout_if_needed_recursive(smartData->_priv); pr = ewk_view_repaints_pop(smartData->_priv, &count); pr_end = pr + count; for (; pr < pr_end; pr++) eina_tiler_rect_add(tiler, pr); iterator = eina_tiler_iterator_new(tiler); if (!iterator) { ERR("could not get iterator for tiler"); result = false; goto error_iterator; } int scrollX, scrollY; ewk_frame_scroll_pos_get(smartData->main_frame, &scrollX, &scrollY); EINA_ITERATOR_FOREACH(iterator, rect) { Eina_Rectangle scrolled_rect = { rect->x + scrollX, rect->y + scrollY, rect->w, rect->h }; ewk_view_paint_context_save(context); if ((scrollX) || (scrollY)) ewk_view_paint_context_translate(context, -scrollX, -scrollY); ewk_view_paint_context_clip(context, &scrolled_rect); ewk_view_paint_context_paint_contents(context, &scrolled_rect); ewk_view_paint_context_restore(context); evas_object_image_data_update_add (smartData->backing_store, rect->x, rect->y, rect->w, rect->h); }