From: Hyunjong.park Date: Tue, 26 Aug 2014 02:41:41 +0000 (+0900) Subject: opengl : add feature (redundant table,statistics table) X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=a1507772efcfd04bdcc942e77dce68b2e447eaa8;p=sdk%2Ftools%2Fdynamic-analyzer.git opengl : add feature (redundant table,statistics table) Signed-off-by: Hyunjong.park Change-Id: I51a552896421bec917f159a424ac7d2cffd549c4 --- diff --git a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/nl/GLPageLabels.java b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/nl/GLPageLabels.java index 0e5ad50..4b3178a 100644 --- a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/nl/GLPageLabels.java +++ b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/nl/GLPageLabels.java @@ -77,7 +77,6 @@ public class GLPageLabels extends NLS { public static String GL_STATE_PROGRAM_VIEW_VERTEX_SHADER; public static String GL_STATE_PROGRAM_VIEW_FRAGMENT_SHADER; - public static String GL_TEXTURE_VIEW_TITLE; public static String GL_TEXTURE_VIEW_CONTEXT_NAME; public static String GL_TEXTURE_VIEW_CONTEXT_ID; @@ -87,6 +86,19 @@ public class GLPageLabels extends NLS { public static String GL_TEXTURE_VIEW_CONTEXT_MIN_FILTER; public static String GL_TEXTURE_VIEW_CONTEXT_MAG_FILTER; + public static String GL_STATISTICS_TITLE; + public static String GL_STATISTICS_VIEW_API_NAME; + public static String GL_STATISTICS_VIEW_RATE; + public static String GL_STATISTICS_VIEW_COUNT; + public static String GL_STATISTICS_VIEW_API_TYPE; + + public static String GL_REDUNDANT_TITLE; + public static String GL_REDUNDANT_VIEW_COUNT; + public static String GL_REDUNDANT_VIEW_ELAPSED_TIME; + public static String GL_REDUNDANT_VIEW_API_NAME; + public static String GL_REDUNDANT_VIEW_PARAMETER; + + static { NLS.initializeMessages(BUNDLE_NAME, GLPageLabels.class); } diff --git a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/nl/GLPageLabels.properties b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/nl/GLPageLabels.properties index 22be4b9..7a6c6ed 100644 --- a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/nl/GLPageLabels.properties +++ b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/nl/GLPageLabels.properties @@ -8,7 +8,7 @@ GL_API_LIST_VIEW_TIME=Time GL_API_LIST_VIEW_NAME=API GL_API_LIST_VIEW_PARAMETER=Parameter GL_API_LIST_VIEW_RETURN=Return -GL_API_LIST_VIEW_ELAPSED_TIME=Elapsed time +GL_API_LIST_VIEW_ELAPSED_TIME=Elapsed time(\u03BCs) GL_API_LIST_VIEW_ERROR=Error GL_API_LIST_VIEW_PID=PID GL_API_LIST_VIEW_TID=TID @@ -46,4 +46,16 @@ GL_TEXTURE_VIEW_CONTEXT_TYPE=Type GL_TEXTURE_VIEW_CONTEXT_WRAP_S=WRAP_S GL_TEXTURE_VIEW_CONTEXT_WRAP_T=WRAP_T GL_TEXTURE_VIEW_CONTEXT_MIN_FILTER=MIN_FILTER -GL_TEXTURE_VIEW_CONTEXT_MAG_FILTER=MAG_FILTER \ No newline at end of file +GL_TEXTURE_VIEW_CONTEXT_MAG_FILTER=MAG_FILTER + +GL_STATISTICS_TITLE = Statistics +GL_STATISTICS_VIEW_API_NAME=API name +GL_STATISTICS_VIEW_RATE=Rate +GL_STATISTICS_VIEW_COUNT=Count +GL_STATISTICS_VIEW_API_TYPE=API type + +GL_REDUNDANT_TITLE=Redundant +GL_REDUNDANT_VIEW_COUNT= count +GL_REDUNDANT_VIEW_ELAPSED_TIME=Elapsed time(\u03BCs) +GL_REDUNDANT_VIEW_API_NAME=API Name +GL_REDUNDANT_VIEW_PARAMETER=Parameter diff --git a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/info/callstack/CallstackTable.java b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/info/callstack/CallstackTable.java index 3b28dc7..f7bd2e7 100644 --- a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/info/callstack/CallstackTable.java +++ b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/info/callstack/CallstackTable.java @@ -96,6 +96,8 @@ public class CallstackTable extends DATableComposite { || viewId.equals(GLPage.contextViewID) || viewId.equals(GLPage.contextHistoryID) || viewId.equals(GLPage.programViewID) + || viewId.equals(GLPage.statisticsViewID) + || viewId.equals(GLPage.redundantViewID) || viewId.equals(UIPage.profilingViewID) || viewId.equals(RangePage.profilingViewID) || viewId.equals(SummaryPage.profilingViewID)) { diff --git a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/opengl/GLDetailsView.java b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/opengl/GLDetailsView.java index 82169ff..d1096aa 100644 --- a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/opengl/GLDetailsView.java +++ b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/opengl/GLDetailsView.java @@ -48,10 +48,12 @@ import org.tizen.dynamicanalyzer.resources.FontResources; import org.tizen.dynamicanalyzer.swap.model.data.GLES20LogData; import org.tizen.dynamicanalyzer.ui.opengl.data.GLDataManager; import org.tizen.dynamicanalyzer.ui.opengl.data.type.GLAPINameDefine; -import org.tizen.dynamicanalyzer.ui.opengl.data.type.GLES20ErrorDefine; import org.tizen.dynamicanalyzer.ui.opengl.data.type.GLCurrentFrameDataManger; +import org.tizen.dynamicanalyzer.ui.opengl.data.type.GLES20ErrorDefine; import org.tizen.dynamicanalyzer.ui.opengl.data.type.GLSelectionData; import org.tizen.dynamicanalyzer.ui.opengl.data.type.GLStateShaderType; +import org.tizen.dynamicanalyzer.ui.opengl.table.state.GLRedundantTableView; +import org.tizen.dynamicanalyzer.ui.opengl.table.state.GLStatisticsTableView; import org.tizen.dynamicanalyzer.ui.widgets.table.DATableDataFormat; import org.tizen.dynamicanalyzer.utils.DownloadContentfileManager; import org.tizen.dynamicanalyzer.widgets.da.view.DAViewComposite; @@ -112,6 +114,10 @@ public class GLDetailsView extends DAViewComposite { } @Override + public void updateView() { + } + + @Override public void updateView(DAViewData vdata) { if (vdata instanceof GLSelectionData) { GLSelectionData data = (GLSelectionData) vdata; @@ -124,14 +130,14 @@ public class GLDetailsView extends DAViewComposite { updateContextTableInfo(data); } else if (id.equals(GLPage.programViewID)) { updateProgramTableInfo(data); + } else if (id.equals(GLPage.redundantViewID)) { + updateRedundantTableInfo(data); + } else if (id.equals(GLPage.statisticsViewID)) { + updateStatisticsTableInfo(data); } } } - @Override - public void updateView() { - } - private void updateChartInfo(GLSelectionData data) { int frameIndex = data.getFrameTimeIndex(); GLCurrentFrameDataManger glFrameData = GLDataManager.getInstance() @@ -157,12 +163,40 @@ public class GLDetailsView extends DAViewComposite { GridItem[] gridItems = (GridItem[]) data.getData(); DATableDataFormat tableDataFormat = (DATableDataFormat) gridItems[0].getData(); GLES20LogData logData = (GLES20LogData) tableDataFormat.getLogData(); + detailText.setText(getDetailInfoOfAPI(logData.getApiName(), logData.getErrno(), + logData.getArgs())); + } + + private void updateRedundantTableInfo(GLSelectionData data) { + GridItem[] gridItems = (GridItem[]) data.getData(); + DATableDataFormat tableDataFormat = (DATableDataFormat) gridItems[0].getData(); + detailText + .setText(getDetailInfoOfAPI( + (String) tableDataFormat.getData().get( + GLRedundantTableView.API_NAME_TABLE_INDEX), + 0, + (String) tableDataFormat.getData().get( + GLRedundantTableView.PARAMETER_TABLE_INDEX))); + } + + private void updateStatisticsTableInfo(GLSelectionData data) { + GridItem[] gridItems = (GridItem[]) data.getData(); + DATableDataFormat tableDataFormat = (DATableDataFormat) gridItems[0].getData(); + StringBuffer strDetailView = new StringBuffer(); + strDetailView.append(CommonConstants.NEW_LINE); + strDetailView.append(leftFormAttachment + + (String) tableDataFormat.getData() + .get(GLStatisticsTableView.API_NAME_TABLE_INDEX) + heightFormAttachment); + strDetailView.append(leftFormAttachment + + (String) tableDataFormat.getData() + .get(GLStatisticsTableView.API_TYPE_TABLE_INDEX) + heightFormAttachment); + detailText.setText(strDetailView.toString()); + } + private String getDetailInfoOfAPI(String apiName, long error, String args) { StringBuffer strDetailView = new StringBuffer(); - String apiName = logData.getApiName(); strDetailView.append(CommonConstants.NEW_LINE); strDetailView.append(leftFormAttachment + apiName + heightFormAttachment); - long error = logData.getErrno(); if (error == 0) { strDetailView.append(leftFormAttachment + GLES20ErrorDefine.getErrorDescription(String.valueOf(error)) @@ -172,16 +206,15 @@ public class GLDetailsView extends DAViewComposite { + getErrorDescription(apiName, GLES20ErrorDefine.getError(error)) + heightFormAttachment); } - if (uniformDataMaker.isUniformAPI(apiName)) { - String uniformValue = uniformDataMaker.getUniformData(apiName, logData.getArgs()); - if(null != uniformValue){ + String uniformValue = uniformDataMaker.getUniformData(apiName, args); + if (null != uniformValue) { strDetailView.append(leftFormAttachment + PROGRAM_PUNCTUATION + "uniform value" + heightFormAttachment); - strDetailView.append(uniformDataMaker.getUniformData(apiName, logData.getArgs())); + strDetailView.append(uniformDataMaker.getUniformData(apiName, args)); } } - detailText.setText(strDetailView.toString()); + return strDetailView.toString(); } private void updateContextTableInfo(GLSelectionData data) { diff --git a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/opengl/GLPage.java b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/opengl/GLPage.java index 5507f15..91590c6 100644 --- a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/opengl/GLPage.java +++ b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/opengl/GLPage.java @@ -40,6 +40,8 @@ import org.tizen.dynamicanalyzer.ui.opengl.data.GLDataManager; import org.tizen.dynamicanalyzer.ui.opengl.table.api.GLAPIListView; import org.tizen.dynamicanalyzer.ui.opengl.table.state.GLContextTableView; import org.tizen.dynamicanalyzer.ui.opengl.table.state.GLProgramTableView; +import org.tizen.dynamicanalyzer.ui.opengl.table.state.GLRedundantTableView; +import org.tizen.dynamicanalyzer.ui.opengl.table.state.GLStatisticsTableView; import org.tizen.dynamicanalyzer.ui.opengl.table.state.GLTextureTableView; import org.tizen.dynamicanalyzer.ui.page.ScreenshotTabComposite; import org.tizen.dynamicanalyzer.widgets.da.view.DAPageComposite; @@ -50,17 +52,14 @@ public class GLPage extends DAPageComposite { public static final String chartViewID = GLChartView.class.getName(); public static final String apiListViewID = GLAPIListView.class.getName(); public static final String detailViewID = GLDetailsView.class.getName(); - - public static final String stateTabID = "GLStateTablID.id";//$NON-NLS-1$ - public static final String contextViewID = GLContextTableView.class - .getName(); + public static final String leftTabID = "GLLeftTablID.id";//$NON-NLS-1$ + public static final String rigthTabID = "GLRightTablID.id";//$NON-NLS-1$ + public static final String contextViewID = GLContextTableView.class.getName(); public static final String contextHistoryID = "contextHistoryID.id"; //$NON-NLS-1$ - - public static final String programViewID = GLProgramTableView.class - .getName(); - - public static final String textureViewID = GLTextureTableView.class - .getName(); + public static final String programViewID = GLProgramTableView.class.getName(); + public static final String textureViewID = GLTextureTableView.class.getName(); + public static final String statisticsViewID = GLStatisticsTableView.class.getName(); + public static final String redundantViewID = GLRedundantTableView.class.getName(); SashForm baseForm; SashForm rightForm; @@ -73,54 +72,59 @@ public class GLPage extends DAPageComposite { GLContextTableView glContextView; GLProgramTableView glProgramView; GLTextureTableView glTextureView; + GLStatisticsTableView glStatisticsView; + GLRedundantTableView glRedundantView; public GLPage(Composite parent, int style) { super(parent, style); setTitle(AnalyzerLabels.COOLBAR_AREA_OPENGLES); - this.setData(DAPageComposite.KEY_TOOLTIP, - ShortCutManager.COOLBAR_AREA_GRAPHICS_TOOLTIP); + this.setData(DAPageComposite.KEY_TOOLTIP, ShortCutManager.COOLBAR_AREA_GRAPHICS_TOOLTIP); this.setLayout(new FillLayout()); - baseForm = new SashForm(this, SWT.HORIZONTAL); - leftForm = new SashForm(baseForm, SWT.VERTICAL); glChartView = new GLChartView(leftForm, SWT.NONE); addView(glChartView); - bottomForm = new SashForm(leftForm, SWT.HORIZONTAL); + DATabComposite glLeftTabView = new DATabComposite(bottomForm, SWT.NONE, false); + { + glStatisticsView = new GLStatisticsTableView(glLeftTabView.getContentComposite(), + SWT.NONE); + addView(glStatisticsView); + glLeftTabView.addView(glStatisticsView, false); + + glAPIListView = new GLAPIListView(glLeftTabView.getContentComposite(), SWT.NONE); + addView(glAPIListView); + glLeftTabView.addView(glAPIListView, false); + } - glAPIListView = new GLAPIListView(bottomForm, SWT.NONE); - addView(glAPIListView); - - DATabComposite glStateTabView = new DATabComposite(bottomForm, - SWT.NONE, false); - addView(stateTabID, glStateTabView); + DATabComposite glRightTabView = new DATabComposite(bottomForm, SWT.NONE, false); { - glContextView = new GLContextTableView( - glStateTabView.getContentComposite(), SWT.NONE); + glRedundantView = new GLRedundantTableView(glRightTabView.getContentComposite(), + SWT.NONE); + addView(glRedundantView); + glRightTabView.addView(glRedundantView, false); + + glContextView = new GLContextTableView(glRightTabView.getContentComposite(), SWT.NONE); addView(glContextView); - glStateTabView.addView(glContextView, false); + glRightTabView.addView(glContextView, false); - glProgramView = new GLProgramTableView( - glStateTabView.getContentComposite(), SWT.NONE); + glProgramView = new GLProgramTableView(glRightTabView.getContentComposite(), SWT.NONE); addView(glProgramView); - glStateTabView.addView(glProgramView, false); + glRightTabView.addView(glProgramView, false); - glTextureView = new GLTextureTableView( - glStateTabView.getContentComposite(), SWT.NONE); + glTextureView = new GLTextureTableView(glRightTabView.getContentComposite(), SWT.NONE); addView(glTextureView); - glStateTabView.addView(glTextureView, false); + glRightTabView.addView(glTextureView, false); } leftForm.setWeights(new int[] { 30, 70 }); bottomForm.setWeights(new int[] { 50, 50 }); - rightForm = new SashForm(baseForm, SWT.VERTICAL); - ScreenshotTabComposite tabView = new ScreenshotTabComposite(rightForm, - SWT.NONE, GLPage.pageID); + ScreenshotTabComposite tabView = new ScreenshotTabComposite(rightForm, SWT.NONE, + GLPage.pageID); tabView.setObservingViews(ScreenshotTabComposite.screenshotViewID, new String[] { GLPage.apiListViewID }); tabView.setObservingViews(ScreenshotTabComposite.callstackViewID, @@ -138,8 +142,7 @@ public class GLPage extends DAPageComposite { rightForm.setSashWidth(AnalyzerConstants.SASH_WIDTH); bottomForm.setSashWidth(AnalyzerConstants.SASH_WIDTH); - DataManagerRegistry - .registerPageDataManager(GLDataManager.getInstance()); + DataManagerRegistry.registerPageDataManager(GLDataManager.getInstance()); } @Override diff --git a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/opengl/chart/GLChartView.java b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/opengl/chart/GLChartView.java index 93d07eb..2d31717 100644 --- a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/opengl/chart/GLChartView.java +++ b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/opengl/chart/GLChartView.java @@ -249,7 +249,6 @@ public class GLChartView extends DAViewComposite { } else { frameRateChartBoard.updateView(); } - } @Override diff --git a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/opengl/data/DB/GLRedundantDBTableManager.java b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/opengl/data/DB/GLRedundantDBTableManager.java new file mode 100644 index 0000000..fc865a1 --- /dev/null +++ b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/opengl/data/DB/GLRedundantDBTableManager.java @@ -0,0 +1,127 @@ +/* + * Dynamic Analyzer + * + * Copyright (c) 2013 Samsung Electronics Co., Ltd. All rights reserved. + * + * Contact: + * Hyunjong Park + * Juyoung Kim + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * Contributors: + * - S-Core Co., Ltd + * + */ +package org.tizen.dynamicanalyzer.ui.opengl.data.DB; + +import java.sql.PreparedStatement; +import java.sql.SQLException; +import java.util.ArrayList; +import java.util.List; + +import org.tizen.dynamicanalyzer.common.DALimit; +import org.tizen.dynamicanalyzer.constant.CommonConstants; +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.type.GLRedundantDataType; + +public class GLRedundantDBTableManager extends DBTable { + private static final String TABLE_NAME = "GL_REDUNDANT";//$NON-NLS-1$ + public static final String CALL_COUNT = "CALL_COUNT";//$NON-NLS-1$ + public static final String ELAPSED_TIME = "ELAPSED_TIME";//$NON-NLS-1$ + public static final String API_ID = "API_ID";//$NON-NLS-1$ + public static final String ARGUMENT = "PARAMETER";//$NON-NLS-1$ + + public final static int TABLE_CALL_COUNT_INDEX = 0; + public final static int TABLE_ELAPSED_TIME_INDEX = 1; + public final static int TABLE_API_ID_INDEX = 2; + public final static int TABLE_ARGUMENT_INDEX = 3; + + private static final String SELECT_QUERY = "select "//$NON-NLS-1$ + + CALL_COUNT + CommonConstants.COMMA + ELAPSED_TIME + CommonConstants.COMMA + + API_ID + + CommonConstants.COMMA + ARGUMENT + " from " + TABLE_NAME;//$NON-NLS-1$ + + @Override + public String getTableName() { + return TABLE_NAME; + } + + public GLRedundantDBTableManager() { + addColumn(new DBColumn(CALL_COUNT, DBConstants.NOT_NULL, DBConstants.INTEGER)); + addColumn(new DBColumn(ELAPSED_TIME, DBConstants.NOT_NULL, DBConstants.DBTYPE_LONG)); + addColumn(new DBColumn(API_ID, DBConstants.NOT_NULL, DBConstants.INTEGER)); + addColumn(new DBColumn(ARGUMENT, DBConstants.NOT_NULL, "VARCHAR(" + + DALimit.FUNCTION_ARGUMENTS_VALUE_LENGTH + ")"));//$NON-NLS-1$ + } + + public void insertRedundantData(List data) { + List> insertList = new ArrayList>(); + for (GLRedundantDataType rowData : data) { + List objectList = new ArrayList(); + objectList.add(rowData.getCallCount()); + objectList.add(rowData.getElapsedTime()); + objectList.add(rowData.getApiID()); + objectList.add(rowData.getArgs()); + insertList.add(objectList); + } + insertData(insertList); + } + + public List select() { + List> result = SqlConnectionManager.executeQuery(SELECT_QUERY); + if (null == result || result.size() == 0 || result.get(0).size() == 0) { + return null; + } + List textureList = new ArrayList(); + for (int i = 0; i < result.size(); i++) { + int callCount = (Integer) result.get(i).get(TABLE_CALL_COUNT_INDEX); + long elapsedTime = (Long) result.get(i).get(TABLE_ELAPSED_TIME_INDEX); + int apiID = (Integer) result.get(i).get(TABLE_API_ID_INDEX); + String parameter = (String) result.get(i).get(TABLE_ARGUMENT_INDEX); + GLRedundantDataType data = new GLRedundantDataType(apiID, parameter, callCount, + elapsedTime); + data.setCallCount(callCount); + textureList.add(data); + } + return textureList; + } + + @Override + public boolean prepare(PreparedStatement prep, List rowData) { + boolean isPrepared = true; + + int columnsize = getColumnSize(); + if (columnsize != rowData.size()) { + isPrepared = false; + } else { + try { + prep.setLong(TABLE_CALL_COUNT_INDEX + 1, + (Integer) (rowData.get(TABLE_CALL_COUNT_INDEX))); + prep.setDouble(TABLE_ELAPSED_TIME_INDEX + 1, + (Long) (rowData.get(TABLE_ELAPSED_TIME_INDEX))); + prep.setInt(TABLE_API_ID_INDEX + 1, (Integer) (rowData.get(TABLE_API_ID_INDEX))); + prep.setString(TABLE_ARGUMENT_INDEX + 1, + (String) (rowData.get(TABLE_ARGUMENT_INDEX))); + } catch (SQLException e) { + e.printStackTrace(); + isPrepared = false; + } + } + return isPrepared; + } + +} diff --git a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/opengl/data/GLDataManager.java b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/opengl/data/GLDataManager.java index 2d32737..fa868a8 100644 --- a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/opengl/data/GLDataManager.java +++ b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/opengl/data/GLDataManager.java @@ -31,6 +31,7 @@ import java.util.ArrayList; import java.util.List; import java.util.Map; +import org.tizen.dynamicanalyzer.constant.CommonConstants; import org.tizen.dynamicanalyzer.swap.channel.data.DataChannelConstants; import org.tizen.dynamicanalyzer.swap.logparser.LogPackage; import org.tizen.dynamicanalyzer.swap.logparser.Logs; @@ -39,17 +40,18 @@ import org.tizen.dynamicanalyzer.swap.model.data.GLES20LogData; import org.tizen.dynamicanalyzer.swap.model.data.LogData; import org.tizen.dynamicanalyzer.ui.opengl.GLUtil; import org.tizen.dynamicanalyzer.ui.opengl.data.DB.GLAPIDBTableManager; +import org.tizen.dynamicanalyzer.ui.opengl.data.DB.GLCommonStateDBTableManager; import org.tizen.dynamicanalyzer.ui.opengl.data.DB.GLFrameRateDBTableManager; import org.tizen.dynamicanalyzer.ui.opengl.data.DB.GLFrameTimeDBTableManager; -import org.tizen.dynamicanalyzer.ui.opengl.data.DB.GLCommonStateDBTableManager; +import org.tizen.dynamicanalyzer.ui.opengl.data.DB.GLRedundantDBTableManager; import org.tizen.dynamicanalyzer.ui.opengl.data.DB.GLStateHistoryDBTableManager; import org.tizen.dynamicanalyzer.ui.opengl.data.DB.GLStateProgramDBTableManager; import org.tizen.dynamicanalyzer.ui.opengl.data.DB.GLStateSharingDBTableManager; import org.tizen.dynamicanalyzer.ui.opengl.data.DB.GLStateTextureDBTableManager; -import org.tizen.dynamicanalyzer.ui.opengl.data.type.GLFrameRateInfo; import org.tizen.dynamicanalyzer.ui.opengl.data.type.GLAPIData; import org.tizen.dynamicanalyzer.ui.opengl.data.type.GLCurrentFrameDataManger; import org.tizen.dynamicanalyzer.ui.opengl.data.type.GLES20ErrorDefine; +import org.tizen.dynamicanalyzer.ui.opengl.data.type.GLFrameRateInfo; import org.tizen.dynamicanalyzer.ui.opengl.data.type.GLSharingContextType; import org.tizen.dynamicanalyzer.ui.summary.SummaryDataManager; import org.tizen.dynamicanalyzer.ui.timeline.common.TimelineConstants; @@ -58,6 +60,7 @@ public class GLDataManager extends PageDataManager { private static GLDataManager instance = null; private GLStateDataManager stateDataManager = null; + private GLStatisticsDataManager statisticsDataManger = null; private List frameRateDataList = null; private List sharingContextList = null; private int startFrameRateTime = 1; @@ -65,6 +68,7 @@ public class GLDataManager extends PageDataManager { protected int currentFrameIndex = 1; private boolean isSelectFrameRateChart = true; private long apiTimeOfPreFrameIndex = 0; + private String selectedAPIAtTable = CommonConstants.EMPTY; private GLAPIDBTableManager apiDBTable = null; private GLFrameRateDBTableManager frameRateDBTable = null; @@ -74,6 +78,7 @@ public class GLDataManager extends PageDataManager { private GLStateHistoryDBTableManager stateHistoryDBTable = null; private GLStateTextureDBTableManager stateTextureDBTable = null; private GLStateSharingDBTableManager stateSharingDBTable = null; + private GLRedundantDBTableManager redundantDBTable = null; public static GLDataManager getInstance() { if (instance == null) { @@ -91,17 +96,21 @@ public class GLDataManager extends PageDataManager { stateHistoryDBTable = new GLStateHistoryDBTableManager(); stateTextureDBTable = new GLStateTextureDBTableManager(); stateSharingDBTable = new GLStateSharingDBTableManager(); + statisticsDataManger = new GLStatisticsDataManager(); + setRedundantDBTable(new GLRedundantDBTableManager()); } public void clear() { stateDataManager = new GLStateDataManager(); frameRateDataList = new ArrayList(); sharingContextList = new ArrayList(); + statisticsDataManger = new GLStatisticsDataManager(); startFrameRateTime = 1; selectedContextID = -1; currentFrameIndex = 1; isSelectFrameRateChart = true; apiTimeOfPreFrameIndex = 0; + selectedAPIAtTable = CommonConstants.EMPTY; } public void saveData(Map dataMap) { @@ -116,15 +125,19 @@ public class GLDataManager extends PageDataManager { if (null != stateDataManager) { updateFrameTimeChartEndTimeAtOpen(); stateProgramDBTable.initProgramDataAtOpen(); + stateTextureDBTable.initTextureDataAtOpen(); + statisticsDataManger.selectRedundantData(); } } public void stopProcess() { if (null != stateDataManager) { stateProgramDBTable.insertProgramData(); + stateTextureDBTable.insertTextureData(); + statisticsDataManger.insertRedundantData(); } } - + @Override protected void onThreadStop() { stopProcess(); @@ -140,6 +153,7 @@ public class GLDataManager extends PageDataManager { public void makeGLData(Logs glesLogs) { addAPIDBData(glesLogs); + addAPIStatisticsData(glesLogs); addFrameTimeChartDBData(glesLogs); addFrameRateChartDBData(glesLogs); addStateDBData(glesLogs); @@ -189,18 +203,22 @@ public class GLDataManager extends PageDataManager { apiDBTable.insert(insetAPIDataList); } + private void addAPIStatisticsData(Logs glesLogs) { + for (LogData data : glesLogs.getRawLogs()) { + statisticsDataManger.addAPI((GLES20LogData) data); + } + } + private void addFrameTimeChartDBData(Logs glesLogs) { int currentFrameIndexOfFrameTime = currentFrameIndex; List> insetFrameTimeChartDataList = new ArrayList>(); GLCurrentFrameDataManger currentFrameData = new GLCurrentFrameDataManger(); for (LogData data : glesLogs.getRawLogs()) { GLES20LogData logData = (GLES20LogData) data; - currentFrameData.addAPIData(new GLAPIData(logData, - currentFrameIndexOfFrameTime)); + currentFrameData.addAPIData(new GLAPIData(logData, currentFrameIndexOfFrameTime)); if (GLUtil.isLastAPIOfFrame(logData.getApiName())) { - makeFrameTimeData(insetFrameTimeChartDataList, - currentFrameData, currentFrameIndexOfFrameTime, - apiTimeOfPreFrameIndex, logData.getTime()); + makeFrameTimeData(insetFrameTimeChartDataList, currentFrameData, + currentFrameIndexOfFrameTime, apiTimeOfPreFrameIndex, logData.getTime()); currentFrameIndexOfFrameTime++; apiTimeOfPreFrameIndex = logData.getTime(); } @@ -275,17 +293,13 @@ public class GLDataManager extends PageDataManager { } } - private void makeFrameTimeData( - List> insetFrameTimeChartDataList, - GLCurrentFrameDataManger glCurrentFrameData, - int currentFrameIndexOfFrameTime, long apiTimeOfPreFrameIndex, - long apiTime) { - long frameValue = (apiTime - apiTimeOfPreFrameIndex) - / TimelineConstants.KILO_LONG; + private void makeFrameTimeData(List> insetFrameTimeChartDataList, + GLCurrentFrameDataManger glCurrentFrameData, int currentFrameIndexOfFrameTime, + long apiTimeOfPreFrameIndex, long apiTime) { + long frameValue = (apiTime - apiTimeOfPreFrameIndex) / TimelineConstants.KILO_LONG; List framTimeChartData = new ArrayList(); framTimeChartData.add(currentFrameIndexOfFrameTime); - framTimeChartData.add(GLUtil.getTimeLineTime(glCurrentFrameData - .getFirstLogData())); + framTimeChartData.add(GLUtil.getTimeLineTime(glCurrentFrameData.getFirstLogData())); framTimeChartData.add((int) frameValue); framTimeChartData.add(glCurrentFrameData.hasError()); framTimeChartData.add(glCurrentFrameData.getStartSeq()); @@ -370,6 +384,10 @@ public class GLDataManager extends PageDataManager { return stateSharingDBTable; } + public GLStatisticsDataManager getStatisticsDataManger() { + return statisticsDataManger; + } + public boolean isSelectFrameRateChart() { return isSelectFrameRateChart; } @@ -386,4 +404,20 @@ public class GLDataManager extends PageDataManager { this.startFrameRateTime = startFrameRateTime; } + public String getSelectedAPIAtTable() { + return selectedAPIAtTable; + } + + public void setSelectedAPIAtTable(String selectedAPIAtTable) { + this.selectedAPIAtTable = selectedAPIAtTable; + } + + public GLRedundantDBTableManager getRedundantDBTable() { + return redundantDBTable; + } + + public void setRedundantDBTable(GLRedundantDBTableManager redundantDBTable) { + this.redundantDBTable = redundantDBTable; + } + } diff --git a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/opengl/data/GLStatisticsDataManager.java b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/opengl/data/GLStatisticsDataManager.java new file mode 100644 index 0000000..8e70d10 --- /dev/null +++ b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/opengl/data/GLStatisticsDataManager.java @@ -0,0 +1,194 @@ +/* + * Dynamic Analyzer + * + * Copyright (c) 2013 Samsung Electronics Co., Ltd. All rights reserved. + * + * Contact: + * Hyunjong Park + * Sanghyun Lee + * Juyoung Kim + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * Contributors: + * - S-Core Co., Ltd + * + */ + +package org.tizen.dynamicanalyzer.ui.opengl.data; + +import java.util.ArrayList; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; +import java.util.concurrent.ConcurrentHashMap; + +import org.tizen.dynamicanalyzer.common.AnalyzerManager; +import org.tizen.dynamicanalyzer.constant.CommonConstants; +import org.tizen.dynamicanalyzer.swap.model.data.GLES20LogData; +import org.tizen.dynamicanalyzer.ui.opengl.data.type.GLRedundantDataType; +import org.tizen.dynamicanalyzer.ui.opengl.data.type.GLStatisticsDataType; +import org.tizen.dynamicanalyzer.util.DALogger; + +public class GLStatisticsDataManager { + private static final String SPLIT = CommonConstants.SPACE + CommonConstants.CMD_SPLIT + + CommonConstants.SPACE; + private static final String STATE_CHANGE = "State Change";//$NON-NLS-1$ + private static final String MATRIX = "Matrix";//$NON-NLS-1$ + private static final String TEXTURE = "Texture";//$NON-NLS-1$ + private static final String DRAW = "Draw";//$NON-NLS-1$ + private static final String PROGRAM_AND_SHADER = "Program and Shader";//$NON-NLS-1$ + private static final String BUFFER = "Buffer";//$NON-NLS-1$ + private static final String GET = "Get";//$NON-NLS-1$ + private static final String IS = "Is";//$NON-NLS-1$ + private static final String DELETE = "Delete";//$NON-NLS-1$ + private static final String BIND = "Bind";//$NON-NLS-1$ + private static final String EVAS_GL = "evas_gl";//$NON-NLS-1$ + private ConcurrentHashMap redundantHsahMap = new ConcurrentHashMap(); + private double totalAPICount = 0; + + public void addAPI(GLES20LogData logData) { + String hashKey = logData.getApiName() + logData.getArgs(); + GLRedundantDataType savedHash = redundantHsahMap.get(hashKey); + if (null == savedHash) { + redundantHsahMap.put( + hashKey, + new GLRedundantDataType(logData.getApiId(), logData.getArgs(), 1, logData + .getElapsedTime())); + } else { + savedHash.addCallCount(); + savedHash.addElapsedTime(logData.getElapsedTime()); + } + totalAPICount++; + } + + public void insertRedundantData() { + GLDataManager.getInstance().getRedundantDBTable() + .insertRedundantData(getRedundantTableData()); + } + + public void selectRedundantData() { + List redundantList = GLDataManager.getInstance().getRedundantDBTable() + .select(); + for (GLRedundantDataType data : redundantList) { + String hashKey = AnalyzerManager.getProject().getApiName(data.getApiID()) + + data.getArgs(); + GLRedundantDataType savedHash = redundantHsahMap.get(hashKey); + if (null == savedHash) { + redundantHsahMap.put( + hashKey, + new GLRedundantDataType(data.getApiID(), data.getArgs(), data + .getCallCount(), data.getElapsedTime())); + } else { + savedHash.setCallCount(savedHash.getCallCount() + data.getCallCount()); + } + totalAPICount += data.getCallCount(); + } + } + + public List getRedundantTableData() { + List returnList = new ArrayList(); + for (Map.Entry entry : redundantHsahMap.entrySet()) { + returnList.add(entry.getValue()); + } + return returnList; + } + + public List getStatisticsTableData() { + List returnList = new ArrayList(); + LinkedHashMap statisticsHashMap = getStatisticDataFromRedundantHashMap(); + for (Map.Entry entry : statisticsHashMap.entrySet()) { + returnList.add(entry.getValue()); + } + return returnList; + } + + private LinkedHashMap getStatisticDataFromRedundantHashMap() { + LinkedHashMap returnStatisticsHsahMap = new LinkedHashMap(); + for (Map.Entry entry : redundantHsahMap.entrySet()) { + GLRedundantDataType redundantDataType = entry.getValue(); + String hashKey = redundantDataType.getAPIName(); + GLStatisticsDataType savedHash = returnStatisticsHsahMap.get(hashKey); + if (null == savedHash) { + returnStatisticsHsahMap.put( + hashKey, + new GLStatisticsDataType(redundantDataType.getApiID(), redundantDataType + .getArgs(), getRate(redundantDataType.getCallCount()), + redundantDataType.getCallCount(), redundantDataType + .getElapsedTime(), getAPIType(redundantDataType + .getAPIName()))); + } else { + savedHash.addCallCount(redundantDataType.getCallCount()); + savedHash.setRate(getRate(savedHash.getCallCount())); + savedHash.addElapsedTime(redundantDataType.getElapsedTime()); + } + } + return returnStatisticsHsahMap; + } + + private double getRate(double callCount) { + return callCount / totalAPICount * 100; + } + + private String getAPIType(String apiName) { + StringBuffer returnBuffer = new StringBuffer(); + if (apiName.contains(MATRIX)) { + returnBuffer.append(MATRIX).append(SPLIT); + } + if (apiName.contains(TEXTURE) || apiName.contains("Tex")) {//$NON-NLS-1$ + returnBuffer.append(TEXTURE).append(SPLIT); + } + if (apiName.contains(BUFFER)) { + returnBuffer.append(BUFFER).append(SPLIT); + } + if (apiName.contains(GET) || apiName.contains("glHint")) {//$NON-NLS-1$ + returnBuffer.append(GET).append(SPLIT); + } + if (apiName.contains(IS)) { + returnBuffer.append(IS).append(SPLIT); + } + if (apiName.contains(DRAW) || apiName.contains("glFinish") || apiName.contains("glFlush")) {//$NON-NLS-1$//$NON-NLS-2$ + returnBuffer.append(DRAW).append(SPLIT); + } + if (apiName.contains(DELETE)) { + returnBuffer.append(DELETE).append(SPLIT); + } + if (apiName.contains("Bind") || apiName.contains("Gen")) {//$NON-NLS-1$//$NON-NLS-2$ + returnBuffer.append(BIND).append(SPLIT); + } + if (apiName.contains("Program") || apiName.contains("Shader")//$NON-NLS-1$//$NON-NLS-2$ + || apiName.contains("Uniform") || apiName.contains("Vertex")) {//$NON-NLS-1$//$NON-NLS-2$ + returnBuffer.append(PROGRAM_AND_SHADER).append(SPLIT); + } + if (apiName.contains("Blend") || apiName.contains("Clear") || apiName.contains("Color")//$NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$ + || apiName.contains("Cull") || apiName.contains("Depth")//$NON-NLS-1$//$NON-NLS-2$ + || apiName.contains("Disable") || apiName.contains("Enable")//$NON-NLS-1$//$NON-NLS-2$ + || apiName.contains("Stencil") || apiName.contains("glLineWidth")//$NON-NLS-1$//$NON-NLS-2$ + || apiName.contains("glPixelStorei") || apiName.contains("glPolygonOffset")//$NON-NLS-1$//$NON-NLS-2$ + || apiName.contains("glReadPixels") || apiName.contains("glSampleCoverage")//$NON-NLS-1$//$NON-NLS-2$ + || apiName.contains("glScissor") || apiName.contains("glViewport")) {//$NON-NLS-1$//$NON-NLS-2$ + returnBuffer.append(STATE_CHANGE).append(SPLIT); + } + if (apiName.contains(EVAS_GL)) { + returnBuffer.append(EVAS_GL); + } + if (returnBuffer.length() == 0) { + DALogger.getInstance().error("Not Define API Type of Statistics : " + apiName); + return CommonConstants.EMPTY; + } + if (returnBuffer.lastIndexOf(SPLIT) == returnBuffer.length() - SPLIT.length()) { + returnBuffer.delete(returnBuffer.length() - SPLIT.length(), returnBuffer.length()); + } + return returnBuffer.toString(); + } +} diff --git a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/opengl/data/type/GLRedundantDataType.java b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/opengl/data/type/GLRedundantDataType.java new file mode 100644 index 0000000..c020dd9 --- /dev/null +++ b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/opengl/data/type/GLRedundantDataType.java @@ -0,0 +1,92 @@ +/* + * Dynamic Analyzer + * + * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved. + * + * Contact: + * Hyunjong Park + * Juyoung Kim + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * Contributors: + * - S-Core Co., Ltd + * + */ + +package org.tizen.dynamicanalyzer.ui.opengl.data.type; + +import org.tizen.dynamicanalyzer.common.AnalyzerManager; +import org.tizen.dynamicanalyzer.constant.CommonConstants; + +public class GLRedundantDataType { + private int apiID = -1; + private String args = CommonConstants.EMPTY; + private int callCount = -1; + private long elapsedTime = 0; + + public GLRedundantDataType(int apiID, String args, int callCount, long elapsedTime) { + this.apiID = apiID; + this.args = args; + this.elapsedTime = elapsedTime; + this.callCount = callCount; + } + + public int getApiID() { + return apiID; + } + + public String getAPIName() { + return AnalyzerManager.getProject().getApiName(apiID); + } + + public void setApiID(int apiID) { + this.apiID = apiID; + } + + public String getArgs() { + return args; + } + + public void setArgs(String args) { + this.args = args; + } + + public int getCallCount() { + return callCount; + } + + public void addCallCount() { + callCount++; + } + + public void addCallCount(int preCallCount) { + callCount += preCallCount; + } + + public void setCallCount(int callCount) { + this.callCount = callCount; + } + + public long getElapsedTime() { + return elapsedTime; + } + + public void setElapsedTime(long elapsedTime) { + this.elapsedTime = elapsedTime; + } + + public void addElapsedTime(long elapsedTime) { + this.elapsedTime += elapsedTime; + } +} \ No newline at end of file diff --git a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/opengl/data/type/GLStatisticsDataType.java b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/opengl/data/type/GLStatisticsDataType.java new file mode 100644 index 0000000..b309a54 --- /dev/null +++ b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/opengl/data/type/GLStatisticsDataType.java @@ -0,0 +1,59 @@ +/* + * Dynamic Analyzer + * + * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved. + * + * Contact: + * Hyunjong Park + * Juyoung Kim + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * Contributors: + * - S-Core Co., Ltd + * + */ + +package org.tizen.dynamicanalyzer.ui.opengl.data.type; + +import org.tizen.dynamicanalyzer.constant.CommonConstants; + +public class GLStatisticsDataType extends GLRedundantDataType { + private String apiType = CommonConstants.EMPTY; + private double rate = -1; + + public GLStatisticsDataType(int apiID, String parameter, double rate, int callCount, + long elapsedTime, String apiType) { + super(apiID, parameter, callCount, elapsedTime); + this.apiType = apiType; + this.setRate(rate); + setCallCount(callCount); + } + + public String getAPIType() { + return apiType; + } + + public void setAPIType(String apiType) { + this.apiType = apiType; + } + + public double getRate() { + return this.rate; + } + + public void setRate(double rate) { + this.rate = rate; + } + +} \ No newline at end of file diff --git a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/opengl/table/state/GLContextTable.java b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/opengl/table/state/GLContextTable.java index f1b5649..5b916c0 100644 --- a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/opengl/table/state/GLContextTable.java +++ b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/opengl/table/state/GLContextTable.java @@ -324,6 +324,7 @@ public class GLContextTable extends DATableComposite { @Override public void handleClickEvent(DACustomButton button) { + GLDataManager.getInstance().setSelectedAPIAtTable(CommonConstants.EMPTY); int contextDBIndex = getSelectedStateIndex(); if (contextDBIndex < 0) { return; @@ -341,6 +342,7 @@ public class GLContextTable extends DATableComposite { @Override public void handleClickEvent(DACustomButton button) { + GLDataManager.getInstance().setSelectedAPIAtTable(CommonConstants.EMPTY); int contextDBIndex = getSelectedStateIndex(); if (contextDBIndex < 0) { return; diff --git a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/opengl/table/state/GLContextTableView.java b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/opengl/table/state/GLContextTableView.java index f7e6fbe..84f48c7 100644 --- a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/opengl/table/state/GLContextTableView.java +++ b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/opengl/table/state/GLContextTableView.java @@ -45,7 +45,6 @@ import org.tizen.dynamicanalyzer.common.AnalyzerConstants; import org.tizen.dynamicanalyzer.common.DASelectionData; import org.tizen.dynamicanalyzer.constant.CommonConstants; import org.tizen.dynamicanalyzer.nl.GLPageLabels; -import org.tizen.dynamicanalyzer.nl.UserInterfacePageLabels; import org.tizen.dynamicanalyzer.resources.ColorResources; import org.tizen.dynamicanalyzer.resources.ImageResources; import org.tizen.dynamicanalyzer.swap.model.data.LogData; @@ -73,11 +72,9 @@ public class GLContextTableView extends DAViewComposite { private Image checkImg = ImageResources.OPENGL_SHOW_ONLY_CHANGED_SELECTED; private String[] columnNames = { GLPageLabels.GL_CONTEXT_VIEW_NAME, - GLPageLabels.GL_CONTEXT_VIEW_DEFAULT_VALUE, - GLPageLabels.GL_CONTEXT_VIEW_CURRENT_VALUE }; + GLPageLabels.GL_CONTEXT_VIEW_DEFAULT_VALUE, GLPageLabels.GL_CONTEXT_VIEW_CURRENT_VALUE }; - int[] sortTypes = { AnalyzerConstants.SORT_TYPE_STRING, - AnalyzerConstants.SORT_TYPE_STRING, + int[] sortTypes = { AnalyzerConstants.SORT_TYPE_STRING, AnalyzerConstants.SORT_TYPE_STRING, AnalyzerConstants.SORT_TYPE_STRING }; public GLContextTableView(Composite parent, int style) { @@ -92,20 +89,16 @@ public class GLContextTableView extends DAViewComposite { Composite contents = getContentArea(); contents.setBackground(ColorResources.WINDOW_BG_COLOR); contents.setLayout(new FillLayout()); - tableComp = new GLContextTable(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 = new GLContextTable(contents, SWT.NONE, SWT.MULTI | SWT.BORDER + | SWT.FULL_SELECTION | SWT.H_SCROLL | SWT.V_SCROLL); + tableComp.setTableName(GLPageLabels.GL_CONTEXT_VIEW_TITLE); tableComp.setSortTypes(sortTypes); tableComp.setColumnAlignment(columnAlignment); tableComp.setColumns(columnNames); tableComp.setColumnSize(columnSizes); tableComp.setColumnVisibility(columnVisibility); tableComp.setTableToolTipEnable(false); - - contents.addControlListener(new TableColumnSizePackListener(tableComp, - columnSizes)); - + contents.addControlListener(new TableColumnSizePackListener(tableComp, columnSizes)); } @Override @@ -119,8 +112,7 @@ public class GLContextTableView extends DAViewComposite { String id = data.getViewID(); if ((id.equals(GLPage.apiListViewID) && data instanceof GLSelectionData)) { GridItem[] gridItems = (GridItem[]) data.getData(); - DATableDataFormat tableDataFormat = (DATableDataFormat) gridItems[0] - .getData(); + DATableDataFormat tableDataFormat = (DATableDataFormat) gridItems[0].getData(); LogData logData = tableDataFormat.getLogData(); int frameIndex = ((GLSelectionData) data).getFrameTimeIndex(); @@ -128,20 +120,18 @@ public class GLContextTableView extends DAViewComposite { String apiName = ((GLAPIData) logData).getApiName(); selectedSeq = Integer.toString(logData.getSeq()); - selectedStateValueList = GLDataManager.getInstance() - .getContextDBTableManage() + selectedStateValueList = GLDataManager.getInstance().getContextDBTableManage() .getContextData(selectedSeq, contextId); if (null == selectedStateValueList) { return; } - tableComp.setSelectedSeq(isCheckedBox, selectedSeq, - selectedStateValueList); + tableComp.setSelectedSeq(isCheckedBox, selectedSeq, selectedStateValueList); tableComp.updateTable(); tableComp.setSelectedSeq(isCheckedBox, selectedSeq, null); - long contextID = (Long) selectedStateValueList - .get(GLContextNameEnum.CONTEXT_ID.ordinal()); + long contextID = (Long) selectedStateValueList.get(GLContextNameEnum.CONTEXT_ID + .ordinal()); String curretnContextNember = "Context_" + contextID;//$NON-NLS-1$ setTitle(curretnContextNember + " ( " + apiName + " of "//$NON-NLS-1$ //$NON-NLS-2$ + frameIndex + " frame )");//$NON-NLS-1$ @@ -187,8 +177,7 @@ public class GLContextTableView extends DAViewComposite { checkImg = ImageResources.OPENGL_SHOW_ONLY_CHANGED_SELECTED; } titleBar.redraw(); - tableComp.setSelectedSeq(isCheckedBox, selectedSeq, - selectedStateValueList); + tableComp.setSelectedSeq(isCheckedBox, selectedSeq, selectedStateValueList); tableComp.updateTable(); tableComp.setSelectedSeq(isCheckedBox, selectedSeq, null); } diff --git a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/opengl/table/state/GLProgramTable.java b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/opengl/table/state/GLProgramTable.java index 6189128..a5710a0 100644 --- a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/opengl/table/state/GLProgramTable.java +++ b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/opengl/table/state/GLProgramTable.java @@ -106,10 +106,10 @@ public class GLProgramTable extends DATableComposite { long contextID = programList.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; diff --git a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/opengl/table/state/GLProgramTableView.java b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/opengl/table/state/GLProgramTableView.java index d326e4a..6d96296 100644 --- a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/opengl/table/state/GLProgramTableView.java +++ b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/opengl/table/state/GLProgramTableView.java @@ -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; @@ -67,7 +66,7 @@ public class GLProgramTableView extends DAViewComposite { contents.setLayout(new FillLayout()); tableComp = new GLProgramTable(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_PROGRAMS_VIEW_TITLE); tableComp.setComparator(new DefaultTableComparator()); tableComp.setSortTypes(sortTypes); tableComp.setColumnAlignment(columnAlignment); @@ -86,7 +85,6 @@ public class GLProgramTableView extends DAViewComposite { @Override public void updateView(DAViewData vdata) { - if (vdata instanceof DASelectionData) { DASelectionData data = (DASelectionData) vdata; String id = data.getViewID(); diff --git a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/opengl/table/state/GLRedundantTable.java b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/opengl/table/state/GLRedundantTable.java new file mode 100644 index 0000000..4da2db3 --- /dev/null +++ b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/opengl/table/state/GLRedundantTable.java @@ -0,0 +1,118 @@ +/* + * Dynamic Analyzer + * + * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved. + * + * Contact: + * Hyunjong Park + * Juyoung Kim + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * Contributors: + * - S-Core Co., Ltd + * + */ + +package org.tizen.dynamicanalyzer.ui.opengl.table.state; + +import java.util.ArrayList; +import java.util.List; + +import org.eclipse.nebula.widgets.grid.GridItem; +import org.eclipse.swt.events.SelectionEvent; +import org.eclipse.swt.events.SelectionListener; +import org.eclipse.swt.widgets.Composite; +import org.tizen.dynamicanalyzer.common.AnalyzerConstants; +import org.tizen.dynamicanalyzer.common.AnalyzerManager; +import org.tizen.dynamicanalyzer.constant.CommonConstants; +import org.tizen.dynamicanalyzer.model.TableInput; +import org.tizen.dynamicanalyzer.ui.opengl.GLPage; +import org.tizen.dynamicanalyzer.ui.opengl.data.GLDataManager; +import org.tizen.dynamicanalyzer.ui.opengl.data.type.GLConstantDefine; +import org.tizen.dynamicanalyzer.ui.opengl.data.type.GLRedundantDataType; +import org.tizen.dynamicanalyzer.ui.opengl.data.type.GLSelectionData; +import org.tizen.dynamicanalyzer.ui.widgets.table.DATableComposite; +import org.tizen.dynamicanalyzer.ui.widgets.table.DATableDataFormat; +import org.tizen.dynamicanalyzer.utils.Formatter; + +public class GLRedundantTable extends DATableComposite { + + public GLRedundantTable(Composite parent, int style, int tableStyle) { + super(parent, style, tableStyle); + setContextMenu(AnalyzerConstants.CONTEXT_TABLE_RANGE); + table.addSelectionListener(new SelectionListener() { + @Override + public void widgetSelected(SelectionEvent e) { + GridItem[] items = table.getSelection(); + if (null == items) { + return; + } + DATableDataFormat tableDataFormat = (DATableDataFormat) items[0].getData(); + GLDataManager.getInstance().setSelectedAPIAtTable( + (String) tableDataFormat.getData().get( + GLRedundantTableView.API_NAME_TABLE_INDEX)); + GLSelectionData selData = new GLSelectionData(GLPage.redundantViewID, 0, 0, items, + table, 0, 0); + AnalyzerManager.getCurrentPage().updateView(selData); + AnalyzerManager.updateView(GLPage.redundantViewID, selData); + } + + @Override + public void widgetDefaultSelected(SelectionEvent e) { + } + }); + } + + protected List makeTableInput() { + List input = new ArrayList(); + GLDataManager.getInstance().updateSharingContextList(); + List dataList = GLDataManager.getInstance().getStatisticsDataManger() + .getRedundantTableData(); + if (null == dataList) { + return null; + } + int size = dataList.size(); + for (int i = 0; i < size; i++) { + GLRedundantDataType data = dataList.get(i); + List text = new ArrayList(); + text.add(Integer.toString(data.getCallCount())); + text.add(Formatter.toTimeFormat4((data.getElapsedTime()))); + text.add(data.getAPIName()); + text.add(GLConstantDefine.convertEnumValue(data.getArgs(), CommonConstants.COMMA, null)); + DATableDataFormat tableData = new DATableDataFormat(i); + List compareData = new ArrayList(); + for (int j = 0; j < text.size(); j++) { + if (j == 1) { + compareData.add(String.valueOf(data.getElapsedTime())); + } else { + compareData.add(text.get(j)); + } + } + tableData.setData(compareData); + TableInput tableInput = new TableInput(); + tableInput.setText(text); + tableInput.setData(tableData); + if (GLDataManager.getInstance().getSelectedAPIAtTable().equals(data.getAPIName())) { + tableInput.setSecondSelection(true); + } + input.add(tableInput); + } + return input; + } + + public void removeSelection() { + table.removeAll(); + updateTable(); + } +} diff --git a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/opengl/table/state/GLRedundantTableView.java b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/opengl/table/state/GLRedundantTableView.java new file mode 100644 index 0000000..3b8adbf --- /dev/null +++ b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/opengl/table/state/GLRedundantTableView.java @@ -0,0 +1,117 @@ +/* + * Dynamic Analyzer + * + * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved. + * + * Contact: + * Hyunjong Park + * Juyoung Kim + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * Contributors: + * - S-Core Co., Ltd + * + */ + +package org.tizen.dynamicanalyzer.ui.opengl.table.state; + +import org.eclipse.swt.SWT; +import org.eclipse.swt.layout.FillLayout; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Control; +import org.tizen.dynamicanalyzer.common.AnalyzerConstants; +import org.tizen.dynamicanalyzer.common.AnalyzerManager; +import org.tizen.dynamicanalyzer.nl.GLPageLabels; +import org.tizen.dynamicanalyzer.resources.ColorResources; +import org.tizen.dynamicanalyzer.ui.opengl.GLPage; +import org.tizen.dynamicanalyzer.ui.opengl.data.type.GLSelectionData; +import org.tizen.dynamicanalyzer.ui.widgets.table.DefaultTableComparator; +import org.tizen.dynamicanalyzer.ui.widgets.table.TableColumnSizePackListener; +import org.tizen.dynamicanalyzer.widgets.da.view.DAViewComposite; +import org.tizen.dynamicanalyzer.widgets.da.view.DAViewData; + +public class GLRedundantTableView extends DAViewComposite { + public static final int COUNT_TABLE_INDEX = 0; + public static final int ELAPSED_TIME_TABLE_INDEX = 1; + public static final int API_NAME_TABLE_INDEX = 2; + public static final int PARAMETER_TABLE_INDEX = 3; + GLRedundantTable tableComp = null; + private int[] columnSizes = { 50, 90, 150, 150 }; + private boolean[] columnVisibility = { true, true, true, true }; + private int[] columnAlignment = { SWT.CENTER, SWT.CENTER, SWT.LEFT, SWT.LEFT }; + + private String[] columnNames = { GLPageLabels.GL_REDUNDANT_VIEW_COUNT, + GLPageLabels.GL_REDUNDANT_VIEW_ELAPSED_TIME, GLPageLabels.GL_REDUNDANT_VIEW_API_NAME, + GLPageLabels.GL_REDUNDANT_VIEW_PARAMETER }; + + int[] sortTypes = { AnalyzerConstants.SORT_TYPE_NUM, AnalyzerConstants.SORT_TYPE_NUM, + AnalyzerConstants.SORT_TYPE_STRING, AnalyzerConstants.SORT_TYPE_STRING }; + + public GLRedundantTableView(Composite parent, int style) { + super(parent, style, true); + this.setLayout(new FillLayout()); + setTitle(GLPageLabels.GL_REDUNDANT_TITLE); + Composite contents = getContentArea(); + contents.setBackground(ColorResources.WINDOW_BG_COLOR); + contents.setLayout(new FillLayout()); + tableComp = new GLRedundantTable(contents, SWT.NONE, SWT.MULTI | SWT.BORDER + | SWT.FULL_SELECTION | SWT.H_SCROLL | SWT.V_SCROLL); + tableComp.setTableName(GLPageLabels.GL_REDUNDANT_TITLE); + tableComp.setComparator(new DefaultTableComparator()); + tableComp.setSortTypes(sortTypes); + tableComp.setColumnAlignment(columnAlignment); + tableComp.setColumns(columnNames); + tableComp.setColumnSize(columnSizes); + tableComp.setColumnVisibility(columnVisibility); + tableComp.setTableToolTipEnable(false); + contents.addControlListener(new TableColumnSizePackListener(tableComp, columnSizes)); + } + + @Override + public void updateView() { + if (!AnalyzerManager.isVisibleView(this.getID())) { + return; + } + if (null == tableComp) { + return; + } + tableComp.updateTable(); + } + + @Override + public void updateView(DAViewData vdata) { + if (null == tableComp) { + return; + } + if (vdata instanceof GLSelectionData) { + String id = ((GLSelectionData) vdata).getViewID(); + if (id.equals(GLPage.redundantViewID) || id.equals(GLPage.statisticsViewID) + || id.equals(GLPage.apiListViewID)) { + tableComp.removeSelection(); + tableComp.updateTable(); + } + } + } + + @Override + public void clear() { + tableComp.clear(); + } + + @Override + public Control getControl() { + return tableComp; + } + +} diff --git a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/opengl/table/state/GLStatisticsTable.java b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/opengl/table/state/GLStatisticsTable.java new file mode 100644 index 0000000..031325a --- /dev/null +++ b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/opengl/table/state/GLStatisticsTable.java @@ -0,0 +1,136 @@ +/* + * Dynamic Analyzer + * + * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved. + * + * Contact: + * Hyunjong Park + * Juyoung Kim + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * Contributors: + * - S-Core Co., Ltd + * + */ + +package org.tizen.dynamicanalyzer.ui.opengl.table.state; + +import java.util.ArrayList; +import java.util.List; + +import org.eclipse.nebula.widgets.grid.GridItem; +import org.eclipse.swt.events.SelectionEvent; +import org.eclipse.swt.events.SelectionListener; +import org.eclipse.swt.widgets.Composite; +import org.tizen.dynamicanalyzer.common.AnalyzerConstants; +import org.tizen.dynamicanalyzer.common.AnalyzerManager; +import org.tizen.dynamicanalyzer.constant.CommonConstants; +import org.tizen.dynamicanalyzer.model.TableInput; +import org.tizen.dynamicanalyzer.ui.opengl.GLPage; +import org.tizen.dynamicanalyzer.ui.opengl.data.GLDataManager; +import org.tizen.dynamicanalyzer.ui.opengl.data.type.GLSelectionData; +import org.tizen.dynamicanalyzer.ui.opengl.data.type.GLStatisticsDataType; +import org.tizen.dynamicanalyzer.ui.widgets.table.DATableComposite; +import org.tizen.dynamicanalyzer.ui.widgets.table.DATableDataFormat; + +public class GLStatisticsTable extends DATableComposite { + public GLStatisticsTable(Composite parent, int style, int tableStyle) { + super(parent, style, tableStyle); + setContextMenu(AnalyzerConstants.CONTEXT_TABLE_RANGE); + table.addSelectionListener(new SelectionListener() { + @Override + public void widgetSelected(SelectionEvent e) { + GridItem[] items = table.getSelection(); + if (null == items) { + return; + } + DATableDataFormat tableDataFormat = (DATableDataFormat) items[0].getData(); + GLDataManager.getInstance().setSelectedAPIAtTable( + (String) tableDataFormat.getData().get( + GLStatisticsTableView.API_NAME_TABLE_INDEX)); + GLSelectionData selData = new GLSelectionData(GLPage.statisticsViewID, 0, 0, items, + table, 0, 0); + AnalyzerManager.getCurrentPage().updateView(selData); + AnalyzerManager.updateView(GLPage.statisticsViewID, selData); + } + + @Override + public void widgetDefaultSelected(SelectionEvent e) { + } + }); + } + + protected List makeTableInput() { + List input = new ArrayList(); + GLDataManager.getInstance().updateSharingContextList(); + List dataList = GLDataManager.getInstance().getStatisticsDataManger() + .getStatisticsTableData(); + if (null == dataList) { + return null; + } + int totalCallCount = 0; + int size = dataList.size(); + for (int i = 0; i < size; i++) { + GLStatisticsDataType data = dataList.get(i); + List text = new ArrayList(); + text.add(data.getAPIName()); + text.add(String.format("%.2f", data.getRate()));//$NON-NLS-1$ + text.add(Integer.toString(data.getCallCount())); + text.add(data.getAPIType()); + DATableDataFormat tableData = new DATableDataFormat(i + 1); + List compareData = new ArrayList(); + compareData.add(text.get(0)); + compareData.add(String.format("%.0f", data.getRate() * 100));//$NON-NLS-1$ + compareData.add(text.get(2)); + compareData.add(text.get(3)); + tableData.setData(compareData); + TableInput tableInput = new TableInput(); + tableInput.setText(text); + tableInput.setData(tableData); + if (GLDataManager.getInstance().getSelectedAPIAtTable().equals(data.getAPIName())) { + tableInput.setSecondSelection(true); + } + input.add(tableInput); + + totalCallCount += data.getCallCount(); + + } + input.add(makeTotalRowInfo(size, totalCallCount)); + return input; + } + + private TableInput makeTotalRowInfo(int size, int totalCallCount) { + List text = new ArrayList(); + text.add("Total (" + size + " items)");//$NON-NLS-1$//$NON-NLS-2$ + text.add("100");//$NON-NLS-1$ + text.add(Integer.toString(totalCallCount)); + text.add(CommonConstants.DASH); + DATableDataFormat tableData = new DATableDataFormat(0); + List compareData = new ArrayList(); + compareData.add(text.get(0)); + compareData.add("10000");//$NON-NLS-1 + compareData.add(text.get(2)); + compareData.add(text.get(3)); + tableData.setData(compareData); + TableInput tableInput = new TableInput(); + tableInput.setText(text); + tableInput.setData(tableData); + return tableInput; + } + + public void removeSelection() { + table.removeAll(); + updateTable(); + } +} diff --git a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/opengl/table/state/GLStatisticsTableView.java b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/opengl/table/state/GLStatisticsTableView.java new file mode 100644 index 0000000..a2315f0 --- /dev/null +++ b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/opengl/table/state/GLStatisticsTableView.java @@ -0,0 +1,115 @@ +/* + * Dynamic Analyzer + * + * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved. + * + * Contact: + * Hyunjong Park + * Juyoung Kim + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * Contributors: + * - S-Core Co., Ltd + * + */ + +package org.tizen.dynamicanalyzer.ui.opengl.table.state; + +import org.eclipse.swt.SWT; +import org.eclipse.swt.layout.FillLayout; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Control; +import org.tizen.dynamicanalyzer.common.AnalyzerConstants; +import org.tizen.dynamicanalyzer.common.AnalyzerManager; +import org.tizen.dynamicanalyzer.nl.GLPageLabels; +import org.tizen.dynamicanalyzer.resources.ColorResources; +import org.tizen.dynamicanalyzer.ui.opengl.GLPage; +import org.tizen.dynamicanalyzer.ui.opengl.data.type.GLSelectionData; +import org.tizen.dynamicanalyzer.ui.widgets.table.DefaultTableComparator; +import org.tizen.dynamicanalyzer.ui.widgets.table.TableColumnSizePackListener; +import org.tizen.dynamicanalyzer.widgets.da.view.DAViewComposite; +import org.tizen.dynamicanalyzer.widgets.da.view.DAViewData; + +public class GLStatisticsTableView extends DAViewComposite { + public static final int API_NAME_TABLE_INDEX = 0; + public static final int TABLE_RATE_TABLE_INDEX = 1; + public static final int COUNT_TABLE_INDEX = 2; + public static final int API_TYPE_TABLE_INDEX = 3; + + GLStatisticsTable tableComp = null; + private int[] columnSizes = { 150, 80, 80, 200 }; + private boolean[] columnVisibility = { true, true, true, true }; + private int[] columnAlignment = { SWT.LEFT, SWT.CENTER, SWT.CENTER, SWT.CENTER }; + + private String[] columnNames = { GLPageLabels.GL_STATISTICS_VIEW_API_NAME, + GLPageLabels.GL_STATISTICS_VIEW_RATE, GLPageLabels.GL_STATISTICS_VIEW_COUNT, + GLPageLabels.GL_STATISTICS_VIEW_API_TYPE }; + + int[] sortTypes = { AnalyzerConstants.SORT_TYPE_STRING, AnalyzerConstants.SORT_TYPE_NUM, + AnalyzerConstants.SORT_TYPE_NUM, AnalyzerConstants.SORT_TYPE_STRING }; + + public GLStatisticsTableView(Composite parent, int style) { + super(parent, style, true); + this.setLayout(new FillLayout()); + setTitle(GLPageLabels.GL_STATISTICS_TITLE); + Composite contents = getContentArea(); + contents.setBackground(ColorResources.WINDOW_BG_COLOR); + contents.setLayout(new FillLayout()); + tableComp = new GLStatisticsTable(contents, SWT.NONE, SWT.MULTI | SWT.BORDER + | SWT.FULL_SELECTION | SWT.H_SCROLL | SWT.V_SCROLL); + tableComp.setTableName(GLPageLabels.GL_STATISTICS_TITLE); + tableComp.setComparator(new DefaultTableComparator()); + tableComp.setSortTypes(sortTypes); + tableComp.setColumnAlignment(columnAlignment); + tableComp.setColumns(columnNames); + tableComp.setColumnSize(columnSizes); + tableComp.setColumnVisibility(columnVisibility); + tableComp.setTableToolTipEnable(false); + contents.addControlListener(new TableColumnSizePackListener(tableComp, columnSizes)); + } + + @Override + public void updateView() { + if (!AnalyzerManager.isVisibleView(this.getID())) { + return; + } + if (null == tableComp) { + return; + } + tableComp.updateTable(); + } + + @Override + public void updateView(DAViewData vdata) { + if (vdata instanceof GLSelectionData) { + String id = ((GLSelectionData) vdata).getViewID(); + if (id.equals(GLPage.redundantViewID) || id.equals(GLPage.statisticsViewID) + || id.equals(GLPage.apiListViewID)) { + tableComp.removeSelection(); + tableComp.updateTable(); + } + } + } + + @Override + public void clear() { + tableComp.clear(); + } + + @Override + public Control getControl() { + return tableComp; + } + +}