Exemple #1
0
void ScrollView::removeChild(Widget* widget)
{
    m_data->m_children.remove(widget);

    if (nativeWindow() && widget->nativeWindow()) {
        nativeWindow()->RemoveChild(widget->nativeWindow());
        // FIXME: Is this the right place to do deletion? I see
        // detachFromParent2/3/4, initiated by FrameLoader::detachFromParent,
        // but I'm not sure if it's better to handle there or not.
        widget->nativeWindow()->Destroy();
    }
}
Exemple #2
0
bool ScrollView::inWindow() const
{
    // NB: This is called from RenderObject::willRenderImage
    // and really seems to be more of a "is the window in a valid state" test,
    // despite the API name.
    return nativeWindow() != NULL;
}
Exemple #3
0
void ScrollView::resizeContents(int w,int h)
{
    wxWindow* win = nativeWindow();
    if (win) {
        win->SetVirtualSize(w, h);
        adjustScrollbars();
    }
}
Exemple #4
0
int ScrollView::contentsHeight() const
{
    int height = 0;
    wxWindow* win = nativeWindow();
    if (win)
        win->GetVirtualSize(NULL, &height);
    ASSERT(height >= 0);
    return height;
}
Exemple #5
0
int ScrollView::contentsWidth() const
{
    int width = 0;
    wxWindow* win = nativeWindow();
    if (win)
        win->GetVirtualSize(&width, NULL);
    ASSERT(width >= 0);
    return width;
}
Exemple #6
0
int ScrollView::visibleWidth() const
{
    int width = 0;
    wxWindow* win = nativeWindow();
    if (win)
        win->GetClientSize(&width, NULL);
    
    ASSERT(width >= 0);
    return width;
}
Exemple #7
0
int ScrollView::visibleHeight() const
{
    int height = 0;
    wxWindow* win = nativeWindow();
    if (win)
        win->GetClientSize(NULL, &height);
    
    ASSERT(height >= 0);
    return height;
}
Exemple #8
0
void ScrollView::updateContents(const IntRect& updateRect, bool now)
{
    // we need to convert coordinates to scrolled position
    wxRect contentsRect = updateRect;
    contentsRect.Offset(-contentsX(), -contentsY());
    wxWindow* win = nativeWindow();
    if (win) {
        win->RefreshRect(contentsRect, true);
        if (now)
            win->Update();
    }
}
Exemple #9
0
void ScrollView::adjustScrollbars(int x, int y, bool refresh)
{
    wxWindow* win = nativeWindow();
    if (!win)
        return;

    wxRect crect(win->GetClientRect()), vrect(win->GetVirtualSize());

    if (x == -1) x = m_data->viewStart.x;
    if (y == -1) y = m_data->viewStart.y;

    long style = win->GetWindowStyle();

    // by setting the wxALWAYS_SHOW_SB wxWindow flag before
    // each SetScrollbar call, we can control the scrollbars
    // visibility individually.

    // horizontal scrollbar
    switch (m_data->hScrollbarMode) {
        case ScrollbarAlwaysOff:
            win->SetWindowStyleFlag(style & ~wxALWAYS_SHOW_SB);
            win->SetScrollbar(wxHORIZONTAL, 0, 0, 0, refresh);
            break;

        case ScrollbarAuto:
            win->SetWindowStyleFlag(style & ~wxALWAYS_SHOW_SB);
            win->SetScrollbar(wxHORIZONTAL, x, crect.width, vrect.width, refresh);
            break;

        default: // ScrollbarAlwaysOn
            win->SetWindowStyleFlag(style | wxALWAYS_SHOW_SB);
            win->SetScrollbar(wxHORIZONTAL, x, crect.width, vrect.width, refresh);
            break;
    }

    // vertical scrollbar
    switch (m_data->vScrollbarMode) {
        case ScrollbarAlwaysOff:
            win->SetWindowStyleFlag(style & ~wxALWAYS_SHOW_SB);
            win->SetScrollbar(wxVERTICAL, 0, 0, 0, refresh);
            break;

        case ScrollbarAlwaysOn:
            win->SetWindowStyleFlag(style | wxALWAYS_SHOW_SB);
            win->SetScrollbar(wxVERTICAL, y, crect.height, vrect.height, refresh);
            break;

        default: // case ScrollbarAuto:
            win->SetWindowStyleFlag(style & ~wxALWAYS_SHOW_SB);
            win->SetScrollbar(wxVERTICAL, y, crect.height, vrect.height, refresh);
    }
}
Exemple #10
0
bool CanvasTexture::uploadImageBitmap(SkBitmap* bitmap)
{
    m_hasValidTexture = false;
    SurfaceTextureClient* anw = nativeWindow();
    if (!anw)
        return false;
    // Size mismatch, early abort (will fall back to software)
    if (bitmap->width() != m_size.width() ||
            bitmap->height() != m_size.height())
        return false;

    if (!GLUtils::updateSharedSurfaceTextureWithBitmap(anw, *bitmap))
        return false;
    m_hasValidTexture = true;
    return true;
}
Exemple #11
0
bool CanvasTexture::uploadImageBuffer(ImageBuffer* imageBuffer)
{
    m_hasValidTexture = false;
    SurfaceTextureClient* anw = nativeWindow();
    if (!anw || ! imageBuffer) // CAPPFIX_WEB_NULL_CHECK_CANVASTEXTURE
        return false;
    // Size mismatch, early abort (will fall back to software)
    if (imageBuffer->size() != m_size)
        return false;
    SkCanvas* canvas = imageBufferCanvas(imageBuffer);
    if (!canvas)
        return false;
    const SkBitmap& bitmap = canvas->getDevice()->accessBitmap(false);
    if (!GLUtils::updateSharedSurfaceTextureWithBitmap(anw, bitmap))
        return false;
    m_hasValidTexture = true;
    return true;
}
bool CanvasTexture::uploadImageBuffer(ImageBuffer* imageBuffer)
{
    m_hasValidTexture = false;
    SurfaceTextureClient* anw = nativeWindow();
    if (!anw)
        return false;
    // Size mismatch, early abort (will fall back to software)
    if (imageBuffer->size() != m_size)
        return false;
    GraphicsContext* gc = imageBuffer ? imageBuffer->context() : 0;
    if (!gc)
        return false;
    const SkBitmap& bitmap = android_gc2canvas(gc)->getDevice()->accessBitmap(false);
    if (!GLUtils::updateSharedSurfaceTextureWithBitmap(anw, bitmap))
        return false;
    m_hasValidTexture = true;
    return true;
}
Exemple #13
0
void ScrollView::scrollBy(int dx, int dy)
{
    wxWindow* win = nativeWindow();
    if (!win)
        return;

    wxPoint scrollOffset = m_data->viewStart;
    wxPoint orig(scrollOffset);
    wxPoint newScrollOffset = scrollOffset + wxPoint(dx, dy);

    wxRect vRect(win->GetVirtualSize());
    wxRect cRect(win->GetClientSize());

    // clamp to scroll area
    if (newScrollOffset.x < 0)
        newScrollOffset.x = 0;
    else if (newScrollOffset.x + cRect.width > vRect.width)
        newScrollOffset.x = max(0, vRect.width - cRect.width - 1);

    if (newScrollOffset.y < 0)
        newScrollOffset.y = 0;
    else if (newScrollOffset.y + cRect.height > vRect.height)
        newScrollOffset.y = max(0, vRect.height - cRect.height - 1);

    if (newScrollOffset == scrollOffset)
        return;

    m_data->viewStart = newScrollOffset;

    wxPoint delta(orig - newScrollOffset);

    if (m_data->hasStaticBackground)
        win->Refresh();
    else
        win->ScrollWindow(delta.x, delta.y);

    adjustScrollbars();
}
Exemple #14
0
EGLSurface QEgl::createSurface(QPaintDevice *device, EGLConfig cfg, const QEglProperties *properties)
{
    // Create the native drawable for the paint device.
    int devType = device->devType();
    EGLNativePixmapType pixmapDrawable = 0;
    EGLNativeWindowType windowDrawable = 0;
    bool ok;
    if (devType == QInternal::Pixmap) {
        pixmapDrawable = nativePixmap(static_cast<QPixmap *>(device));
        ok = (pixmapDrawable != 0);
    } else if (devType == QInternal::Widget) {
        windowDrawable = nativeWindow(static_cast<QWidget *>(device));
        ok = (windowDrawable != 0);
    } else {
        ok = false;
    }
    if (!ok) {
        qWarning("QEglContext::createSurface(): Cannot create the native EGL drawable");
        return EGL_NO_SURFACE;
    }

    // Create the EGL surface to draw into, based on the native drawable.
    const int *props;
    if (properties)
        props = properties->properties();
    else
        props = 0;
    EGLSurface surf;
    if (devType == QInternal::Widget)
        surf = eglCreateWindowSurface(QEgl::display(), cfg, windowDrawable, props);
    else
        surf = eglCreatePixmapSurface(QEgl::display(), cfg, pixmapDrawable, props);
    if (surf == EGL_NO_SURFACE) {
        qWarning("QEglContext::createSurface(): Unable to create EGL surface, error = 0x%x", eglGetError());
    }
    return surf;
}
Exemple #15
0
void ScrollView::update()
{
    wxWindow* win = nativeWindow();
    if (win)
        win->Update();
}
Exemple #16
0
EGLSurface QEgl::createSurface(QPaintDevice *device, EGLConfig cfg, const QEglProperties *properties)
{
    // Create the native drawable for the paint device.
    int devType = device->devType();
    EGLNativePixmapType pixmapDrawable = 0;
    EGLNativeWindowType windowDrawable = 0;
    bool ok;
    if (devType == QInternal::Pixmap) {
        pixmapDrawable = nativePixmap(static_cast<QPixmap *>(device));
        ok = (pixmapDrawable != 0);
    } else if (devType == QInternal::Widget) {
        windowDrawable = nativeWindow(static_cast<QWidget *>(device));
        ok = (windowDrawable != 0);
    } else {
        ok = false;
    }
    if (!ok) {
        qWarning("QEglContext::createSurface(): Cannot create the native EGL drawable");
        return EGL_NO_SURFACE;
    }

    // Create the EGL surface to draw into, based on the native drawable.
    const int *props;
    if (properties)
        props = properties->properties();
    else
        props = 0;
    EGLSurface surf = EGL_NO_SURFACE;
#ifdef Q_OS_SYMBIAN
    // On Symbian there might be situations (especially on 32MB GPU devices)
    // where Qt is trying to create EGL surface while some other application
    // is still holding all available GPU memory but is about to release it
    // soon. For an example when exiting native video recorder and going back to
    // Qt application behind it. Video stack tear down takes some time and Qt
    // app might be too quick in reserving its EGL surface and thus running out
    // of GPU memory right away. So if EGL surface creation fails due to bad
    // alloc, let's try recreating it four times within ~1 second if needed.
    // This strategy gives some time for video recorder to tear down its stack
    // and a chance to Qt for creating a valid surface.
    // If the surface is still failing however, we don't keep the app blocked.
    static int tries = 4;
    if (tries <= 0)
        tries = 1;
    while (tries-- > 0) {
        if (devType == QInternal::Widget)
            surf = eglCreateWindowSurface(QEgl::display(), cfg, windowDrawable, props);
        else
            surf = eglCreatePixmapSurface(QEgl::display(), cfg, pixmapDrawable, props);
        if (surf == EGL_NO_SURFACE) {
            EGLint error = eglGetError();
            if (error == EGL_BAD_ALLOC) {
                if (tries > 0) {
                    User::After(1000 * 250); // 250ms
                    continue;
                }
            }
            qWarning("QEglContext::createSurface(): Unable to create EGL surface, error = 0x%x", error);
            S60->eglSurfaceCreationError = true;
        } else {
            tries = 4;
            break;
        }
    }
#else
    if (devType == QInternal::Widget)
        surf = eglCreateWindowSurface(QEgl::display(), cfg, windowDrawable, props);
    else
        surf = eglCreatePixmapSurface(QEgl::display(), cfg, pixmapDrawable, props);
    if (surf == EGL_NO_SURFACE) {
        qWarning("QEglContext::createSurface(): Unable to create EGL surface, error = 0x%x", eglGetError());
    }
#endif
    return surf;
}