Bug 1692250 - Use ImageSourceHandle with Yuv image primtives. r=gw

Differential Revision: https://phabricator.services.mozilla.com/D105951
This commit is contained in:
Nicolas Silva 2021-02-23 14:47:10 +00:00
Родитель 7a5fe8b08c
Коммит 8ff2dd18be
4 изменённых файлов: 58 добавлений и 28 удалений

Просмотреть файл

@ -16,7 +16,6 @@ use crate::gpu_types::{PrimitiveInstanceData, RasterizationSpace, GlyphInstance}
use crate::gpu_types::{PrimitiveHeader, PrimitiveHeaderIndex, TransformPaletteId, TransformPalette}; use crate::gpu_types::{PrimitiveHeader, PrimitiveHeaderIndex, TransformPaletteId, TransformPalette};
use crate::gpu_types::{ImageBrushData, get_shader_opacity, BoxShadowData}; use crate::gpu_types::{ImageBrushData, get_shader_opacity, BoxShadowData};
use crate::gpu_types::{ClipMaskInstanceCommon, ClipMaskInstanceImage, ClipMaskInstanceRect, ClipMaskInstanceBoxShadow}; use crate::gpu_types::{ClipMaskInstanceCommon, ClipMaskInstanceImage, ClipMaskInstanceRect, ClipMaskInstanceBoxShadow};
use crate::image_source::resolve_image;
use crate::internal_types::{FastHashMap, Swizzle, TextureSource, Filter}; use crate::internal_types::{FastHashMap, Swizzle, TextureSource, Filter};
use crate::picture::{Picture3DContext, PictureCompositeMode, PicturePrimitive}; use crate::picture::{Picture3DContext, PictureCompositeMode, PicturePrimitive};
use crate::picture::{ClusterFlags, SurfaceIndex, SurfaceRenderTasks}; use crate::picture::{ClusterFlags, SurfaceIndex, SurfaceRenderTasks};
@ -2341,26 +2340,19 @@ impl BatchBuilder {
let channel_count = yuv_image_data.format.get_plane_num(); let channel_count = yuv_image_data.format.get_plane_num();
debug_assert!(channel_count <= 3); debug_assert!(channel_count <= 3);
for channel in 0 .. channel_count { for channel in 0 .. channel_count {
let image_key = yuv_image_data.yuv_key[channel];
let cache_item = resolve_image( let src_channel = yuv_image_data.src_yuv[channel].resolve(render_tasks, ctx, gpu_cache);
ImageRequest {
key: image_key,
rendering: yuv_image_data.image_rendering,
tile: None,
},
ctx.resource_cache,
gpu_cache,
deferred_resolves,
);
if cache_item.texture_id == TextureSource::Invalid { let (uv_rect_address, texture_source) = match src_channel {
warn!("Warnings: skip a PrimitiveKind::YuvImage"); Some(src) => src,
return; None => {
} warn!("Warnings: skip a PrimitiveKind::YuvImage");
return;
}
};
textures.colors[channel] = cache_item.texture_id; textures.colors[channel] = texture_source;
uv_rect_addresses[channel] = cache_item.uv_rect_handle.as_int(gpu_cache); uv_rect_addresses[channel] = uv_rect_address.as_int();
} }
// All yuv textures should be the same type. // All yuv textures should be the same type.

Просмотреть файл

@ -2948,11 +2948,23 @@ impl TileCacheInstance {
api_keys: &[ImageKey; 3], api_keys: &[ImageKey; 3],
resource_cache: &mut ResourceCache, resource_cache: &mut ResourceCache,
composite_state: &mut CompositeState, composite_state: &mut CompositeState,
gpu_cache: &mut GpuCache,
image_rendering: ImageRendering, image_rendering: ImageRendering,
color_depth: ColorDepth, color_depth: ColorDepth,
color_space: YuvColorSpace, color_space: YuvColorSpace,
format: YuvFormat, format: YuvFormat,
) -> bool { ) -> bool {
for &key in api_keys {
// TODO: See comment in setup_compositor_surfaces_rgb.
resource_cache.request_image(ImageRequest {
key,
rendering: image_rendering,
tile: None,
},
gpu_cache,
);
}
self.setup_compositor_surfaces_impl( self.setup_compositor_surfaces_impl(
prim_info, prim_info,
flags, flags,
@ -3488,6 +3500,7 @@ impl TileCacheInstance {
&prim_data.kind.yuv_key, &prim_data.kind.yuv_key,
resource_cache, resource_cache,
composite_state, composite_state,
gpu_cache,
prim_data.kind.image_rendering, prim_data.kind.image_rendering,
prim_data.kind.color_depth, prim_data.kind.color_depth,
prim_data.kind.color_space, prim_data.kind.color_space,

Просмотреть файл

@ -482,6 +482,7 @@ impl InternDebug for YuvImageKey {}
pub struct YuvImageData { pub struct YuvImageData {
pub color_depth: ColorDepth, pub color_depth: ColorDepth,
pub yuv_key: [ApiImageKey; 3], pub yuv_key: [ApiImageKey; 3],
pub src_yuv: [ImageSourceHandle; 3],
pub format: YuvFormat, pub format: YuvFormat,
pub color_space: YuvColorSpace, pub color_space: YuvColorSpace,
pub color_range: ColorRange, pub color_range: ColorRange,
@ -493,6 +494,11 @@ impl From<YuvImage> for YuvImageData {
YuvImageData { YuvImageData {
color_depth: image.color_depth, color_depth: image.color_depth,
yuv_key: image.yuv_key, yuv_key: image.yuv_key,
src_yuv: [
ImageSourceHandle::None,
ImageSourceHandle::None,
ImageSourceHandle::None,
],
format: image.format, format: image.format,
color_space: image.color_space, color_space: image.color_space,
color_range: image.color_range, color_range: image.color_range,
@ -511,6 +517,34 @@ impl YuvImageData {
common: &mut PrimTemplateCommonData, common: &mut PrimTemplateCommonData,
frame_state: &mut FrameBuildingState, frame_state: &mut FrameBuildingState,
) { ) {
self.src_yuv = [
ImageSourceHandle::None,
ImageSourceHandle::None,
ImageSourceHandle::None,
];
let channel_num = self.format.get_plane_num();
debug_assert!(channel_num <= 3);
for channel in 0 .. channel_num {
let request = ImageRequest {
key: self.yuv_key[channel],
rendering: self.image_rendering,
tile: None,
};
let size = frame_state.resource_cache.request_image(
request,
frame_state.gpu_cache,
);
let task_id = frame_state.rg_builder.add().init(
RenderTask::new_image(size, request)
);
self.src_yuv[channel] = ImageSourceHandle::RenderTask(task_id);
}
if let Some(mut request) = frame_state.gpu_cache.request(&mut common.gpu_cache_handle) { if let Some(mut request) = frame_state.gpu_cache.request(&mut common.gpu_cache_handle) {
self.write_prim_gpu_blocks(&mut request); self.write_prim_gpu_blocks(&mut request);
}; };
@ -612,6 +646,6 @@ fn test_struct_sizes() {
assert_eq!(mem::size_of::<ImageTemplate>(), 72, "ImageTemplate size changed"); assert_eq!(mem::size_of::<ImageTemplate>(), 72, "ImageTemplate size changed");
assert_eq!(mem::size_of::<ImageKey>(), 52, "ImageKey size changed"); assert_eq!(mem::size_of::<ImageKey>(), 52, "ImageKey size changed");
assert_eq!(mem::size_of::<YuvImage>(), 32, "YuvImage size changed"); assert_eq!(mem::size_of::<YuvImage>(), 32, "YuvImage size changed");
assert_eq!(mem::size_of::<YuvImageTemplate>(), 60, "YuvImageTemplate size changed"); assert_eq!(mem::size_of::<YuvImageTemplate>(), 96, "YuvImageTemplate size changed");
assert_eq!(mem::size_of::<YuvImageKey>(), 52, "YuvImageKey size changed"); assert_eq!(mem::size_of::<YuvImageKey>(), 52, "YuvImageKey size changed");
} }

Просмотреть файл

@ -604,7 +604,6 @@ pub fn update_primitive_visibility(
prim_instance, prim_instance,
world_culling_rect, world_culling_rect,
&map_surface_to_world, &map_surface_to_world,
frame_state,
); );
} }
} }
@ -703,7 +702,6 @@ fn update_prim_post_visibility(
prim_instance: &mut PrimitiveInstance, prim_instance: &mut PrimitiveInstance,
world_culling_rect: WorldRect, world_culling_rect: WorldRect,
map_surface_to_world: &SpaceMapper<PicturePixel, WorldPixel>, map_surface_to_world: &SpaceMapper<PicturePixel, WorldPixel>,
frame_state: &mut FrameVisibilityState,
) { ) {
profile_scope!("update_prim_post_visibility"); profile_scope!("update_prim_post_visibility");
match prim_instance.kind { match prim_instance.kind {
@ -727,13 +725,6 @@ fn update_prim_post_visibility(
// TODO(gw): We might be able to detect simple cases of this earlier, // TODO(gw): We might be able to detect simple cases of this earlier,
// during the picture traversal. But it's probably not worth it? // during the picture traversal. But it's probably not worth it?
} }
PrimitiveInstanceKind::YuvImage { data_handle, .. } => {
let prim_data = &mut frame_state.data_stores.yuv_image[data_handle];
prim_data.kind.request_resources(
frame_state.resource_cache,
frame_state.gpu_cache,
);
}
_ => {} _ => {}
} }
} }