| 1 | /****************************************************************************** |
| 2 | * Arachnoid Graphics Plugin for Mupen64Plus |
| 3 | * http://bitbucket.org/wahrhaft/mupen64plus-video-arachnoid/ |
| 4 | * |
| 5 | * Copyright (C) 2007 Kristofer Karlsson, Rickard Niklasson |
| 6 | * |
| 7 | * This program is free software; you can redistribute it and/or |
| 8 | * modify it under the terms of the GNU General Public License |
| 9 | * as published by the Free Software Foundation; either version 2 |
| 10 | * of the License, or (at your option) any later version. |
| 11 | * |
| 12 | * This program is distributed in the hope that it will be useful, |
| 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 15 | * GNU General Public License for more details. |
| 16 | * |
| 17 | * You should have received a copy of the GNU General Public License |
| 18 | * along with this program; if not, write to the Free Software |
| 19 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
| 20 | *****************************************************************************/ |
| 21 | |
| 22 | #include "CombinerCache.h" |
| 23 | |
| 24 | //----------------------------------------------------------------------------- |
| 25 | //* New Compiled Combiner |
| 26 | //! Function used to add decoded mux values and the result of them to the list. |
| 27 | //----------------------------------------------------------------------------- |
| 28 | void CombinerCache::newCompiledCombiner(unsigned long long mux, TexEnvCombiner* compiled) |
| 29 | { |
| 30 | //Create new Combiner |
| 31 | CachedCombiner* newCombiner = new CachedCombiner(); |
| 32 | newCombiner->mux = mux; |
| 33 | newCombiner->compiled = compiled; |
| 34 | |
| 35 | //Add Combiner to list |
| 36 | m_cachedCombiners.push_back(newCombiner); |
| 37 | } |
| 38 | |
| 39 | //----------------------------------------------------------------------------- |
| 40 | //* New Compiled Combiner |
| 41 | //! Function used to retrive decoded mux values and the result of them to the list. |
| 42 | //----------------------------------------------------------------------------- |
| 43 | CachedCombiner* CombinerCache::findCachedCombiner(unsigned long long mux) |
| 44 | { |
| 45 | for (CombinerList::iterator it = m_cachedCombiners.begin(); it!=m_cachedCombiners.end(); ++it) |
| 46 | { |
| 47 | if ( (*it)->mux == mux ) |
| 48 | { |
| 49 | return (*it); //Found old combiner!! |
| 50 | } |
| 51 | } |
| 52 | |
| 53 | return 0; //Could not find it |
| 54 | } |
| 55 | |
| 56 | //----------------------------------------------------------------------------- |
| 57 | //* Dispose |
| 58 | //! Destroys all values in list. |
| 59 | //----------------------------------------------------------------------------- |
| 60 | void CombinerCache::dispose() |
| 61 | { |
| 62 | for (CombinerList::iterator it = m_cachedCombiners.begin(); it!=m_cachedCombiners.end(); ++it) |
| 63 | { |
| 64 | delete (*it)->compiled; |
| 65 | delete (*it); |
| 66 | } |
| 67 | |
| 68 | m_cachedCombiners.clear(); |
| 69 | } |