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

Method applyMaskMix

Engine/ImageMaskMix.cpp:188–299  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

186}
187
188void
189Image::applyMaskMix(const RectI& roi,
190 const Image* maskImg,
191 const Image* originalImg,
192 bool masked,
193 bool maskInvert,
194 float mix,
195 const OSGLContextPtr& glContext)
196{
197 ///!masked && mix == 1 has nothing to do
198 if ( !masked && (mix == 1) ) {
199 return;
200 }
201
202 QWriteLocker k(&_entryLock);
203 std::unique_ptr<QReadLocker> originalLock;
204 std::unique_ptr<QReadLocker> maskLock;
205 if (originalImg) {
206 originalLock.reset( new QReadLocker(&originalImg->_entryLock) );
207 }
208 if (maskImg) {
209 maskLock.reset( new QReadLocker(&maskImg->_entryLock) );
210 }
211 RectI realRoI;
212 roi.intersect(_bounds, &realRoI);
213
214 assert( !originalImg || getBitDepth() == originalImg->getBitDepth() );
215 assert( !masked || !maskImg || maskImg->getComponents() == ImagePlaneDesc::getAlphaComponents() );
216
217 if (getStorageMode() == eStorageModeGLTex) {
218 assert(glContext);
219 assert(!originalImg || originalImg->getStorageMode() == eStorageModeGLTex);
220 GLShaderPtr shader = glContext->getOrCreateMaskMixShader(maskImg != 0);
221 assert(shader);
222 GLuint fboID = glContext->getFBOId();
223
224 glBindFramebuffer(GL_FRAMEBUFFER, fboID);
225 int target = getGLTextureTarget();
226 glEnable(target);
227 glActiveTexture(GL_TEXTURE0);
228 glBindTexture( target, getGLTextureID() );
229
230 glTexParameteri (target, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
231 glTexParameteri (target, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
232
233 glTexParameteri (target, GL_TEXTURE_WRAP_S, GL_REPEAT);
234 glTexParameteri (target, GL_TEXTURE_WRAP_T, GL_REPEAT);
235
236 glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, target, getGLTextureID(), 0 /*LoD*/);
237 glCheckFramebufferError();
238
239 glActiveTexture(GL_TEXTURE1);
240 glBindTexture(target, originalImg ? originalImg->getGLTextureID() : 0);
241
242 glTexParameteri (target, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
243 glTexParameteri (target, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
244
245 glTexParameteri (target, GL_TEXTURE_WRAP_S, GL_REPEAT);

Callers 1

renderHandlerMethod · 0.80

Calls 13

getBitDepthFunction · 0.85
getComponentsMethod · 0.80
getFBOIdMethod · 0.80
bindMethod · 0.80
setUniformMethod · 0.80
unbindMethod · 0.80
getComponentsCountMethod · 0.80
resetMethod · 0.45
intersectMethod · 0.45
getBitDepthMethod · 0.45
getStorageModeMethod · 0.45

Tested by

no test coverage detected