MCPcopy Create free account
hub / github.com/beefytech/Beef / MergeLayers

Method MergeLayers

BeefySysLib/img/PSDReader.cpp:1542–1741  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1540typedef std::set<int> IntSet;
1541
1542ImageData* PSDReader::MergeLayers(PSDLayerInfo* group, const std::vector<int>& layerIndices, ImageData* bottomImage)
1543{
1544 AutoPerf gPerf("PSDReader::MergeLayers");
1545
1546 bool isImageAllocated = false;
1547 ImageData* combinedImage = bottomImage;
1548
1549 ImageData* prevBottom = NULL;
1550 bool doPostGroupBlend = false;
1551 bool needsPrevBottom = (group != NULL) && (group->mOpacity != 255);
1552
1553 for (int indexIdx = 0; indexIdx < (int) layerIndices.size(); indexIdx++)
1554 {
1555 PSDLayerInfo* layerInfo = mPSDLayerInfoVector[layerIndices[indexIdx]];
1556 if (layerInfo->mBits == NULL)
1557 layerInfo->ReadData();
1558 if (layerInfo->mKnockout == 1) // Shallow
1559 needsPrevBottom = true;
1560 }
1561
1562 if ((group != NULL) && (bottomImage != NULL) && (group->mSectionBlendMode != 'pass'))
1563 {
1564 doPostGroupBlend = true;
1565 combinedImage = NULL;
1566 }
1567
1568 if (needsPrevBottom && (bottomImage != NULL))
1569 prevBottom = bottomImage->Duplicate();
1570
1571 bool hasAllocatedClipBase = false;
1572 PSDLayerInfo* clipBaseLayer = NULL;
1573 ImageData* clipBaseImage = NULL;
1574
1575 for (int indexIdx = 0; indexIdx <= (int) layerIndices.size(); indexIdx++)
1576 {
1577 PSDLayerInfo* layerInfo = NULL;
1578
1579 if (indexIdx < (int) layerIndices.size())
1580 layerInfo = mPSDLayerInfoVector[layerIndices[indexIdx]];
1581
1582 PSDLayerInfo* pendingFlushLayer = NULL;
1583 ImageData* pendingFlushImage = NULL;
1584
1585 if ((layerInfo != NULL) && (!layerInfo->mBaseClipping))
1586 {
1587 if (clipBaseLayer != NULL)
1588 {
1589 if (clipBaseLayer->mBlendClippedElementsAsGroup)
1590 {
1591 ImageData* newImage = layerInfo->mImageEffects->FlattenInto(clipBaseImage, layerInfo, layerInfo, prevBottom, NULL);
1592 SetImageAlpha(newImage, 255);
1593
1594 if (hasAllocatedClipBase)
1595 delete clipBaseImage;
1596
1597 hasAllocatedClipBase = true;
1598 clipBaseImage = newImage;
1599 }

Callers 1

mainFunction · 0.80

Calls 5

FlattenIntoMethod · 0.80
sizeMethod · 0.45
ReadDataMethod · 0.45
DuplicateMethod · 0.45
push_backMethod · 0.45

Tested by

no test coverage detected