From 0ff2ba13c64c5234e012326130dc5f08332951d4 Mon Sep 17 00:00:00 2001 From: Siva Velusamy Date: Tue, 6 Mar 2012 13:47:14 -0800 Subject: gltrace: Display state transformation errors in a console. This patch adds a Eclipse Message Console for GLTrace View. Errors that occur during creation of state transformations, and during application of these transformations are displayed in this console. Change-Id: If8686217f7809efeea39d088d70ab665af674930 --- .../META-INF/MANIFEST.MF | 5 +- .../android/ide/eclipse/gldebugger/Activator.java | 83 ------------- .../ide/eclipse/gldebugger/GlTracePlugin.java | 130 +++++++++++++++++++++ .../ide/eclipse/gltrace/GLTraceOptionsDialog.java | 6 +- .../ide/eclipse/gltrace/TraceFileParserTask.java | 13 ++- .../eclipse/gltrace/editors/DurationMinimap.java | 20 +++- .../gltrace/editors/GLFunctionTraceViewer.java | 6 + .../ide/eclipse/gltrace/editors/StateViewPage.java | 28 +++-- .../android/ide/eclipse/gltrace/model/GLCall.java | 26 ++++- .../transforms/CurrentProgramPropertyAccessor.java | 7 ++ .../transforms/CurrentVboPropertyAccessor.java | 5 + .../state/transforms/GLPropertyAccessor.java | 20 +++- .../state/transforms/IGLPropertyAccessor.java | 4 + .../state/transforms/PropertyChangeTransform.java | 8 +- .../state/transforms/StateTransformFactory.java | 3 + .../state/transforms/TexturePropertyAccessor.java | 5 + .../transforms/TextureUnitPropertyAccessor.java | 5 + .../eclipse/gltrace/views/FitToCanvasAction.java | 4 +- 18 files changed, 264 insertions(+), 114 deletions(-) delete mode 100644 eclipse/plugins/com.android.ide.eclipse.gldebugger/src/com/android/ide/eclipse/gldebugger/Activator.java create mode 100644 eclipse/plugins/com.android.ide.eclipse.gldebugger/src/com/android/ide/eclipse/gldebugger/GlTracePlugin.java (limited to 'eclipse') diff --git a/eclipse/plugins/com.android.ide.eclipse.gldebugger/META-INF/MANIFEST.MF b/eclipse/plugins/com.android.ide.eclipse.gldebugger/META-INF/MANIFEST.MF index e3ca918..a03c229 100644 --- a/eclipse/plugins/com.android.ide.eclipse.gldebugger/META-INF/MANIFEST.MF +++ b/eclipse/plugins/com.android.ide.eclipse.gldebugger/META-INF/MANIFEST.MF @@ -3,13 +3,14 @@ Bundle-ManifestVersion: 2 Bundle-Name: GLESv2 Debugger Client Bundle-SymbolicName: com.android.ide.eclipse.gldebugger;singleton:=true Bundle-Version: 17.0.0.qualifier -Bundle-Activator: com.android.ide.eclipse.gldebugger.Activator +Bundle-Activator: com.android.ide.eclipse.gldebugger.GlTracePlugin Require-Bundle: org.eclipse.ui, org.eclipse.core.runtime, com.android.ide.eclipse.ddms, org.eclipse.ui.ide, org.eclipse.core.resources, - org.eclipse.core.filesystem + org.eclipse.core.filesystem, + org.eclipse.ui.console Bundle-ActivationPolicy: lazy Bundle-ClassPath: libs/host-libprotobuf-java-2.3.0-lite.jar, libs/liblzf.jar, diff --git a/eclipse/plugins/com.android.ide.eclipse.gldebugger/src/com/android/ide/eclipse/gldebugger/Activator.java b/eclipse/plugins/com.android.ide.eclipse.gldebugger/src/com/android/ide/eclipse/gldebugger/Activator.java deleted file mode 100644 index 67fd809..0000000 --- a/eclipse/plugins/com.android.ide.eclipse.gldebugger/src/com/android/ide/eclipse/gldebugger/Activator.java +++ /dev/null @@ -1,83 +0,0 @@ -/* - ** Copyright 2011, The Android Open Source Project - ** - ** 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. - */ - -package com.android.ide.eclipse.gldebugger; - -import org.eclipse.jface.resource.ImageDescriptor; -import org.eclipse.ui.plugin.AbstractUIPlugin; -import org.osgi.framework.BundleContext; - -/** - * The activator class controls the plug-in life cycle - */ -public class Activator extends AbstractUIPlugin { - - // The plug-in ID - public static final String PLUGIN_ID = "com.android.ide.eclipse.gldebugger"; //$NON-NLS-1$ - - // The shared instance - private static Activator plugin; - - /** - * The constructor - */ - public Activator() { - } - - /* - * (non-Javadoc) - * @see - * org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext - * ) - */ - @Override - public void start(BundleContext context) throws Exception { - super.start(context); - plugin = this; - } - - /* - * (non-Javadoc) - * @see - * org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext - * ) - */ - @Override - public void stop(BundleContext context) throws Exception { - plugin = null; - super.stop(context); - } - - /** - * Returns the shared instance - * - * @return the shared instance - */ - public static Activator getDefault() { - return plugin; - } - - /** - * Returns an image descriptor for the image file at the given plug-in - * relative path - * - * @param path the path - * @return the image descriptor - */ - public static ImageDescriptor getImageDescriptor(String path) { - return imageDescriptorFromPlugin(PLUGIN_ID, path); - } -} diff --git a/eclipse/plugins/com.android.ide.eclipse.gldebugger/src/com/android/ide/eclipse/gldebugger/GlTracePlugin.java b/eclipse/plugins/com.android.ide.eclipse.gldebugger/src/com/android/ide/eclipse/gldebugger/GlTracePlugin.java new file mode 100644 index 0000000..dafb661 --- /dev/null +++ b/eclipse/plugins/com.android.ide.eclipse.gldebugger/src/com/android/ide/eclipse/gldebugger/GlTracePlugin.java @@ -0,0 +1,130 @@ +/* + ** Copyright 2011, The Android Open Source Project + ** + ** 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. + */ + +package com.android.ide.eclipse.gldebugger; + +import org.eclipse.jface.resource.ImageDescriptor; +import org.eclipse.swt.widgets.Display; +import org.eclipse.ui.IWorkbenchPage; +import org.eclipse.ui.IWorkbenchWindow; +import org.eclipse.ui.PartInitException; +import org.eclipse.ui.PlatformUI; +import org.eclipse.ui.console.ConsolePlugin; +import org.eclipse.ui.console.IConsole; +import org.eclipse.ui.console.IConsoleConstants; +import org.eclipse.ui.console.MessageConsole; +import org.eclipse.ui.console.MessageConsoleStream; +import org.eclipse.ui.plugin.AbstractUIPlugin; +import org.osgi.framework.BundleContext; + +/** + * The activator class controls the plug-in life cycle + */ +public class GlTracePlugin extends AbstractUIPlugin { + + // The plug-in ID + public static final String PLUGIN_ID = "com.android.ide.eclipse.gldebugger"; //$NON-NLS-1$ + + // The shared instance + private static GlTracePlugin plugin; + + private MessageConsole mConsole; + private MessageConsoleStream mConsoleStream; + + /** + * The constructor + */ + public GlTracePlugin() { + } + + /* + * (non-Javadoc) + * @see + * org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext + * ) + */ + @Override + public void start(BundleContext context) throws Exception { + super.start(context); + plugin = this; + + mConsole = new MessageConsole("OpenGL Trace View", null); + ConsolePlugin.getDefault().getConsoleManager().addConsoles(new IConsole[] { + mConsole }); + + mConsoleStream = mConsole.newMessageStream(); + } + + /* + * (non-Javadoc) + * @see + * org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext + * ) + */ + @Override + public void stop(BundleContext context) throws Exception { + plugin = null; + super.stop(context); + } + + /** + * Returns the shared instance + * + * @return the shared instance + */ + public static GlTracePlugin getDefault() { + return plugin; + } + + /** + * Returns an image descriptor for the image file at the given plug-in + * relative path + * + * @param path the path + * @return the image descriptor + */ + public static ImageDescriptor getImageDescriptor(String path) { + return imageDescriptorFromPlugin(PLUGIN_ID, path); + } + + public void logMessage(String message) { + mConsoleStream.println(message); + + Display.getDefault().asyncExec(sShowConsoleRunnable); + } + + private static Runnable sShowConsoleRunnable = new Runnable() { + @Override + public void run() { + showConsoleView(); + }; + }; + + private static void showConsoleView() { + IWorkbenchWindow w = PlatformUI.getWorkbench().getActiveWorkbenchWindow(); + if (w != null) { + IWorkbenchPage page = w.getActivePage(); + if (page != null) { + try { + page.showView(IConsoleConstants.ID_CONSOLE_VIEW, null, + IWorkbenchPage.VIEW_VISIBLE); + } catch (PartInitException e) { + // ignore + } + } + } + } +} diff --git a/eclipse/plugins/com.android.ide.eclipse.gldebugger/src/com/android/ide/eclipse/gltrace/GLTraceOptionsDialog.java b/eclipse/plugins/com.android.ide.eclipse.gldebugger/src/com/android/ide/eclipse/gltrace/GLTraceOptionsDialog.java index b0e1b1f..ac752e7 100644 --- a/eclipse/plugins/com.android.ide.eclipse.gldebugger/src/com/android/ide/eclipse/gltrace/GLTraceOptionsDialog.java +++ b/eclipse/plugins/com.android.ide.eclipse.gldebugger/src/com/android/ide/eclipse/gltrace/GLTraceOptionsDialog.java @@ -18,7 +18,7 @@ package com.android.ide.eclipse.gltrace; import com.android.ddmlib.AndroidDebugBridge; import com.android.ddmlib.IDevice; -import com.android.ide.eclipse.gldebugger.Activator; +import com.android.ide.eclipse.gldebugger.GlTracePlugin; import org.eclipse.core.runtime.preferences.IEclipsePreferences; import org.eclipse.core.runtime.preferences.InstanceScope; @@ -283,7 +283,7 @@ public class GLTraceOptionsDialog extends TitleAreaDialog { } private void savePreferences() { - IEclipsePreferences prefs = new InstanceScope().getNode(Activator.PLUGIN_ID); + IEclipsePreferences prefs = new InstanceScope().getNode(GlTracePlugin.PLUGIN_ID); prefs.put(PREF_APPNAME, mActivityToTrace); prefs.put(PREF_TRACEFILE, mTraceFilePath); try { @@ -294,7 +294,7 @@ public class GLTraceOptionsDialog extends TitleAreaDialog { } private void loadPreferences() { - IEclipsePreferences prefs = new InstanceScope().getNode(Activator.PLUGIN_ID); + IEclipsePreferences prefs = new InstanceScope().getNode(GlTracePlugin.PLUGIN_ID); mActivityToTrace = prefs.get(PREF_APPNAME, ""); mTraceFilePath = prefs.get(PREF_TRACEFILE, ""); } diff --git a/eclipse/plugins/com.android.ide.eclipse.gldebugger/src/com/android/ide/eclipse/gltrace/TraceFileParserTask.java b/eclipse/plugins/com.android.ide.eclipse.gldebugger/src/com/android/ide/eclipse/gltrace/TraceFileParserTask.java index 083cba5..7bd86d5 100644 --- a/eclipse/plugins/com.android.ide.eclipse.gldebugger/src/com/android/ide/eclipse/gltrace/TraceFileParserTask.java +++ b/eclipse/plugins/com.android.ide.eclipse.gldebugger/src/com/android/ide/eclipse/gltrace/TraceFileParserTask.java @@ -17,6 +17,7 @@ package com.android.ide.eclipse.gltrace; import com.android.ide.eclipse.gldebugger.GLEnum; +import com.android.ide.eclipse.gldebugger.GlTracePlugin; import com.android.ide.eclipse.gltrace.GLProtoBuf.GLMessage; import com.android.ide.eclipse.gltrace.GLProtoBuf.GLMessage.Function; import com.android.ide.eclipse.gltrace.format.GLAPISpec; @@ -107,11 +108,19 @@ public class TraceFileParserTask implements IRunnableWithProgress { msg.hasFb(), msg.getContextId(), msg.getDuration(), - msg.getThreadtime(), - StateTransformFactory.getTransformsFor(msg)); + msg.getThreadtime()); addProperties(c, msg); + try { + c.setStateTransformations(StateTransformFactory.getTransformsFor(msg)); + } catch (Exception e) { + c.setStateTransformationCreationError(e.getMessage()); + GlTracePlugin.getDefault().logMessage("Error while creating transformations for " + + c.toString() + ":"); + GlTracePlugin.getDefault().logMessage(e.getMessage()); + } + mGLCalls.add(c); mGLContextIds.add(Integer.valueOf(c.getContextId())); } diff --git a/eclipse/plugins/com.android.ide.eclipse.gldebugger/src/com/android/ide/eclipse/gltrace/editors/DurationMinimap.java b/eclipse/plugins/com.android.ide.eclipse.gldebugger/src/com/android/ide/eclipse/gltrace/editors/DurationMinimap.java index a6802c9..7f468e1 100644 --- a/eclipse/plugins/com.android.ide.eclipse.gldebugger/src/com/android/ide/eclipse/gltrace/editors/DurationMinimap.java +++ b/eclipse/plugins/com.android.ide.eclipse.gldebugger/src/com/android/ide/eclipse/gltrace/editors/DurationMinimap.java @@ -79,6 +79,7 @@ public class DurationMinimap extends Canvas { private Color mBackgroundColor; private Color mDurationLineColor; private Color mGlDrawColor; + private Color mGlErrorColor; private Color mContextHeaderColor; private Color mVisibleCallsHighlightColor; private Color mMouseMarkerColor; @@ -174,6 +175,8 @@ public class DurationMinimap extends Canvas { mContextHeaderColor = new Color(getDisplay(), 0xd1, 0xe5, 0xf0); mVisibleCallsHighlightColor = new Color(getDisplay(), 0xcc, 0xcc, 0xcc); mMouseMarkerColor = new Color(getDisplay(), 0xaa, 0xaa, 0xaa); + + mGlErrorColor = getDisplay().getSystemColor(SWT.COLOR_RED); } private void disposeColors() { @@ -301,17 +304,22 @@ public class DurationMinimap extends Canvas { boolean resetColor = false; GLCall c = mCalls.get(i); - if (c.getFunction() == Function.glDrawArrays + long duration = c.getWallDuration(); + + if (c.hasErrors()) { + gc.setBackground(mGlErrorColor); + resetColor = true; + + // If the call has any errors, we want it to be visible in the minimap + // regardless of how long it took. + duration = mPositionHelper.getMaxDuration(); + } else if (c.getFunction() == Function.glDrawArrays || c.getFunction() == Function.glDrawElements || c.getFunction() == Function.eglSwapBuffers) { gc.setBackground(mGlDrawColor); resetColor = true; - } - long duration = c.getWallDuration(); - if (c.getFunction() == Function.eglSwapBuffers) { - // egl swap buffers typically takes very little time, but since - // it is a significant call, we explicitly size it to the max length + // render all draw calls & swap buffer at max length duration = mPositionHelper.getMaxDuration(); } diff --git a/eclipse/plugins/com.android.ide.eclipse.gldebugger/src/com/android/ide/eclipse/gltrace/editors/GLFunctionTraceViewer.java b/eclipse/plugins/com.android.ide.eclipse.gldebugger/src/com/android/ide/eclipse/gltrace/editors/GLFunctionTraceViewer.java index 4d1da1f..7a9f167 100644 --- a/eclipse/plugins/com.android.ide.eclipse.gldebugger/src/com/android/ide/eclipse/gltrace/editors/GLFunctionTraceViewer.java +++ b/eclipse/plugins/com.android.ide.eclipse.gldebugger/src/com/android/ide/eclipse/gltrace/editors/GLFunctionTraceViewer.java @@ -100,6 +100,7 @@ public class GLFunctionTraceViewer extends EditorPart implements ISelectionProvi private GLCallFilter mGLCallFilter; private Color mGldrawTextColor; + private Color mGlCallErrorColor; // Currently displayed frame's start and end call indices. private int mCallStartIndex; @@ -116,6 +117,7 @@ public class GLFunctionTraceViewer extends EditorPart implements ISelectionProvi public GLFunctionTraceViewer() { mGldrawTextColor = Display.getDefault().getSystemColor(SWT.COLOR_BLUE); + mGlCallErrorColor = Display.getDefault().getSystemColor(SWT.COLOR_RED); } @Override @@ -528,6 +530,10 @@ public class GLFunctionTraceViewer extends EditorPart implements ISelectionProvi cell.setForeground(mGldrawTextColor); } + if (c.hasErrors()) { + cell.setForeground(mGlCallErrorColor); + } + cell.setText(getColumnText(c, cell.getColumnIndex())); } diff --git a/eclipse/plugins/com.android.ide.eclipse.gldebugger/src/com/android/ide/eclipse/gltrace/editors/StateViewPage.java b/eclipse/plugins/com.android.ide.eclipse.gldebugger/src/com/android/ide/eclipse/gltrace/editors/StateViewPage.java index 174e70f..288dc15 100644 --- a/eclipse/plugins/com.android.ide.eclipse.gldebugger/src/com/android/ide/eclipse/gltrace/editors/StateViewPage.java +++ b/eclipse/plugins/com.android.ide.eclipse.gldebugger/src/com/android/ide/eclipse/gltrace/editors/StateViewPage.java @@ -16,7 +16,7 @@ package com.android.ide.eclipse.gltrace.editors; -import com.android.ide.eclipse.gldebugger.Activator; +import com.android.ide.eclipse.gldebugger.GlTracePlugin; import com.android.ide.eclipse.gltrace.editors.GLCallGroups.GLCallNode; import com.android.ide.eclipse.gltrace.model.GLCall; import com.android.ide.eclipse.gltrace.model.GLTrace; @@ -29,6 +29,7 @@ import org.eclipse.core.runtime.IStatus; import org.eclipse.core.runtime.Status; import org.eclipse.core.runtime.jobs.ILock; import org.eclipse.core.runtime.jobs.Job; +import org.eclipse.jface.layout.GridDataFactory; import org.eclipse.jface.viewers.ISelection; import org.eclipse.jface.viewers.ISelectionChangedListener; import org.eclipse.jface.viewers.ISelectionProvider; @@ -82,6 +83,8 @@ public class StateViewPage extends Page implements ISelectionListener, ISelectio @Override public void createControl(Composite parent) { final Tree tree = new Tree(parent, SWT.VIRTUAL | SWT.H_SCROLL | SWT.V_SCROLL); + GridDataFactory.fillDefaults().grab(true, true).applyTo(tree); + tree.setHeaderVisible(true); tree.setLinesVisible(true); tree.setLayoutData(new GridData(GridData.FILL_BOTH)); @@ -154,8 +157,11 @@ public class StateViewPage extends Page implements ISelectionListener, ISelectio selectedCallIndex); mCurrentStateIndex = selectedCallIndex; } catch (Exception e) { + GlTracePlugin.getDefault().logMessage( + "Unexpected error while updating GL State."); + GlTracePlugin.getDefault().logMessage(e.getMessage()); return new Status(Status.ERROR, - Activator.PLUGIN_ID, + GlTracePlugin.PLUGIN_ID, "Unexpected error while updating GL State.", e); } finally { @@ -218,12 +224,18 @@ public class StateViewPage extends Page implements ISelectionListener, ISelectio Set changedProperties = new HashSet(setSizeHint); for (int i = fromIndex + 1; i <= toIndex; i++) { - for (IStateTransform f : mGLCalls.get(i).getStateTransformations()) { - f.apply(mState); - - IGLProperty changedProperty = f.getChangedProperty(mState); - if (changedProperty != null) { - changedProperties.addAll(getHierarchy(changedProperty)); + GLCall call = mGLCalls.get(i); + for (IStateTransform f : call.getStateTransformations()) { + try { + f.apply(mState); + IGLProperty changedProperty = f.getChangedProperty(mState); + if (changedProperty != null) { + changedProperties.addAll(getHierarchy(changedProperty)); + } + } catch (Exception e) { + GlTracePlugin.getDefault().logMessage("Error applying transformations for " + + call); + GlTracePlugin.getDefault().logMessage(e.getMessage()); } } } diff --git a/eclipse/plugins/com.android.ide.eclipse.gldebugger/src/com/android/ide/eclipse/gltrace/model/GLCall.java b/eclipse/plugins/com.android.ide.eclipse.gldebugger/src/com/android/ide/eclipse/gltrace/model/GLCall.java index d049c9e..aae91c0 100644 --- a/eclipse/plugins/com.android.ide.eclipse.gldebugger/src/com/android/ide/eclipse/gltrace/model/GLCall.java +++ b/eclipse/plugins/com.android.ide.eclipse.gldebugger/src/com/android/ide/eclipse/gltrace/model/GLCall.java @@ -23,6 +23,7 @@ import com.android.sdklib.util.SparseArray; import org.eclipse.swt.graphics.Image; +import java.util.Collections; import java.util.List; /** @@ -78,15 +79,17 @@ public class GLCall { private final int mThreadDuration; /** List of state transformations performed by this call. */ - private final List mStateTransforms; + private List mStateTransforms = Collections.emptyList(); + + /** Error conditions while creating state transforms for this call. */ + private String mStateTransformationCreationErrorMessage; /** List of properties associated to this call. */ private SparseArray mProperties; public GLCall(int index, long startTime, long traceFileOffset, String displayString, Image thumbnailImage, Function function, boolean hasFb, int contextId, - int wallTime, int threadTime, - List stateTransforms) { + int wallTime, int threadTime) { mIndex = index; mStartTime = startTime; mTraceFileOffset = traceFileOffset; @@ -97,7 +100,6 @@ public class GLCall { mContextId = contextId; mWallDuration = wallTime; mThreadDuration = threadTime; - mStateTransforms = stateTransforms; } public int getIndex() { @@ -140,6 +142,22 @@ public class GLCall { return mThreadDuration; } + public void setStateTransformations(List transforms) { + mStateTransforms = transforms; + } + + public void setStateTransformationCreationError(String errorMessage) { + mStateTransformationCreationErrorMessage = errorMessage; + } + + public boolean hasErrors() { + return mStateTransformationCreationErrorMessage != null; + } + + public String getError() { + return mStateTransformationCreationErrorMessage; + } + public List getStateTransformations() { return mStateTransforms; } diff --git a/eclipse/plugins/com.android.ide.eclipse.gldebugger/src/com/android/ide/eclipse/gltrace/state/transforms/CurrentProgramPropertyAccessor.java b/eclipse/plugins/com.android.ide.eclipse.gldebugger/src/com/android/ide/eclipse/gltrace/state/transforms/CurrentProgramPropertyAccessor.java index b977d87..9cc3cb8 100644 --- a/eclipse/plugins/com.android.ide.eclipse.gldebugger/src/com/android/ide/eclipse/gltrace/state/transforms/CurrentProgramPropertyAccessor.java +++ b/eclipse/plugins/com.android.ide.eclipse.gldebugger/src/com/android/ide/eclipse/gltrace/state/transforms/CurrentProgramPropertyAccessor.java @@ -38,6 +38,7 @@ public class CurrentProgramPropertyAccessor implements IGLPropertyAccessor { GLStateType.PROGRAM_STATE, GLStateType.CURRENT_PROGRAM); } + @Override public IGLProperty getProperty(IGLProperty state) { // obtain the current program @@ -57,4 +58,10 @@ public class CurrentProgramPropertyAccessor implements IGLPropertyAccessor { Integer.valueOf(mLocation), mStateType).getProperty(state); } + + @Override + public String getPath() { + return String.format("PROGRAM_STATE/PROGRAMS/${program}/%s/%d/%s", + mStateCategory, mLocation, mStateType); + } } diff --git a/eclipse/plugins/com.android.ide.eclipse.gldebugger/src/com/android/ide/eclipse/gltrace/state/transforms/CurrentVboPropertyAccessor.java b/eclipse/plugins/com.android.ide.eclipse.gldebugger/src/com/android/ide/eclipse/gltrace/state/transforms/CurrentVboPropertyAccessor.java index 3f763e0..ea7617d 100644 --- a/eclipse/plugins/com.android.ide.eclipse.gldebugger/src/com/android/ide/eclipse/gltrace/state/transforms/CurrentVboPropertyAccessor.java +++ b/eclipse/plugins/com.android.ide.eclipse.gldebugger/src/com/android/ide/eclipse/gltrace/state/transforms/CurrentVboPropertyAccessor.java @@ -63,4 +63,9 @@ public class CurrentVboPropertyAccessor implements IGLPropertyAccessor { buffer, mVboProperty).getProperty(state); } + + @Override + public String getPath() { + return String.format("VERTEX_ARRAY_DATA/VBO/${currentBuffer}/%s", mVboProperty); + } } diff --git a/eclipse/plugins/com.android.ide.eclipse.gldebugger/src/com/android/ide/eclipse/gltrace/state/transforms/GLPropertyAccessor.java b/eclipse/plugins/com.android.ide.eclipse.gldebugger/src/com/android/ide/eclipse/gltrace/state/transforms/GLPropertyAccessor.java index 8772a72..be338be 100644 --- a/eclipse/plugins/com.android.ide.eclipse.gldebugger/src/com/android/ide/eclipse/gltrace/state/transforms/GLPropertyAccessor.java +++ b/eclipse/plugins/com.android.ide.eclipse.gldebugger/src/com/android/ide/eclipse/gltrace/state/transforms/GLPropertyAccessor.java @@ -45,7 +45,8 @@ public class GLPropertyAccessor implements IGLPropertyAccessor { for (GLPropertyExtractor e : mExtractors) { IGLProperty successor = e.getProperty(root); if (successor == null) { - return null; + root = null; + break; } root = successor; } @@ -111,7 +112,7 @@ public class GLPropertyAccessor implements IGLPropertyAccessor { @Override public IGLProperty getProperty(IGLProperty p) { - if (p instanceof GLListProperty) { + if (p instanceof GLListProperty && mIndex >= 0) { return ((GLListProperty) p).get(mIndex); } if (p instanceof GLSparseArrayProperty) { @@ -120,4 +121,19 @@ public class GLPropertyAccessor implements IGLPropertyAccessor { return null; } } + + @Override + public String getPath() { + StringBuilder sb = new StringBuilder(mExtractors.size() * 10); + for (GLPropertyExtractor e: mExtractors) { + if (e instanceof GLNamePropertyExtractor) { + sb.append(((GLNamePropertyExtractor) e).mType); + } else { + sb.append(((GLIndexPropertyExtractor) e).mIndex); + } + sb.append('/'); + } + + return sb.toString(); + } } diff --git a/eclipse/plugins/com.android.ide.eclipse.gldebugger/src/com/android/ide/eclipse/gltrace/state/transforms/IGLPropertyAccessor.java b/eclipse/plugins/com.android.ide.eclipse.gldebugger/src/com/android/ide/eclipse/gltrace/state/transforms/IGLPropertyAccessor.java index 32cda39..5df21b9 100644 --- a/eclipse/plugins/com.android.ide.eclipse.gldebugger/src/com/android/ide/eclipse/gltrace/state/transforms/IGLPropertyAccessor.java +++ b/eclipse/plugins/com.android.ide.eclipse.gldebugger/src/com/android/ide/eclipse/gltrace/state/transforms/IGLPropertyAccessor.java @@ -23,5 +23,9 @@ import com.android.ide.eclipse.gltrace.state.IGLProperty; * a specific property from a composite property. */ public interface IGLPropertyAccessor { + /** Obtain a specific property from the given state. */ IGLProperty getProperty(IGLProperty state); + + /** Returns the string representation of this property accessor. */ + String getPath(); } diff --git a/eclipse/plugins/com.android.ide.eclipse.gldebugger/src/com/android/ide/eclipse/gltrace/state/transforms/PropertyChangeTransform.java b/eclipse/plugins/com.android.ide.eclipse.gldebugger/src/com/android/ide/eclipse/gltrace/state/transforms/PropertyChangeTransform.java index 79014cf..276f6f4 100644 --- a/eclipse/plugins/com.android.ide.eclipse.gldebugger/src/com/android/ide/eclipse/gltrace/state/transforms/PropertyChangeTransform.java +++ b/eclipse/plugins/com.android.ide.eclipse.gldebugger/src/com/android/ide/eclipse/gltrace/state/transforms/PropertyChangeTransform.java @@ -64,8 +64,12 @@ public class PropertyChangeTransform implements IStateTransform { } } - mOldValue = property.getValue(); - property.setValue(mNewValue); + if (property != null) { + mOldValue = property.getValue(); + property.setValue(mNewValue); + } else { + throw new RuntimeException("No such property: " + mAccessor.getPath()); + } } /** diff --git a/eclipse/plugins/com.android.ide.eclipse.gldebugger/src/com/android/ide/eclipse/gltrace/state/transforms/StateTransformFactory.java b/eclipse/plugins/com.android.ide.eclipse.gldebugger/src/com/android/ide/eclipse/gltrace/state/transforms/StateTransformFactory.java index 5751025..576e87b 100644 --- a/eclipse/plugins/com.android.ide.eclipse.gldebugger/src/com/android/ide/eclipse/gltrace/state/transforms/StateTransformFactory.java +++ b/eclipse/plugins/com.android.ide.eclipse.gldebugger/src/com/android/ide/eclipse/gltrace/state/transforms/StateTransformFactory.java @@ -1252,6 +1252,9 @@ public class StateTransformFactory { // .. 4i int location = msg.getArgs(0).getIntValue(0); + if (location < 0) { + throw new IllegalArgumentException("Argument location cannot be less than 0."); + } List uniforms; if (isFloats) { List args = new ArrayList(msg.getArgsCount() - 1); diff --git a/eclipse/plugins/com.android.ide.eclipse.gldebugger/src/com/android/ide/eclipse/gltrace/state/transforms/TexturePropertyAccessor.java b/eclipse/plugins/com.android.ide.eclipse.gldebugger/src/com/android/ide/eclipse/gltrace/state/transforms/TexturePropertyAccessor.java index 7aa8fd6..2116283 100644 --- a/eclipse/plugins/com.android.ide.eclipse.gldebugger/src/com/android/ide/eclipse/gltrace/state/transforms/TexturePropertyAccessor.java +++ b/eclipse/plugins/com.android.ide.eclipse.gldebugger/src/com/android/ide/eclipse/gltrace/state/transforms/TexturePropertyAccessor.java @@ -61,4 +61,9 @@ public class TexturePropertyAccessor implements IGLPropertyAccessor { return textureAccessor.getProperty(state); } + @Override + public String getPath() { + return String.format("TEXTURE_STATE/TEXTURES/${activeTexture}/%s", mTextureType); + } + } diff --git a/eclipse/plugins/com.android.ide.eclipse.gldebugger/src/com/android/ide/eclipse/gltrace/state/transforms/TextureUnitPropertyAccessor.java b/eclipse/plugins/com.android.ide.eclipse.gldebugger/src/com/android/ide/eclipse/gltrace/state/transforms/TextureUnitPropertyAccessor.java index 7c52cd5..2489e14 100644 --- a/eclipse/plugins/com.android.ide.eclipse.gldebugger/src/com/android/ide/eclipse/gltrace/state/transforms/TextureUnitPropertyAccessor.java +++ b/eclipse/plugins/com.android.ide.eclipse.gldebugger/src/com/android/ide/eclipse/gltrace/state/transforms/TextureUnitPropertyAccessor.java @@ -56,4 +56,9 @@ public class TextureUnitPropertyAccessor implements IGLPropertyAccessor { mTargetType); return targetAccessor.getProperty(state); } + + @Override + public String getPath() { + return String.format("TEXTURE_STATE/TEXTURE_UNITS/${activeTextureUnit}/%s", mTargetType); + } } diff --git a/eclipse/plugins/com.android.ide.eclipse.gldebugger/src/com/android/ide/eclipse/gltrace/views/FitToCanvasAction.java b/eclipse/plugins/com.android.ide.eclipse.gldebugger/src/com/android/ide/eclipse/gltrace/views/FitToCanvasAction.java index ccd2cbe..eecd86e 100644 --- a/eclipse/plugins/com.android.ide.eclipse.gldebugger/src/com/android/ide/eclipse/gltrace/views/FitToCanvasAction.java +++ b/eclipse/plugins/com.android.ide.eclipse.gldebugger/src/com/android/ide/eclipse/gltrace/views/FitToCanvasAction.java @@ -16,7 +16,7 @@ package com.android.ide.eclipse.gltrace.views; -import com.android.ide.eclipse.gldebugger.Activator; +import com.android.ide.eclipse.gldebugger.GlTracePlugin; import com.android.ide.eclipse.gltrace.widgets.ImageCanvas; import org.eclipse.jface.action.Action; @@ -25,7 +25,7 @@ public class FitToCanvasAction extends Action { private ImageCanvas mImageCanvas; public FitToCanvasAction(boolean fitByDefault, ImageCanvas canvas) { - super("Fit to Canvas", Activator.getImageDescriptor("/icons/zoomfit.png")); //$NON-NLS-2$ + super("Fit to Canvas", GlTracePlugin.getImageDescriptor("/icons/zoomfit.png")); //$NON-NLS-2$ setToolTipText("Fit Image to Canvas"); mImageCanvas = canvas; -- cgit v1.1