本文整理汇总了C++中LayerComposite::GetLayer方法的典型用法代码示例。如果您正苦于以下问题:C++ LayerComposite::GetLayer方法的具体用法?C++ LayerComposite::GetLayer怎么用?C++ LayerComposite::GetLayer使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类LayerComposite
的用法示例。
在下文中一共展示了LayerComposite::GetLayer方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: aRect
template<class ContainerT> void
ContainerRender(ContainerT* aContainer,
LayerManagerComposite* aManager,
const nsIntRect& aClipRect)
{
/**
* Setup our temporary surface for rendering the contents of this container.
*/
RefPtr<CompositingRenderTarget> surface;
Compositor* compositor = aManager->GetCompositor();
RefPtr<CompositingRenderTarget> previousTarget = compositor->GetCurrentRenderTarget();
nsIntRect visibleRect = aContainer->GetEffectiveVisibleRegion().GetBounds();
aContainer->mSupportsComponentAlphaChildren = false;
float opacity = aContainer->GetEffectiveOpacity();
bool needsSurface = aContainer->UseIntermediateSurface();
if (needsSurface) {
SurfaceInitMode mode = INIT_MODE_CLEAR;
bool surfaceCopyNeeded = false;
gfx::IntRect surfaceRect = gfx::IntRect(visibleRect.x, visibleRect.y,
visibleRect.width, visibleRect.height);
gfx::IntPoint sourcePoint = gfx::IntPoint(visibleRect.x, visibleRect.y);
// we're about to create a framebuffer backed by textures to use as an intermediate
// surface. What to do if its size (as given by framebufferRect) would exceed the
// maximum texture size supported by the GL? The present code chooses the compromise
// of just clamping the framebuffer's size to the max supported size.
// This gives us a lower resolution rendering of the intermediate surface (children layers).
// See bug 827170 for a discussion.
int32_t maxTextureSize = compositor->GetMaxTextureSize();
surfaceRect.width = std::min(maxTextureSize, surfaceRect.width);
surfaceRect.height = std::min(maxTextureSize, surfaceRect.height);
if (aContainer->GetEffectiveVisibleRegion().GetNumRects() == 1 &&
(aContainer->GetContentFlags() & Layer::CONTENT_OPAQUE))
{
// don't need a background, we're going to paint all opaque stuff
aContainer->mSupportsComponentAlphaChildren = true;
mode = INIT_MODE_NONE;
} else {
const gfx::Matrix4x4& transform3D = aContainer->GetEffectiveTransform();
gfx::Matrix transform;
// If we have an opaque ancestor layer, then we can be sure that
// all the pixels we draw into are either opaque already or will be
// covered by something opaque. Otherwise copying up the background is
// not safe.
if (HasOpaqueAncestorLayer(aContainer) &&
transform3D.Is2D(&transform) && !ThebesMatrix(transform).HasNonIntegerTranslation()) {
surfaceCopyNeeded = gfxPlatform::ComponentAlphaEnabled();
sourcePoint.x += transform._31;
sourcePoint.y += transform._32;
aContainer->mSupportsComponentAlphaChildren
= gfxPlatform::ComponentAlphaEnabled();
}
}
sourcePoint -= compositor->GetCurrentRenderTarget()->GetOrigin();
if (surfaceCopyNeeded) {
surface = compositor->CreateRenderTargetFromSource(surfaceRect, previousTarget, sourcePoint);
} else {
surface = compositor->CreateRenderTarget(surfaceRect, mode);
}
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;
//.........这里部分代码省略.........
示例2: childOffset
template<class ContainerT> void
ContainerRender(ContainerT* aContainer,
const nsIntPoint& aOffset,
LayerManagerComposite* aManager,
const nsIntRect& aClipRect)
{
/**
* Setup our temporary surface for rendering the contents of this container.
*/
RefPtr<CompositingRenderTarget> surface;
Compositor* compositor = aManager->GetCompositor();
RefPtr<CompositingRenderTarget> previousTarget = compositor->GetCurrentRenderTarget();
nsIntPoint childOffset(aOffset);
nsIntRect visibleRect = aContainer->GetEffectiveVisibleRegion().GetBounds();
aContainer->mSupportsComponentAlphaChildren = false;
float opacity = aContainer->GetEffectiveOpacity();
bool needsSurface = aContainer->UseIntermediateSurface();
if (needsSurface) {
SurfaceInitMode mode = INIT_MODE_CLEAR;
bool surfaceCopyNeeded = false;
gfx::IntRect surfaceRect = gfx::IntRect(visibleRect.x, visibleRect.y,
visibleRect.width, visibleRect.height);
// we're about to create a framebuffer backed by textures to use as an intermediate
// surface. What to do if its size (as given by framebufferRect) would exceed the
// maximum texture size supported by the GL? The present code chooses the compromise
// of just clamping the framebuffer's size to the max supported size.
// This gives us a lower resolution rendering of the intermediate surface (children layers).
// See bug 827170 for a discussion.
int32_t maxTextureSize = compositor->GetMaxTextureSize();
surfaceRect.width = std::min(maxTextureSize, surfaceRect.width);
surfaceRect.height = std::min(maxTextureSize, surfaceRect.height);
if (aContainer->GetEffectiveVisibleRegion().GetNumRects() == 1 &&
(aContainer->GetContentFlags() & Layer::CONTENT_OPAQUE))
{
// don't need a background, we're going to paint all opaque stuff
aContainer->mSupportsComponentAlphaChildren = true;
mode = INIT_MODE_NONE;
} else {
const gfx3DMatrix& transform3D = aContainer->GetEffectiveTransform();
gfxMatrix transform;
// If we have an opaque ancestor layer, then we can be sure that
// all the pixels we draw into are either opaque already or will be
// covered by something opaque. Otherwise copying up the background is
// not safe.
if (HasOpaqueAncestorLayer(aContainer) &&
transform3D.Is2D(&transform) && !transform.HasNonIntegerTranslation()) {
mode = gfxPlatform::GetPlatform()->UsesSubpixelAATextRendering() ?
INIT_MODE_COPY : INIT_MODE_CLEAR;
surfaceCopyNeeded = (mode == INIT_MODE_COPY);
surfaceRect.x += transform.x0;
surfaceRect.y += transform.y0;
aContainer->mSupportsComponentAlphaChildren
= gfxPlatform::GetPlatform()->UsesSubpixelAATextRendering();
}
}
surfaceRect -= gfx::IntPoint(aOffset.x, aOffset.y);
if (surfaceCopyNeeded) {
surface = compositor->CreateRenderTargetFromSource(surfaceRect, previousTarget);
} else {
surface = compositor->CreateRenderTarget(surfaceRect, mode);
}
compositor->SetRenderTarget(surface);
childOffset.x = visibleRect.x;
childOffset.y = visibleRect.y;
} 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;
}
nsIntRect clipRect = layerToRender->GetLayer()->
CalculateScissorRect(aClipRect, &aManager->GetWorldTransform());
if (clipRect.IsEmpty()) {
continue;
}
layerToRender->RenderLayer(childOffset, clipRect);
// invariant: our GL context should be current here, I don't think we can
// assert it though
//.........这里部分代码省略.........
示例3: effectChain
// ContainerRender is shared between RefLayer and ContainerLayer
template<class ContainerT> void
ContainerRender(ContainerT* aContainer,
LayerManagerComposite* aManager,
const nsIntRect& aClipRect)
{
/**
* Setup our temporary surface for rendering the contents of this container.
*/
RefPtr<CompositingRenderTarget> surface;
Compositor* compositor = aManager->GetCompositor();
RefPtr<CompositingRenderTarget> previousTarget = compositor->GetCurrentRenderTarget();
nsIntRect visibleRect = aContainer->GetEffectiveVisibleRegion().GetBounds();
float opacity = aContainer->GetEffectiveOpacity();
bool needsSurface = aContainer->UseIntermediateSurface();
bool surfaceCopyNeeded;
aContainer->DefaultComputeSupportsComponentAlphaChildren(&surfaceCopyNeeded);
if (needsSurface) {
SurfaceInitMode mode = INIT_MODE_CLEAR;
gfx::IntRect surfaceRect = gfx::IntRect(visibleRect.x, visibleRect.y,
visibleRect.width, visibleRect.height);
// we're about to create a framebuffer backed by textures to use as an intermediate
// surface. What to do if its size (as given by framebufferRect) would exceed the
// maximum texture size supported by the GL? The present code chooses the compromise
// of just clamping the framebuffer's size to the max supported size.
// This gives us a lower resolution rendering of the intermediate surface (children layers).
// See bug 827170 for a discussion.
int32_t maxTextureSize = compositor->GetMaxTextureSize();
surfaceRect.width = std::min(maxTextureSize, surfaceRect.width);
surfaceRect.height = std::min(maxTextureSize, surfaceRect.height);
if (aContainer->GetEffectiveVisibleRegion().GetNumRects() == 1 &&
(aContainer->GetContentFlags() & Layer::CONTENT_OPAQUE))
{
mode = INIT_MODE_NONE;
}
if (surfaceCopyNeeded) {
gfx::IntPoint sourcePoint = gfx::IntPoint(visibleRect.x, visibleRect.y);
gfx::Matrix4x4 transform = aContainer->GetEffectiveTransform();
DebugOnly<gfx::Matrix> transform2d;
MOZ_ASSERT(transform.Is2D(&transform2d) && !gfx::ThebesMatrix(transform2d).HasNonIntegerTranslation());
sourcePoint += gfx::IntPoint(transform._41, transform._42);
sourcePoint -= compositor->GetCurrentRenderTarget()->GetOrigin();
surface = compositor->CreateRenderTargetFromSource(surfaceRect, previousTarget, sourcePoint);
} else {
surface = compositor->CreateRenderTarget(surfaceRect, mode);
}
if (!surface) {
return;
}
compositor->SetRenderTarget(surface);
} else {
surface = previousTarget;
}
nsAutoTArray<Layer*, 12> children;
aContainer->SortChildrenBy3DZOrder(children);
// If this is a scrollable container layer, and it's overscrolled, the layer's
// contents are transformed in a way that would leave blank regions in the
// composited area. If the layer has a background color, fill these areas
// with the background color by drawing a rectangle of the background color
// over the entire composited area before drawing the container contents.
if (AsyncPanZoomController* apzc = aContainer->GetAsyncPanZoomController()) {
// Make sure not to do this on a "scrollinfo" layer (one with an empty visible
// region) because it's just a placeholder for APZ purposes.
if (apzc->IsOverscrolled() && !aContainer->GetVisibleRegion().IsEmpty()) {
gfxRGBA color = aContainer->GetBackgroundColor();
// If the background is completely transparent, there's no point in
// drawing anything for it. Hopefully the layers behind, if any, will
// provide suitable content for the overscroll effect.
if (color.a != 0.0) {
EffectChain effectChain(aContainer);
effectChain.mPrimaryEffect = new EffectSolidColor(ToColor(color));
gfx::Rect clipRect(aClipRect.x, aClipRect.y, aClipRect.width, aClipRect.height);
Compositor* compositor = aManager->GetCompositor();
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()) {
//.........这里部分代码省略.........