Example #1
0
void NativeEngine::GameLoop() {
    mApp->userData = this;
    mApp->onAppCmd = _handle_cmd_proxy;
    mApp->onInputEvent = _handle_input_proxy;

    while (1) {
        int ident, events;
        struct android_poll_source* source;
        bool wasAnimating = IsAnimating();

        // If not animating, block until we get an event; if animating, don't block.
        while ((ident = ALooper_pollAll(IsAnimating() ? 0 : -1, NULL, &events,
                (void**)&source)) >= 0) {

            // process event
            if (source != NULL) {
                source->process(mApp, source);
            }

            // are we exiting?
            if (mApp->destroyRequested) {
                return;
            }
        }

        if (IsAnimating()) {
            DoFrame();
        }
    }
}
Example #2
0
glm::mat4 Renderer::_GetAnimateBlockMatrix(int x, int y, int z) {
	glm::mat4 animateMatrix;

	std::time_t currentTime = (std::clock() > animationStartTime + animationTime) ? animationStartTime + animationTime : std::clock();

	float distance = ((float) currentTime - animationStartTime) / animationTime * glm::pi<float>() / 2;

	if (IsAnimating()) {
		switch (animationAxis) {
		case X:
			if (x == animationSide + 1)
				animateMatrix = glm::rotate(animationDirection * distance, glm::vec3(1, 0, 0));
			break;
		case Y:
			if (y == animationSide + 1)
				animateMatrix = glm::rotate(animationDirection * distance, glm::vec3(0, 1, 0));
			break;
		case Z:
			if (z == animationSide + 1)
				animateMatrix = glm::rotate(animationDirection * distance, glm::vec3(0, 0, 1));
			break;
		}
	}

	shouldStopAnimating_ = (currentTime == animationStartTime + animationTime);
	return animateMatrix;
}
bool CGUIWindowFullScreen::NeedRenderFullScreen()
{
  CSingleLock lock (g_graphicsContext);
  if (g_application.m_pPlayer)
  {
    if (g_application.m_pPlayer->IsPaused() ) return true;
    if (g_application.m_pPlayer->IsCaching() ) return true;
    if (!g_application.m_pPlayer->IsPlaying() ) return true;
  }
  if (g_application.GetPlaySpeed() != 1) return true;
  if (m_timeCodeShow) return true;
  if (g_infoManager.GetBool(PLAYER_SHOWCODEC)) return true;
  if (g_infoManager.GetBool(PLAYER_SHOWINFO)) return true;
  if (IsAnimating(ANIM_TYPE_HIDDEN)) return true; // for the above info conditions
  if (m_bShowViewModeInfo) return true;
  if (m_bShowCurrentTime) return true;
  if (g_infoManager.GetDisplayAfterSeek()) return true;
  if (g_infoManager.GetBool(PLAYER_SEEKBAR, GetID())) return true;
  if (CUtil::IsUsingTTFSubtitles() && g_application.m_pPlayer->GetSubtitleVisible() && m_subsLayout)
    return true;
  if (m_bLastRender)
  {
    m_bLastRender = false;
  }

  return false;
}
Example #4
0
void CGUIDialog::Show_Internal()
{
  //Lock graphic context here as it is sometimes called from non rendering threads
  //maybe we should have a critical section per window instead??
  CSingleLock lock(g_graphicsContext);

  if (m_active && !m_closing && !IsAnimating(ANIM_TYPE_WINDOW_CLOSE)) return;

  if (!g_windowManager.Initialized())
    return; // don't do anything

  m_bModal = false;

  // set running before it's added to the window manager, else the auto-show code
  // could show it as well if we are in a different thread from
  // the main rendering thread (this should really be handled via
  // a thread message though IMO)
  m_active = true;
  m_closing = false;
  g_windowManager.AddModeless(this);

  // active this window...
  CGUIMessage msg(GUI_MSG_WINDOW_INIT, 0, 0);
  OnMessage(msg);
}
void OnPaint(HWND hwnd)
{
    HRESULT hr = S_OK;

    // Update the current state.
    UpdateAnimation(hwnd);
    if (g_renderer == NULL)
    {
        hr = CreateRenderer(hwnd);
    }

    // Paint the current frame.
    if (SUCCEEDED(hr))
    {
        PAINTSTRUCT ps;
        HDC hdc = BeginPaint(hwnd, &ps);
        SetLayout(ps.hdc, LAYOUT_BITMAPORIENTATIONPRESERVED);
        hr = g_renderer->Draw(hdc);
        EndPaint(hwnd, &ps);
    }

    if (FAILED(hr))
    {
        PostQuitMessage(hr);
        return;
    }

    // Invalidate if we're animating.
    if (IsAnimating())
    {
        InvalidateRect(hwnd, NULL, TRUE);
    }
}
Example #6
0
void CGUIControl::SetVisible(bool bVisible, bool setVisState)
{
  if (bVisible && setVisState)
  {  // TODO: currently we only update m_visible from GUI_MSG_VISIBLE (SET_CONTROL_VISIBLE)
     //       otherwise we just set m_forceHidden
    GUIVISIBLE visible;
    if (m_visibleCondition)
      visible = m_visibleCondition->Get() ? VISIBLE : HIDDEN;
    else
      visible = VISIBLE;
    if (visible != m_visible)
    {
      m_visible = visible;
      SetInvalid();
    }
  }
  if (m_forceHidden == bVisible)
  {
    m_forceHidden = !bVisible;
    SetInvalid();
    if (m_forceHidden)
      MarkDirtyRegion();
  }
  if (m_forceHidden)
  { // reset any visible animations that are in process
    if (IsAnimating(ANIM_TYPE_VISIBLE))
    {
//        CLog::Log(LOGDEBUG, "Resetting visible animation on control %i (we are %s)", m_controlID, m_visible ? "visible" : "hidden");
      CAnimation *visibleAnim = GetAnimation(ANIM_TYPE_VISIBLE);
      if (visibleAnim) visibleAnim->ResetAnimation();
    }
  }
}
void UpdateAnimation(HWND hwnd)
{
    if (!IsAnimating())
        return;

    // Compute the elapsed time since the start of the animation in seconds.
    DWORD const tickCount = GetTickCount();
    float elapsed = (tickCount - g_animationStartCount) * (1.0f / 1000);

    if (elapsed < g_animationDuration)
    {
        // We're still animating. Compuate the current x by interpolating between 
        // the start x and end x.
        float r = elapsed / g_animationDuration;
        g_animationCurrentX = (g_animationStartX * (1 - r)) + (g_animationEndX * r);
    }
    else
    {
        // We're done with this animation. Let both the current and start x equal the end x.
        g_animationCurrentX = g_animationEndX;
        g_animationStartX   = g_animationEndX;

        // If we're not at zero, we'll start a new animation ending at zero. The duration of
        // this animation depends on the distance.
        g_animationEndX = 0;
        g_animationStartCount = tickCount;
        g_animationDuration = fabs(g_animationStartX) / 10;
    }

    SetTransform(hwnd);
}
Example #8
0
void CGUIDialog::Close(bool forceClose /*= false*/)
{
  //Lock graphic context here as it is sometimes called from non rendering threads
  //maybe we should have a critical section per window instead??
  CSingleLock lock(g_graphicsContext);

  if (!m_bRunning) return;

  //  Play the window specific deinit sound
  g_audioManager.PlayWindowSound(GetID(), SOUND_DEINIT);

  // don't close if we should be animating
  if (!forceClose && HasAnimation(ANIM_TYPE_WINDOW_CLOSE))
  {
    if (!m_dialogClosing && !IsAnimating(ANIM_TYPE_WINDOW_CLOSE))
    {
      QueueAnimation(ANIM_TYPE_WINDOW_CLOSE);
      m_dialogClosing = true;
    }
    return;
  }

  CGUIMessage msg(GUI_MSG_WINDOW_DEINIT, 0, 0);
  OnMessage(msg);
}
void
DOMSVGAnimatedNumberList::InternalBaseValListWillChangeTo(const SVGNumberList& aNewValue)
{
  // When the number of items in our internal counterpart's baseVal changes,
  // we MUST keep our baseVal in sync. If we don't, script will either see a
  // list that is too short and be unable to access indexes that should be
  // valid, or else, MUCH WORSE, script will see a list that is too long and be
  // able to access "items" at indexes that are out of bounds (read/write to
  // bad memory)!!

  RefPtr<DOMSVGAnimatedNumberList> kungFuDeathGrip;
  if (mBaseVal) {
    if (aNewValue.Length() < mBaseVal->LengthNoFlush()) {
      // InternalListLengthWillChange might clear last reference to |this|.
      // Retain a temporary reference to keep from dying before returning.
      kungFuDeathGrip = this;
    }
    mBaseVal->InternalListLengthWillChange(aNewValue.Length());
  }

  // If our attribute is not animating, then our animVal mirrors our baseVal
  // and we must sync its length too. (If our attribute is animating, then the
  // SMIL engine takes care of calling InternalAnimValListWillChangeTo() if
  // necessary.)

  if (!IsAnimating()) {
    InternalAnimValListWillChangeTo(aNewValue);
  }
}
Example #10
0
void CGUIDialog::Show_Internal()
{
  //Lock graphic context here as it is sometimes called from non rendering threads
  //maybe we should have a critical section per window instead??
  CSingleLock lock(g_graphicsContext);

  if (m_bRunning && !m_dialogClosing && !IsAnimating(ANIM_TYPE_WINDOW_CLOSE)) return;

  m_bModal = false;
  
  // set running before it's added to the window manager, else the auto-show code
  // could show it as well if we are in a different thread from
  // the main rendering thread (this should really be handled via
  // a thread message though IMO)
  m_bRunning = true;
  m_dialogClosing = false;
  m_gWindowManager.AddModeless(this);

  //  Play the window specific init sound
  g_audioManager.PlayWindowSound(GetID(), SOUND_INIT);

  // active this window...
  CGUIMessage msg(GUI_MSG_WINDOW_INIT, 0, 0);
  OnMessage(msg);

//  m_bRunning = true;
}
Example #11
0
void CGUIDialogBusy::Render()
{
  //only render if system is busy
  if (g_ApplicationRenderer.IsBusy() || IsAnimating(ANIM_TYPE_WINDOW_CLOSE))
  {
    CGUIDialog::Render();
  }
}
void NeoPixelAnimator::StopAnimation(uint16_t n)
{
    if (IsAnimating(n))
    {
        _activeAnimations--;
        _animations[n].time = 0;
        _animations[n].remaining = 0;
        _animations[n].fnUpdate = NULL;
    }
}
Example #13
0
void CGUIDialogKaiToast::FrameMove()
{
  //  Fading does not count as display time
  if (IsAnimating(ANIM_TYPE_WINDOW_OPEN))
    ResetTimer();

  // now check if we should exit
  if (CTimeUtils::GetFrameTime() - m_timer > m_toastDisplayTime)
    Close();
  
  CGUIDialog::FrameMove();
}
nsresult
SVGAnimatedPathSegList::SetBaseValueString(const nsAString& aValue)
{
  SVGPathData newBaseValue;

  // The spec says that the path data is parsed and accepted up to the first
  // error encountered, so we don't return early if an error occurs. However,
  // we do want to throw any error code from setAttribute if there's a problem.

  nsresult rv = newBaseValue.SetValueFromString(aValue);

  // We must send these notifications *before* changing mBaseVal! Our baseVal's
  // DOM wrapper list may have to remove DOM items from itself, and any removed
  // DOM items need to copy their internal counterpart's values *before* we
  // change them. See the comments in
  // DOMSVGPathSegList::InternalListWillChangeTo().

  DOMSVGPathSegList *baseValWrapper =
    DOMSVGPathSegList::GetDOMWrapperIfExists(GetBaseValKey());
  if (baseValWrapper) {
    baseValWrapper->InternalListWillChangeTo(newBaseValue);
  }

  DOMSVGPathSegList* animValWrapper = nullptr;
  if (!IsAnimating()) {  // DOM anim val wraps our base val too!
    animValWrapper = DOMSVGPathSegList::GetDOMWrapperIfExists(GetAnimValKey());
    if (animValWrapper) {
      animValWrapper->InternalListWillChangeTo(newBaseValue);
    }
  }

  // Only now may we modify mBaseVal!

  // We don't need to call DidChange* here - we're only called by
  // nsSVGElement::ParseAttribute under Element::SetAttr,
  // which takes care of notifying.

  nsresult rv2 = mBaseVal.CopyFrom(newBaseValue);
  if (NS_FAILED(rv2)) {
    // Attempting to increase mBaseVal's length failed (mBaseVal is left
    // unmodified). We MUST keep any DOM wrappers in sync:
    if (baseValWrapper) {
      baseValWrapper->InternalListWillChangeTo(mBaseVal);
    }
    if (animValWrapper) {
      animValWrapper->InternalListWillChangeTo(mBaseVal);
    }
    return rv2;
  }
  return rv;
}
Example #15
0
void BaseTabStrip::StopAnimating(bool layout)
{
    if(!IsAnimating())
    {
        return;
    }

    bounds_animator().Cancel();

    if(layout)
    {
        DoLayout();
    }
}
Example #16
0
void BaseTabStrip::MaybeStartDrag(BaseTab* tab,
                                  const view::MouseEvent& event)
{
    // Don't accidentally start any drag operations during animations if the
    // mouse is down... during an animation tabs are being resized automatically,
    // so the View system can misinterpret this easily if the mouse is down that
    // the user is dragging.
    if(IsAnimating() || tab->closing() ||
        controller_->HasAvailableDragActions()==0)
    {
        return;
    }
    int model_index = GetModelIndexOfBaseTab(tab);
    if(!IsValidModelIndex(model_index))
    {
        CHECK(false);
        return;
    }
    drag_controller_.reset(new DraggedTabController());
    std::vector<BaseTab*> tabs;
    int size_to_selected = 0;
    int x = tab->GetMirroredXInView(event.x());
    int y = event.y();
    // Build the set of selected tabs to drag and calculate the offset from the
    // first selected tab.
    for(int i=0; i<tab_count(); ++i)
    {
        BaseTab* other_tab = base_tab_at_tab_index(i);
        if(IsTabSelected(other_tab) && !other_tab->closing())
        {
            tabs.push_back(other_tab);
            if(other_tab == tab)
            {
                size_to_selected = GetSizeNeededForTabs(tabs);
                if(type() == HORIZONTAL_TAB_STRIP)
                {
                    x = size_to_selected - tab->width() + x;
                }
                else
                {
                    y = size_to_selected - tab->height() + y;
                }
            }
        }
    }
    DCHECK(!tabs.empty());
    DCHECK(std::find(tabs.begin(), tabs.end(), tab) != tabs.end());
    drag_controller_->Init(this, tab, tabs, gfx::Point(x, y),
        tab->GetMirroredXInView(event.x()));
}
void
SVGAnimatedPathSegList::ClearBaseValue()
{
  // We must send these notifications *before* changing mBaseVal! (See above.)

  DOMSVGPathSegList *baseValWrapper =
    DOMSVGPathSegList::GetDOMWrapperIfExists(GetBaseValKey());
  if (baseValWrapper) {
    baseValWrapper->InternalListWillChangeTo(SVGPathData());
  }

  if (!IsAnimating()) { // DOM anim val wraps our base val too!
    DOMSVGPathSegList *animValWrapper =
      DOMSVGPathSegList::GetDOMWrapperIfExists(GetAnimValKey());
    if (animValWrapper) {
      animValWrapper->InternalListWillChangeTo(SVGPathData());
    }
  }

  mBaseVal.Clear();
  // Caller notifies
}
Example #18
0
void CGUIDialogProgress::Open(const std::string &param /* = "" */)
{
  CLog::Log(LOGDEBUG, "DialogProgress::Open called %s", m_active ? "(already running)!" : "");

  {
    CSingleLock lock(g_graphicsContext);
    ShowProgressBar(false);
  }
  
  CGUIDialog::Open_Internal(false, param);

  while (m_active && IsAnimating(ANIM_TYPE_WINDOW_OPEN))
  {
    Progress();
    // we should have rendered at least once by now - if we haven't, then
    // we must be running from fullscreen video or similar where the
    // calling thread handles rendering (ie not main app thread) but
    // is waiting on this routine before rendering begins
    if (!HasProcessed())
      break;
  }
}
void
DOMSVGAnimatedLengthList::InternalBaseValListWillChangeTo(const SVGLengthList& aNewValue)
{
  // When the number of items in our internal counterpart's baseVal changes,
  // we MUST keep our baseVal in sync. If we don't, script will either see a
  // list that is too short and be unable to access indexes that should be
  // valid, or else, MUCH WORSE, script will see a list that is too long and be
  // able to access "items" at indexes that are out of bounds (read/write to
  // bad memory)!!

  if (mBaseVal) {
    mBaseVal->InternalListLengthWillChange(aNewValue.Length());
  }

  // If our attribute is not animating, then our animVal mirrors our baseVal
  // and we must sync its length too. (If our attribute is animating, then the
  // SMIL engine takes care of calling InternalAnimValListWillChangeTo() if
  // necessary.)

  if (!IsAnimating()) {
    InternalAnimValListWillChangeTo(aNewValue);
  }
}
Example #20
0
glm::vec3 Renderer::SideNotToRender_(int x, int y, int z, std::shared_ptr<Cube> cube) {
	glm::vec3 side = glm::vec3(0, 0, 0);
	if (IsAnimating()) {
		switch (animationAxis) {
		case X:
			if (x == animationSide + 1) side = glm::vec3(-animationSide * 0.51f, 0, 0);
			if (x == 1) side = glm::vec3(animationSide * 0.51f, 0, 0);
			break;
		case Y:
			if (y == animationSide + 1) side = glm::vec3(0, -animationSide * 0.51f, 0);
			if (y == 1) side = glm::vec3(0, animationSide * 0.51f, 0);
			break;
		case Z:
			if (z == animationSide + 1) side = glm::vec3(0, 0, -animationSide * 0.51f);
			if (z == 1) side = glm::vec3(0, 0, animationSide * 0.51f);
			break;
		}
		glm::mat4 rotation = glm::inverse(OrientationToMatrix__(cube->blocks[x][y][z]));
		side = glm::vec3(rotation * glm::vec4(side, 0.0f));
		// std::cout << side.x << " " << side.y << " " << side.z << std::endl;
	}
	return side;
}
Example #21
0
bool CGUIControl::CheckAnimation(ANIMATION_TYPE animType)
{
  // rule out the animations we shouldn't perform
  if (!IsVisible() || !HasProcessed())
  { // hidden or never processed - don't allow exit or entry animations for this control
    if (animType == ANIM_TYPE_WINDOW_CLOSE)
    { // could be animating a (delayed) window open anim, so reset it
      ResetAnimation(ANIM_TYPE_WINDOW_OPEN);
      return false;
    }
  }
  if (!IsVisible())
  { // hidden - only allow hidden anims if we're animating a visible anim
    if (animType == ANIM_TYPE_HIDDEN && !IsAnimating(ANIM_TYPE_VISIBLE))
    {
      // update states to force it hidden
      UpdateStates(animType, ANIM_PROCESS_NORMAL, ANIM_STATE_APPLIED);
      return false;
    }
    if (animType == ANIM_TYPE_WINDOW_OPEN)
      return false;
  }
  return true;
}
Example #22
0
void Image::Update()
{
	super::Update();

	if (IsUpdating() && IsAnimating() && GetMaxFrame() > 0) NextFrame();
}
Example #23
0
 bool IsPendingOnDelete() const { return m_pendingOnDelete && !IsAnimating(); }