| 656 | atomic<int> Image::sId(0); |
| 657 | |
| 658 | Image::Image(const fs::path& path, fs::file_time_type fileLastModified, ImageData&& data, string_view channelSelector, bool groupChannels) : |
| 659 | mPath{path}, mFileLastModified{fileLastModified}, mChannelSelector{channelSelector}, mData{std::move(data)}, mId{Image::drawId()} { |
| 660 | mName = channelSelector.empty() ? tev::toDisplayString(path) : fmt::format("{}:{}", tev::toDisplayString(path), channelSelector); |
| 661 | |
| 662 | if (groupChannels) { |
| 663 | for (const auto& l : mData.layers) { |
| 664 | const auto groups = getGroupedChannels(l); |
| 665 | mChannelGroups.insert(end(mChannelGroups), begin(groups), end(groups)); |
| 666 | } |
| 667 | } else { |
| 668 | // If we don't group channels, then each channel is its own group. |
| 669 | for (const auto& c : mData.channels) { |
| 670 | mChannelGroups.emplace_back( |
| 671 | ChannelGroup{ |
| 672 | string{c.name()}, |
| 673 | vector<string>{string{c.name()}, string{c.name()}, string{c.name()}} |
| 674 | } |
| 675 | ); |
| 676 | } |
| 677 | } |
| 678 | |
| 679 | // Ensure that alpha channels are last in their group |
| 680 | for (const auto& group : mChannelGroups) { |
| 681 | for (const auto& channel : group.channels) { |
| 682 | TEV_ASSERT(Channel::tail(channel) != "A" || &channel == &group.channels.back(), "Alpha channel must be last in channel group."); |
| 683 | } |
| 684 | } |
| 685 | } |
| 686 | |
| 687 | Image::~Image() { |
| 688 | // Move the texture pointers to the main thread such that their reference count hits zero there. This is required, because OpenGL calls |
nothing calls this directly
no test coverage detected