Ejemplo n.º 1
0
void BaseLayerAndroid::updatePositionsRecursive(const SkRect& visibleContentRect)
{
    TRACE_METHOD();

    updateLayerPositions(visibleContentRect);
    TransformationMatrix ident;

    // Start with an unnecessarily large clip, since the base layer can
    // dynamically increase in size to cover the viewport, and we cache its draw
    // clip. This way the base layer will never have it's visible area clipped
    // by its m_clippingRect, only the viewport.
    // Note: values larger than this suffer from floating point rounding issues
    FloatRect clip(0, 0, 1e7, 1e7);

    bool forcePositionCalculation = !m_positionsCalculated;
    float scale = 1.0f;
    // To minimize tearing in single surface mode, don't update the fixed element
    // when scrolling. The fixed element will move incorrectly when scrolling,
    // but its position will be corrected after scrolling.
    bool disableFixedElemUpdate = false;
    GLWebViewState* webViewState = state();
    if (webViewState) {
        scale = webViewState->scale();
        disableFixedElemUpdate = webViewState->isScrolling()
                                 && webViewState->isSingleSurfaceRenderingMode();
    }
    updateGLPositionsAndScale(ident, clip, 1, scale, forcePositionCalculation,
                              disableFixedElemUpdate);

    m_positionsCalculated = true;
}
void SurfaceCollection::prepareGL(const SkRect& visibleContentRect, bool tryToFastBlit)
{
    TRACE_METHOD();
    updateLayerPositions(visibleContentRect);
    bool layerTilesDisabled = m_compositedRoot->state()->isSingleSurfaceRenderingMode();
    if (!layerTilesDisabled) {
        for (unsigned int i = 0; tryToFastBlit && i < m_surfaces.size(); i++)
            tryToFastBlit &= m_surfaces[i]->canUpdateWithBlit();
    }
    for (unsigned int i = 0; i < m_surfaces.size(); i++)
        m_surfaces[i]->prepareGL(layerTilesDisabled, tryToFastBlit);
}
bool SurfaceCollection::drawGL(const SkRect& visibleContentRect)
{
    TRACE_METHOD();
#ifdef DEBUG_COUNT
    ClassTracker::instance()->show();
#endif

    bool needsRedraw = false;
    updateLayerPositions(visibleContentRect);
    bool layerTilesDisabled = m_compositedRoot->state()->isSingleSurfaceRenderingMode();

    // create a duplicate vector of surfaces, sorted by z value
    Vector <Surface*> surfaces;
    for (unsigned int i = 0; i < m_surfaces.size(); i++)
        surfaces.append(m_surfaces[i]);
    std::stable_sort(surfaces.begin()+1, surfaces.end(), compareSurfaceZ);

    // draw the sorted vector
    for (unsigned int i = 0; i < m_surfaces.size(); i++)
        needsRedraw |= surfaces[i]->drawGL(layerTilesDisabled);

    return needsRedraw;
}