зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1666782. Fix GrayAlpha color conversion. r=aosmond
GrayAlpha::has_alpha was accidentally set to false. Differential Revision: https://phabricator.services.mozilla.com/D91147
This commit is contained in:
Родитель
c0e282f68a
Коммит
a9b12a7d10
|
@ -2,13 +2,9 @@
|
|||
mod test {
|
||||
|
||||
use crate::{
|
||||
iccread::qcms_CIE_xyY, iccread::qcms_CIE_xyYTRIPLE,
|
||||
iccread::qcms_profile_create_rgb_with_gamma, iccread::qcms_profile_from_memory,
|
||||
iccread::qcms_profile_release, iccread::qcms_white_point_sRGB,
|
||||
transform::qcms_enable_iccv4, transform::qcms_profile_precache_output_transform,
|
||||
transform::qcms_transform, transform::qcms_transform_create,
|
||||
transform::qcms_transform_data, transform::qcms_transform_release,
|
||||
transform::QCMS_DATA_RGB_8, transform_util::lut_inverse_interp16, QCMS_INTENT_PERCEPTUAL,
|
||||
iccread::*,
|
||||
transform::*,
|
||||
transform_util::lut_inverse_interp16, QCMS_INTENT_PERCEPTUAL,
|
||||
};
|
||||
|
||||
#[test]
|
||||
|
@ -200,6 +196,41 @@ mod test {
|
|||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn gray_alpha() {
|
||||
let sRGB_profile = unsafe { crate::iccread::qcms_profile_sRGB() };
|
||||
let other = unsafe { qcms_profile_create_gray_with_gamma(2.2) };
|
||||
unsafe { qcms_profile_precache_output_transform(other) };
|
||||
|
||||
let transform = unsafe {
|
||||
qcms_transform_create(
|
||||
other,
|
||||
QCMS_DATA_GRAYA_8,
|
||||
sRGB_profile,
|
||||
QCMS_DATA_RGBA_8,
|
||||
QCMS_INTENT_PERCEPTUAL,
|
||||
)
|
||||
};
|
||||
assert!(!transform.is_null());
|
||||
|
||||
let mut in_data: [u8; 4] = [0, 255, 255, 0];
|
||||
let mut out_data: [u8; 2 * 4] = [0; 8];
|
||||
unsafe {
|
||||
qcms_transform_data(
|
||||
transform,
|
||||
in_data.as_ptr() as *const libc::c_void,
|
||||
out_data.as_mut_ptr() as *mut libc::c_void,
|
||||
in_data.len() / 2,
|
||||
)
|
||||
};
|
||||
|
||||
assert_eq!(out_data, [0, 0, 0, 255, 255, 255, 255, 0]);
|
||||
unsafe {
|
||||
qcms_transform_release(transform);
|
||||
qcms_profile_release(sRGB_profile);
|
||||
qcms_profile_release(other);
|
||||
}
|
||||
}
|
||||
#[test]
|
||||
fn samples() {
|
||||
use libc::c_void;
|
||||
|
|
|
@ -1227,6 +1227,22 @@ pub unsafe extern "C" fn qcms_profile_create_rgb_with_gamma_set(
|
|||
(*profile).pcs = XYZ_TYPE;
|
||||
return Box::into_raw(profile);
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub unsafe extern "C" fn qcms_profile_create_gray_with_gamma(mut gamma: f32) -> *mut qcms_profile {
|
||||
let mut profile = qcms_profile_create();
|
||||
|
||||
(*profile).grayTRC = curve_from_gamma(gamma);
|
||||
if (*profile).grayTRC.is_null() {
|
||||
return 0 as *mut qcms_profile;
|
||||
}
|
||||
(*profile).class_type = DISPLAY_DEVICE_PROFILE;
|
||||
(*profile).rendering_intent = QCMS_INTENT_PERCEPTUAL;
|
||||
(*profile).color_space = GRAY_SIGNATURE;
|
||||
(*profile).pcs = XYZ_TYPE;
|
||||
return Box::into_raw(profile);
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub unsafe extern "C" fn qcms_profile_create_rgb_with_gamma(
|
||||
mut white_point: qcms_CIE_xyY,
|
||||
|
|
|
@ -243,7 +243,7 @@ impl GrayFormat for Gray {
|
|||
|
||||
pub struct GrayAlpha;
|
||||
impl GrayFormat for GrayAlpha {
|
||||
const has_alpha: bool = false;
|
||||
const has_alpha: bool = true;
|
||||
}
|
||||
|
||||
#[inline]
|
||||
|
|
Загрузка…
Ссылка в новой задаче