// Moves a window to the recent end of the accessed list void CWsWindow::Accessed() { WS_ASSERT_DEBUG(iAccessListRecentEnd && iAccessListOldestEnd, EWsPanicAccessList); RemoveFromAccessList(); InsertIntoAccessListRecentEnd(); }
void CWsSpriteBase::SetMember(TInt aIndex) { const TSize oldSize = iSize; const TPoint oldPos = iPos; if(IsFloating()) { TRect rect(iPos,iSize); } iCurIndex=aIndex; iPos=iBasePos+(*iMembers)[iCurIndex]->iOffset; if ((*iMembers)[iCurIndex]->iBitmap) iSize=(*iMembers)[iCurIndex]->iBitmap->SizeInPixels(); else iSize.SetSize(0,0); if (iSize.iWidth > iMaxSize.iWidth || iSize.iHeight > iMaxSize.iHeight) { WS_ASSERT_DEBUG(EFalse, EWsPanicSpriteBitmapSizeChange); CheckSizesL(); } if(oldSize!=iSize || oldPos!=iPos) NotifyExtentChanged(); }
/** @see MWsWindowTreeNode */ const MWsWindowTreeNode* CWsSpriteBase::ParentNode() const { if (iWin) return iWin; else if (iGroupWin) return iGroupWin->BaseParent(); //floating Sprite, will return the rootwin WS_ASSERT_DEBUG(EFalse,EWsPanicInvalidOperation); return NULL; }
void CWsTop::ClearSurfaceMap(CWsClient *aClient) { TInt tempScreens = CWsTop::NumberOfScreens(); for (TInt ii = 0; ii < tempScreens; ii++) { __DEBUG_ONLY(TInt err=) CWsTop::Screen(ii)->SurfaceMap()->RemoveAll(*aClient); WS_ASSERT_DEBUG((err==KErrNone||err==KErrNotFound||err==KErrInUse), EWsPanicSurfaceMapError); } }
/** @see MWsWindowTreeNode */ const MWsWindowGroup* CWsSpriteBase::WindowGroup() const { if(iWin) return iWin->WindowGroup(); else if (iGroupWin) return static_cast<MWsWindowGroup*>(iGroupWin); //floating Sprite WS_ASSERT_DEBUG(EFalse,EWsPanicInvalidOperation); return NULL; }
/** This function draws the region specified Andy - I would be happier if no region was specified here - the GC should incorporate that information */ void CWsWindow::Render(CFbsBitGc * aGc, const TRegion& aRegion) { WS_ASSERT_DEBUG(IsVisible() || (WinType() == EWinTypeRoot), EWsPanicScheduledRedraw); Accessed(); iFlags |= EFlagDrawnToScreen; iRedraw->PreDrawWindow(aGc, aRegion); iRedraw->DrawWindow(); iRedraw->PostDrawWindow(aGc); }
void CWsWindow::SetVisibleRegion(const TRegion& aNewRegion, const TRegion* aTop, TRegion& aNewFadableRegion) { STACK_REGION difference; TBool diffs = EFalse; difference.Copy(iVisibleRegion); difference.SubRegion(aNewRegion); if (!difference.IsEmpty()) { diffs = ETrue; if (IsTranslucent()) { // Andy - If this is a client window (what else could it be) we can also subtract the // user defined opaque region before doing this: iScreen->AddRedrawRegion(difference, EFalse); } } difference.Copy(aNewRegion); if (HasBeenDrawnToScreen()) { difference.SubRegion(iVisibleRegion); } if (!difference.IsEmpty()) { diffs = ETrue; STACK_REGION topDiff; topDiff.Copy(difference); WS_ASSERT_DEBUG(aTop,EWsPanicRegion); topDiff.Intersect(*aTop); difference.SubRegion(topDiff); iScreen->AddRedrawRegion(topDiff, EFalse, ERedrawTopOnly); iScreen->AddRedrawRegion(difference, EFalse, ERedrawAll); topDiff.Close(); } difference.Close(); AbortDsaIfRequired(aNewRegion, aTop); if (diffs) { ResetVisibleRegion(); iVisibleRegion.Copy(aNewRegion); PossibleVisibilityChangedEvent(EFalse); } iFadableRegion.Copy( aNewFadableRegion ); // Just because the visible region (screen coordinates) didn't change doesn't // mean the invalid region (window coordinates) didn't change, so we always call this. iRedraw->VisibleRegionChange(); }
/** This function updates the window's dirty region and schedules a redraw if needed. Only used when the screen is run in CHANGETRACKING mode. @param aRegion in window coordinates */ void CWsBackedUpWindow::MarkDirtyAndSchedule(const TRegion& aRegion) { WS_ASSERT_DEBUG(Screen()->ChangeTracking(),EWsPanicNoChangetracking); if(!aRegion.IsEmpty()) { iWsWin->AddDirtyWindowRegion(aRegion); if (iWsWin->IsActive() && iWsWin->IsVisible()) { Screen()->ScheduleWindow(iWsWin); } } }
TInt CWsObjectIx::At(const CWsObject* anObj) { const TWsObject* base=FirstObject(); const TWsObject* ptr=base; const TWsObject* end=base+iObjectArray.Count(); WS_ASSERT_DEBUG(ptr->iObject==NULL, EWsPanicObjectIndexError); while(++ptr<end) { if (ptr->iObject==anObj && (ptr->iHandle&TWsObject::ETypeMask)==(TUint)anObj->Type()) return(ptr-base); } return(KErrNotFound); }
TInt CWsObjectIx::Count() const { const TWsObject* ptr=FirstObject(); const TWsObject* end=ptr+iObjectArray.Count(); WS_ASSERT_DEBUG(ptr->iObject==NULL, EWsPanicObjectIndexError); TInt count=0; while(++ptr<end) { if (ptr->iObject && ptr->iObject->Type()!=WS_HANDLE_CLIENT) count++; } return(count); }
/** This function draws the region specified */ void CWsWindow::Render(MWsGraphicsContext& aGc, const TRegion& aWindowRegion, const TRegion& aWindowChildNodeRegion) { WS_ASSERT_DEBUG(IsVisible() || (WinType() == EWinTypeRoot), EWsPanicScheduledRedraw); AnnotateWindowRedrawStart(*this, aWindowRegion); Accessed(); iFlags |= EFlagDrawnToScreen; aGc.Reset(); iRedraw->PreDrawWindow(&aGc, aWindowRegion); iRedraw->DrawWindow(); iRedraw->PostDrawWindow(&aGc, aWindowChildNodeRegion); }
CWsDirectScreenAccess::~CWsDirectScreenAccess() { DeleteRegionSyncWatchcat(); iFrozenRegion.Close(); iVisible.Close(); if (iStatus!=EDirectStatusTimeNotCreated) { if (iStatus==EDirectStatusRunning) AbortNow(); if (iStatus>=EDirectStatusAborted) CorrectScreen(); } WS_ASSERT_DEBUG(!OnQueue(), EWsPanicDirectScreenAccess); delete iMsgQueue; }
void CWsObjectIx::Remove(CWsObject* anObj) { const TWsObject* ptr=FirstObject(); const TWsObject* end=ptr+iObjectArray.Count(); WS_ASSERT_DEBUG(ptr->iObject==NULL, EWsPanicObjectIndexError); while(++ptr<end) { if (ptr->iObject==anObj) { Remove(ptr); Tidy(); return; } } }
void CWsBackedUpWindow::ConstructL() { iDisplayMode=iWsWin->SetRequiredDisplayModeL(iDisplayMode); TSize size=iWsWin->Size(); iBitmap=new(ELeave) CFbsBitmap(); User::LeaveIfError(iBitmap->Create(size, iDisplayMode)); iBitmapDevice=CFbsBitmapDevice::NewL(iBitmap); SetSizeInTwips(); // ActivateGc(); iBitGc->SetDrawMode(CGraphicsContext::EDrawModeWriteAlpha); iBitGc->Clear(TRect(size)); iBitGc->SetDrawMode(CGraphicsContext::EDrawModePEN); WS_ASSERT_DEBUG(iWsWin->WinType()==EWinTypeClient,EWsPanicWindowType); }
void CWsRootWindow::SetSystemFaded(TBool aFaded, TUint8 aBlackMap, TUint8 aWhiteMap) { WS_ASSERT_DEBUG(Screen(),EWsPanicNoScreen); TBool stateChanged = EFalse; //will be set to true if one or more windows change fade state. for(CWsWindowGroup* win=Child();win!=NULL;win=win->NextSibling()) { TWalkWindowTreeSetSystemFaded wwt(aFaded, win, aBlackMap, aWhiteMap, stateChanged); win->WalkWindowTree(wwt,EWalkChildren); } MWsWindowTreeObserver* windowTreeObserver = Screen()->WindowTreeObserver(); if(windowTreeObserver && stateChanged) { windowTreeObserver->FadeAllChildren(*this, aFaded); } }
void CWsWindow::ClearVisibleRegion() { AbortAllDSAs(); iScreen->AddRedrawRegion(VisibleRegion(), EFalse); ResetVisibleRegion(); PossibleVisibilityChangedEvent(EFalse); if (Redraw()->HasElement()) { WS_ASSERT_DEBUG(WinType()==EWinTypeClient,EWsPanicWindowType); if (WinType()==EWinTypeClient) { iScreen->WindowElements().SetVisibleRegion(*static_cast<CWsClientWindow*>(this)); } } iFlags &= ~EFlagDrawnToScreen; }
/** Adds the object to the list. If there is an empty slot (i.e. a slot that was previously used but has been freed) the object is put in that slot else a new slot is created at the end of the array. @param anObj The object to add to the list. @return The handle to be used by the client to identify this object. @internalComponent @released */ TInt CWsObjectIx::AddL(CWsObject* anObj) { TWsObject* ptr=&iObjectArray[0]; const TWsObject* base=ptr; TInt index=iObjectArray.Count(); const TWsObject* end=ptr+index; WS_ASSERT_DEBUG(base->iObject==NULL, EWsPanicObjectIndexError); // Search for an empty slot while(++ptr<end) { if (ptr->iObject==NULL) { ptr->iObject=anObj; index=ptr-base; break; } } // create a new handle for the object TUint handleCount = ((iNewObjectCount<<TWsObject::ECountPosition) + TWsObject::ECountInc) & TWsObject::ECountMask; if (ptr==end) { // No available empty slot, so append this object to the queue if (index==TWsObject::ECountInc) { User::LeaveNoMemory(); //Things will go wrong later if we ever have more 64K objects } TWsObject newObject(anObj,handleCount); iObjectArray.AppendL(newObject); ptr=&iObjectArray[index]; } // assign the object a unique server-side handle (combination of handle count & object type) ptr->iHandle = handleCount | anObj->Type(); // increment the object counter if (++iNewObjectCount==TWsObject::ECountWrapAround) iNewObjectCount = KNewObjectInitialCount; // return to the client their unique handle for the object (combination of handle count & slot number) return (handleCount + index); }
void CWsSprite::ConstructL(const TWsClCmdCreateSprite &aParams) { NewObjL(); CWsWindowBase *win; WsOwner()->HandleToWindow(aParams.window,&win); WS_ASSERT_DEBUG(win,EWsPanicWindowNull); if (win->WinType()==EWinTypeGroup) { //If a sprite is attached to a group window it is floating. //Floating sprite drawing is performed by the sprite manager. iGroupWin=(CWsWindowGroup *)win; win=NULL; //Floating sprites aren't associated with any particular window. SetIsFloating(ETrue); //In case the GroupWin is destroyed before the sprite it needs to call DisconnectGroupWin iGroupWin->AddSprite(this); } CWsSpriteBase::ConstructL(aParams.flags&ESpriteNonSystemFlags,(CWsWindow *)win); iBasePos=aParams.pos; }
void CWsSpriteManager::RemoveFloatingSprite(CWsSpriteBase* aSprite) { #ifdef _DEBUG TInt removed = 0; #endif for (TInt i=0 ; i<iFloatingSprites.Count() ; i++) { if(iFloatingSprites[i]==aSprite) { //Just remove the sprite don't delete it. the manager doesn't have ownership iFloatingSprites.Remove(i); #ifdef _DEBUG removed++; #else break; #endif } } WS_ASSERT_DEBUG(removed==1,EWsPanicFloatingSprite); }
void CWsWindow::RestartAnimations(const TRegion& aNewRegion) { //When not ChangeTracking, restarting is handled by AddRedrawRegion (called from CWsWindow::SetVisibleRegion) and TWalkWindowTreeScheduleRegions WS_ASSERT_DEBUG(iScreen->ChangeTracking(),EWsPanicNoChangetracking); //Restart uncovered window animations for (CWsAnim* anim = iAnimList; anim; anim = anim->Next()) { if(!iScreen->IsScheduled(EWindowAnim, anim->BestRect(), this) && aNewRegion.Intersects(anim->BestRect())) { iScreen->ScheduleAnimation(EWindowAnim, anim->BestRect(), 0, 0, 0, this); } } //Restart uncovered sprite animations for (CWsSpriteBase* sprite = iSpriteList; sprite; sprite = sprite->Next()) { if(!iScreen->IsScheduled(ESpriteAnim, sprite->Rect(), sprite->Win()) && aNewRegion.Intersects(sprite->Rect())) { iScreen->ScheduleAnimation(ESpriteAnim, sprite->Rect(), 0, 0, 0, sprite->Win()); } } }
void CWsWindow::SetVisibleRegion(const TRegion& aNewRegion, const TRegion* aTop) { WS_ASSERT_DEBUG(iScreen, EWsPanicNoScreen); STACK_REGION difference; TBool diffs = EFalse; difference.Copy(iVisibleRegion); difference.SubRegion(aNewRegion); if (!difference.IsEmpty()) { diffs = ETrue; if (IsTranslucent()) { iScreen->AddRedrawRegion(difference, EFalse); } } difference.Copy(aNewRegion); if (HasBeenDrawnToScreen()) { difference.SubRegion(iVisibleRegion); } if (!difference.IsEmpty()) { diffs = ETrue; if(!iScreen->ChangeTracking()) { //the following code will restart animations STACK_REGION topDiff; topDiff.Copy(difference); WS_ASSERT_DEBUG(aTop,EWsPanicRegion); topDiff.Intersect(*aTop); difference.SubRegion(topDiff); iScreen->AddRedrawRegion(topDiff, EFalse, ERedrawTopOnly); iScreen->AddRedrawRegion(difference, EFalse, ERedrawAll); topDiff.Close(); } else if(IsVisible()) { RestartAnimations(aNewRegion); } } difference.Close(); AbortDsaIfRequired(aNewRegion, aTop); if (diffs) { ResetVisibleRegion(); iVisibleRegion.Copy(aNewRegion); PossibleVisibilityChangedEvent(EFalse); if (Redraw()->HasElement()) { WS_ASSERT_DEBUG(WinType()==EWinTypeClient,EWsPanicWindowType); if (WinType()==EWinTypeClient) { iScreen->WindowElements().SetVisibleRegion(*static_cast<CWsClientWindow*>(this)); } } } // Just because the visible region (screen coordinates) didn't change doesn't // mean the invalid region (window coordinates) didn't change, so we always call this. iRedraw->VisibleRegionChange(); }
//This function sets up the quick fadable region. //It removes anything that cannot be quick faded, and schedules it to be drawn in the normal fashion. void CWsWindow::SetFadeableRegion(const TRegion& aNewFadableRegion, const TRegion& aTop) { WS_ASSERT_DEBUG(iScreen, EWsPanicNoScreen); iFadableRegion.Copy(aNewFadableRegion); //Try to figure out if any part of iFadableRegion can be quick faded (i.e. fading applied to //the screen without first having to redraw all visible windows intersecting the region). if ( !iFadableRegion.IsEmpty() && iScreen->IsQuickFadeScheduled(this) ) { if (IsTranslucent()) { //If a window is semitransparent, then we cannot apply a quickfade to it if //the window below is faded too. iScreen->AddRedrawRegion(iVisibleRegion, EFalse, ERedrawAll); iScreen->RemoveFromQuickFadeList(this); } else { iQuickFadeRegion.Intersection(iFadableRegion, aTop); //Remove any regions not possible to quick fade from iQuickFadeRegion and //schedule these regions for full back-front rendering instead. STACK_REGION nonQuickFadableRegion; for(CWsSpriteBase * sprite = iSpriteList; sprite; sprite = sprite->Next()) { nonQuickFadableRegion.AddRect(sprite->Rect()); } for(CWsAnim * anim = iAnimList; anim; anim = anim->Next()) { nonQuickFadableRegion.AddRect(anim->BestRect()); } RWsTextCursor* const cursor = CWsTop::CurrentTextCursor(); if( cursor && (cursor->Window()==this) && cursor->IsStandardCursorActive() ) { nonQuickFadableRegion.AddRect(cursor->Rect()); } //Any regions scheduled for fading but partly or fully covered by transparent windows above them STACK_REGION coveredFadableRegion; coveredFadableRegion.Copy(iFadableRegion); coveredFadableRegion.SubRegion(iQuickFadeRegion); nonQuickFadableRegion.Union(coveredFadableRegion); coveredFadableRegion.Close(); nonQuickFadableRegion.Tidy(); //Remove any regions not possible to quick fade from iQuickFadeRegion iQuickFadeRegion.SubRegion(nonQuickFadableRegion); if (!nonQuickFadableRegion.CheckError()) { //Schedule normal drawing (full back to front rendering) for the region not possible to quick fade if (!nonQuickFadableRegion.IsEmpty()) { iScreen->AddRedrawRegion(nonQuickFadableRegion, EFalse, ERedrawAll); } } else { //Schedule normal drawing for the whole iVisibleRegion if the calculations are broken iScreen->AddRedrawRegion(iVisibleRegion, EFalse, ERedrawAll); } nonQuickFadableRegion.Close(); } } else { iQuickFadeRegion.Reset(); } }
void CWsObjectIx::Remove(const TWsObject* aObject) { WS_ASSERT_DEBUG(aObject->iObject!=NULL, EWsPanicObjectIndexError); WS_ASSERT_DEBUG((aObject->iHandle&TWsObject::ETypeMask)==(TUint)aObject->iObject->Type(), EWsPanicObjectIndexError); const_cast<TWsObject*>(aObject)->iObject=NULL; }
CWsPointerCursor::~CWsPointerCursor() { WS_ASSERT_DEBUG(iAccessCount==0, EWsPanicPointerCursorAccessCount); }
void CWsPointerCursor::Close() { WS_ASSERT_DEBUG(iAccessCount>0, EWsPanicPointerCursorAccessCount); if (--iAccessCount==0) delete this; }
/** Called from groupwin destructor only */ void CWsSpriteBase::DisconnectGroupWin() { WS_ASSERT_DEBUG(IsFloating(),EWsPanicFloatingSprite); iGroupWin=NULL; }