mirror of
https://repo.dactyloidae.xyz/Dactyloidae/UXP.git
synced 2026-09-29 20:07:30 +09:00
Issue #2524 - Implement smart granularity for canvas poisoning.
User-configurable time interval between 1s and 8h. Default 5 minutes. Resolves #2524
This commit is contained in:
parent
91fc5614ec
commit
359a4a2069
2 changed files with 14 additions and 4 deletions
|
|
@ -2094,7 +2094,10 @@ CanvasRenderingContext2D::GetInputStream(const char* aMimeType,
|
||||||
|
|
||||||
bool PoisonData = Preferences::GetBool("canvas.poisondata",false);
|
bool PoisonData = Preferences::GetBool("canvas.poisondata",false);
|
||||||
if (PoisonData) {
|
if (PoisonData) {
|
||||||
srand(time(NULL));
|
int PoisonInterval = Preferences::GetInt("canvas.poisondata.interval", 300);
|
||||||
|
PoisonInterval = (PoisonInterval < 1) ? 1 : (PoisonInterval > 28800) ? 28800 : PoisonInterval;
|
||||||
|
unsigned int epoch = time(nullptr);
|
||||||
|
srand(epoch / PoisonInterval);
|
||||||
// Image buffer is always a packed BGRA array (BGRX -> BGR[FF])
|
// Image buffer is always a packed BGRA array (BGRX -> BGR[FF])
|
||||||
// so always 4-byte pixels.
|
// so always 4-byte pixels.
|
||||||
// GetImageBuffer => SurfaceToPackedBGRA [=> ConvertBGRXToBGRA]
|
// GetImageBuffer => SurfaceToPackedBGRA [=> ConvertBGRXToBGRA]
|
||||||
|
|
@ -5775,9 +5778,13 @@ CanvasRenderingContext2D::GetImageDataArray(JSContext* aCx,
|
||||||
|
|
||||||
MOZ_ASSERT(aWidth && aHeight);
|
MOZ_ASSERT(aWidth && aHeight);
|
||||||
|
|
||||||
bool PoisonData = Preferences::GetBool("canvas.poisondata",false);
|
bool PoisonData = Preferences::GetBool("canvas.poisondata", false);
|
||||||
if (PoisonData)
|
if (PoisonData) {
|
||||||
srand(time(NULL));
|
int PoisonInterval = Preferences::GetInt("canvas.poisondata.interval", 300);
|
||||||
|
PoisonInterval = (PoisonInterval < 1) ? 1 : (PoisonInterval > 28800) ? 28800 : PoisonInterval;
|
||||||
|
unsigned int epoch = time(nullptr);
|
||||||
|
srand(epoch / PoisonInterval);
|
||||||
|
}
|
||||||
|
|
||||||
CheckedInt<uint32_t> len = CheckedInt<uint32_t>(aWidth) * aHeight * 4;
|
CheckedInt<uint32_t> len = CheckedInt<uint32_t>(aWidth) * aHeight * 4;
|
||||||
if (!len.isValid()) {
|
if (!len.isValid()) {
|
||||||
|
|
|
||||||
|
|
@ -4305,6 +4305,9 @@ pref("canvas.image.cache.limit", 0);
|
||||||
// Allow track-fobics to deliberately poison canvas data for
|
// Allow track-fobics to deliberately poison canvas data for
|
||||||
// toDataURL() and getImageData()
|
// toDataURL() and getImageData()
|
||||||
pref("canvas.poisondata", false);
|
pref("canvas.poisondata", false);
|
||||||
|
// Rotate randomness of data poisoning every n seconds. Default 5 minutes.
|
||||||
|
// Valid range [1..28800] (1s-8h).
|
||||||
|
pref("canvas.poisondata.interval", 300);
|
||||||
|
|
||||||
// WebGL prefs
|
// WebGL prefs
|
||||||
pref("gl.msaa-level", 2);
|
pref("gl.msaa-level", 2);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue