本文整理汇总了C++中HTMLVideoElement::RotationDegrees方法的典型用法代码示例。如果您正苦于以下问题:C++ HTMLVideoElement::RotationDegrees方法的具体用法?C++ HTMLVideoElement::RotationDegrees怎么用?C++ HTMLVideoElement::RotationDegrees使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类HTMLVideoElement
的用法示例。
在下文中一共展示了HTMLVideoElement::RotationDegrees方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: aspectRatio
already_AddRefed<Layer>
nsVideoFrame::BuildLayer(nsDisplayListBuilder* aBuilder,
LayerManager* aManager,
nsDisplayItem* aItem,
const ContainerLayerParameters& aContainerParameters)
{
nsRect area = GetContentRectRelativeToSelf() + aItem->ToReferenceFrame();
HTMLVideoElement* element = static_cast<HTMLVideoElement*>(GetContent());
nsIntSize videoSizeInPx;
if (NS_FAILED(element->GetVideoSize(&videoSizeInPx)) ||
area.IsEmpty()) {
return nullptr;
}
RefPtr<ImageContainer> container = element->GetImageContainer();
if (!container)
return nullptr;
// Retrieve the size of the decoded video frame, before being scaled
// by pixel aspect ratio.
mozilla::gfx::IntSize frameSize = container->GetCurrentSize();
if (frameSize.width == 0 || frameSize.height == 0) {
// No image, or zero-sized image. No point creating a layer.
return nullptr;
}
// Convert video size from pixel units into app units, to get an aspect-ratio
// (which has to be represented as a nsSize) and an IntrinsicSize that we
// can pass to ComputeObjectRenderRect.
nsSize aspectRatio(nsPresContext::CSSPixelsToAppUnits(videoSizeInPx.width),
nsPresContext::CSSPixelsToAppUnits(videoSizeInPx.height));
IntrinsicSize intrinsicSize;
intrinsicSize.width.SetCoordValue(aspectRatio.width);
intrinsicSize.height.SetCoordValue(aspectRatio.height);
nsRect dest = nsLayoutUtils::ComputeObjectDestRect(area,
intrinsicSize,
aspectRatio,
StylePosition());
gfxRect destGFXRect = PresContext()->AppUnitsToGfxUnits(dest);
destGFXRect.Round();
if (destGFXRect.IsEmpty()) {
return nullptr;
}
VideoInfo::Rotation rotationDeg = element->RotationDegrees();
IntSize scaleHint(static_cast<int32_t>(destGFXRect.Width()),
static_cast<int32_t>(destGFXRect.Height()));
// scaleHint is set regardless of rotation, so swap w/h if needed.
SwapScaleWidthHeightForRotation(scaleHint, rotationDeg);
container->SetScaleHint(scaleHint);
RefPtr<ImageLayer> layer = static_cast<ImageLayer*>
(aManager->GetLayerBuilder()->GetLeafLayerFor(aBuilder, aItem));
if (!layer) {
layer = aManager->CreateImageLayer();
if (!layer)
return nullptr;
}
layer->SetContainer(container);
layer->SetSamplingFilter(nsLayoutUtils::GetSamplingFilterForFrame(this));
// Set a transform on the layer to draw the video in the right place
gfxPoint p = destGFXRect.TopLeft() + aContainerParameters.mOffset;
Matrix preTransform = ComputeRotationMatrix(destGFXRect.Width(),
destGFXRect.Height(),
rotationDeg);
Matrix transform = preTransform * Matrix::Translation(p.x, p.y);
layer->SetBaseTransform(gfx::Matrix4x4::From2D(transform));
layer->SetScaleToSize(scaleHint, ScaleMode::STRETCH);
RefPtr<Layer> result = layer.forget();
return result.forget();
}