diff --git a/common/view/view.cpp b/common/view/view.cpp index 339ac77e6e..7616f5397c 100644 --- a/common/view/view.cpp +++ b/common/view/view.cpp @@ -143,7 +143,7 @@ VIEW::VIEW( bool aIsDynamic, bool aUseGroups ) : m_dynamic( aIsDynamic ), m_useGroups( aUseGroups ) { - // By default there is not layer on the top + // By default there is no layer on the top m_topLayer.enabled = false; } @@ -201,6 +201,10 @@ void VIEW::SetGAL( GAL* aGal ) { m_gal = aGal; + // items need to be recached after changing GAL + if( m_useGroups ) + itemsRecache(); + // force the new GAL to display the current viewport. SetCenter( m_center ); SetScale( m_scale ); @@ -374,19 +378,14 @@ struct VIEW::drawItem { group = gal->BeginGroup(); aItem->m_cachedGroup = group; - aItem->ViewDraw( 0, gal, tmp ); + view->m_painter->Draw( static_cast( aItem ), currentLayer ); gal->EndGroup(); gal->DrawGroup( group ); } } else if( aItem->ViewIsVisible() ) { - if( !( view->m_painter - && view->m_painter->Draw( static_cast( aItem ), currentLayer ) ) ) - { - // Fallback, if there is no painter or painter does not know how to draw aItem - aItem->ViewDraw( currentLayer, gal, tmp ); - } + view->m_painter->Draw( static_cast( aItem ), currentLayer ); } time += rdtsc() - ts; @@ -445,6 +444,15 @@ struct VIEW::unlinkItem }; +struct VIEW::recacheItem +{ + void operator()( VIEW_ITEM* aItem ) + { + aItem->m_cachedGroup = -1; + } +}; + + void VIEW::Clear() { BOX2I r; @@ -544,3 +552,18 @@ void VIEW::clearGroupCache() l->items->Query( r, visitor ); }; } + + +void VIEW::itemsRecache() +{ + BOX2I r; + + r.SetMaximum(); + + for( LayerMapIter i = m_layers.begin(); i != m_layers.end(); ++i ) + { + VIEW_LAYER* l = & ( ( *i ).second ); + recacheItem visitor; + l->items->Query( r, visitor ); + }; +} diff --git a/include/view/view.h b/include/view/view.h index 8f25f45081..d7c879ee47 100644 --- a/include/view/view.h +++ b/include/view/view.h @@ -328,6 +328,7 @@ private: // Function objects that need to access VIEW/VIEW_ITEM private/protected members struct clearItemCache; struct unlinkItem; + struct recacheItem; struct drawItem; ///* Saves current top layer settings in order to restore it when it's not top anymore @@ -349,6 +350,9 @@ private: ///* Clears cached GAL display lists void clearGroupCache(); + ///* Rebuilds GAL display lists + void itemsRecache(); + /// Determines rendering order of layers. Used in display order sorting function. static bool compareRenderingOrder( VIEW_LAYER* i, VIEW_LAYER* j ) {