本文整理汇总了C++中Layer::AsShadowLayer方法的典型用法代码示例。如果您正苦于以下问题:C++ Layer::AsShadowLayer方法的具体用法?C++ Layer::AsShadowLayer怎么用?C++ Layer::AsShadowLayer使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Layer
的用法示例。
在下文中一共展示了Layer::AsShadowLayer方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: switch
bool
CompositableParentManager::ReceiveCompositableUpdate(const CompositableOperation& aEdit,
EditReplyVector& replyv)
{
switch (aEdit.type()) {
case CompositableOperation::TOpCreatedSingleBuffer: {
MOZ_LAYERS_LOG(("[ParentSide] Created single buffer"));
const OpCreatedSingleBuffer& op = aEdit.get_OpCreatedSingleBuffer();
CompositableParent* compositableParent = static_cast<CompositableParent*>(op.compositableParent());
TextureParent* textureParent = static_cast<TextureParent*>(op.bufferParent());
textureParent->EnsureTextureHost(op.descriptor().type());
textureParent->GetTextureHost()->SetBuffer(new SurfaceDescriptor(op.descriptor()),
compositableParent->GetCompositableManager());
ContentHostBase* content = static_cast<ContentHostBase*>(compositableParent->GetCompositableHost());
content->SetTextureHosts(textureParent->GetTextureHost());
break;
}
case CompositableOperation::TOpCreatedDoubleBuffer: {
MOZ_LAYERS_LOG(("[ParentSide] Created double buffer"));
const OpCreatedDoubleBuffer& op = aEdit.get_OpCreatedDoubleBuffer();
CompositableParent* compositableParent = static_cast<CompositableParent*>(op.compositableParent());
TextureParent* frontParent = static_cast<TextureParent*>(op.frontParent());
TextureParent* backParent = static_cast<TextureParent*>(op.backParent());
frontParent->EnsureTextureHost(op.frontDescriptor().type());
backParent->EnsureTextureHost(op.backDescriptor().type());
frontParent->GetTextureHost()->SetBuffer(new SurfaceDescriptor(op.frontDescriptor()),
compositableParent->GetCompositableManager());
backParent->GetTextureHost()->SetBuffer(new SurfaceDescriptor(op.backDescriptor()),
compositableParent->GetCompositableManager());
ContentHostBase* content = static_cast<ContentHostBase*>(compositableParent->GetCompositableHost());
content->SetTextureHosts(frontParent->GetTextureHost(),
backParent->GetTextureHost());
break;
}
case CompositableOperation::TOpDestroyThebesBuffer: {
MOZ_LAYERS_LOG(("[ParentSide] Created double buffer"));
const OpDestroyThebesBuffer& op = aEdit.get_OpDestroyThebesBuffer();
CompositableParent* compositableParent = static_cast<CompositableParent*>(op.compositableParent());
ContentHostBase* content = static_cast<ContentHostBase*>(compositableParent->GetCompositableHost());
content->DestroyTextures();
break;
}
case CompositableOperation::TOpPaintTexture: {
MOZ_LAYERS_LOG(("[ParentSide] Paint Texture X"));
const OpPaintTexture& op = aEdit.get_OpPaintTexture();
TextureParent* textureParent = static_cast<TextureParent*>(op.textureParent());
CompositableHost* compositable = textureParent->GetCompositableHost();
Layer* layer = GetLayerFromOpPaint(op);
ShadowLayer* shadowLayer = layer ? layer->AsShadowLayer() : nullptr;
if (shadowLayer) {
Compositor* compositor = static_cast<LayerManagerComposite*>(layer->Manager())->GetCompositor();
compositable->SetCompositor(compositor);
compositable->SetLayer(layer);
} else {
// if we reach this branch, it most likely means that async textures
// are coming in before we had time to attach the conmpositable to a
// layer. Don't panic, it is okay in this case. it should not be
// happening continuously, though.
}
if (layer) {
RenderTraceInvalidateStart(layer, "FF00FF", layer->GetVisibleRegion().GetBounds());
}
const SurfaceDescriptor& descriptor = op.image();
textureParent->EnsureTextureHost(descriptor.type());
MOZ_ASSERT(textureParent->GetTextureHost());
SurfaceDescriptor newBack;
bool shouldRecomposite = compositable->Update(op.image(), &newBack);
if (IsSurfaceDescriptorValid(newBack)) {
replyv.push_back(OpTextureSwap(op.textureParent(), nullptr, newBack));
}
if (shouldRecomposite && textureParent->GetCompositorID()) {
CompositorParent* cp
= CompositorParent::GetCompositor(textureParent->GetCompositorID());
if (cp) {
cp->ScheduleComposition();
}
}
if (layer) {
RenderTraceInvalidateEnd(layer, "FF00FF");
}
break;
}
case CompositableOperation::TOpPaintTextureRegion: {
MOZ_LAYERS_LOG(("[ParentSide] Paint ThebesLayer"));
//.........这里部分代码省略.........
示例2: metricsScrollOffset
void
CompositorParent::TransformShadowTree()
{
Layer* layer = GetPrimaryScrollableLayer();
ShadowLayer* shadow = layer->AsShadowLayer();
ContainerLayer* container = layer->AsContainerLayer();
const FrameMetrics* metrics = &container->GetFrameMetrics();
const gfx3DMatrix& rootTransform = mLayerManager->GetRoot()->GetTransform();
const gfx3DMatrix& currentTransform = layer->GetTransform();
float rootScaleX = rootTransform.GetXScale();
float rootScaleY = rootTransform.GetYScale();
if (mIsFirstPaint && metrics) {
nsIntPoint scrollOffset = metrics->mViewportScrollOffset;
mContentSize = metrics->mContentSize;
SetFirstPaintViewport(scrollOffset.x, scrollOffset.y,
1/rootScaleX,
mContentSize.width,
mContentSize.height,
metrics->mCSSContentSize.width,
metrics->mCSSContentSize.height);
mIsFirstPaint = false;
} else if (metrics && (metrics->mContentSize != mContentSize)) {
mContentSize = metrics->mContentSize;
SetPageSize(1/rootScaleX, mContentSize.width,
mContentSize.height,
metrics->mCSSContentSize.width,
metrics->mCSSContentSize.height);
}
// We synchronise the viewport information with Java after sending the above
// notifications, so that Java can take these into account in its response.
if (metrics) {
// Calculate the absolute display port to send to Java
nsIntRect displayPort = metrics->mDisplayPort;
nsIntPoint scrollOffset = metrics->mViewportScrollOffset;
displayPort.x += scrollOffset.x;
displayPort.y += scrollOffset.y;
SyncViewportInfo(displayPort, 1/rootScaleX, mLayersUpdated,
mScrollOffset, mXScale, mYScale);
mLayersUpdated = false;
}
// Handle transformations for asynchronous panning and zooming. We determine the
// zoom used by Gecko from the transformation set on the root layer, and we
// determine the scroll offset used by Gecko from the frame metrics of the
// primary scrollable layer. We compare this to the desired zoom and scroll
// offset in the view transform we obtained from Java in order to compute the
// transformation we need to apply.
if (metrics) {
float tempScaleDiffX = rootScaleX * mXScale;
float tempScaleDiffY = rootScaleY * mYScale;
nsIntPoint metricsScrollOffset(0, 0);
if (metrics->IsScrollable())
metricsScrollOffset = metrics->mViewportScrollOffset;
nsIntPoint scrollCompensation(
(mScrollOffset.x / tempScaleDiffX - metricsScrollOffset.x) * mXScale,
(mScrollOffset.y / tempScaleDiffY - metricsScrollOffset.y) * mYScale);
ViewTransform treeTransform(-scrollCompensation, mXScale, mYScale);
shadow->SetShadowTransform(gfx3DMatrix(treeTransform) * currentTransform);
} else {
ViewTransform treeTransform(nsIntPoint(0,0), mXScale, mYScale);
shadow->SetShadowTransform(gfx3DMatrix(treeTransform) * currentTransform);
}
}
示例3: metricsScrollOffset
void
CompositorParent::TransformShadowTree()
{
Layer* layer = GetPrimaryScrollableLayer();
ShadowLayer* shadow = layer->AsShadowLayer();
ContainerLayer* container = layer->AsContainerLayer();
const FrameMetrics& metrics = container->GetFrameMetrics();
const gfx3DMatrix& rootTransform = mLayerManager->GetRoot()->GetTransform();
const gfx3DMatrix& currentTransform = layer->GetTransform();
float rootScaleX = rootTransform.GetXScale();
float rootScaleY = rootTransform.GetYScale();
if (mIsFirstPaint) {
mContentRect = metrics.mContentRect;
SetFirstPaintViewport(metrics.mViewportScrollOffset,
1/rootScaleX,
mContentRect,
metrics.mCSSContentRect);
mIsFirstPaint = false;
} else if (!metrics.mContentRect.IsEqualEdges(mContentRect)) {
mContentRect = metrics.mContentRect;
SetPageRect(1/rootScaleX, mContentRect, metrics.mCSSContentRect);
}
// We synchronise the viewport information with Java after sending the above
// notifications, so that Java can take these into account in its response.
// Calculate the absolute display port to send to Java
nsIntRect displayPort = metrics.mDisplayPort;
nsIntPoint scrollOffset = metrics.mViewportScrollOffset;
displayPort.x += scrollOffset.x;
displayPort.y += scrollOffset.y;
SyncViewportInfo(displayPort, 1/rootScaleX, mLayersUpdated,
mScrollOffset, mXScale, mYScale);
mLayersUpdated = false;
// Handle transformations for asynchronous panning and zooming. We determine the
// zoom used by Gecko from the transformation set on the root layer, and we
// determine the scroll offset used by Gecko from the frame metrics of the
// primary scrollable layer. We compare this to the desired zoom and scroll
// offset in the view transform we obtained from Java in order to compute the
// transformation we need to apply.
float tempScaleDiffX = rootScaleX * mXScale;
float tempScaleDiffY = rootScaleY * mYScale;
nsIntPoint metricsScrollOffset(0, 0);
if (metrics.IsScrollable())
metricsScrollOffset = metrics.mViewportScrollOffset;
nsIntPoint scrollCompensation(
(mScrollOffset.x / tempScaleDiffX - metricsScrollOffset.x) * mXScale,
(mScrollOffset.y / tempScaleDiffY - metricsScrollOffset.y) * mYScale);
ViewTransform treeTransform(-scrollCompensation, mXScale, mYScale);
shadow->SetShadowTransform(gfx3DMatrix(treeTransform) * currentTransform);
// Alter the scroll offset so that fixed position layers remain within
// the page area.
float offsetX = mScrollOffset.x / tempScaleDiffX;
float offsetY = mScrollOffset.y / tempScaleDiffY;
offsetX = NS_MAX((float)mContentRect.x, NS_MIN(offsetX, (float)(mContentRect.XMost() - mWidgetSize.width)));
offsetY = NS_MAX((float)mContentRect.y, NS_MIN(offsetY, (float)(mContentRect.YMost() - mWidgetSize.height)));
gfxPoint reverseViewTranslation(offsetX - metricsScrollOffset.x,
offsetY - metricsScrollOffset.y);
TranslateFixedLayers(layer, reverseViewTranslation);
}