本文整理汇总了C++中LayerImage::isBackground方法的典型用法代码示例。如果您正苦于以下问题:C++ LayerImage::isBackground方法的具体用法?C++ LayerImage::isBackground怎么用?C++ LayerImage::isBackground使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类LayerImage
的用法示例。
在下文中一共展示了LayerImage::isBackground方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: onExecute
void CopyCel::onExecute()
{
LayerImage* srcLayer = static_cast<LayerImage*>(m_srcLayer.layer());
LayerImage* dstLayer = static_cast<LayerImage*>(m_dstLayer.layer());
ASSERT(srcLayer);
ASSERT(dstLayer);
Sprite* srcSprite = srcLayer->sprite();
Sprite* dstSprite = dstLayer->sprite();
ASSERT(srcSprite);
ASSERT(dstSprite);
ASSERT(m_srcFrame >= 0 && m_srcFrame < srcSprite->totalFrames());
ASSERT(m_dstFrame >= 0);
(void)srcSprite; // To avoid unused variable warning on Release mode
Cel* srcCel = srcLayer->cel(m_srcFrame);
Cel* dstCel = dstLayer->cel(m_dstFrame);
// Clear destination cel if it does exist. It'll be overriden by the
// copy of srcCel.
if (dstCel) {
if (dstCel->links())
executeAndAdd(new cmd::UnlinkCel(dstCel));
executeAndAdd(new cmd::ClearCel(dstCel));
}
// Add empty frames until newFrame
while (dstSprite->totalFrames() <= m_dstFrame)
executeAndAdd(new cmd::AddFrame(dstSprite, dstSprite->totalFrames()));
Image* srcImage = (srcCel ? srcCel->image(): NULL);
ImageRef dstImage;
dstCel = dstLayer->cel(m_dstFrame);
if (dstCel)
dstImage = dstCel->imageRef();
bool createLink =
(srcLayer == dstLayer && dstLayer->isContinuous());
// For background layer
if (dstLayer->isBackground()) {
ASSERT(dstCel);
ASSERT(dstImage);
if (!dstCel || !dstImage ||
!srcCel || !srcImage)
return;
if (createLink) {
executeAndAdd(new cmd::SetCelData(dstCel, srcCel->dataRef()));
}
else {
BlendMode blend = (srcLayer->isBackground() ?
BlendMode::SRC:
BlendMode::NORMAL);
ImageRef tmp(Image::createCopy(dstImage.get()));
render::composite_image(tmp.get(), srcImage,
srcCel->x(), srcCel->y(), 255, blend);
executeAndAdd(new cmd::CopyRect(dstImage.get(), tmp.get(), gfx::Clip(tmp->bounds())));
}
}
// For transparent layers
else {
if (dstCel)
executeAndAdd(new cmd::RemoveCel(dstCel));
if (srcCel) {
if (createLink)
dstCel = Cel::createLink(srcCel);
else
dstCel = Cel::createCopy(srcCel);
dstCel->setFrame(m_dstFrame);
executeAndAdd(new cmd::AddCel(dstLayer, dstCel));
}
}
}