Пример #1
0
IntRect ContentLayerChromium::visibleLayerRect(const IntRect& targetSurfaceRect)
{
    if (targetSurfaceRect.isEmpty())
        return targetSurfaceRect;

    const IntRect layerBoundRect = layerBounds();
    const TransformationMatrix transform = tilingTransform();

    // Is this layer fully contained within the target surface?
    IntRect layerInSurfaceSpace = transform.mapRect(layerBoundRect);
    if (targetSurfaceRect.contains(layerInSurfaceSpace))
        return layerBoundRect;

    // If the layer doesn't fill up the entire surface, then find the part of
    // the surface rect where the layer could be visible. This avoids trying to
    // project surface rect points that are behind the projection point.
    IntRect minimalSurfaceRect = targetSurfaceRect;
    minimalSurfaceRect.intersect(layerInSurfaceSpace);

    // Project the corners of the target surface rect into the layer space.
    // This bounding rectangle may be larger than it needs to be (being
    // axis-aligned), but is a reasonable filter on the space to consider.
    // Non-invertible transforms will create an empty rect here.
    const TransformationMatrix surfaceToLayer = transform.inverse();
    IntRect layerRect = surfaceToLayer.projectQuad(FloatQuad(FloatRect(minimalSurfaceRect))).enclosingBoundingBox();
    layerRect.intersect(layerBoundRect);
    return layerRect;
}
Пример #2
0
void ContentLayerChromium::draw(const IntRect& targetSurfaceRect)
{
    const TransformationMatrix transform = tilingTransform();
    IntRect layerRect = visibleLayerRect(targetSurfaceRect);
    if (!layerRect.isEmpty())
        m_tiler->draw(layerRect, transform, ccLayerImpl()->drawOpacity());
}
Пример #3
0
void TiledLayerChromium::pushPropertiesTo(CCLayerImpl* layer)
{
    LayerChromium::pushPropertiesTo(layer);

    CCTiledLayerImpl* tiledLayer = static_cast<CCTiledLayerImpl*>(layer);
    if (!m_tiler) {
        tiledLayer->setSkipsDraw(true);
        return;
    }

    tiledLayer->setTilingTransform(tilingTransform());
    tiledLayer->setSkipsDraw(m_skipsDraw);
    tiledLayer->setTextureOrientation(m_textureOrientation);
    tiledLayer->setSampledTexelFormat(m_sampledTexelFormat);
    tiledLayer->setTilingData(*m_tiler);

    for (CCLayerTilingData::TileMap::const_iterator iter = m_tiler->tiles().begin(); iter != m_tiler->tiles().end(); ++iter) {
        int i = iter->first.first;
        int j = iter->first.second;
        UpdatableTile* tile = static_cast<UpdatableTile*>(iter->second.get());
        if (!tile->texture()->isValid(m_tiler->tileSize(), m_textureFormat))
            continue;

        tiledLayer->syncTextureId(i, j, tile->texture()->textureId());
    }
}