Skip to content

Commit

Permalink
Merge pull request #2779 from AnalyticalGraphicsInc/performance-style
Browse files Browse the repository at this point in the history
PerformanceDisplay styled by CSS instead of JS.
  • Loading branch information
Hannah committed Jun 3, 2015
2 parents 3f58120 + 8060ccc commit f6257a5
Show file tree
Hide file tree
Showing 6 changed files with 48 additions and 28 deletions.
4 changes: 4 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
Change Log
==========

### 1.11 - 2015-07-01

* The performance statistics displayed by setting `scene.debugShowFramesPerSecond` to `true` can now be styled using the `cesium-performanceDisplay` CSS classes in `shared.css`.

### 1.10 - 2015-06-01

* Breaking changes
Expand Down
21 changes: 4 additions & 17 deletions Source/Scene/PerformanceDisplay.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,6 @@ define([
getElement) {
"use strict";

var defaultFpsColor = Color.fromCssColorString('#e52');
var defaultFrameTimeColor = Color.fromCssColorString('#de3');
var defaultBackgroundColor = Color.fromCssColorString('rgba(40, 40, 40, 0.7)');

/**
* @private
*/
Expand All @@ -33,28 +29,19 @@ define([
}

this._container = container;
this._fpsColor = defaultValue(options.fpsColor, defaultFpsColor).toCssColorString();
this._frameTimeColor = defaultValue(options.frameTimeColor, defaultFrameTimeColor).toCssColorString();
this._backgroundColor = defaultValue(options.backgroundColor, defaultBackgroundColor).toCssColorString();
this._font = defaultValue(options.font, 'bold 12px Helvetica,Arial,sans-serif');

var display = document.createElement('div');
display.className = 'cesium-performanceDisplay';
var fpsElement = document.createElement('div');
fpsElement.className = 'cesium-performanceDisplay-fps';
this._fpsText = document.createTextNode("");
fpsElement.appendChild(this._fpsText);
fpsElement.style.color = this._fpsColor;
var msElement = document.createElement('div');
msElement.className = 'cesium-performanceDisplay-ms';
this._msText = document.createTextNode("");
msElement.style.color = this._frameTimeColor;
msElement.appendChild(this._msText);
display.appendChild(fpsElement);
display.appendChild(msElement);
display.style['z-index'] = 1;
display.style['background-color'] = this._backgroundColor;
display.style.font = this._font;
display.style.padding = '7px';
display.style['border-radius'] = '5px';
display.style.border = '1px solid #444';
display.appendChild(fpsElement);
this._container.appendChild(display);

this._lastFpsSampleTime = undefined;
Expand Down
5 changes: 1 addition & 4 deletions Source/Scene/Scene.js
Original file line number Diff line number Diff line change
Expand Up @@ -1647,10 +1647,7 @@ define([
if (scene.debugShowFramesPerSecond) {
if (!defined(scene._performanceDisplay)) {
var performanceContainer = document.createElement('div');
performanceContainer.className = 'cesium-performanceDisplay';
performanceContainer.style.position = 'absolute';
performanceContainer.style.top = '50px';
performanceContainer.style.right = '10px';
performanceContainer.className = 'cesium-performanceDisplay-defaultContainer';
var container = scene._canvas.parentNode;
container.appendChild(performanceContainer);
var performanceDisplay = new PerformanceDisplay({container: performanceContainer});
Expand Down
6 changes: 1 addition & 5 deletions Source/Widgets/CesiumInspector/CesiumInspectorViewModel.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,6 @@ define([
return str;
}

var bc = new Color(0.15, 0.15, 0.15, 0.75);

function boundDepthFrustum(lower, upper, proposed) {
var bounded = Math.min(proposed, upper);
bounded = Math.max(bounded, lower);
Expand Down Expand Up @@ -336,9 +334,7 @@ define([
this._showPerformance = createCommand(function() {
if (that.performance) {
that._performanceDisplay = new PerformanceDisplay({
container : that._performanceContainer,
backgroundColor : bc,
font : '12px arial,sans-serif'
container : that._performanceContainer
});
} else {
that._performanceContainer.innerHTML = '';
Expand Down
15 changes: 14 additions & 1 deletion Source/Widgets/lighterShared.css
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,17 @@
color: #999; /* For text buttons */
fill: #999; /* For SVG buttons */
box-shadow: none;
}
}

.cesium-lighter .cesium-performanceDisplay {
background-color: #e2f0ff;
border-color: #759dc0;
}

.cesium-lighter .cesium-performanceDisplay-fps {
color: #e52;
}

.cesium-lighter .cesium-performanceDisplay-ms {
color: #ea4;
}
25 changes: 24 additions & 1 deletion Source/Widgets/shared.css
Original file line number Diff line number Diff line change
Expand Up @@ -80,4 +80,27 @@
padding: 0;
vertical-align: middle;
z-index: 0; /* Workaround for rounded raster image corners in Chrome */
}
}

.cesium-performanceDisplay-defaultContainer {
position: absolute;
top: 50px;
right: 10px;
text-align: right;
}

.cesium-performanceDisplay {
background-color: rgba(40, 40, 40, 0.7);
padding: 7px;
border-radius: 5px;
border: 1px solid #444;
font: bold 12px sans-serif;
}

.cesium-performanceDisplay-fps {
color: #e52;
}

.cesium-performanceDisplay-ms {
color: #de3;
}

0 comments on commit f6257a5

Please sign in to comment.