Ejemplo n.º 1
0
void PluginWidgetAndroid::setWindow(NPWindow* window, bool isTransparent) {

    // store the reference locally for easy lookup
    m_pluginWindow = window;

    // make a copy of the previous bounds
    SkIRect oldPluginBounds = m_pluginBounds;

    // keep a local copy of the plugin bounds because the m_pluginWindow pointer
    // gets updated values prior to this method being called
    m_pluginBounds.set(m_pluginWindow->x, m_pluginWindow->y,
                       m_pluginWindow->x + m_pluginWindow->width,
                       m_pluginWindow->y + m_pluginWindow->height);

    PLUGIN_LOG("%p PluginBounds (%d,%d,%d,%d)", m_pluginView->instance(),
               m_pluginBounds.fLeft, m_pluginBounds.fTop,
               m_pluginBounds.fRight, m_pluginBounds.fBottom);

    layoutSurface(m_pluginBounds != oldPluginBounds);

    if (m_drawingModel != kSurface_ANPDrawingModel) {
        m_flipPixelRef->safeUnref();
        m_flipPixelRef = new SkFlipPixelRef(computeConfig(isTransparent),
                                            window->width, window->height);
    }
}
void PluginWidgetAndroid::setWindow(int x, int y, int width, int height,
                                    bool isTransparent) {
    m_x = x;
    m_y = y;
    m_flipPixelRef->safeUnref();
    m_flipPixelRef = new SkFlipPixelRef(computeConfig(isTransparent),
                                        width, height);
}
void PluginWidgetAndroid::setWindow(NPWindow* window, bool isTransparent) {

    // store the reference locally for easy lookup
    m_pluginWindow = window;

    // make a copy of the previous bounds
    SkIRect oldPluginBounds = m_pluginBounds;

    // keep a local copy of the plugin bounds because the m_pluginWindow pointer
    // gets updated values prior to this method being called
    m_pluginBounds.set(m_pluginWindow->x, m_pluginWindow->y,
                       m_pluginWindow->x + m_pluginWindow->width,
                       m_pluginWindow->y + m_pluginWindow->height);

    PLUGIN_LOG("%p PluginBounds (%d,%d,%d,%d)", m_pluginView->instance(),
               m_pluginBounds.fLeft, m_pluginBounds.fTop,
               m_pluginBounds.fRight, m_pluginBounds.fBottom);

    const bool boundsChanged = m_pluginBounds != oldPluginBounds;

    //TODO hack to ensure that we grab the most recent screen dimensions and scale
    ANPRectI screenCoords;
    m_core->getVisibleScreen(screenCoords);
    float scale = m_core->scale();
    bool scaleChanged = m_cachedZoomLevel != scale;
    setVisibleScreen(screenCoords, scale);

    // if the scale changed then setVisibleScreen will call this function and
    // this call will potentially fire a duplicate draw event
    if (!scaleChanged) {
        sendSizeAndVisibilityEvents(boundsChanged);
    }
    layoutSurface(boundsChanged);

    if (m_drawingModel != kSurface_ANPDrawingModel) {
        SkSafeUnref(m_flipPixelRef);
        m_flipPixelRef = new SkFlipPixelRef(computeConfig(isTransparent),
                                            window->width, window->height);
    }
}