void nuiRect::RoundToZero() { mLeft = (nuiSize)ToZero(mLeft ); mRight = (nuiSize)ToZero(mRight ); mTop = (nuiSize)ToZero(mTop ); mBottom = (nuiSize)ToZero(mBottom); }
void nuiGLDrawContext::BlurRect(const nuiRect& rRect, uint Strength) { nuiRect Rect = rRect; if (mClippingRect.mEnabled) Rect.Intersect(mClippingRect,rRect); nuiRect size = Rect.Size(); nuiTexture* pScratchPad = GetScratchPad(ToZero(size.GetWidth()), ToZero(size.GetHeight())); if (!pScratchPad) return; SetTexture(pScratchPad); glPushMatrix(); glLoadIdentity(); EnableBlending(true); EnableTexture2D(true); SetBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); do { glCopyTexSubImage2D( GL_TEXTURE_2D, 0, 0, 0, ToZero(rRect.mLeft), ToZero(mHeight) - 1 - ToZero(rRect.mTop) - ToZero(rRect.GetHeight()), ToZero(rRect.GetWidth()), ToZero(rRect.GetHeight()) ); SetFillColor(nuiColor(1,1,1,.15f)); nuiRect rect = Rect; rect.Move(-1,-1); DrawImage(rect,size); rect.Move(1,0); DrawImage(rect,size); rect.Move(1,0); DrawImage(rect,size); rect.Move(-2,1); DrawImage(rect,size); rect.Move(1,0); DrawImage(rect,size); rect.Move(1,0); DrawImage(rect,size); rect.Move(-2,1); DrawImage(rect,size); rect.Move(0,1); DrawImage(rect,size); rect.Move(0,1); DrawImage(rect,size); } while ((long)(Strength--) > 0); EnableBlending(false); EnableTexture2D(false); glPopMatrix(); }
void Matrix4::ToIdentity() { ToZero(); values[0] = 1.0f; values[5] = 1.0f; values[10] = 1.0f; values[15] = 1.0f; }
void VarioSynthesiser::Synthesise(int16_t *buffer, size_t n) { mutex.lock(); assert(audible_count > 0 || silence_count > 0); if (silence_count == 0 || beep_file >= 0) { /* magic value for "continuous tone" */ ToneSynthesiser::Synthesise(buffer, n); mutex.unlock(); return; } while (n > 0) { if (audible_remaining > 0) { /* generate a period of audible tone */ unsigned o = silence_count > 0 ? std::min(n, audible_remaining) : n; ToneSynthesiser::Synthesise(buffer, o); buffer += o; n -= o; audible_remaining -= o; if (audible_remaining == 0 && silence_remaining > 0) { /* finish the current sine wave to avoid clicking noise */ audible_remaining = ToZero(); if (audible_remaining == 0) /* finished, we can now emit a period of silence */ Restart(); } } else if (silence_remaining > 0) { /* generate a period of silence (climbing) */ unsigned o = audible_count > 0 ? std::min(n, silence_remaining) : n; /* the "silence" PCM sample value is zero */ std::fill(buffer, buffer + o, 0); buffer += o; n -= o; silence_remaining -= o; } else { /* period finished, begin next one */ audible_remaining = audible_count; silence_remaining = silence_count; } } mutex.unlock(); }