Example #1
0
// We keep two copies of the surface here, which will double the memory usage, but increase
// scrolling performance since we do not have to keep reallocating a memory region during
// quick scrolling requests.
WidgetBackingStoreCairo::WidgetBackingStoreCairo(PlatformWidget widget, const IntSize& size)
    : WidgetBackingStore(size)
    , m_surface(createSurfaceForBackingStore(widget, size))
    , m_scrollSurface(createSurfaceForBackingStore(widget, size))
		, m_widget(widget)

{

}
PassOwnPtr<RenderThemeEfl::ThemePartCacheEntry> RenderThemeEfl::ThemePartCacheEntry::create(const String& themePath, FormType type, const IntSize& size)
{
    ASSERT(!themePath.isEmpty());

    if (isFormElementTooLargeToDisplay(size) || size.isEmpty()) {
        EINA_LOG_ERR("Cannot render an element of size %dx%d.", size.width(), size.height());
        return nullptr;
    }

    OwnPtr<ThemePartCacheEntry> entry = adoptPtr(new ThemePartCacheEntry);

    entry->m_canvas = adoptPtr(ecore_evas_buffer_new(size.width(), size.height()));
    if (!entry->canvas()) {
        EINA_LOG_ERR("ecore_evas_buffer_new(%d, %d) failed.", size.width(), size.height());
        return nullptr;
    }

    // By default EFL creates buffers without alpha.
    ecore_evas_alpha_set(entry->canvas(), EINA_TRUE);

    entry->m_edje = adoptRef(edje_object_add(ecore_evas_get(entry->canvas())));
    ASSERT(entry->edje());

    if (!setSourceGroupForEdjeObject(entry->edje(), themePath, toEdjeGroup(type)))
        return nullptr;

    entry->m_surface = createSurfaceForBackingStore(entry->canvas());
    if (!entry->surface())
        return nullptr;

    evas_object_resize(entry->edje(), size.width(), size.height());
    evas_object_show(entry->edje());

    entry->type = type;
    entry->size = size;

    return entry.release();
}
void RenderThemeEfl::ThemePartCacheEntry::reuse(const String& themePath, FormType newType, const IntSize& newSize)
{
    ASSERT(!themePath.isEmpty());

    if (type != newType) {
        type = newType;
        if (!setSourceGroupForEdjeObject(edje(), themePath, toEdjeGroup(newType))) {
            type = FormTypeLast; // Invalidate.
            return;
        }
    }

    if (size != newSize) {
        size = newSize;
        ecore_evas_resize(canvas(), newSize.width(), newSize.height());
        evas_object_resize(edje(), newSize.width(), newSize.height());

        m_surface = createSurfaceForBackingStore(canvas());
        if (!surface()) {
            type = FormTypeLast; // Invalidate;
            return;
        }
    }
}