Beispiel #1
0
/**
 @pre	CWsSpriteBase::CalcRedrawRegion(TRegion&,TRegion&) should have been called.
 @param aRegion Is the region that will definitely be redrawn if dirty. This param should
                be calculated by calling CalcRedrawRegion(TRegion&,TRegion&)
 */
void CWsSpriteBase::Redraw(MWsGraphicsContext * aGc, const TRegion& aRegion)
	{
	TFlashState currentState=EFlashOn;
	if(IsFlashingEnabled())
		{
		currentState=Screen()->SpriteManager()->CurrentSpriteFlashState(this);
		AnnotateSpriteFlash(*this, currentState==EFlashOn);
		}

	if(currentState==EFlashOn && (IsDirty() || HasAnimation()) )
		{
		const TRegion * pr = &aRegion;

		if (pr->CheckError())
			{
			if(iWin)
				{
				if (Screen()->ChangeTracking())
					pr = &iWin->WindowArea();
				else
					pr = &iWin->VisibleRegion();
				}
			else
				pr = &RootWindow()->WindowArea();
			}

		if (!pr->IsEmpty())
			{
			CWsSpriteMember *member=(*iMembers)[iCurIndex];
			if (member->iBitmap)
				{
				aGc->SetClippingRegion(*pr);

				// Calculate which piece (rect) of the bitmap needs to be drawn
				const TRect redrawRect = pr->BoundingRect();
				TRect bitmapRect(Pos(), iSize); // sprite rect relative to screen
				bitmapRect.Intersection(redrawRect);
				bitmapRect.Move(-Pos()); // adjust relative to bitmap origin

				if (member->iMaskBitmap)
					aGc->BitBltMasked(Pos() + bitmapRect.iTl, *member->iBitmap, bitmapRect, *member->iMaskBitmap, member->iInvertMask);
				else
					{
					aGc->SetDrawMode(BitGdiToMWsGraphicsContextMappings::LossyConvert(member->iDrawMode));
					aGc->BitBlt(Pos() + bitmapRect.iTl, *member->iBitmap, bitmapRect);
					aGc->SetDrawMode(MWsGraphicsContext::EDrawModePEN);
					}
				aGc->ResetClippingRegion();
				}
			}
		if (Screen()->ChangeTracking())
			SetDirty(EFalse);
		
		}
		
	//Flashing sprites need to reschedule themselves after drawing (unless they have
	//an animation, because for animating sprites the rescheduling is done in CWsAnim).
	if(IsFlashingEnabled() && !HasAnimation())
		Screen()->SpriteManager()->Schedule(this);
	}
Beispiel #2
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);
}
//----------------------------------------------------------------------------
bool SceneBuilder::ConvertFRGBAAttrib(IParamBlock2* paramBlock, int index,
									  std::string &name, PX2::Float4 &value)
{
	ParamBlockDesc2 *paramDesc = paramBlock->GetDesc();

	if (!paramDesc)
		return false;

	ParamDef &paramDef = paramDesc->GetParamDef(paramDesc->IndextoID(index));

	Point4 vectorValue;
	Interval validInterval;
	BOOL retrieved = false;	

	retrieved =  paramBlock->GetValue((ParamID)index, 0 , vectorValue, validInterval);
	if(retrieved)
	{
		TCHAR* valueName = paramDef.int_name;
		if (!IsValidName(valueName)) 
			valueName = paramBlock->GetLocalName((ParamID)index );
		assertion(IsValidName(valueName), "valueName must be valuable.");
		name = std::string(valueName);

		value = PX2::Float4(vectorValue.x, vectorValue.y, vectorValue.z, 
			vectorValue.w);

		if(HasAnimation(paramBlock, index))
		{
		}
	}

	return true;
}
Beispiel #4
0
void
Decoder::PostFrameStop(Opacity aFrameOpacity
                         /* = Opacity::SOME_TRANSPARENCY */,
                       DisposalMethod aDisposalMethod
                         /* = DisposalMethod::KEEP */,
                       int32_t aTimeout         /* = 0 */,
                       BlendMethod aBlendMethod /* = BlendMethod::OVER */)
{
  // We should be mid-frame
  MOZ_ASSERT(!IsMetadataDecode(), "Stopping frame during metadata decode");
  MOZ_ASSERT(mInFrame, "Stopping frame when we didn't start one");
  MOZ_ASSERT(mCurrentFrame, "Stopping frame when we don't have one");

  // Update our state
  mInFrame = false;

  mCurrentFrame->Finish(aFrameOpacity, aDisposalMethod, aTimeout, aBlendMethod);

  mProgress |= FLAG_FRAME_COMPLETE;

  // If we're not sending partial invalidations, then we send an invalidation
  // here when the first frame is complete.
  if (!ShouldSendPartialInvalidations() && mFrameCount == 1) {
    mInvalidRect.UnionRect(mInvalidRect,
                           gfx::IntRect(gfx::IntPoint(0, 0), GetSize()));
  }

  // If we are going to keep decoding we should notify now about the first frame being done.
  if (mImage && mFrameCount == 1 && HasAnimation()) {
    MOZ_ASSERT(HasProgress());
    DecodePool::Singleton()->NotifyProgress(this);
  }
}
Beispiel #5
0
nsresult
Decoder::AllocateFrame(uint32_t aFrameNum,
                       const nsIntSize& aTargetSize,
                       const nsIntRect& aFrameRect,
                       gfx::SurfaceFormat aFormat,
                       uint8_t aPaletteDepth)
{
  mCurrentFrame = AllocateFrameInternal(aFrameNum, aTargetSize, aFrameRect,
                                        aFormat, aPaletteDepth,
                                        mCurrentFrame.get());

  if (mCurrentFrame) {
    // Gather the raw pointers the decoders will use.
    mCurrentFrame->GetImageData(&mImageData, &mImageDataLength);
    mCurrentFrame->GetPaletteData(&mColormap, &mColormapSize);

    if (aFrameNum + 1 == mFrameCount) {
      // If we're past the first frame, PostIsAnimated() should've been called.
      MOZ_ASSERT_IF(mFrameCount > 1, HasAnimation());

      // Update our state to reflect the new frame
      MOZ_ASSERT(!mInFrame, "Starting new frame but not done with old one!");
      mInFrame = true;
    }
  } else {
    PostDataError();
  }

  return mCurrentFrame ? NS_OK : NS_ERROR_FAILURE;
}
Beispiel #6
0
void
Decoder::CompleteDecode()
{
  // Implementation-specific finalization
  BeforeFinishInternal();
  if (!HasError()) {
    FinishInternal();
  } else {
    FinishWithErrorInternal();
  }

  // If the implementation left us mid-frame, finish that up.
  if (mInFrame && !HasError()) {
    PostFrameStop();
  }

  // If PostDecodeDone() has not been called, and this decoder wasn't aborted
  // early because of low-memory conditions or losing a race with another
  // decoder, we need to send teardown notifications (and report an error to the
  // console later).
  if (!IsMetadataDecode() && !mDecodeDone && !WasAborted()) {
    mShouldReportError = true;

    // If we only have a data error, we're usable if we have at least one
    // complete frame.
    if (!HasDecoderError() && GetCompleteFrameCount() > 0) {
      // We're usable, so do exactly what we should have when the decoder
      // completed.

      // Not writing to the entire frame may have left us transparent.
      PostHasTransparency();

      if (mInFrame) {
        PostFrameStop();
      }
      PostDecodeDone();
    } else {
      // We're not usable. Record some final progress indicating the error.
      if (!IsMetadataDecode()) {
        mProgress |= FLAG_DECODE_COMPLETE;
      }
      mProgress |= FLAG_HAS_ERROR;
    }
  }

  if (mDecodeDone && !IsMetadataDecode()) {
    MOZ_ASSERT(HasError() || mCurrentFrame, "Should have an error or a frame");

    // If this image wasn't animated and isn't a transient image, mark its frame
    // as optimizable. We don't support optimizing animated images and
    // optimizing transient images isn't worth it.
    if (!HasAnimation() &&
        !(mDecoderFlags & DecoderFlags::IMAGE_IS_TRANSIENT) &&
        mCurrentFrame) {
      mCurrentFrame->SetOptimizable();
    }
  }
}
Beispiel #7
0
    DiAnimation* DiMotion::CreateAnimation(const DiString& name, float length)
    {
        if (HasAnimation(name))
        {
            DI_WARNING("The animatin %s has already existed",name.c_str());
            return nullptr;
        }

        DiAnimation* am = DI_NEW DiAnimation(name,length);
        mAnimationList[name] = am;
        return am;
    }
void CModelViewRender::PlaySequence(const ANIMATIONSEQUENCE &sequence)
{
    // make a copy of the requested sequence
    m_PlayingAnimationSequence.clear();
    std::copy(sequence.begin(), sequence.end(), std::back_inserter(m_PlayingAnimationSequence));
    m_itCurrentAnimationID = m_PlayingAnimationSequence.begin();

    // create all the callbacks at once for the sequence
    set<int> uniqueCallbackSet;
    for (ANIMATIONSEQUENCE::iterator itrAnim = m_PlayingAnimationSequence.begin(); itrAnim != m_PlayingAnimationSequence.end(); itrAnim++)
    {
        // skip duplicate animations (only need to make one callback per animation)
        if (uniqueCallbackSet.find( *itrAnim ) != uniqueCallbackSet.end())
            continue;

        IArchive* pArchive = CreateMemoryArchive();
        pArchive->Write(m_hszEntityName.GetString(), _T("EntityName"));
        pArchive->Write(*itrAnim);
        pArchive->SetIsWriting(false);
        m_AnimationCallbackArchives.push_back( pArchive );

        static CHashString hszCal3DRenderObject = _T("Cal3DRenderObject");
        static CHashString hszCModelViewComponent(_T("CModelViewComponent"));
        static CHashString hszPlayAnimationSequenceStep(_T("PlayAnimationSequenceStep"));

        REGISTERCAL3DANIMATIONCALLBACK ac;
        ac.AnimationId = *itrAnim;
        ac.bTriggerOnComplete = true;
        ac.bTriggerOnStop = false;
        ac.StateObjectName = &hszCModelViewComponent;
        ac.EventName = &hszPlayAnimationSequenceStep;
        ac.EventParamsArchive = pArchive;

        static DWORD msgHash_RegisterAnimationCallback = CHashString(_T("RegisterAnimationCallback")).GetUniqueID();
        DWORD res = m_ToolBox->SendMessage(msgHash_RegisterAnimationCallback, sizeof(ac), &ac, &m_hszEntityName, &hszCal3DRenderObject);
        if (MSG_HANDLED != res)
        {
            m_ToolBox->Log(LOGERROR, _T("%s(%i): Cannot register animation callback. \n"), __FILE__, __LINE__);
        }
        uniqueCallbackSet.insert( *itrAnim );
    }

    if (HasAnimation())
    {
        SINGLETONINSTANCE(CModelViewComponent)->PlayAnimation(this);
    }
}
void CModelViewRender::PlayNextAnimation()
{
    static CHashString hszCal3DRenderObject(_T("Cal3DRenderObject"));
    static DWORD msgStopAllAnimationActions = CHashString(_T("StopAllAnimationActions")).GetUniqueID();
    m_ToolBox->SendMessage( msgStopAllAnimationActions, 0, NULL, &m_hszEntityName, &hszCal3DRenderObject );

    if (m_itCurrentAnimationID != m_PlayingAnimationSequence.end())
        m_itCurrentAnimationID++;

    if (m_bLoop && m_itCurrentAnimationID == m_PlayingAnimationSequence.end())
    {
        m_itCurrentAnimationID = m_PlayingAnimationSequence.begin();
    }

    if (HasAnimation())
    {
        SINGLETONINSTANCE(CModelViewComponent)->PlayAnimation(this);
    }
}
void CModelViewRender::StopSequence()
{
    m_bPlayNextInSequence = false;

    static CHashString hszCal3DRenderObject = _T("Cal3DRenderObject");

    // unregister all animation callbacks
    static DWORD msgHash_UnregisterAllAnimationCallbacks = CHashString(_T("UnregisterAllAnimationCallbacks")).GetUniqueID();
    DWORD res = m_ToolBox->SendMessage(msgHash_UnregisterAllAnimationCallbacks, 0, NULL, &m_hszEntityName, &hszCal3DRenderObject);
    if (MSG_HANDLED != res)
    {
        m_ToolBox->Log(LOGERROR, _T("%s(%i): Cannot unregister animation callbacks.\n"), __FILE__, __LINE__);
    }
    // clean up all the callback archives
    vector<IArchive*>::iterator itrCallback = m_AnimationCallbackArchives.begin();
    while (itrCallback != m_AnimationCallbackArchives.end())
    {
        (*itrCallback)->Close();
        itrCallback++;
    }
    m_AnimationCallbackArchives.clear();

    // stop all animations
    static DWORD msgStopAllAnimationActions = CHashString(_T("StopAllAnimationActions")).GetUniqueID();
    m_ToolBox->SendMessage( msgStopAllAnimationActions, 0, NULL, &m_hszEntityName, &hszCal3DRenderObject );

    if (HasAnimation())
    {
        m_PlayingAnimationSequence.clear();
        m_itCurrentAnimationID = m_PlayingAnimationSequence.end();
        m_bLoop = false;

        // initiate delayed deletion for cal3Dmodel callbacks with Update event
        // this prevents memory leaks with EventParamsArchive
        // TODO. This may be fixed in cal3DModel probably
        AfxGetApp()->OnIdle(2);
    }

    GetDockDlg()->OnStopSequence();
}
void FaerieAnimationsCollection::AddAnimation(FaerieAnimation* animation) {
	assert(!HasAnimation(animation->GetName()));
	_mapAnimations[animation->GetName()] = animation;
}
int CModelViewRender::GetCurrentAnimationID() const
{
    ASSERT(HasAnimation());
    return *m_itCurrentAnimationID;
}