Skip to content

Commit

Permalink
The debugger has to be explicitly enabled.
Browse files Browse the repository at this point in the history
Only once per debugging session though..
  • Loading branch information
ingemaradahl committed Aug 24, 2012
1 parent 35c8c1b commit e2e4549
Show file tree
Hide file tree
Showing 5 changed files with 53 additions and 14 deletions.
2 changes: 1 addition & 1 deletion src/ecma-debugger/stop_at.js
Expand Up @@ -418,7 +418,7 @@ cls.EcmascriptDebugger["6.0"].StopAt = function()
stopAt.stopped_reason == 'new script')
{
runtime_id = stopAt.runtime_id;
if (!webgl.injected)
if (!webgl.injected && webgl.enabled)
{
var continue_callback = (function () { this.__continue('run'); }).bind(this);
webgl.inject(stopAt.runtime_id, continue_callback);
Expand Down
19 changes: 14 additions & 5 deletions src/webgl/start_view.js
Expand Up @@ -21,11 +21,13 @@ cls.WebGLStartView = function(id, name, container_class)
{
if (!this._container) return;

var state = window.webgl.injected
? snapshot_present
? "select"
: "snapshot"
: "init";
var state = window.webgl.enabled
? window.webgl.injected
? snapshot_present
? "select"
: "snapshot"
: "init"
: "enable";
this._container.clearAndRender(window.templates.webgl.start_view(state, info_open));
};

Expand All @@ -34,6 +36,12 @@ cls.WebGLStartView = function(id, name, container_class)
this._container = null;
};

var on_enable = function(event, target)
{
webgl.enable();
runtimes.reloadWindow();
};

var on_settings = function(msg)
{
if (msg.id === "webgl-snapshot")
Expand Down Expand Up @@ -140,6 +148,7 @@ cls.WebGLStartView = function(id, name, container_class)
messages.addListener('webgl-clear', on_clear.bind(this));

var eh = window.eventHandlers;
eh.click["webgl-enable"] = on_enable.bind(this);
eh.click["webgl-open-settings"] = on_open_settings.bind(this);
eh.click["webgl-info-box-toggle"] = on_toggle_info.bind(this);

Expand Down
2 changes: 1 addition & 1 deletion src/webgl/views.js
Expand Up @@ -173,7 +173,7 @@ cls.WebGLGeneralView.create_ui_widgets = function()
'webgl-general',
// key-value map
{
'enable-debugger' : true,
'enable-debugger' : true, // TODO: Actually use this setting for hiding the webgl-mode tab
'highlight-objects' : true,

'first-run' : true,
Expand Down
9 changes: 7 additions & 2 deletions src/webgl/webgl.js
Expand Up @@ -8,6 +8,7 @@ cls.WebGL.WebGLDebugger = function ()
{
this.injected = false;
this.runtime_id = -1;
this.enabled = false;

/* Context IDs for wrapped contexts. NOT an object id */
this.contexts = [];
Expand Down Expand Up @@ -38,10 +39,14 @@ cls.WebGL.WebGLDebugger = function ()
/* Contains shader used when displaying textures and buffers in the debugger */
this.shaders = {};

this.enable = function ()
{
this.enabled = true;
};

this.inject = function (rt_id, cont_callback)
{
// TODO: Better disabling
if (this.runtime_id !== rt_id && window.settings['webgl-general'].map['enable-debugger'])
if (this.runtime_id !== rt_id)
{
this.runtime_id = rt_id;
window.host_tabs.activeTab.addEventListener("webgl-debugger-ready",
Expand Down
35 changes: 30 additions & 5 deletions src/webgl/webgl_templates.js
Expand Up @@ -1637,10 +1637,18 @@ window.templates.webgl.collapse_box = function(title, string, button, custom, in
window.templates.webgl.start_view = function(state, info_open)
{
var html = ["div"];
html.push(["h2", "Welcome to the Dragonfly WebGL Debugger"]);


// TODO: Do this check at a better place :/
if (!window.services["ecmascript-debugger"].is_enabled)
{
return window.templates.disabled_view();
}

// Add the pre-compositing warning if applicable
switch (state)
{
case "enable":
case "init":
var warning = window.settings["webgl-snapshot"].map["pre-composite-capture"];
if (warning)
Expand All @@ -1657,14 +1665,31 @@ window.templates.webgl.start_view = function(state, info_open)
];
html.push(warning_html);
}
break;
}

switch (state)
{
case "enable":
html.push(window.templates.webgl.info_box(
"Refresh the page you want to debug",
"The WebGL Debugger needs to be present from the start of the " +
"Enable the WebGL debugger",
"Click the button below to enable the WebGL debugger. This will " +
"refresh the current debugging context window",
[ "span", "Enable the WebGL debugger",
"class", "ui-button",
"handler", "webgl-enable",
"tabindex", "1"
]
));
break;
case "init":
html.push(window.templates.webgl.info_box(
"Refresh the window you want to debug",
"The WebGL debugger needs to be present from the start of the " +
"execution of the application you want to debug. Click the button " +
"below to refresh.",
[ "span", "Initialize WebGL Debugger",
"class", "ui-button reload-window",
[ "span", "Refresh window",
"class", "ui-button",
"handler", "reload-window",
"tabindex", "1"
]
Expand Down

1 comment on commit e2e4549

@ingemaradahl
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, this commit disables the WebGL debugger when Dragonfly is in profiler mode, albeit in a very ugly way :(

Please sign in to comment.