-
-
Notifications
You must be signed in to change notification settings - Fork 309
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add hardware acceleration preference
- Loading branch information
Showing
19 changed files
with
436 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
# If You See Visual Glitches in Twine | ||
|
||
This page only applies to app Twine. | ||
|
||
If you see visual glitches often in Twine, turning off hardware accleration may | ||
help. You should only do this if you are seeing a problem. As the name implies, | ||
using hardware acceleration speeds up Twine's display. | ||
|
||
To do this, go to _Troubleshooting_ under the _Help_ menu, then choose _Disable | ||
Hardware Acceleration_. This item will be checked when hardware acceleration is | ||
disabled, but changing the setting will only take effect the next time you | ||
launch Twine. | ||
|
||
You can also disable hardware acceleration by launching Twine with the | ||
command-line switch | ||
<code>‑‑disableHardwareAcceleration=true</code>. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
{ | ||
"name": "Twine", | ||
"version": "2.7.1", | ||
"version": "2.8.0-alpha1", | ||
"description": "a GUI for creating nonlinear stories", | ||
"author": "Chris Klimas <[email protected]>", | ||
"license": "GPL-3.0", | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
export const app = { | ||
disableHardwareAcceleration: jest.fn(), | ||
getName() { | ||
return `mock-electron-app-name`; | ||
}, | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
88 changes: 88 additions & 0 deletions
88
src/electron/main-process/__tests__/hardware-acceleration.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
import {app} from 'electron'; | ||
import {AppPrefName, getAppPref, setAppPref} from '../app-prefs'; | ||
import { | ||
initHardwareAcceleration, | ||
toggleHardwareAcceleration | ||
} from '../hardware-acceleration'; | ||
import {showRelaunchDialog} from '../relaunch-dialog'; | ||
|
||
jest.mock('electron'); | ||
jest.mock('../app-prefs'); | ||
jest.mock('../relaunch-dialog'); | ||
|
||
describe('initHardwareAcceleration', () => { | ||
const getAppPrefMock = getAppPref as jest.Mock; | ||
const disableHardwareAccelerationMock = | ||
app.disableHardwareAcceleration as jest.Mock; | ||
|
||
beforeEach(() => { | ||
jest.spyOn(console, 'log').mockReturnValue(); | ||
}); | ||
|
||
it('disables hardware acceleration if the app pref is true', () => { | ||
getAppPrefMock.mockImplementation((name: AppPrefName) => { | ||
if (name === 'disableHardwareAcceleration') { | ||
return true; | ||
} | ||
|
||
throw new Error(`Asked for a non-mocked pref: ${name}`); | ||
}); | ||
|
||
initHardwareAcceleration(); | ||
expect(disableHardwareAccelerationMock).toBeCalledTimes(1); | ||
}); | ||
|
||
it("doesn't disable hardware acceleration if the app pref is falsy", () => { | ||
getAppPrefMock.mockImplementation((name: AppPrefName) => { | ||
if (name === 'disableHardwareAcceleration') { | ||
return undefined; | ||
} | ||
|
||
throw new Error(`Asked for a non-mocked pref: ${name}`); | ||
}); | ||
|
||
initHardwareAcceleration(); | ||
expect(disableHardwareAccelerationMock).not.toBeCalled(); | ||
}); | ||
}); | ||
|
||
describe('toggleHardwareAcceleration', () => { | ||
const getAppPrefMock = getAppPref as jest.Mock; | ||
const setAppPrefMock = setAppPref as jest.Mock; | ||
const showRelaunchDialogMock = showRelaunchDialog as jest.Mock; | ||
|
||
it('sets the preference to true if the preference was falsy', () => { | ||
getAppPrefMock.mockImplementation((name: AppPrefName) => { | ||
if (name === 'disableHardwareAcceleration') { | ||
return true; | ||
} | ||
|
||
throw new Error(`Asked for a non-mocked pref: ${name}`); | ||
}); | ||
|
||
toggleHardwareAcceleration(); | ||
expect(setAppPrefMock.mock.calls).toEqual([ | ||
['disableHardwareAcceleration', false] | ||
]); | ||
}); | ||
|
||
it('sets the preference to false if the preference was true', () => { | ||
getAppPrefMock.mockImplementation((name: AppPrefName) => { | ||
if (name === 'disableHardwareAcceleration') { | ||
return false; | ||
} | ||
|
||
throw new Error(`Asked for a non-mocked pref: ${name}`); | ||
}); | ||
|
||
toggleHardwareAcceleration(); | ||
expect(setAppPrefMock.mock.calls).toEqual([ | ||
['disableHardwareAcceleration', true] | ||
]); | ||
}); | ||
|
||
it('shows the relaunch dialog', () => { | ||
toggleHardwareAcceleration(); | ||
expect(showRelaunchDialogMock).toBeCalledTimes(1); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.