opengl : improve the texture data manage to memory 21/26521/1
authorHyunjong.park <phjwithyou.park@samsung.com>
Tue, 26 Aug 2014 02:32:11 +0000 (11:32 +0900)
committerHyunjong.park <phjwithyou.park@samsung.com>
Tue, 26 Aug 2014 02:32:11 +0000 (11:32 +0900)
Signed-off-by: Hyunjong.park <phjwithyou.park@samsung.com>
Change-Id: I8affc3ee3e830c2170aa2ab1d3576e522c2781e3

org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/opengl/data/DB/GLStateTextureDBTableManager.java
org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/opengl/data/GLTextureStateDataMaker.java
org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/opengl/data/type/GLStateTextureType.java
org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/opengl/table/state/GLTextureTable.java
org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/opengl/table/state/GLTextureTableView.java

index 3138a67..2c859f4 100644 (file)
@@ -35,6 +35,7 @@ import org.tizen.dynamicanalyzer.database.DBColumn;
 import org.tizen.dynamicanalyzer.database.DBConstants;
 import org.tizen.dynamicanalyzer.database.DBTable;
 import org.tizen.dynamicanalyzer.database.SqlConnectionManager;
+import org.tizen.dynamicanalyzer.ui.opengl.data.GLDataManager;
 import org.tizen.dynamicanalyzer.ui.opengl.data.type.GLStateTextureType;
 
 public class GLStateTextureDBTableManager extends DBTable {
@@ -59,17 +60,15 @@ public class GLStateTextureDBTableManager extends DBTable {
        public final static int TABLE_TEXTURE_OBJ_WRAP_T_INDEX = 7;
 
        private static final String SELECT_QUERY = "select "//$NON-NLS-1$
-                       + CONTEXT_ID + CommonConstants.COMMA
-                       + CHANGE_SEQ
-                       + CommonConstants.COMMA + TEXTURE_UNIT_TYPE
+                       + CONTEXT_ID + CommonConstants.COMMA + CHANGE_SEQ
                        + CommonConstants.COMMA
-                       + TEXTURE_OBJ_ID + CommonConstants.COMMA
-                       + TEXTURE_OBJ_MAG_FUNC
+                       + TEXTURE_UNIT_TYPE + CommonConstants.COMMA + TEXTURE_OBJ_ID
                        + CommonConstants.COMMA
+                       + TEXTURE_OBJ_MAG_FUNC + CommonConstants.COMMA
                        + TEXTURE_OBJ_MIN_FUNC
+                       + CommonConstants.COMMA + TEXTURE_OBJ_WRAP_S
                        + CommonConstants.COMMA
-                       + TEXTURE_OBJ_WRAP_S
-                       + CommonConstants.COMMA + TEXTURE_OBJ_WRAP_T + " from " + TABLENAME;//$NON-NLS-1$
+                       + TEXTURE_OBJ_WRAP_T + " from " + TABLENAME;//$NON-NLS-1$
 
        @Override
        public String getTableName() {
@@ -77,22 +76,14 @@ public class GLStateTextureDBTableManager extends DBTable {
        }
 
        public GLStateTextureDBTableManager() {
-               addColumn(new DBColumn(CONTEXT_ID, DBConstants.NOT_NULL,
-                               DBConstants.LONG));
-               addColumn(new DBColumn(CHANGE_SEQ, DBConstants.NOT_NULL,
-                               DBConstants.INTEGER));
-               addColumn(new DBColumn(TEXTURE_UNIT_TYPE, DBConstants.NOT_NULL,
-                               DBConstants.INTEGER));
-               addColumn(new DBColumn(TEXTURE_OBJ_ID, DBConstants.NOT_NULL,
-                               DBConstants.INTEGER));
-               addColumn(new DBColumn(TEXTURE_OBJ_MAG_FUNC, DBConstants.NOT_NULL,
-                               DBConstants.INTEGER));
-               addColumn(new DBColumn(TEXTURE_OBJ_MIN_FUNC, DBConstants.NOT_NULL,
-                               DBConstants.INTEGER));
-               addColumn(new DBColumn(TEXTURE_OBJ_WRAP_S, DBConstants.NOT_NULL,
-                               DBConstants.INTEGER));
-               addColumn(new DBColumn(TEXTURE_OBJ_WRAP_T, DBConstants.NOT_NULL,
-                               DBConstants.INTEGER));
+               addColumn(new DBColumn(CONTEXT_ID, DBConstants.NOT_NULL, DBConstants.LONG));
+               addColumn(new DBColumn(CHANGE_SEQ, DBConstants.NOT_NULL, DBConstants.INTEGER));
+               addColumn(new DBColumn(TEXTURE_UNIT_TYPE, DBConstants.NOT_NULL, DBConstants.INTEGER));
+               addColumn(new DBColumn(TEXTURE_OBJ_ID, DBConstants.NOT_NULL, DBConstants.INTEGER));
+               addColumn(new DBColumn(TEXTURE_OBJ_MAG_FUNC, DBConstants.NOT_NULL, DBConstants.INTEGER));
+               addColumn(new DBColumn(TEXTURE_OBJ_MIN_FUNC, DBConstants.NOT_NULL, DBConstants.INTEGER));
+               addColumn(new DBColumn(TEXTURE_OBJ_WRAP_S, DBConstants.NOT_NULL, DBConstants.INTEGER));
+               addColumn(new DBColumn(TEXTURE_OBJ_WRAP_T, DBConstants.NOT_NULL, DBConstants.INTEGER));
        }
 
        public void insertData(GLStateTextureType data) {
@@ -110,9 +101,24 @@ public class GLStateTextureDBTableManager extends DBTable {
                insertData(insertList);
        }
 
+       public void initTextureDataAtOpen() {
+               List<GLStateTextureType> selectedList = select();
+               for (GLStateTextureType type : selectedList) {
+                       GLDataManager.getInstance().getStateDataManager().getTextureMakeObject()
+                                       .addTextureList(type);
+               }
+       }
+
+       public void insertTextureData() {
+               List<GLStateTextureType> insertList = GLDataManager.getInstance().getStateDataManager()
+                               .getTextureMakeObject().getTextureList();
+               for (GLStateTextureType type : insertList) {
+                       insertData(type);
+               }
+       }
+
        public List<GLStateTextureType> select() {
-               List<List<Object>> result = SqlConnectionManager
-                               .executeQuery(SELECT_QUERY);
+               List<List<Object>> result = SqlConnectionManager.executeQuery(SELECT_QUERY);
                if (null == result || result.size() == 0 || result.get(0).size() == 0) {
                        return null;
                }
@@ -121,21 +127,14 @@ public class GLStateTextureDBTableManager extends DBTable {
                for (int i = 0; i < result.size(); i++) {
                        long contextID = (Long) result.get(i).get(TABLE_CONTEXT_ID_INDEX);
                        int seq = (Integer) result.get(i).get(TABLE_CHANGE_SEQ_INDEX);
-                       int unitType = (Integer) result.get(i).get(
-                                       TABLE_TEXTURE_UNIT_TYPE_INDEX);
-                       int textureId = (Integer) result.get(i).get(
-                                       TABLE_TEXTURE_OBJ_ID_INDEX);
-                       int magFilter = (Integer) result.get(i).get(
-                                       TABLE_TEXTURE_OBJ_MAG_FUNC_INDEX);
-                       int minFilter = (Integer) result.get(i).get(
-                                       TABLE_TEXTURE_OBJ_MIN_FUNC_INDEX);
-                       int wrapS = (Integer) result.get(i).get(
-                                       TABLE_TEXTURE_OBJ_WRAP_S_INDEX);
-                       int wrapT = (Integer) result.get(i).get(
-                                       TABLE_TEXTURE_OBJ_WRAP_T_INDEX);
-
-                       GLStateTextureType textureType = new GLStateTextureType(textureId,
-                                       contextID, seq);
+                       int unitType = (Integer) result.get(i).get(TABLE_TEXTURE_UNIT_TYPE_INDEX);
+                       int textureId = (Integer) result.get(i).get(TABLE_TEXTURE_OBJ_ID_INDEX);
+                       int magFilter = (Integer) result.get(i).get(TABLE_TEXTURE_OBJ_MAG_FUNC_INDEX);
+                       int minFilter = (Integer) result.get(i).get(TABLE_TEXTURE_OBJ_MIN_FUNC_INDEX);
+                       int wrapS = (Integer) result.get(i).get(TABLE_TEXTURE_OBJ_WRAP_S_INDEX);
+                       int wrapT = (Integer) result.get(i).get(TABLE_TEXTURE_OBJ_WRAP_T_INDEX);
+
+                       GLStateTextureType textureType = new GLStateTextureType(textureId, contextID, seq);
                        textureType.setMagFilter(magFilter);
                        textureType.setMinFilter(minFilter);
                        textureType.setWrapS(wrapS);
@@ -164,11 +163,9 @@ public class GLStateTextureDBTableManager extends DBTable {
                                prep.setInt(TABLE_TEXTURE_OBJ_ID_INDEX + 1,
                                                (Integer) (rowData.get(TABLE_TEXTURE_OBJ_ID_INDEX)));
                                prep.setInt(TABLE_TEXTURE_OBJ_MAG_FUNC_INDEX + 1,
-                                               (Integer) (rowData
-                                                               .get(TABLE_TEXTURE_OBJ_MAG_FUNC_INDEX)));
+                                               (Integer) (rowData.get(TABLE_TEXTURE_OBJ_MAG_FUNC_INDEX)));
                                prep.setInt(TABLE_TEXTURE_OBJ_MIN_FUNC_INDEX + 1,
-                                               (Integer) (rowData
-                                                               .get(TABLE_TEXTURE_OBJ_MIN_FUNC_INDEX)));
+                                               (Integer) (rowData.get(TABLE_TEXTURE_OBJ_MIN_FUNC_INDEX)));
                                prep.setInt(TABLE_TEXTURE_OBJ_WRAP_S_INDEX + 1,
                                                (Integer) (rowData.get(TABLE_TEXTURE_OBJ_WRAP_S_INDEX)));
                                prep.setInt(TABLE_TEXTURE_OBJ_WRAP_T_INDEX + 1,
index a99d8f2..38e3e16 100644 (file)
@@ -27,9 +27,9 @@
 
 package org.tizen.dynamicanalyzer.ui.opengl.data;
 
-import java.util.Iterator;
+import java.util.ArrayList;
+import java.util.List;
 import java.util.Map;
-import java.util.Map.Entry;
 
 import org.tizen.dynamicanalyzer.constant.CommonConstants;
 import org.tizen.dynamicanalyzer.swap.model.data.GLES20LogData;
@@ -135,7 +135,6 @@ public class GLTextureStateDataMaker {
                                                DA_LOG.error("GL " + apiName + " undefine type : " + parameters[1]);
                                        }
                                }
-                               insertTextureData();
                        } else if (apiName.equals(GLAPINameDefine.API_GL_TEXTURE_PARAM_FV)
                                        || apiName.equals(GLAPINameDefine.API_GL_TEXTURE_PARAM_IV)) {
                                if (parameters.length != 3) {
@@ -168,11 +167,29 @@ public class GLTextureStateDataMaker {
                                                DA_LOG.error("GL " + apiName + " undefine type : " + parameters[1]);
                                        }
                                }
-                               insertTextureData();
                        }
                }
        }
 
+       public void addTextureList(GLStateTextureType textureType) {
+               GLContextDataManager contextValue = getStateDataManager().getGLContextDataManager(
+                               textureType.getContextID());
+               if (null == contextValue) {
+                       contextValue = new GLContextDataManager(textureType.getContextID());
+                       getStateDataManager().getStateHashMap().put(textureType.getContextID(), contextValue);
+               }
+               contextValue.textureList.add(textureType);
+       }
+
+       public List<GLStateTextureType> getTextureList() {
+               List<GLStateTextureType> returnProgramList = new ArrayList<GLStateTextureType>();
+               for (Map.Entry<Long, GLContextDataManager> entry : getStateDataManager().getStateHashMap()
+                               .entrySet()) {
+                       returnProgramList.addAll(entry.getValue().textureList);
+               }
+               return returnProgramList;
+       }
+
        private boolean isSameTextureType(GLStateTextureType existingTexture,
                        String parameterTextureObjId, long contextId) {
                if (existingTexture.getObjID() == Integer.parseInt(parameterTextureObjId.trim())
@@ -182,31 +199,4 @@ public class GLTextureStateDataMaker {
                        return false;
                }
        }
-
-       private void insertTextureData() {
-               Iterator<Entry<Long, GLContextDataManager>> itr = getStateDataManager().getStateHashMap()
-                               .entrySet().iterator();
-               while (itr.hasNext()) {
-                       GLContextDataManager contextValue = ((Map.Entry<Long, GLContextDataManager>) itr.next())
-                                       .getValue();
-                       GLStateTextureType insertTextureType = returnInsertTextureType(contextValue);
-                       if (null != insertTextureType) {
-                               GLDataManager.getInstance().getStateTextureDBTableManage()
-                                               .insertData(insertTextureType);
-                       }
-               }
-       }
-
-       private GLStateTextureType returnInsertTextureType(GLContextDataManager contextValue) {
-               GLStateTextureType insertTextureType = null;
-               for (int i = 0; i < contextValue.textureList.size(); i++) {
-                       if (contextValue.textureList.get(i).validInsertState()) {
-                               insertTextureType = contextValue.textureList.get(i);
-                               contextValue.textureList.remove(i);
-                               break;
-                       }
-               }
-               return insertTextureType;
-
-       }
 }
index b966103..b81b546 100644 (file)
@@ -117,14 +117,4 @@ public class GLStateTextureType {
        public void setDelete(boolean isDelete) {
                this.isDelete = isDelete;
        }
-
-       public boolean validInsertState() {
-               if (seq != -1 && contextID != -1 && type != -1 && objID != -1
-                               && magFilter != -1 && minFilter != -1 && wrapS != -1
-                               && wrapT != -1) {
-                       return true;
-               } else {
-                       return false;
-               }
-       }
 }
\ No newline at end of file
index d2a7b94..1f7659a 100644 (file)
@@ -68,8 +68,9 @@ public class GLTextureTable extends DATableComposite {
 
                GLDataManager.getInstance().updateSharingContextList();
 
-               List<GLStateTextureType> textureList = GLDataManager.getInstance()
-                               .getStateTextureDBTableManage().select();
+               List<GLStateTextureType> textureList = GLDataManager.getInstance().getStateDataManager()
+                               .getTextureMakeObject().getTextureList();
+
                if (null == textureList) {
                        return null;
                }
@@ -80,23 +81,16 @@ public class GLTextureTable extends DATableComposite {
 
                        String textureId = Integer.toString(textureList.get(i).getObjID());
 
-                       DATableDataFormat tableData = new DATableDataFormat(
-                                       Long.parseLong(textureId));
+                       DATableDataFormat tableData = new DATableDataFormat(Long.parseLong(textureId));
 
-                       text.add(GLPageLabels.GL_CONTEXT
-                                       + Long.toString(textureList.get(i).getContextID()));
+                       text.add(GLPageLabels.GL_CONTEXT + Long.toString(textureList.get(i).getContextID()));
                        text.add(GLPageLabels.GL_TEXTURE + textureId);
 
-                       text.add(GLConstantDefine.getConstantString(textureList.get(i)
-                                       .getType()));
-                       text.add(GLConstantDefine.getConstantString(textureList.get(i)
-                                       .getWrapS()));
-                       text.add(GLConstantDefine.getConstantString(textureList.get(i)
-                                       .getWrapT()));
-                       text.add(GLConstantDefine.getConstantString(textureList.get(i)
-                                       .getMinFilter()));
-                       text.add(GLConstantDefine.getConstantString(textureList.get(i)
-                                       .getMagFilter()));
+                       text.add(GLConstantDefine.getConstantString(textureList.get(i).getType()));
+                       text.add(GLConstantDefine.getConstantString(textureList.get(i).getWrapS()));
+                       text.add(GLConstantDefine.getConstantString(textureList.get(i).getWrapT()));
+                       text.add(GLConstantDefine.getConstantString(textureList.get(i).getMinFilter()));
+                       text.add(GLConstantDefine.getConstantString(textureList.get(i).getMagFilter()));
 
                        TableInput tableInput = new TableInput();
                        tableInput.setText(text);
@@ -106,10 +100,10 @@ public class GLTextureTable extends DATableComposite {
                        long contextID = textureList.get(i).getContextID();
 
                        if (GLDataManager.getInstance().getSelectedContextID() == contextID) {
-                               tableInput.setInRange(true);
+                               tableInput.setSecondSelection(true);
                        }
                        if (GLDataManager.getInstance().isSharingData(contextID)) {
-                               tableInput.setInRange(true);
+                               tableInput.setSecondSelection(true);
                        }
                }
                return input;
index 690f735..7785a0f 100644 (file)
@@ -33,7 +33,6 @@ import org.eclipse.swt.widgets.Control;
 import org.tizen.dynamicanalyzer.common.AnalyzerConstants;
 import org.tizen.dynamicanalyzer.common.DASelectionData;
 import org.tizen.dynamicanalyzer.nl.GLPageLabels;
-import org.tizen.dynamicanalyzer.nl.UserInterfacePageLabels;
 import org.tizen.dynamicanalyzer.resources.ColorResources;
 import org.tizen.dynamicanalyzer.ui.opengl.GLPage;
 import org.tizen.dynamicanalyzer.ui.opengl.data.type.GLSelectionData;
@@ -72,7 +71,7 @@ public class GLTextureTableView extends DAViewComposite {
                contents.setLayout(new FillLayout());
                tableComp = new GLTextureTable(contents, SWT.NONE, SWT.MULTI | SWT.BORDER
                                | SWT.FULL_SELECTION | SWT.H_SCROLL | SWT.V_SCROLL);
-               tableComp.setTableName(UserInterfacePageLabels.USERINTERFACE_SCENETRANSFORM_LIST_VIEW_NAME);
+               tableComp.setTableName(GLPageLabels.GL_TEXTURE_VIEW_TITLE);
                tableComp.setComparator(new DefaultTableComparator());
                tableComp.setSortTypes(sortTypes);
                tableComp.setColumnAlignment(columnAlignment);
@@ -91,14 +90,12 @@ public class GLTextureTableView extends DAViewComposite {
 
        @Override
        public void updateView(DAViewData vdata) {
-
                if (vdata instanceof DASelectionData) {
                        DASelectionData data = (DASelectionData) vdata;
                        String id = data.getViewID();
                        if (!id.equals(GLPage.textureViewID)) {
                                tableComp.removeSelection();
                        }
-
                        if ((id.equals(GLPage.apiListViewID) && data instanceof GLSelectionData)) {
                                tableComp.updateTable();
                        }