EAPI void * e_icon_data_get(const Evas_Object *obj, int *w, int *h) { E_Smart_Data *sd; if (evas_object_smart_smart_get(obj) != _e_smart) SMARTERR(NULL); if (!(sd = evas_object_smart_data_get(obj))) return NULL; if (sd->edje) return NULL; evas_object_image_size_get(sd->obj, w, h); return evas_object_image_data_get(sd->obj, 0); }
void eps_page_render (const Eps_Page *page, Evas_Object *o) { unsigned char *data; unsigned char *d; unsigned int *m = NULL; double hscale; double vscale; SpectreStatus status; int width; int height; int stride; int yy; if (!page || !o) return; spectre_page_render (page->page, page->rc, &data, &stride); status = spectre_page_status (page->page); if (status != SPECTRE_STATUS_SUCCESS) { printf ("[eps] %s\n", spectre_status_to_string (status)); return; } eps_page_scale_get (page, &hscale, &vscale); eps_page_size_get (page, &width, &height); width *= hscale; height *= vscale; evas_object_image_size_set (o, width, height); evas_object_image_fill_set (o, 0, 0, width, height); m = (unsigned int *)evas_object_image_data_get (o, 1); if (!m) { free (data); return; } if (stride == 4 * width) memcpy(m, data, height * stride); else { d = data; for (yy = 0; yy < height; d += stride, m += width, ++yy) { memcpy (m, d, width * 4); } } evas_object_image_data_update_add (o, 0, 0, width, height); evas_object_resize (o, width, height); free (data); }
EAPI void * e_icon_data_get(Evas_Object *obj, int *w, int *h) { E_Smart_Data *sd; sd = evas_object_smart_data_get(obj); if (!sd) return NULL; if (!strcmp(evas_object_type_get(sd->obj), "edje")) return NULL; evas_object_image_size_get(sd->obj, w, h); return evas_object_image_data_get(sd->obj, 0); }
void eps_page_render_slice (const Eps_Page *page, Evas_Object *o, int x, int y, int width, int height) { unsigned char *data; unsigned char *d; unsigned int *m = NULL; double hscale; double vscale; SpectreStatus status; int stride; int yy; if (!page || !o || (width <= 0) || (height <= 0)) return; spectre_page_render_slice (page->page, page->rc, x, y, width, height, &data, &stride); status = spectre_page_status (page->page); if (status != SPECTRE_STATUS_SUCCESS) { printf ("aie !!%d %d %d %d %d\n", status, x, y, width, height); printf ("[eps] %s\n", spectre_status_to_string (status)); return; } eps_page_scale_get (page, &hscale, &vscale); width *= hscale; height *= vscale; evas_object_image_size_set (o, width, height); evas_object_image_fill_set (o, 0, 0, width, height); m = (unsigned int *)evas_object_image_data_get (o, 1); if (!m) { free (data); return; } d = data + y * stride + x; for (yy = 0; yy < height; d += stride, m += width, ++yy) { memcpy (m, d, width * 4); } evas_object_image_data_update_add (o, 0, 0, width, height); evas_object_resize (o, width, height); free (data); }
unsigned int read_texture(Evas_Object *parent, const char *filename) { unsigned int gltex_object; int w, h; int surface_w, surface_h; evas_object_geometry_get(parent, NULL, NULL, &surface_w, &surface_h); Evas_Object* inline_buffer = elm_win_add(parent,"Img Read",ELM_WIN_INLINED_IMAGE); evas_object_move(inline_buffer, 0, 0); evas_object_resize(inline_buffer, surface_w, surface_h); evas_object_show(inline_buffer); Evas* canvas = evas_object_evas_get(inline_buffer); Evas_Object* image = evas_object_image_add(canvas); char path[200]; sprintf(path, "%s%s", app_get_resource_path(), filename); evas_object_image_file_set(image, path, NULL); evas_object_image_size_get(image, &w, &h); evas_object_image_fill_set(image, 0, 0, w, h); evas_object_image_filled_set(image, EINA_TRUE); evas_object_resize(image, w, h); evas_object_show(image); elm_win_render(inline_buffer); GLubyte* pixels; pixels = (GLubyte*) evas_object_image_data_get(image, EINA_FALSE); glPixelStorei(GL_UNPACK_ALIGNMENT, 1); glGenTextures(1, &gltex_object); glBindTexture(GL_TEXTURE_2D, gltex_object); glTexImage2D(GL_TEXTURE_2D, 0, GL_BGRA_EXT, w, h, 0, GL_BGRA_EXT, GL_UNSIGNED_BYTE, pixels); glGenerateMipmap(GL_TEXTURE_2D); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT); glBindTexture(GL_TEXTURE_2D, 0); evas_object_del(inline_buffer); return gltex_object; }
EAPI Eina_Bool efx_bumpmap(Evas_Object *obj, Evas_Coord x, Evas_Coord y) { EFX *e; Efx_Bumpmap_Data *ebd; EINA_SAFETY_ON_NULL_RETURN_VAL(obj, EINA_FALSE); e = evas_object_data_get(obj, "efx-data"); if (!e) e = efx_new(obj); EINA_SAFETY_ON_NULL_RETURN_VAL(e, EINA_FALSE); if (!e->bumpmap_data) e->bumpmap_data = calloc(1, sizeof(Efx_Bumpmap_Data)); EINA_SAFETY_ON_NULL_RETURN_VAL(e->bumpmap_data, EINA_FALSE); ebd = e->bumpmap_data; ebd->e = e; ebd->x = x; ebd->y = y; ebd->z = 30; ebd->depth = 0x200; ebd->red = 0x200; ebd->green = 0x200; ebd->blue = 0x200; ebd->ambient = 0; if (!ebd->img_data) { unsigned int *m; int w; int h; evas_object_image_size_get(obj, &w, &h); m = (unsigned int *)evas_object_image_data_get(obj, 1); ebd->img_data = (unsigned int *)malloc(w * h * sizeof(unsigned int)); if (!ebd->img_data) { free(ebd); return EINA_FALSE; } printf("memcpy\n"); memcpy(ebd->img_data, m, (w * h * sizeof(unsigned int))); evas_object_image_data_set(obj, m); } _bumpmap(ebd); return EINA_TRUE; (void)efx_speed_str; }
static Eina_Bool _ewk_view_single_smart_scrolls_process(Ewk_View_Smart_Data* smartData) { Evas_Coord imageWidth, imageHeight; void* pixels = evas_object_image_data_get(smartData->backing_store, 1); evas_object_image_size_get(smartData->backing_store, &imageWidth, &imageHeight); const WTF::Vector<WebCore::IntSize>& scrollOffset = ewk_view_scroll_offsets_get(smartData->_priv); const WTF::Vector<WebCore::IntRect>& rectsToScroll = ewk_view_scroll_rects_get(smartData->_priv); for (size_t i = 0; i < scrollOffset.size(); ++i) _ewk_view_single_scroll_process_single(smartData, pixels, imageWidth, imageHeight, scrollOffset[i], rectsToScroll[i]); evas_object_image_data_set(smartData->backing_store, pixels); return true; }
static bool _ewk_view_tiled_render_cb(void* data, Ewk_Tile* tile, const Eina_Rectangle* area) { Ewk_View_Private_Data* priv = static_cast<Ewk_View_Private_Data*>(data); Eina_Rectangle rect = {area->x + tile->x, area->y + tile->y, area->w, area->h}; uint8_t* pixels = static_cast<uint8_t*>(evas_object_image_data_get(tile->image, true)); Ewk_Paint_Context* context = ewk_paint_context_from_image_data_new(pixels, tile->width, tile->height, tile->cspace); ewk_paint_context_translate(context, -tile->x, -tile->y); bool result = ewk_view_paint_contents(priv, context, &rect); ewk_paint_context_free(context); evas_object_image_data_set(tile->image, pixels); return result; }
Ewk_Paint_Context* ewk_paint_context_from_image_new(Evas_Object* image) { EINA_SAFETY_ON_NULL_RETURN_VAL(image, 0); Evas_Coord width, height; uint8_t* pixels = static_cast<uint8_t*>(evas_object_image_data_get(image, true)); evas_object_image_size_get(image, &width, &height); Ewk_Paint_Context* context = ewk_paint_context_from_image_data_new(pixels, width, height, EVAS_COLORSPACE_ARGB8888); if (context) { context->pixels = pixels; context->image = image; } return context; }
static Eina_Bool _ewk_view_single_smart_scrolls_process(Ewk_View_Smart_Data *sd) { const Ewk_Scroll_Request *sr; const Ewk_Scroll_Request *sr_end; Evas_Coord ow, oh; size_t count; void *pixels = evas_object_image_data_get(sd->backing_store, 1); evas_object_image_size_get(sd->backing_store, &ow, &oh); sr = ewk_view_scroll_requests_get(sd->_priv, &count); sr_end = sr + count; for (; sr < sr_end; sr++) _ewk_view_single_scroll_process_single(sd, pixels, ow, oh, sr); return EINA_TRUE; }
int get_top_margin() { int imgw,imgh; int hor,ver; int firstpix; int *imgptr=evas_object_image_data_get(EWL_PDF(pdfwidget)->image,0); evas_object_image_size_get(EWL_PDF(pdfwidget)->image,&imgw,&imgh); firstpix=imgptr[0]; for(ver=0;ver<imgh;ver++) { for(hor=0;hor<imgw;hor++) { if(imgptr[ver*imgw+hor]!=firstpix) return ver; } } return 0; }
PassRefPtr<cairo_surface_t> createSurfaceForImage(Evas_Object* image) { ASSERT(image); Evas_Coord width; Evas_Coord height; evas_object_image_size_get(image, &width, &height); ASSERT(width > 0 && height > 0); unsigned char* buffer = static_cast<unsigned char*>(const_cast<void*>(evas_object_image_data_get(image, true))); RefPtr<cairo_surface_t> surface = adoptRef(cairo_image_surface_create_for_data(buffer, CAIRO_FORMAT_ARGB32, width, height, width * 4)); cairo_status_t status = cairo_surface_status(surface.get()); if (status != CAIRO_STATUS_SUCCESS) { EINA_LOG_ERR("Could not create cairo surface: %s", cairo_status_to_string(status)); return 0; } return surface.release(); }
void icon_editor_file_save() { if (!editor || !editor->edf) return; icon_editor_exec_set(ewl_entry_text_get(EWL_ENTRY(editor->exec.entry))); if (editor->icon_image) { int w, h; Evas_Object *im; im = EWL_IMAGE(editor->icon_image)->image; evas_object_image_size_get(im, &w, &h); icon_editor_image_data_set(evas_object_image_data_get(im, FALSE), w, h); } /* FIXME create a new file name based on the name */ /* (delete the old file first?) */ edje_edit_file_save(editor->edf, editor->file); }
int get_right_margin() { int imgw,imgh; int hor,ver; int firstpix; int *imgptr=evas_object_image_data_get(EWL_PDF(pdfwidget)->image,0); evas_object_image_size_get(EWL_PDF(pdfwidget)->image,&imgw,&imgh); firstpix=imgptr[imgw-1]; for(hor=imgw-1;hor>=0;hor--) { //fprintf(stderr,"firstpix:%d",firstpix); for(ver=0;ver<imgh;ver++) { //fprintf(stderr,"pix:%d",imgptr[ver*imgw+hor]); if(imgptr[ver*imgw+hor]!=firstpix) return imgw-1-hor; } } return 0; }
void _evas_object_bg_set (Evas_Object *o, int r, int g, int b) { unsigned int *m; int w, h; int i, j; evas_object_image_size_get (o, &w, &h); evas_object_image_fill_set (o, 0, 0, w, h); m = (unsigned int *)evas_object_image_data_get (o, 1); if (!m) return; for (j = 0; j < h; j++) { for (i = 0; i < w; i++) { m[j * w + i] = (255 << 24) | (r << 16) | (g << 8) | b; } } evas_object_image_data_update_add (o, 0, 0, w, h); evas_object_resize (o, w, h); }
int get_bottom_margin() { int imgw,imgh; int hor,ver; int firstpix; int curpix; int *imgptr=evas_object_image_data_get(EWL_PDF(pdfwidget)->image,0); evas_object_image_size_get(EWL_PDF(pdfwidget)->image,&imgw,&imgh); firstpix=imgptr[(imgh-1)*imgw]; for(ver=imgh-1;ver>=0;ver--) { for(hor=0;hor<imgw;hor++) { if(imgptr[ver*imgw+hor]!=firstpix) return imgh-1-ver; } } return 0; }
static void _emotion_image_data_zero(Evas_Object *img) { void *data = NULL; data = evas_object_image_data_get(img, 1); if (data) { int w, h, sz = 0; Evas_Colorspace cs; evas_object_image_size_get(img, &w, &h); cs = evas_object_image_colorspace_get(img); if (cs == EVAS_COLORSPACE_ARGB8888) sz = w * h * 4; if ((cs == EVAS_COLORSPACE_YCBCR422P601_PL) || (cs == EVAS_COLORSPACE_YCBCR422P709_PL)) sz = h * 2 * sizeof(unsigned char *); if (sz != 0) memset(data, 0, sz); } evas_object_image_data_set(img, data); }
static Eina_Bool _ecore_evas_buffer_prepare(Ecore_Evas *ee) { Ecore_Evas_Engine_Buffer_Data *bdata; bdata = ee->engine.data; if (bdata->image) { int w, h; evas_object_image_size_get(bdata->image, &w, &h); if ((w != ee->w) || (h != ee->h)) _ecore_evas_resize(ee, w, h); bdata->pixels = evas_object_image_data_get(bdata->image, 1); } else if (bdata->resized) { if (ee->func.fn_resize) ee->func.fn_resize(ee); bdata->resized = 0; } return EINA_TRUE; }
static Evas_Object* differenceImageFromDifferenceBuffer(Evas* evas, unsigned char* buffer, int width, int height) { Evas_Object* image = evas_object_image_filled_add(evas); if (!image) abortWithErrorMessage("could not create difference image"); evas_object_image_size_set(image, width, height); evas_object_image_colorspace_set(image, EVAS_COLORSPACE_ARGB8888); unsigned char* diffPixels = static_cast<unsigned char*>(evas_object_image_data_get(image, EINA_TRUE)); const int rowStride = evas_object_image_stride_get(image); for (int x = 0; x < width; x++) { for (int y = 0; y < height; y++) { unsigned char* diffPixel = pixelFromImageData(diffPixels, rowStride, x, y); diffPixel[Red] = diffPixel[Green] = diffPixel[Blue] = *buffer++; diffPixel[Alpha] = 0xff; } } evas_object_image_data_set(image, diffPixels); return image; }
void esmart_dvi_render (Evas_Object *obj) { Smart_Dvi *sp; E_SMART_OBJ_GET (sp, obj, E_OBJ_NAME); if (!sp->filename) return; if (sp->dvi_document) { if (sp->dvi_page) edvi_page_delete (sp->dvi_page); if (sp->obj) { unsigned int *m; int w; int h; sp->dvi_page = edvi_page_new (sp->dvi_document); edvi_page_size_get (sp->dvi_page, &w, &h); evas_object_image_size_set (sp->obj, w, h); evas_object_image_fill_set (sp->obj, 0, 0, w, h); m = (unsigned int *)evas_object_image_data_get (sp->obj, 1); if (!m) return; memset(m, (255 << 24) | (255 << 16) | (255 << 8) | 255, w * h * 4); evas_object_image_data_update_add (sp->obj, 0, 0, w, h); evas_object_resize (sp->obj, w, h); edvi_page_render (sp->dvi_page, sp->dvi_device, sp->obj); } evas_object_show (sp->obj); } }
void FileLoader::ReadTexture(const char *filename, TexData &out) const { Evas_Object * parent = SampleLauncher::GetInstance()->GetParent(); int w, h; int surface_w, surface_h; evas_object_geometry_get(parent, NULL, NULL, &surface_w, &surface_h); Evas_Object * inline_buffer = elm_win_add(parent, "Img Read", ELM_WIN_INLINED_IMAGE); evas_object_move(inline_buffer, 0, 0); evas_object_resize(inline_buffer, surface_w, surface_h); evas_object_show(inline_buffer); Evas *canvas = evas_object_evas_get(inline_buffer); Evas_Object * image = evas_object_image_add(canvas); char path[200]; sprintf(path, "%s%s", app_get_resource_path(), filename); evas_object_image_file_set(image, path, NULL); evas_object_image_size_get(image, &w, &h); evas_object_image_fill_set(image, 0, 0, w, h); evas_object_image_filled_set(image, EINA_TRUE); evas_object_resize(image, w, h); evas_object_show(image); elm_win_render(inline_buffer); GLubyte *pixels; pixels = static_cast<GLubyte *>(evas_object_image_data_get(image, EINA_FALSE)); out.SetData(w * h, pixels, w, h, GL_BGRA_EXT); evas_object_del(inline_buffer); }
void epdf_page_render (Epdf_Page *page, Evas_Object *o) { SplashOutputDev *output_dev; SplashColor white; SplashColorPtr color_ptr; Epdf_Document *doc; unsigned int *m = NULL; double hscale; double vscale; int rotate; int width; int height; double t1,t2; t1 = ecore_time_get(); white[0] = 255; white[1] = 255; white[2] = 255; white[3] = 255; if (!page->page || !page->page->isOk ()) return; doc = page->doc; output_dev = new SplashOutputDev(splashModeXBGR8, 4, gFalse, white); output_dev->startDoc(doc->pdfdoc->getXRef ()); switch (page->orientation) { case EPDF_PAGE_ORIENTATION_LANDSCAPE: rotate = 90; break; case EPDF_PAGE_ORIENTATION_UPSIDEDOWN: rotate = 180; break; case EPDF_PAGE_ORIENTATION_SEASCAPE: rotate = 270; break; case EPDF_PAGE_ORIENTATION_PORTRAIT: default: rotate = 0; break; } epdf_page_scale_get (page, &hscale, &vscale); page->page->display (output_dev, 72.0 * hscale, 72.0 * vscale, rotate, false, false, false, doc->pdfdoc->getCatalog ()); color_ptr = output_dev->getBitmap ()->getDataPtr (); width = output_dev->getBitmap()->getWidth(); height = output_dev->getBitmap()->getHeight(); evas_object_image_size_set(o, width, height); evas_object_image_fill_set(o, 0, 0, width, height); m = (unsigned int *)evas_object_image_data_get(o, 1); if (!m) goto sortie; memcpy (m, color_ptr, height * width * 4); evas_object_image_data_set(o, m); evas_object_image_data_update_add(o, 0, 0, width, height); evas_object_resize(o, width, height); // evas_object_image_alpha_set (o, 0); sortie: delete output_dev; t2 = ecore_time_get(); printf ("time poppler: %f\n", t2-t1); }
static float calculateDifference(Evas_Object* baselineImage, Evas_Object* actualImage, RefPtr<Evas_Object>& differenceImage) { int width, height, baselineWidth, baselineHeight; evas_object_image_size_get(actualImage, &width, &height); evas_object_image_size_get(baselineImage, &baselineWidth, &baselineHeight); if (width != baselineWidth || height != baselineHeight) { printf("Error, test and reference image have different sizes.\n"); return 100; // Completely different. } OwnArrayPtr<unsigned char> diffBuffer = adoptArrayPtr(new unsigned char[width * height]); if (!diffBuffer) abortWithErrorMessage("could not create difference buffer"); const int actualRowStride = evas_object_image_stride_get(actualImage); const int baseRowStride = evas_object_image_stride_get(baselineImage); unsigned numberOfDifferentPixels = 0; float totalDistance = 0; float maxDistance = 0; unsigned char* actualPixels = static_cast<unsigned char*>(evas_object_image_data_get(actualImage, EINA_FALSE)); unsigned char* basePixels = static_cast<unsigned char*>(evas_object_image_data_get(baselineImage, EINA_FALSE)); unsigned char* currentDiffPixel = diffBuffer.get(); for (int x = 0; x < width; x++) { for (int y = 0; y < height; y++) { unsigned char* actualPixel = pixelFromImageData(actualPixels, actualRowStride, x, y); unsigned char* basePixel = pixelFromImageData(basePixels, baseRowStride, x, y); const float distance = calculatePixelDifference(basePixel, actualPixel); *currentDiffPixel++ = static_cast<unsigned char>(distance * 255.0f); if (distance >= 1.0f / 255.0f) { ++numberOfDifferentPixels; totalDistance += distance; maxDistance = std::max<float>(maxDistance, distance); } } } // When using evas_object_image_data_get(), a complementary evas_object_data_set() must be // issued to balance the reference count, even if the image hasn't been changed. evas_object_image_data_set(baselineImage, basePixels); evas_object_image_data_set(actualImage, actualPixels); // Compute the difference as a percentage combining both the number of // different pixels and their difference amount i.e. the average distance // over the entire image float difference = 0; if (numberOfDifferentPixels) difference = 100.0f * totalDistance / (height * width); if (difference <= gTolerance) difference = 0; else { difference = roundf(difference * 100.0f) / 100.0f; difference = std::max(difference, 0.01f); // round to 2 decimal places differenceImage = adoptRef(differenceImageFromDifferenceBuffer(evas_object_evas_get(baselineImage), diffBuffer.get(), width, height)); } return difference; }
bool EflResources::copyResource( Evas_Object* const _image , std::string const& _path , bool const _keep_aspect , int _width , int _height ) const { bool result( true ); Evas_Object* object = nullptr; if( 0 != preloaded_images__.count( _path ) ) object = preloaded_images__.find( _path )->second; else { object = preloaded_images__.find( IMG_DIR "/placeholder.png" )->second; LOGGER( "Could not find file among preloaded images: " + _path ); result = false; } int src_w = 0; int src_h = 0; evas_object_image_size_get( object , &src_w , &src_h ); evas_object_image_size_set( _image , src_w , src_h ); evas_object_image_alpha_set( _image , evas_object_image_alpha_get( object ) ); evas_object_image_data_set( _image , evas_object_image_data_get( object , 0 ) ); if( _keep_aspect ) { if( 0 == _width || 0 == _height ) { evas_object_geometry_get( _image , nullptr , nullptr , &_width , &_height ); } int new_w = 0; int new_h = 0; Utility::calculateImageSize( _width , _height , src_w , src_h , new_w , new_h ); evas_object_resize( _image , new_w , new_h ); } evas_object_image_pixels_dirty_set( _image , 1 ); return result; }
static void _bumpmap(Efx_Bumpmap_Data *ebd) { Evas_Object *o; int w; int h; int i, j; int x; int y; int z; int depth; int red; int green; int blue; int ambient; double z_2, lightx, lighty; int mx; int my; unsigned int *d1; unsigned int *d2; unsigned int *src; unsigned int *mp; unsigned int *mpy; unsigned int *mpp; x = ebd->x; y = ebd->y; z = ebd->z; red = ebd->red / 0x100; green = ebd->green / 0x100; blue = ebd->blue / 0x100; ambient = ebd->ambient / 0x100; depth = ebd->depth / 0x100; depth /= (255 * (255 + 255 + 255)); z_2 = z * z; o = ebd->e->obj; evas_object_image_size_get(o, &w, &h); if ((!w) || (!h)) return; d1 = malloc(w * h * sizeof(int)); memcpy(d1, ebd->img_data, w * h * sizeof(int)); src = d1; d2 = malloc(w * h * sizeof(int)); memcpy(d2, ebd->img_data, w * h * sizeof(int)); mpp = d2; my = h; lighty = -y; for (j = h; --j >= 0;) { mp = mpp; mpp += w; if (--my <= 0) { mpp -= w * h; my = h; } mpy = mpp; mx = w; lightx = -x; i = w - 1; do { double x1, y_1, v; int r, g, b, gr; gr = A_VAL(mp) * (R_VAL(mp) + G_VAL(mp) + B_VAL(mp)); y_1 = depth * (double)(A_VAL(mpy) * (R_VAL(mpy) + G_VAL(mpy) + B_VAL(mpy)) - gr); mp++; mpy++; if (--mx <= 0) { mp -= w; mpy -= w; mx = w; } x1 = depth * (double)(A_VAL(mp) * (R_VAL(mp) + G_VAL(mp) + B_VAL(mp)) - gr); v = x1 * lightx + y_1 * lighty + z; v /= sqrt((x1 * x1) + (y_1 * y_1) + 1.0); v /= sqrt((lightx * lightx) + (lighty * lighty) + z_2); v += ambient; r = v * R_VAL(src) * red; g = v * G_VAL(src) * green; b = v * B_VAL(src) * blue; if (r < 0) r = 0; else if (r > 255) r = 255; if (g < 0) g = 0; else if (g > 255) g = 255; if (b < 0) b = 0; else if (b > 255) b = 255; R_VAL(src) = r; G_VAL(src) = g; B_VAL(src) = b; lightx++; src++; } while (--i >= 0); lighty++; } unsigned int *m; m = (unsigned int *)evas_object_image_data_get(o, 1); memcpy(m, d1, w * h * sizeof(unsigned int)); evas_object_image_data_set(o, m); evas_object_image_data_update_add(o, 0, 0, w, h); free(d1); free(d2); }
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); }
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); }