mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-19 08:15:31 +00:00
Bug 1692250 - Make image borders use ImageSourceHandle. r=gw
Differential Revision: https://phabricator.services.mozilla.com/D105950
This commit is contained in:
parent
98e0a77b54
commit
7a5fe8b08c
@ -2197,19 +2197,14 @@ impl BatchBuilder {
|
||||
let common_data = &prim_data.common;
|
||||
let border_data = &prim_data.kind;
|
||||
|
||||
let cache_item = resolve_image(
|
||||
border_data.request,
|
||||
ctx.resource_cache,
|
||||
gpu_cache,
|
||||
deferred_resolves,
|
||||
);
|
||||
if cache_item.texture_id == TextureSource::Invalid {
|
||||
return;
|
||||
}
|
||||
let (uv_rect_address, texture) = match border_data.src_color.resolve(render_tasks, ctx, gpu_cache) {
|
||||
Some(src) => src,
|
||||
None => {
|
||||
return;
|
||||
}
|
||||
};
|
||||
|
||||
let textures = TextureSet::prim_textured(
|
||||
cache_item.texture_id,
|
||||
);
|
||||
let textures = TextureSet::prim_textured(texture);
|
||||
let prim_cache_address = gpu_cache.get_address(&common_data.gpu_cache_handle);
|
||||
let specified_blend_mode = BlendMode::PremultipliedAlpha;
|
||||
let non_segmented_blend_mode = if !common_data.opacity.is_opaque ||
|
||||
@ -2229,7 +2224,7 @@ impl BatchBuilder {
|
||||
};
|
||||
|
||||
let batch_params = BrushBatchParameters::shared(
|
||||
BrushBatchKind::Image(cache_item.texture_id.image_buffer_kind()),
|
||||
BrushBatchKind::Image(texture.image_buffer_kind()),
|
||||
textures,
|
||||
ImageBrushData {
|
||||
color_mode: ShaderColorMode::Image,
|
||||
@ -2237,7 +2232,7 @@ impl BatchBuilder {
|
||||
raster_space: RasterizationSpace::Local,
|
||||
opacity: 1.0,
|
||||
}.encode(),
|
||||
cache_item.uv_rect_handle.as_int(gpu_cache),
|
||||
uv_rect_address.as_int(),
|
||||
);
|
||||
|
||||
let prim_header_index = prim_headers.push(
|
||||
|
@ -190,7 +190,6 @@ impl FrameGraphBuilder {
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(debug_assertions)]
|
||||
pub fn frame_id(&self) -> FrameId {
|
||||
self.frame_id
|
||||
}
|
||||
|
@ -29,6 +29,7 @@ use crate::internal_types::{TextureSource, DeferredResolveIndex};
|
||||
/// enumerating the details of how it was produced. Hopefully we can get there
|
||||
/// incrementally).
|
||||
#[derive(Debug)]
|
||||
#[derive(MallocSizeOf)]
|
||||
#[cfg_attr(feature = "capture", derive(Serialize))]
|
||||
#[cfg_attr(feature = "replay", derive(Deserialize))]
|
||||
pub enum ImageSourceHandle {
|
||||
|
@ -517,12 +517,15 @@ fn prepare_interned_prim_for_render(
|
||||
profile_scope!("ImageBorder");
|
||||
let prim_data = &mut data_stores.image_border[*data_handle];
|
||||
|
||||
// TODO: get access to the ninepatch and to check whwther we need support
|
||||
// TODO: get access to the ninepatch and to check whether we need support
|
||||
// for repetitions in the shader.
|
||||
|
||||
// Update the template this instane references, which may refresh the GPU
|
||||
// Update the template this instance references, which may refresh the GPU
|
||||
// cache with any shared template data.
|
||||
prim_data.kind.update(&mut prim_data.common, frame_state);
|
||||
prim_data.kind.update(
|
||||
&mut prim_data.common,
|
||||
frame_state
|
||||
);
|
||||
}
|
||||
PrimitiveInstanceKind::Rectangle { data_handle, segment_instance_index, color_binding_index, .. } => {
|
||||
profile_scope!("Rectangle");
|
||||
|
@ -8,7 +8,7 @@ use crate::border::create_border_segments;
|
||||
use crate::border::NormalBorderAu;
|
||||
use crate::scene_building::{CreateShadow, IsVisible};
|
||||
use crate::frame_builder::{FrameBuildingState};
|
||||
use crate::gpu_cache::{GpuCache, GpuDataRequest};
|
||||
use crate::gpu_cache::GpuDataRequest;
|
||||
use crate::intern;
|
||||
use crate::internal_types::LayoutPrimitiveInfo;
|
||||
use crate::prim_store::{
|
||||
@ -17,7 +17,10 @@ use crate::prim_store::{
|
||||
PrimitiveInstanceKind, PrimitiveOpacity,
|
||||
PrimitiveStore, InternablePrimitive,
|
||||
};
|
||||
use crate::resource_cache::{ImageRequest, ResourceCache};
|
||||
use crate::resource_cache::ImageRequest;
|
||||
use crate::image_source::ImageSourceHandle;
|
||||
use crate::render_task::RenderTask;
|
||||
use crate::render_backend::FrameId;
|
||||
|
||||
use super::storage;
|
||||
|
||||
@ -229,6 +232,9 @@ pub struct ImageBorderData {
|
||||
#[ignore_malloc_size_of = "Arc"]
|
||||
pub request: ImageRequest,
|
||||
pub brush_segments: Vec<BrushSegment>,
|
||||
pub src_color: ImageSourceHandle,
|
||||
pub frame_id: FrameId,
|
||||
pub is_opaque: bool,
|
||||
}
|
||||
|
||||
impl ImageBorderData {
|
||||
@ -246,28 +252,31 @@ impl ImageBorderData {
|
||||
self.write_segment_gpu_blocks(request);
|
||||
}
|
||||
|
||||
let image_properties = frame_state
|
||||
.resource_cache
|
||||
.get_image_properties(self.request.key);
|
||||
let frame_id = frame_state.rg_builder.frame_id();
|
||||
if self.frame_id != frame_id {
|
||||
self.frame_id = frame_id;
|
||||
|
||||
common.opacity = if let Some(image_properties) = image_properties {
|
||||
PrimitiveOpacity {
|
||||
is_opaque: image_properties.descriptor.is_opaque(),
|
||||
}
|
||||
} else {
|
||||
PrimitiveOpacity::opaque()
|
||||
let size = frame_state.resource_cache.request_image(
|
||||
self.request,
|
||||
frame_state.gpu_cache,
|
||||
);
|
||||
|
||||
let task_id = frame_state.rg_builder.add().init(
|
||||
RenderTask::new_image(size, self.request)
|
||||
);
|
||||
|
||||
self.src_color = ImageSourceHandle::RenderTask(task_id);
|
||||
|
||||
let image_properties = frame_state
|
||||
.resource_cache
|
||||
.get_image_properties(self.request.key);
|
||||
|
||||
self.is_opaque = image_properties
|
||||
.map(|properties| properties.descriptor.is_opaque())
|
||||
.unwrap_or(true);
|
||||
}
|
||||
}
|
||||
|
||||
pub fn request_resources(
|
||||
&mut self,
|
||||
resource_cache: &mut ResourceCache,
|
||||
gpu_cache: &mut GpuCache,
|
||||
) {
|
||||
resource_cache.request_image(
|
||||
self.request,
|
||||
gpu_cache,
|
||||
);
|
||||
common.opacity = PrimitiveOpacity { is_opaque: self.is_opaque };
|
||||
}
|
||||
|
||||
fn write_prim_gpu_blocks(
|
||||
@ -314,6 +323,9 @@ impl From<ImageBorderKey> for ImageBorderTemplate {
|
||||
kind: ImageBorderData {
|
||||
request: key.kind.request,
|
||||
brush_segments,
|
||||
src_color: ImageSourceHandle::None,
|
||||
frame_id: FrameId::INVALID,
|
||||
is_opaque: false,
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -371,6 +383,6 @@ fn test_struct_sizes() {
|
||||
assert_eq!(mem::size_of::<NormalBorderTemplate>(), 216, "NormalBorderTemplate size changed");
|
||||
assert_eq!(mem::size_of::<NormalBorderKey>(), 104, "NormalBorderKey size changed");
|
||||
assert_eq!(mem::size_of::<ImageBorder>(), 84, "ImageBorder size changed");
|
||||
assert_eq!(mem::size_of::<ImageBorderTemplate>(), 80, "ImageBorderTemplate size changed");
|
||||
assert_eq!(mem::size_of::<ImageBorderTemplate>(), 104, "ImageBorderTemplate size changed");
|
||||
assert_eq!(mem::size_of::<ImageBorderKey>(), 104, "ImageBorderKey size changed");
|
||||
}
|
||||
|
@ -38,6 +38,7 @@ impl<'l> RenderTaskAllocation<'l> {
|
||||
}
|
||||
|
||||
#[derive(Copy, Clone, PartialEq, Eq, Hash, Debug)]
|
||||
#[derive(MallocSizeOf)]
|
||||
#[cfg_attr(feature = "capture", derive(Serialize))]
|
||||
#[cfg_attr(feature = "replay", derive(Deserialize))]
|
||||
pub struct RenderTaskId {
|
||||
|
@ -727,16 +727,6 @@ fn update_prim_post_visibility(
|
||||
// TODO(gw): We might be able to detect simple cases of this earlier,
|
||||
// during the picture traversal. But it's probably not worth it?
|
||||
}
|
||||
PrimitiveInstanceKind::Image { .. } => {
|
||||
|
||||
}
|
||||
PrimitiveInstanceKind::ImageBorder { data_handle, .. } => {
|
||||
let prim_data = &mut frame_state.data_stores.image_border[data_handle];
|
||||
prim_data.kind.request_resources(
|
||||
frame_state.resource_cache,
|
||||
frame_state.gpu_cache,
|
||||
);
|
||||
}
|
||||
PrimitiveInstanceKind::YuvImage { data_handle, .. } => {
|
||||
let prim_data = &mut frame_state.data_stores.yuv_image[data_handle];
|
||||
prim_data.kind.request_resources(
|
||||
|
Loading…
Reference in New Issue
Block a user