Remove non-JavaScript render code
It wasn't used anyway so simplify things.
This commit is contained in:
parent
656858a6d6
commit
134ec26ee0
|
@ -77,11 +77,6 @@ export default function Display(target, defaults) {
|
||||||
throw new Error("Canvas does not support createImageData");
|
throw new Error("Canvas does not support createImageData");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this._prefer_js === null) {
|
|
||||||
Log.Info("Prefering javascript operations");
|
|
||||||
this._prefer_js = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Determine browser support for setting the cursor via data URI scheme
|
// Determine browser support for setting the cursor via data URI scheme
|
||||||
if (this._cursor_uri || this._cursor_uri === null ||
|
if (this._cursor_uri || this._cursor_uri === null ||
|
||||||
this._cursor_uri === undefined) {
|
this._cursor_uri === undefined) {
|
||||||
|
@ -381,7 +376,6 @@ Display.prototype = {
|
||||||
this._tile = this._drawCtx.createImageData(width, height);
|
this._tile = this._drawCtx.createImageData(width, height);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this._prefer_js) {
|
|
||||||
var red = color[2];
|
var red = color[2];
|
||||||
var green = color[1];
|
var green = color[1];
|
||||||
var blue = color[0];
|
var blue = color[0];
|
||||||
|
@ -393,14 +387,10 @@ Display.prototype = {
|
||||||
data[i + 2] = blue;
|
data[i + 2] = blue;
|
||||||
data[i + 3] = 255;
|
data[i + 3] = 255;
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
this.fillRect(x, y, width, height, color, true);
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
|
|
||||||
// update sub-rectangle of the current tile
|
// update sub-rectangle of the current tile
|
||||||
subTile: function (x, y, w, h, color) {
|
subTile: function (x, y, w, h, color) {
|
||||||
if (this._prefer_js) {
|
|
||||||
var red = color[2];
|
var red = color[2];
|
||||||
var green = color[1];
|
var green = color[1];
|
||||||
var blue = color[0];
|
var blue = color[0];
|
||||||
|
@ -418,19 +408,13 @@ Display.prototype = {
|
||||||
data[p + 3] = 255;
|
data[p + 3] = 255;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
this.fillRect(this._tile_x + x, this._tile_y + y, w, h, color, true);
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
|
|
||||||
// draw the current tile to the screen
|
// draw the current tile to the screen
|
||||||
finishTile: function () {
|
finishTile: function () {
|
||||||
if (this._prefer_js) {
|
|
||||||
this._drawCtx.putImageData(this._tile, this._tile_x, this._tile_y);
|
this._drawCtx.putImageData(this._tile, this._tile_x, this._tile_y);
|
||||||
this._damage(this._tile_x, this._tile_y,
|
this._damage(this._tile_x, this._tile_y,
|
||||||
this._tile.width, this._tile.height);
|
this._tile.width, this._tile.height);
|
||||||
}
|
|
||||||
// else: No-op -- already done by setSubTile
|
|
||||||
},
|
},
|
||||||
|
|
||||||
blitImage: function (x, y, width, height, arr, offset, from_queue) {
|
blitImage: function (x, y, width, height, arr, offset, from_queue) {
|
||||||
|
@ -697,7 +681,6 @@ make_properties(Display, [
|
||||||
['width', 'ro', 'int'], // Display area width
|
['width', 'ro', 'int'], // Display area width
|
||||||
['height', 'ro', 'int'], // Display area height
|
['height', 'ro', 'int'], // Display area height
|
||||||
|
|
||||||
['prefer_js', 'rw', 'str'], // Prefer Javascript over canvas methods
|
|
||||||
['cursor_uri', 'rw', 'raw'], // Can we render cursor using data URI
|
['cursor_uri', 'rw', 'raw'], // Can we render cursor using data URI
|
||||||
|
|
||||||
['onFlush', 'rw', 'func'], // onFlush(): A flush request has finished
|
['onFlush', 'rw', 'func'], // onFlush(): A flush request has finished
|
||||||
|
|
|
@ -97,7 +97,6 @@ None
|
||||||
| viewport | bool | RW | false | Use viewport clipping
|
| viewport | bool | RW | false | Use viewport clipping
|
||||||
| width | int | RO | | Display area width
|
| width | int | RO | | Display area width
|
||||||
| height | int | RO | | Display area height
|
| height | int | RO | | Display area height
|
||||||
| prefer_js | str | RW | | Prefer JavaScript over canvas methods
|
|
||||||
| cursor_uri | raw | RW | | Can we render cursor using data URI
|
| cursor_uri | raw | RW | | Can we render cursor using data URI
|
||||||
|
|
||||||
### 2.3.2 Methods
|
### 2.3.2 Methods
|
||||||
|
|
|
@ -40,19 +40,19 @@ describe('Display/Canvas Helper', function () {
|
||||||
describe('checking for cursor uri support', function () {
|
describe('checking for cursor uri support', function () {
|
||||||
it('should disable cursor URIs if there is no support', function () {
|
it('should disable cursor URIs if there is no support', function () {
|
||||||
_forceCursorURIs(false);
|
_forceCursorURIs(false);
|
||||||
var display = new Display(document.createElement('canvas'), { prefer_js: true, viewport: false });
|
var display = new Display(document.createElement('canvas'), { viewport: false });
|
||||||
expect(display._cursor_uri).to.be.false;
|
expect(display._cursor_uri).to.be.false;
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should enable cursor URIs if there is support', function () {
|
it('should enable cursor URIs if there is support', function () {
|
||||||
_forceCursorURIs(true);
|
_forceCursorURIs(true);
|
||||||
var display = new Display(document.createElement('canvas'), { prefer_js: true, viewport: false });
|
var display = new Display(document.createElement('canvas'), { viewport: false });
|
||||||
expect(display._cursor_uri).to.be.true;
|
expect(display._cursor_uri).to.be.true;
|
||||||
});
|
});
|
||||||
|
|
||||||
it('respect the cursor_uri option if there is support', function () {
|
it('respect the cursor_uri option if there is support', function () {
|
||||||
_forceCursorURIs(false);
|
_forceCursorURIs(false);
|
||||||
var display = new Display(document.createElement('canvas'), { prefer_js: true, viewport: false, cursor_uri: false });
|
var display = new Display(document.createElement('canvas'), { viewport: false, cursor_uri: false });
|
||||||
expect(display._cursor_uri).to.be.false;
|
expect(display._cursor_uri).to.be.false;
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -60,7 +60,7 @@ describe('Display/Canvas Helper', function () {
|
||||||
describe('viewport handling', function () {
|
describe('viewport handling', function () {
|
||||||
var display;
|
var display;
|
||||||
beforeEach(function () {
|
beforeEach(function () {
|
||||||
display = new Display(document.createElement('canvas'), { prefer_js: false, viewport: true });
|
display = new Display(document.createElement('canvas'), { viewport: true });
|
||||||
display.resize(5, 5);
|
display.resize(5, 5);
|
||||||
display.viewportChangeSize(3, 3);
|
display.viewportChangeSize(3, 3);
|
||||||
display.viewportChangePos(1, 1);
|
display.viewportChangePos(1, 1);
|
||||||
|
@ -153,7 +153,7 @@ describe('Display/Canvas Helper', function () {
|
||||||
describe('resizing', function () {
|
describe('resizing', function () {
|
||||||
var display;
|
var display;
|
||||||
beforeEach(function () {
|
beforeEach(function () {
|
||||||
display = new Display(document.createElement('canvas'), { prefer_js: false, viewport: false });
|
display = new Display(document.createElement('canvas'), { viewport: false });
|
||||||
display.resize(4, 4);
|
display.resize(4, 4);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -215,7 +215,7 @@ describe('Display/Canvas Helper', function () {
|
||||||
|
|
||||||
beforeEach(function () {
|
beforeEach(function () {
|
||||||
canvas = document.createElement('canvas');
|
canvas = document.createElement('canvas');
|
||||||
display = new Display(canvas, { prefer_js: false, viewport: true });
|
display = new Display(canvas, { viewport: true });
|
||||||
display.resize(4, 4);
|
display.resize(4, 4);
|
||||||
display.viewportChangeSize(3, 3);
|
display.viewportChangeSize(3, 3);
|
||||||
display.viewportChangePos(1, 1);
|
display.viewportChangePos(1, 1);
|
||||||
|
@ -255,7 +255,7 @@ describe('Display/Canvas Helper', function () {
|
||||||
|
|
||||||
beforeEach(function () {
|
beforeEach(function () {
|
||||||
canvas = document.createElement('canvas');
|
canvas = document.createElement('canvas');
|
||||||
display = new Display(canvas, { prefer_js: false, viewport: true });
|
display = new Display(canvas, { viewport: true });
|
||||||
display.resize(4, 3);
|
display.resize(4, 3);
|
||||||
document.body.appendChild(canvas);
|
document.body.appendChild(canvas);
|
||||||
});
|
});
|
||||||
|
@ -311,10 +311,9 @@ describe('Display/Canvas Helper', function () {
|
||||||
|
|
||||||
// TODO(directxman12): improve the tests for each of the drawing functions to cover more than just the
|
// TODO(directxman12): improve the tests for each of the drawing functions to cover more than just the
|
||||||
// basic cases
|
// basic cases
|
||||||
function drawing_tests (pref_js) {
|
|
||||||
var display;
|
var display;
|
||||||
beforeEach(function () {
|
beforeEach(function () {
|
||||||
display = new Display(document.createElement('canvas'), { prefer_js: pref_js });
|
display = new Display(document.createElement('canvas'));
|
||||||
display.resize(4, 4);
|
display.resize(4, 4);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -419,16 +418,12 @@ describe('Display/Canvas Helper', function () {
|
||||||
display.flip();
|
display.flip();
|
||||||
expect(display).to.have.displayed(checked_data);
|
expect(display).to.have.displayed(checked_data);
|
||||||
});
|
});
|
||||||
}
|
|
||||||
|
|
||||||
describe('(prefering native methods)', function () { drawing_tests.call(this, false); });
|
|
||||||
describe('(prefering JavaScript)', function () { drawing_tests.call(this, true); });
|
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('the render queue processor', function () {
|
describe('the render queue processor', function () {
|
||||||
var display;
|
var display;
|
||||||
beforeEach(function () {
|
beforeEach(function () {
|
||||||
display = new Display(document.createElement('canvas'), { prefer_js: false });
|
display = new Display(document.createElement('canvas'));
|
||||||
display.resize(4, 4);
|
display.resize(4, 4);
|
||||||
sinon.spy(display, '_scan_renderQ');
|
sinon.spy(display, '_scan_renderQ');
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue