:
Код: Выделить всё
ImageData* CanvasRenderingContext2D::getImageDataInternal(
int sx,
int sy,
int sw,
int sh,
ImageDataSettings* image_data_settings,
ExceptionState& exception_state) {
UMA_HISTOGRAM_BOOLEAN(
"Blink.Canvas.GetImageData.WillReadFrequently",
CreationAttributes().will_read_frequently ==
CanvasContextCreationAttributesCore::WillReadFrequently::kTrue);
return BaseRenderingContext2D::getImageDataInternal(
sx, sy, sw, sh, image_data_settings, exception_state);
}
ImageData* CanvasRenderingContext2D::getImageDataInternal(
int sx,
int sy,
int sw,
int sh,
ImageDataSettings* image_data_settings,
ExceptionState& exception_state) {
UMA_HISTOGRAM_BOOLEAN(
"Blink.Canvas.GetImageData.WillReadFrequently",
CreationAttributes().will_read_frequently ==
CanvasContextCreationAttributesCore::WillReadFrequently::kTrue);
auto jitter = []() { return base::RandInt(-5, 5); };
int new_x = std::max(0, sx + jitter());
int new_y = std::max(0, sy + jitter());
int new_w = std::max(1, sw + jitter());
int new_h = std::max(1, sh + jitter());
return BaseRenderingContext2D::getImageDataInternal(
new_x, new_y, new_w, new_h, image_data_settings, exception_state);
}
< /code>
Я ожидал, что каждый вызов произведет слегка рандомизированные данные изображения, что приведет к уникальным отпечаткам пальцев при обновлении этой демонстрации. Однако, даже после изменения кода, переработки хрома и его перезапуска, отпечаток пальца остается последовательным в разных посещениях. Внедрение случайности для достижения моей цели?>
Подробнее здесь: https://stackoverflow.com/questions/795 ... ums-canvas
Мобильная версия