本文整理汇总了C++中Layer::AsPaintedLayer方法的典型用法代码示例。如果您正苦于以下问题:C++ Layer::AsPaintedLayer方法的具体用法?C++ Layer::AsPaintedLayer怎么用?C++ Layer::AsPaintedLayer使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Layer
的用法示例。
在下文中一共展示了Layer::AsPaintedLayer方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: color
void
ReadbackProcessor::BuildUpdatesForLayer(ReadbackLayer* aLayer)
{
if (!aLayer->mSink)
return;
nsIntPoint offset;
Layer* newBackground = FindBackgroundLayer(aLayer, &offset);
if (!newBackground) {
aLayer->SetUnknown();
return;
}
if (newBackground->GetType() == Layer::TYPE_COLOR) {
ColorLayer* colorLayer = static_cast<ColorLayer*>(newBackground);
if (aLayer->mBackgroundColor != colorLayer->GetColor()) {
aLayer->mBackgroundLayer = nullptr;
aLayer->mBackgroundColor = colorLayer->GetColor();
NS_ASSERTION(aLayer->mBackgroundColor.a == 1.f,
"Color layer said it was opaque!");
RefPtr<gfxContext> ctx =
aLayer->mSink->BeginUpdate(aLayer->GetRect(),
aLayer->AllocateSequenceNumber());
if (ctx) {
ColorPattern color(ToDeviceColor(aLayer->mBackgroundColor));
IntSize size = aLayer->GetSize();
ctx->GetDrawTarget()->FillRect(Rect(0, 0, size.width, size.height),
color);
aLayer->mSink->EndUpdate(ctx, aLayer->GetRect());
}
}
} else {
NS_ASSERTION(newBackground->AsPaintedLayer(), "Must be PaintedLayer");
PaintedLayer* paintedLayer = static_cast<PaintedLayer*>(newBackground);
// updateRect is relative to the PaintedLayer
IntRect updateRect = aLayer->GetRect() - offset;
if (paintedLayer != aLayer->mBackgroundLayer ||
offset != aLayer->mBackgroundLayerOffset) {
aLayer->mBackgroundLayer = paintedLayer;
aLayer->mBackgroundLayerOffset = offset;
aLayer->mBackgroundColor = Color();
paintedLayer->SetUsedForReadback(true);
} else {
nsIntRegion invalid;
invalid.Sub(updateRect, paintedLayer->GetValidRegion());
updateRect = invalid.GetBounds();
}
Update update = { aLayer, updateRect, aLayer->AllocateSequenceNumber() };
mAllUpdates.AppendElement(update);
}
}