当前位置: 首页>>代码示例>>C++>>正文


C++ FillLayer::backgroundXOrigin方法代码示例

本文整理汇总了C++中FillLayer::backgroundXOrigin方法的典型用法代码示例。如果您正苦于以下问题:C++ FillLayer::backgroundXOrigin方法的具体用法?C++ FillLayer::backgroundXOrigin怎么用?C++ FillLayer::backgroundXOrigin使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在FillLayer的用法示例。


在下文中一共展示了FillLayer::backgroundXOrigin方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: setRepeatX

void BackgroundImageGeometry::setRepeatX(const FillLayer& fillLayer,
                                         LayoutUnit unsnappedTileWidth,
                                         LayoutUnit snappedAvailableWidth,
                                         LayoutUnit unsnappedAvailableWidth,
                                         LayoutUnit extraOffset) {
  // We would like to identify the phase as a fraction of the image size in the
  // absence of snapping, then re-apply it to the snapped values. This is to
  // handle large positions.
  if (unsnappedTileWidth) {
    LayoutUnit computedXPosition = roundedMinimumValueForLength(
        fillLayer.xPosition(), unsnappedAvailableWidth);
    if (fillLayer.backgroundXOrigin() == RightEdge) {
      float numberOfTilesInPosition =
          (snappedAvailableWidth - computedXPosition + extraOffset).toFloat() /
          unsnappedTileWidth.toFloat();
      float fractionalPositionWithinTile =
          numberOfTilesInPosition - truncf(numberOfTilesInPosition);
      setPhaseX(LayoutUnit(
          roundf(fractionalPositionWithinTile * tileSize().width())));
    } else {
      float numberOfTilesInPosition =
          (computedXPosition + extraOffset).toFloat() /
          unsnappedTileWidth.toFloat();
      float fractionalPositionWithinTile =
          1.0f - (numberOfTilesInPosition - truncf(numberOfTilesInPosition));
      setPhaseX(LayoutUnit(
          roundf(fractionalPositionWithinTile * tileSize().width())));
    }
  } else {
    setPhaseX(LayoutUnit());
  }
  setSpaceSize(LayoutSize(LayoutUnit(), spaceSize().height()));
}
开发者ID:mirror,项目名称:chromium,代码行数:33,代码来源:BackgroundImageGeometry.cpp

示例2: calculate


//.........这里部分代码省略.........
      positioningAreaSize.height() - tileSize().height();

  LayoutUnit computedXPosition =
      roundedMinimumValueForLength(fillLayer.xPosition(), availableWidth);
  if (backgroundRepeatX == RoundFill &&
      positioningAreaSize.width() > LayoutUnit() &&
      fillTileSize.width() > LayoutUnit()) {
    int nrTiles = std::max(
        1, roundToInt(positioningAreaSize.width() / fillTileSize.width()));
    LayoutUnit roundedWidth = positioningAreaSize.width() / nrTiles;

    // Maintain aspect ratio if background-size: auto is set
    if (fillLayer.size().size.height().isAuto() &&
        backgroundRepeatY != RoundFill) {
      fillTileSize.setHeight(fillTileSize.height() * roundedWidth /
                             fillTileSize.width());
    }
    fillTileSize.setWidth(roundedWidth);

    setTileSize(applySubPixelHeuristicToImageSize(fillTileSize, m_destRect));
    setPhaseX(tileSize().width()
                  ? LayoutUnit(roundf(
                        tileSize().width() -
                        fmodf((computedXPosition + left), tileSize().width())))
                  : LayoutUnit());
    setSpaceSize(LayoutSize());
  }

  LayoutUnit computedYPosition =
      roundedMinimumValueForLength(fillLayer.yPosition(), availableHeight);
  if (backgroundRepeatY == RoundFill &&
      positioningAreaSize.height() > LayoutUnit() &&
      fillTileSize.height() > LayoutUnit()) {
    int nrTiles = std::max(
        1, roundToInt(positioningAreaSize.height() / fillTileSize.height()));
    LayoutUnit roundedHeight = positioningAreaSize.height() / nrTiles;
    // Maintain aspect ratio if background-size: auto is set
    if (fillLayer.size().size.width().isAuto() &&
        backgroundRepeatX != RoundFill) {
      fillTileSize.setWidth(fillTileSize.width() * roundedHeight /
                            fillTileSize.height());
    }
    fillTileSize.setHeight(roundedHeight);

    setTileSize(applySubPixelHeuristicToImageSize(fillTileSize, m_destRect));
    setPhaseY(tileSize().height()
                  ? LayoutUnit(roundf(
                        tileSize().height() -
                        fmodf((computedYPosition + top), tileSize().height())))
                  : LayoutUnit());
    setSpaceSize(LayoutSize());
  }

  if (backgroundRepeatX == RepeatFill) {
    setRepeatX(fillLayer, fillTileSize.width(), availableWidth,
               unsnappedAvailableWidth, left);
  } else if (backgroundRepeatX == SpaceFill &&
             tileSize().width() > LayoutUnit()) {
    LayoutUnit space = getSpaceBetweenImageTiles(positioningAreaSize.width(),
                                                 tileSize().width());
    if (space >= LayoutUnit())
      setSpaceX(space, availableWidth, left);
    else
      backgroundRepeatX = NoRepeatFill;
  }
  if (backgroundRepeatX == NoRepeatFill) {
    LayoutUnit xOffset = fillLayer.backgroundXOrigin() == RightEdge
                             ? availableWidth - computedXPosition
                             : computedXPosition;
    setNoRepeatX(left + xOffset);
  }

  if (backgroundRepeatY == RepeatFill) {
    setRepeatY(fillLayer, fillTileSize.height(), availableHeight,
               unsnappedAvailableHeight, top);
  } else if (backgroundRepeatY == SpaceFill &&
             tileSize().height() > LayoutUnit()) {
    LayoutUnit space = getSpaceBetweenImageTiles(positioningAreaSize.height(),
                                                 tileSize().height());
    if (space >= LayoutUnit())
      setSpaceY(space, availableHeight, top);
    else
      backgroundRepeatY = NoRepeatFill;
  }
  if (backgroundRepeatY == NoRepeatFill) {
    LayoutUnit yOffset = fillLayer.backgroundYOrigin() == BottomEdge
                             ? availableHeight - computedYPosition
                             : computedYPosition;
    setNoRepeatY(top + yOffset);
  }

  if (fixedAttachment)
    useFixedAttachment(paintRect.location());

  // Clip the final output rect to the paint rect
  m_destRect.intersect(paintRect);

  // Snap as-yet unsnapped values.
  setDestRect(LayoutRect(pixelSnappedIntRect(m_destRect)));
}
开发者ID:mirror,项目名称:chromium,代码行数:101,代码来源:BackgroundImageGeometry.cpp


注:本文中的FillLayer::backgroundXOrigin方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。