MCPcopy Create free account
hub / github.com/NatronGitHub/Natron / copyUnProcessedChannels

Method copyUnProcessedChannels

Engine/ImageCopyChannels.cpp:587–696  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

585}
586
587void
588Image::copyUnProcessedChannels(const RectI& roi,
589 const ImagePremultiplicationEnum outputPremult,
590 const ImagePremultiplicationEnum originalImagePremult,
591 const std::bitset<4> processChannels,
592 const ImagePtr& originalImage,
593 bool ignorePremult,
594 const OSGLContextPtr& glContext)
595{
596 int numComp = getComponents().getNumComponents();
597
598 if (numComp == 0) {
599 return;
600 }
601 if ( (numComp == 1) && processChannels[3] ) { // 1 component is alpha
602 return;
603 } else if ( (numComp == 2) && processChannels[0] && processChannels[1] ) {
604 return;
605 } else if ( (numComp == 3) && processChannels[0] && processChannels[1] && processChannels[2] ) {
606 return;
607 } else if ( (numComp == 4) && processChannels[0] && processChannels[1] && processChannels[2] && processChannels[3] ) {
608 return;
609 }
610
611
612 if ( originalImage && ( getMipMapLevel() != originalImage->getMipMapLevel() ) ) {
613 qDebug() << "WARNING: attempting to call copyUnProcessedChannels on images with different mipMapLevel";
614
615 return;
616 }
617
618 QWriteLocker k(&_entryLock);
619 assert( !originalImage || getBitDepth() == originalImage->getBitDepth() );
620
621
622 RectI srcRoi;
623 roi.intersect(_bounds, &srcRoi);
624
625 if (getStorageMode() == eStorageModeGLTex) {
626 assert(glContext);
627 assert(originalImage->getStorageMode() == eStorageModeGLTex);
628 GLShaderPtr shader = glContext->getOrCreateCopyUnprocessedChannelsShader(processChannels[0], processChannels[1], processChannels[2], processChannels[3]);
629 assert(shader);
630 GLuint fboID = glContext->getFBOId();
631
632 glBindFramebuffer(GL_FRAMEBUFFER, fboID);
633 int target = getGLTextureTarget();
634 glEnable(target);
635 glActiveTexture(GL_TEXTURE0);
636 glBindTexture( target, getGLTextureID() );
637
638 glTexParameteri (target, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
639 glTexParameteri (target, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
640
641 glTexParameteri (target, GL_TEXTURE_WRAP_S, GL_REPEAT);
642 glTexParameteri (target, GL_TEXTURE_WRAP_T, GL_REPEAT);
643
644 glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, target, getGLTextureID(), 0 /*LoD*/);

Callers 2

renderMethod · 0.80
renderHandlerMethod · 0.80

Calls 13

getMipMapLevelFunction · 0.85
getBitDepthFunction · 0.85
getFBOIdMethod · 0.80
bindMethod · 0.80
setUniformMethod · 0.80
unbindMethod · 0.80
getNumComponentsMethod · 0.45
getMipMapLevelMethod · 0.45
getBitDepthMethod · 0.45
intersectMethod · 0.45
getStorageModeMethod · 0.45

Tested by

no test coverage detected