| 585 | } |
| 586 | |
| 587 | void |
| 588 | Image::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*/); |
no test coverage detected