本文整理汇总了C++中LayerComposite::GetShadowVisibleRegion方法的典型用法代码示例。如果您正苦于以下问题:C++ LayerComposite::GetShadowVisibleRegion方法的具体用法?C++ LayerComposite::GetShadowVisibleRegion怎么用?C++ LayerComposite::GetShadowVisibleRegion使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类LayerComposite
的用法示例。
在下文中一共展示了LayerComposite::GetShadowVisibleRegion方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ApplyOcclusionCulling
void
LayerManagerComposite::ApplyOcclusionCulling(Layer* aLayer, nsIntRegion& aOpaqueRegion)
{
nsIntRegion localOpaque;
Matrix transform2d;
bool isTranslation = false;
// If aLayer has a simple transform (only an integer translation) then we
// can easily convert aOpaqueRegion into pre-transform coordinates and include
// that region.
if (aLayer->GetLocalTransform().Is2D(&transform2d)) {
if (transform2d.IsIntegerTranslation()) {
isTranslation = true;
localOpaque = aOpaqueRegion;
localOpaque.MoveBy(-transform2d._31, -transform2d._32);
}
}
// Subtract any areas that we know to be opaque from our
// visible region.
LayerComposite *composite = aLayer->AsLayerComposite();
if (!localOpaque.IsEmpty()) {
nsIntRegion visible = composite->GetShadowVisibleRegion();
visible.Sub(visible, localOpaque);
composite->SetShadowVisibleRegion(visible);
}
// Compute occlusions for our descendants (in front-to-back order) and allow them to
// contribute to localOpaque.
for (Layer* child = aLayer->GetLastChild(); child; child = child->GetPrevSibling()) {
ApplyOcclusionCulling(child, localOpaque);
}
// If we have a simple transform, then we can add our opaque area into
// aOpaqueRegion.
if (isTranslation &&
!aLayer->HasMaskLayers() &&
aLayer->GetLocalOpacity() == 1.0f) {
if (aLayer->GetContentFlags() & Layer::CONTENT_OPAQUE) {
localOpaque.Or(localOpaque, composite->GetFullyRenderedRegion());
}
localOpaque.MoveBy(transform2d._31, transform2d._32);
const Maybe<ParentLayerIntRect>& clip = aLayer->GetEffectiveClipRect();
if (clip) {
localOpaque.And(localOpaque, ParentLayerIntRect::ToUntyped(*clip));
}
aOpaqueRegion.Or(aOpaqueRegion, localOpaque);
}
}
示例2: contentVis
static void
BuildBackgroundPatternFor(ContainerLayer* aContainer,
Layer* aShadowRoot,
const ViewConfig& aConfig,
const gfxRGBA& aColor,
LayerManager* aManager,
nsIFrame* aFrame)
{
LayerComposite* shadowRoot = aShadowRoot->AsLayerComposite();
gfxMatrix t;
if (!shadowRoot->GetShadowTransform().Is2D(&t)) {
return;
}
// Get the rect bounding the shadow content, transformed into the
// same space as |aFrame|
nsIntRect contentBounds = shadowRoot->GetShadowVisibleRegion().GetBounds();
gfxRect contentVis(contentBounds.x, contentBounds.y,
contentBounds.width, contentBounds.height);
gfxRect localContentVis(t.Transform(contentVis));
// Round *in* here because this area is punched out of the background
localContentVis.RoundIn();
nsIntRect localIntContentVis(localContentVis.X(), localContentVis.Y(),
localContentVis.Width(), localContentVis.Height());
// Get the frame's rect
nscoord auPerDevPixel = aFrame->PresContext()->AppUnitsPerDevPixel();
nsIntRect frameRect = aFrame->GetRect().ToOutsidePixels(auPerDevPixel);
// If the shadow tree covers the frame rect, don't bother building
// the background, it wouldn't be visible
if (localIntContentVis.Contains(frameRect)) {
return;
}
nsRefPtr<ColorLayer> layer = aManager->CreateColorLayer();
layer->SetColor(aColor);
// The visible area of the background is the frame's area minus the
// content area
nsIntRegion bgRgn(frameRect);
bgRgn.Sub(bgRgn, localIntContentVis);
bgRgn.MoveBy(-frameRect.TopLeft());
layer->SetVisibleRegion(bgRgn);
aContainer->InsertAfter(layer, nullptr);
}
示例3: autoMaskEffect
//.........这里部分代码省略.........
}
if (!surface) {
return;
}
compositor->SetRenderTarget(surface);
} else {
surface = previousTarget;
aContainer->mSupportsComponentAlphaChildren = (aContainer->GetContentFlags() & Layer::CONTENT_OPAQUE) ||
(aContainer->GetParent() && aContainer->GetParent()->SupportsComponentAlphaChildren());
}
nsAutoTArray<Layer*, 12> children;
aContainer->SortChildrenBy3DZOrder(children);
/**
* Render this container's contents.
*/
for (uint32_t i = 0; i < children.Length(); i++) {
LayerComposite* layerToRender = static_cast<LayerComposite*>(children.ElementAt(i)->ImplData());
if (layerToRender->GetLayer()->GetEffectiveVisibleRegion().IsEmpty() &&
!layerToRender->GetLayer()->AsContainerLayer()) {
continue;
}
if (i + 1 < children.Length() &&
layerToRender->GetLayer()->GetEffectiveTransform().IsIdentity()) {
LayerComposite* nextLayer = static_cast<LayerComposite*>(children.ElementAt(i + 1)->ImplData());
nsIntRect nextLayerOpaqueRect;
if (nextLayer && nextLayer->GetLayer()) {
nextLayerOpaqueRect = GetOpaqueRect(nextLayer->GetLayer());
}
if (!nextLayerOpaqueRect.IsEmpty()) {
nsIntRegion visibleRegion;
visibleRegion.Sub(layerToRender->GetShadowVisibleRegion(), nextLayerOpaqueRect);
layerToRender->SetShadowVisibleRegion(visibleRegion);
if (visibleRegion.IsEmpty()) {
continue;
}
}
}
nsIntRect clipRect = layerToRender->GetLayer()->
CalculateScissorRect(aClipRect, &aManager->GetWorldTransform());
if (clipRect.IsEmpty()) {
continue;
}
if (layerToRender->HasLayerBeenComposited()) {
// Composer2D will compose this layer so skip GPU composition
// this time & reset composition flag for next composition phase
layerToRender->SetLayerComposited(false);
} else {
layerToRender->RenderLayer(clipRect);
}
// invariant: our GL context should be current here, I don't think we can
// assert it though
}
if (needsSurface) {
// Unbind the current surface and rebind the previous one.
#ifdef MOZ_DUMP_PAINTING
if (gfxUtils::sDumpPainting) {
nsRefPtr<gfxImageSurface> surf = surface->Dump(aManager->GetCompositor());
WriteSnapshotToDumpFile(aContainer, surf);
}
#endif
compositor->SetRenderTarget(previousTarget);
EffectChain effectChain;
LayerManagerComposite::AutoAddMaskEffect autoMaskEffect(aContainer->GetMaskLayer(),
effectChain,
!aContainer->GetTransform().CanDraw2D());
effectChain.mPrimaryEffect = new EffectRenderTarget(surface);
gfx::Matrix4x4 transform;
ToMatrix4x4(aContainer->GetEffectiveTransform(), transform);
gfx::Rect rect(visibleRect.x, visibleRect.y, visibleRect.width, visibleRect.height);
gfx::Rect clipRect(aClipRect.x, aClipRect.y, aClipRect.width, aClipRect.height);
aManager->GetCompositor()->DrawQuad(rect, clipRect, effectChain, opacity,
transform);
}
if (aContainer->GetFrameMetrics().IsScrollable()) {
gfx::Matrix4x4 transform;
ToMatrix4x4(aContainer->GetEffectiveTransform(), transform);
const FrameMetrics& frame = aContainer->GetFrameMetrics();
LayerRect layerBounds = ScreenRect(frame.mCompositionBounds) * ScreenToLayerScale(1.0);
gfx::Rect rect(layerBounds.x, layerBounds.y, layerBounds.width, layerBounds.height);
gfx::Rect clipRect(aClipRect.x, aClipRect.y, aClipRect.width, aClipRect.height);
aManager->GetCompositor()->DrawDiagnostics(DIAGNOSTIC_CONTAINER,
rect, clipRect,
transform);
}
}
示例4: IntersectMaybeRects
//.........这里部分代码省略.........
// from our ancestors.
LayerComposite* composite = static_cast<LayerComposite*>(aLayer->AsHostLayer());
Maybe<ParentLayerIntRect> layerClip = composite->GetShadowClipRect();
MOZ_ASSERT(!layerClip || !aLayer->Combines3DTransformWithAncestors(),
"The layer with a clip should not participate "
"a 3D rendering context");
Maybe<ParentLayerIntRect> outsideClip =
IntersectMaybeRects(layerClip, aClipFromAncestors);
// Convert the combined clip into our pre-transform coordinate space, so
// that it can later be intersected with our visible region.
// If our transform is a perspective, there's no meaningful insideClip rect
// we can compute (it would need to be a cone).
Maybe<LayerIntRect> insideClip;
if (outsideClip && !transform.HasPerspectiveComponent()) {
Matrix4x4 inverse = transform;
if (inverse.Invert()) {
Maybe<LayerRect> insideClipFloat =
UntransformBy(ViewAs<ParentLayerToLayerMatrix4x4>(inverse),
ParentLayerRect(*outsideClip),
LayerRect::MaxIntRect());
if (insideClipFloat) {
insideClipFloat->RoundOut();
LayerIntRect insideClipInt;
if (insideClipFloat->ToIntRect(&insideClipInt)) {
insideClip = Some(insideClipInt);
}
}
}
}
Maybe<ParentLayerIntRect> ancestorClipForChildren;
if (insideClip) {
ancestorClipForChildren =
Some(ViewAs<ParentLayerPixel>(*insideClip, PixelCastJustification::MovingDownToChildren));
}
// Save the value of localOpaque, which currently stores the region obscured
// by siblings (and uncles and such), before our descendants contribute to it.
nsIntRegion obscured = localOpaque;
// Recurse on our descendants, in front-to-back order. In this process:
// - Occlusions are computed for them, and they contribute to localOpaque.
// - They recalculate their visible regions, taking ancestorClipForChildren
// into account, and accumulate them into descendantsVisibleRegion.
LayerIntRegion descendantsVisibleRegion;
bool hasPreserve3DChild = false;
for (Layer* child = aLayer->GetLastChild(); child; child = child->GetPrevSibling()) {
PostProcessLayers(child, localOpaque, descendantsVisibleRegion, ancestorClipForChildren);
if (child->Extend3DContext()) {
hasPreserve3DChild = true;
}
}
// Recalculate our visible region.
LayerIntRegion visible = composite->GetShadowVisibleRegion();
// If we have descendants, throw away the visible region stored on this
// layer, and use the region accumulated by our descendants instead.
if (aLayer->GetFirstChild() && !hasPreserve3DChild) {
visible = descendantsVisibleRegion;
}
// Subtract any areas that we know to be opaque.
if (!obscured.IsEmpty()) {
visible.SubOut(LayerIntRegion::FromUnknownRegion(obscured));
}
// Clip the visible region using the combined clip.
if (insideClip) {
visible.AndWith(*insideClip);
}
composite->SetShadowVisibleRegion(visible);
// Transform the newly calculated visible region into our parent's space,
// apply our clip to it (if any), and accumulate it into |aVisibleRegion|
// for the caller to use.
ParentLayerIntRegion visibleParentSpace = TransformBy(
ViewAs<LayerToParentLayerMatrix4x4>(transform), visible);
if (const Maybe<ParentLayerIntRect>& clipRect = composite->GetShadowClipRect()) {
visibleParentSpace.AndWith(*clipRect);
}
aVisibleRegion.OrWith(ViewAs<LayerPixel>(visibleParentSpace,
PixelCastJustification::MovingDownToChildren));
// If we have a simple transform, then we can add our opaque area into
// aOpaqueRegion.
if (integerTranslation &&
!aLayer->HasMaskLayers() &&
aLayer->IsOpaqueForVisibility()) {
if (aLayer->IsOpaque()) {
localOpaque.OrWith(composite->GetFullyRenderedRegion());
}
localOpaque.MoveBy(*integerTranslation);
if (layerClip) {
localOpaque.AndWith(layerClip->ToUnknownRect());
}
aOpaqueRegion.OrWith(localOpaque);
}
}
示例5: effectChain
//.........这里部分代码省略.........
compositor->DrawQuad(compositor->ClipRectInLayersCoordinates(clipRect),
clipRect, effectChain, opacity, Matrix4x4());
}
}
}
/**
* Render this container's contents.
*/
for (uint32_t i = 0; i < children.Length(); i++) {
LayerComposite* layerToRender = static_cast<LayerComposite*>(children.ElementAt(i)->ImplData());
if (layerToRender->GetLayer()->GetEffectiveVisibleRegion().IsEmpty() &&
!layerToRender->GetLayer()->AsContainerLayer()) {
continue;
}
nsIntRect clipRect = layerToRender->GetLayer()->
CalculateScissorRect(aClipRect, &aManager->GetWorldTransform());
if (clipRect.IsEmpty()) {
continue;
}
nsIntRegion savedVisibleRegion;
bool restoreVisibleRegion = false;
if (i + 1 < children.Length() &&
layerToRender->GetLayer()->GetEffectiveTransform().IsIdentity()) {
LayerComposite* nextLayer = static_cast<LayerComposite*>(children.ElementAt(i + 1)->ImplData());
nsIntRect nextLayerOpaqueRect;
if (nextLayer && nextLayer->GetLayer()) {
nextLayerOpaqueRect = GetOpaqueRect(nextLayer->GetLayer());
}
if (!nextLayerOpaqueRect.IsEmpty()) {
savedVisibleRegion = layerToRender->GetShadowVisibleRegion();
nsIntRegion visibleRegion;
visibleRegion.Sub(savedVisibleRegion, nextLayerOpaqueRect);
if (visibleRegion.IsEmpty()) {
continue;
}
layerToRender->SetShadowVisibleRegion(visibleRegion);
restoreVisibleRegion = true;
}
}
if (layerToRender->HasLayerBeenComposited()) {
// Composer2D will compose this layer so skip GPU composition
// this time & reset composition flag for next composition phase
layerToRender->SetLayerComposited(false);
nsIntRect clearRect = layerToRender->GetClearRect();
if (!clearRect.IsEmpty()) {
// Clear layer's visible rect on FrameBuffer with transparent pixels
gfx::Rect fbRect(clearRect.x, clearRect.y, clearRect.width, clearRect.height);
compositor->ClearRect(fbRect);
layerToRender->SetClearRect(nsIntRect(0, 0, 0, 0));
}
} else {
layerToRender->RenderLayer(clipRect);
}
if (restoreVisibleRegion) {
// Restore the region in case it's not covered by opaque content next time
layerToRender->SetShadowVisibleRegion(savedVisibleRegion);
}
if (gfxPrefs::LayersScrollGraph()) {
DrawVelGraph(clipRect, aManager, layerToRender->GetLayer());
示例6: Some
void
LayerManagerComposite::PostProcessLayers(Layer* aLayer,
nsIntRegion& aOpaqueRegion,
LayerIntRegion& aVisibleRegion)
{
nsIntRegion localOpaque;
Matrix transform2d;
Maybe<nsIntPoint> integerTranslation;
// If aLayer has a simple transform (only an integer translation) then we
// can easily convert aOpaqueRegion into pre-transform coordinates and include
// that region.
if (aLayer->GetLocalTransform().Is2D(&transform2d)) {
if (transform2d.IsIntegerTranslation()) {
integerTranslation = Some(TruncatedToInt(transform2d.GetTranslation()));
localOpaque = aOpaqueRegion;
localOpaque.MoveBy(-*integerTranslation);
}
}
// Save the value of localOpaque, which currently stores the region obscured
// by siblings (and uncles and such), before our descendants contribute to it.
nsIntRegion obscured = localOpaque;
// Recurse on our descendants, in front-to-back order. In this process:
// - Occlusions are computed for them, and they contribute to localOpaque.
// - They recalculate their visible regions, and accumulate them into
// descendantsVisibleRegion.
LayerIntRegion descendantsVisibleRegion;
for (Layer* child = aLayer->GetLastChild(); child; child = child->GetPrevSibling()) {
PostProcessLayers(child, localOpaque, descendantsVisibleRegion);
}
// Recalculate our visible region.
LayerComposite* composite = aLayer->AsLayerComposite();
LayerIntRegion visible = composite->GetShadowVisibleRegion();
// If we have descendants, throw away the visible region stored on this
// layer, and use the region accumulated by our descendants instead.
if (aLayer->GetFirstChild()) {
visible = descendantsVisibleRegion;
}
// Subtract any areas that we know to be opaque.
if (!obscured.IsEmpty()) {
visible.SubOut(LayerIntRegion::FromUnknownRegion(obscured));
}
composite->SetShadowVisibleRegion(visible);
// Transform the newly calculated visible region into our parent's space,
// apply our clip to it (if any), and accumulate it into |aVisibleRegion|
// for the caller to use.
ParentLayerIntRegion visibleParentSpace = TransformTo<ParentLayerPixel>(
aLayer->GetLocalTransform(), visible);
if (const Maybe<ParentLayerIntRect>& clipRect = composite->GetShadowClipRect()) {
visibleParentSpace.AndWith(*clipRect);
}
aVisibleRegion.OrWith(ViewAs<LayerPixel>(visibleParentSpace,
PixelCastJustification::MovingDownToChildren));
// If we have a simple transform, then we can add our opaque area into
// aOpaqueRegion.
if (integerTranslation &&
!aLayer->HasMaskLayers() &&
aLayer->IsOpaqueForVisibility()) {
if (aLayer->GetContentFlags() & Layer::CONTENT_OPAQUE) {
localOpaque.OrWith(composite->GetFullyRenderedRegion());
}
localOpaque.MoveBy(*integerTranslation);
const Maybe<ParentLayerIntRect>& clip = aLayer->GetEffectiveClipRect();
if (clip) {
localOpaque.AndWith(clip->ToUnknownRect());
}
aOpaqueRegion.OrWith(localOpaque);
}
}