зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1674690 - Remove DocumentLayer while retaining the rest of the Document API. r=nical
This removes some of the complexity in the renderer associated with drawing multiple document layers in a single render. It retains the rest of the document API, which will be used to implement the functionality in bug #1654938. Differential Revision: https://phabricator.services.mozilla.com/D95478
This commit is contained in:
Родитель
5f284ca7bf
Коммит
c1e5418cb9
|
@ -202,10 +202,9 @@ impl DocumentHandle {
|
|||
api: RenderApi,
|
||||
hit_tester: Option<Arc<dyn ApiHitTester>>,
|
||||
size: DeviceIntSize,
|
||||
layer: i8,
|
||||
id: u32,
|
||||
) -> DocumentHandle {
|
||||
let doc = api.add_document_with_id(size, layer, id);
|
||||
let doc = api.add_document_with_id(size, id);
|
||||
let hit_tester_request = if hit_tester.is_none() {
|
||||
// Request the hit tester early to reduce the likelihood of blocking on the
|
||||
// first hit testing query.
|
||||
|
@ -1634,12 +1633,10 @@ pub extern "C" fn wr_window_new(
|
|||
unsafe {
|
||||
*out_max_texture_size = renderer.get_max_texture_size();
|
||||
}
|
||||
let layer = 0;
|
||||
*out_handle = Box::into_raw(Box::new(DocumentHandle::new(
|
||||
sender.create_api_by_client(next_namespace_id()),
|
||||
None,
|
||||
window_size,
|
||||
layer,
|
||||
document_id,
|
||||
)));
|
||||
*out_renderer = Box::into_raw(Box::new(renderer));
|
||||
|
|
|
@ -122,7 +122,7 @@ impl Rectangle {
|
|||
Rectangle {
|
||||
visual,
|
||||
renderer: Some(renderer),
|
||||
document_id: api.add_document(size, 0),
|
||||
document_id: api.add_document(size),
|
||||
api,
|
||||
size,
|
||||
color: api::ColorF { r, g, b, a },
|
||||
|
|
|
@ -384,7 +384,7 @@ fn main() {
|
|||
None,
|
||||
).unwrap();
|
||||
let api = sender.create_api();
|
||||
let document_id = api.add_document(device_size, 0);
|
||||
let document_id = api.add_document(device_size);
|
||||
let device_pixel_ratio = 1.0;
|
||||
let mut current_epoch = Epoch(0);
|
||||
let root_pipeline_id = PipelineId(0, 0);
|
||||
|
|
|
@ -185,7 +185,7 @@ pub fn main_wrapper<E: Example>(
|
|||
None,
|
||||
).unwrap();
|
||||
let mut api = sender.create_api();
|
||||
let document_id = api.add_document(device_size, 0);
|
||||
let document_id = api.add_document(device_size);
|
||||
|
||||
let external = example.get_image_handler(&*gl);
|
||||
|
||||
|
|
|
@ -40,35 +40,31 @@ impl App {
|
|||
let init_data = vec![
|
||||
(
|
||||
PipelineId(1, 0),
|
||||
-2,
|
||||
ColorF::new(0.0, 1.0, 0.0, 1.0),
|
||||
DeviceIntPoint::new(0, 0),
|
||||
),
|
||||
(
|
||||
PipelineId(2, 0),
|
||||
-1,
|
||||
ColorF::new(1.0, 1.0, 0.0, 1.0),
|
||||
DeviceIntPoint::new(200, 0),
|
||||
),
|
||||
(
|
||||
PipelineId(3, 0),
|
||||
0,
|
||||
ColorF::new(1.0, 0.0, 0.0, 1.0),
|
||||
DeviceIntPoint::new(200, 200),
|
||||
),
|
||||
(
|
||||
PipelineId(4, 0),
|
||||
1,
|
||||
ColorF::new(1.0, 0.0, 1.0, 1.0),
|
||||
DeviceIntPoint::new(0, 200),
|
||||
),
|
||||
];
|
||||
|
||||
for (pipeline_id, layer, color, offset) in init_data {
|
||||
for (pipeline_id, color, offset) in init_data {
|
||||
let size = DeviceIntSize::new(250, 250);
|
||||
let bounds = DeviceIntRect::new(offset, size);
|
||||
|
||||
let document_id = api.add_document(size, layer);
|
||||
let document_id = api.add_document(size);
|
||||
let mut txn = Transaction::new();
|
||||
txn.set_document_view(bounds, device_pixel_ratio);
|
||||
txn.set_root_pipeline(pipeline_id);
|
||||
|
|
|
@ -107,7 +107,7 @@ impl Window {
|
|||
let notifier = Box::new(Notifier::new(events_loop.create_proxy()));
|
||||
let (renderer, sender) = webrender::Renderer::new(gl.clone(), notifier, opts, None).unwrap();
|
||||
let mut api = sender.create_api();
|
||||
let document_id = api.add_document(device_size, 0);
|
||||
let document_id = api.add_document(device_size);
|
||||
|
||||
let epoch = Epoch(0);
|
||||
let pipeline_id = PipelineId(0, 0);
|
||||
|
|
|
@ -1235,14 +1235,13 @@ impl DrawTarget {
|
|||
pub fn build_scissor_rect(
|
||||
&self,
|
||||
scissor_rect: Option<DeviceIntRect>,
|
||||
content_origin: DeviceIntPoint,
|
||||
) -> FramebufferIntRect {
|
||||
let dimensions = self.dimensions();
|
||||
|
||||
match scissor_rect {
|
||||
Some(scissor_rect) => match *self {
|
||||
DrawTarget::Default { ref rect, .. } => {
|
||||
self.to_framebuffer_rect(scissor_rect.translate(-content_origin.to_vector()))
|
||||
self.to_framebuffer_rect(scissor_rect)
|
||||
.intersection(rect)
|
||||
.unwrap_or_else(FramebufferIntRect::zero)
|
||||
}
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
use api::{ColorF, DebugFlags, DocumentLayer, FontRenderMode, PremultipliedColorF};
|
||||
use api::{ColorF, DebugFlags, FontRenderMode, PremultipliedColorF};
|
||||
use api::units::*;
|
||||
use crate::batch::{BatchBuilder, AlphaBatchBuilder, AlphaBatchContainer};
|
||||
use crate::clip::{ClipStore, ClipChainStack};
|
||||
|
@ -483,7 +483,6 @@ impl FrameBuilder {
|
|||
gpu_cache: &mut GpuCache,
|
||||
stamp: FrameStamp,
|
||||
global_device_pixel_scale: DevicePixelScale,
|
||||
layer: DocumentLayer,
|
||||
device_origin: DeviceIntPoint,
|
||||
pan: WorldPoint,
|
||||
scene_properties: &SceneProperties,
|
||||
|
@ -629,12 +628,10 @@ impl FrameBuilder {
|
|||
self.composite_state_prealloc.record(&composite_state);
|
||||
|
||||
Frame {
|
||||
content_origin: scene.output_rect.origin,
|
||||
device_rect: DeviceIntRect::new(
|
||||
device_origin,
|
||||
scene.output_rect.size,
|
||||
),
|
||||
layer,
|
||||
passes,
|
||||
transform_palette: transform_palette.finish(),
|
||||
render_tasks,
|
||||
|
@ -988,11 +985,8 @@ pub fn build_render_pass(
|
|||
#[cfg_attr(feature = "capture", derive(Serialize))]
|
||||
#[cfg_attr(feature = "replay", derive(Deserialize))]
|
||||
pub struct Frame {
|
||||
/// The origin on content produced by the render tasks.
|
||||
pub content_origin: DeviceIntPoint,
|
||||
/// The rectangle to show the frame in, on screen.
|
||||
pub device_rect: DeviceIntRect,
|
||||
pub layer: DocumentLayer,
|
||||
pub passes: Vec<RenderPass>,
|
||||
|
||||
pub transform_palette: Vec<TransformData>,
|
||||
|
|
|
@ -17,7 +17,7 @@ use crate::api::{ColorF, BuiltDisplayList, IdNamespace, ExternalScrollId};
|
|||
use crate::api::{SharedFontInstanceMap, FontKey, FontInstanceKey, NativeFontHandle, ZoomFactor};
|
||||
use crate::api::{BlobImageData, BlobImageKey, ImageData, ImageDescriptor, ImageKey, Epoch, QualitySettings};
|
||||
use crate::api::{BlobImageParams, BlobImageRequest, BlobImageResult, AsyncBlobImageRasterizer, BlobImageHandler};
|
||||
use crate::api::{DocumentId, PipelineId, PropertyBindingId, PropertyBindingKey, ExternalEvent, DocumentLayer};
|
||||
use crate::api::{DocumentId, PipelineId, PropertyBindingId, PropertyBindingKey, ExternalEvent};
|
||||
use crate::api::{HitTestResult, HitTesterRequest, ApiHitTester, PropertyValue, DynamicProperties};
|
||||
use crate::api::{ScrollClamping, TileSize, NotificationRequest, DebugFlags, ScrollNodeState};
|
||||
use crate::api::{GlyphDimensionRequest, GlyphIndexRequest, GlyphIndex, GlyphDimensions};
|
||||
|
@ -919,7 +919,7 @@ pub enum ApiMsg {
|
|||
/// Adds a new document namespace.
|
||||
CloneApiByClient(IdNamespace),
|
||||
/// Adds a new document with given initial size.
|
||||
AddDocument(DocumentId, DeviceIntSize, DocumentLayer),
|
||||
AddDocument(DocumentId, DeviceIntSize),
|
||||
/// A message targeted at a particular document.
|
||||
UpdateDocuments(Vec<Box<TransactionMsg>>),
|
||||
/// Flush from the caches anything that isn't necessary, to free some memory.
|
||||
|
@ -1065,15 +1065,14 @@ impl RenderApi {
|
|||
/// Instances can manage one or several documents (using the same render backend thread).
|
||||
/// Each document will internally correspond to a single scene, and scenes are made of
|
||||
/// one or several pipelines.
|
||||
pub fn add_document(&self, initial_size: DeviceIntSize, layer: DocumentLayer) -> DocumentId {
|
||||
pub fn add_document(&self, initial_size: DeviceIntSize) -> DocumentId {
|
||||
let new_id = self.next_unique_id();
|
||||
self.add_document_with_id(initial_size, layer, new_id)
|
||||
self.add_document_with_id(initial_size, new_id)
|
||||
}
|
||||
|
||||
/// See `add_document`
|
||||
pub fn add_document_with_id(&self,
|
||||
initial_size: DeviceIntSize,
|
||||
layer: DocumentLayer,
|
||||
id: u32) -> DocumentId {
|
||||
window_size_sanity_check(initial_size);
|
||||
|
||||
|
@ -1085,10 +1084,10 @@ impl RenderApi {
|
|||
// the render backend knows about the existence of the corresponding document id.
|
||||
// It may not be necessary, though.
|
||||
self.api_sender.send(
|
||||
ApiMsg::AddDocument(document_id, initial_size, layer)
|
||||
ApiMsg::AddDocument(document_id, initial_size)
|
||||
).unwrap();
|
||||
self.scene_sender.send(
|
||||
SceneBuilderRequest::AddDocument(document_id, initial_size, layer)
|
||||
SceneBuilderRequest::AddDocument(document_id, initial_size)
|
||||
).unwrap();
|
||||
|
||||
document_id
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
//! how these two pieces interact.
|
||||
|
||||
use api::{DebugFlags, BlobImageHandler};
|
||||
use api::{DocumentId, DocumentLayer, ExternalScrollId, HitTestResult};
|
||||
use api::{DocumentId, ExternalScrollId, HitTestResult};
|
||||
use api::{IdNamespace, PipelineId, RenderNotifier, ScrollClamping};
|
||||
use api::{NotificationRequest, Checkpoint, QualitySettings};
|
||||
use api::{PrimitiveKeyKind};
|
||||
|
@ -81,7 +81,6 @@ pub struct DocumentView {
|
|||
#[derive(Copy, Clone)]
|
||||
pub struct SceneView {
|
||||
pub device_rect: DeviceIntRect,
|
||||
pub layer: DocumentLayer,
|
||||
pub device_pixel_ratio: f32,
|
||||
pub page_zoom_factor: f32,
|
||||
pub quality_settings: QualitySettings,
|
||||
|
@ -478,7 +477,6 @@ impl Document {
|
|||
pub fn new(
|
||||
id: DocumentId,
|
||||
size: DeviceIntSize,
|
||||
layer: DocumentLayer,
|
||||
default_device_pixel_ratio: f32,
|
||||
) -> Self {
|
||||
Document {
|
||||
|
@ -487,7 +485,6 @@ impl Document {
|
|||
view: DocumentView {
|
||||
scene: SceneView {
|
||||
device_rect: size.into(),
|
||||
layer,
|
||||
page_zoom_factor: 1.0,
|
||||
device_pixel_ratio: default_device_pixel_ratio,
|
||||
quality_settings: QualitySettings::default(),
|
||||
|
@ -628,7 +625,6 @@ impl Document {
|
|||
gpu_cache,
|
||||
self.stamp,
|
||||
accumulated_scale_factor,
|
||||
self.view.scene.layer,
|
||||
self.view.scene.device_rect.origin,
|
||||
pan,
|
||||
&self.dynamic_properties,
|
||||
|
@ -1038,11 +1034,10 @@ impl RenderBackend {
|
|||
assert!(self.namespace_alloc_by_client);
|
||||
debug_assert!(!self.documents.iter().any(|(did, _doc)| did.namespace_id == namespace_id));
|
||||
}
|
||||
ApiMsg::AddDocument(document_id, initial_size, layer) => {
|
||||
ApiMsg::AddDocument(document_id, initial_size) => {
|
||||
let document = Document::new(
|
||||
document_id,
|
||||
initial_size,
|
||||
layer,
|
||||
self.default_device_pixel_ratio,
|
||||
);
|
||||
let old = self.documents.insert(document_id, document);
|
||||
|
|
|
@ -2242,7 +2242,7 @@ pub struct Renderer {
|
|||
pending_gpu_cache_updates: Vec<GpuCacheUpdateList>,
|
||||
pending_gpu_cache_clear: bool,
|
||||
pending_shader_updates: Vec<PathBuf>,
|
||||
active_documents: Vec<(DocumentId, RenderedDocument)>,
|
||||
active_documents: FastHashMap<DocumentId, RenderedDocument>,
|
||||
|
||||
shaders: Rc<RefCell<Shaders>>,
|
||||
|
||||
|
@ -2849,7 +2849,7 @@ impl Renderer {
|
|||
result_rx,
|
||||
debug_server,
|
||||
device,
|
||||
active_documents: Vec::new(),
|
||||
active_documents: FastHashMap::default(),
|
||||
pending_texture_updates: Vec::new(),
|
||||
pending_texture_cache_updates: false,
|
||||
pending_native_surface_updates: Vec::new(),
|
||||
|
@ -3001,27 +3001,28 @@ impl Renderer {
|
|||
mut doc,
|
||||
resource_update_list,
|
||||
) => {
|
||||
// Add a new document to the active set
|
||||
|
||||
// Add a new document to the active set, expressed as a `Vec` in order
|
||||
// to re-order based on `DocumentLayer` during rendering.
|
||||
match self.active_documents.iter().position(|&(id, _)| id == document_id) {
|
||||
Some(pos) => {
|
||||
// If the document we are replacing must be drawn (in order to
|
||||
// update the texture cache), issue a render just to
|
||||
// off-screen targets, ie pass None to render_impl. We do this
|
||||
// because a) we don't need to render to the main framebuffer
|
||||
// so it is cheaper not to, and b) doing so without a
|
||||
// subsequent present would break partial present.
|
||||
if self.active_documents[pos].1.frame.must_be_drawn() {
|
||||
self.render_impl(None).ok();
|
||||
}
|
||||
// If the document we are replacing must be drawn (in order to
|
||||
// update the texture cache), issue a render just to
|
||||
// off-screen targets, ie pass None to render_impl. We do this
|
||||
// because a) we don't need to render to the main framebuffer
|
||||
// so it is cheaper not to, and b) doing so without a
|
||||
// subsequent present would break partial present.
|
||||
if let Some(mut prev_doc) = self.active_documents.remove(&document_id) {
|
||||
doc.profile.merge(&mut prev_doc.profile);
|
||||
|
||||
doc.profile.merge(&mut self.active_documents[pos].1.profile);
|
||||
self.active_documents[pos].1 = doc;
|
||||
if prev_doc.frame.must_be_drawn() {
|
||||
self.render_impl(
|
||||
document_id,
|
||||
&mut prev_doc,
|
||||
None,
|
||||
).ok();
|
||||
}
|
||||
None => self.active_documents.push((document_id, doc)),
|
||||
}
|
||||
|
||||
self.active_documents.insert(document_id, doc);
|
||||
|
||||
// IMPORTANT: The pending texture cache updates must be applied
|
||||
// *after* the previous frame has been rendered above
|
||||
// (if neceessary for a texture cache update). For
|
||||
|
@ -3078,17 +3079,21 @@ impl Renderer {
|
|||
// if any of the existing documents have not rendered yet, and
|
||||
// have picture/texture cache targets, force a render so that
|
||||
// those targets are updated.
|
||||
let must_be_drawn = self.active_documents
|
||||
.iter()
|
||||
.any(|(_, doc)| {
|
||||
doc.frame.must_be_drawn()
|
||||
});
|
||||
|
||||
if must_be_drawn {
|
||||
// As this render will not be presented, we must pass None to
|
||||
// render_impl. This avoids interfering with partial present
|
||||
// logic, as well as being more efficient.
|
||||
self.render_impl(None).ok();
|
||||
let active_documents = mem::replace(
|
||||
&mut self.active_documents,
|
||||
FastHashMap::default(),
|
||||
);
|
||||
for (doc_id, mut doc) in active_documents {
|
||||
if doc.frame.must_be_drawn() {
|
||||
// As this render will not be presented, we must pass None to
|
||||
// render_impl. This avoids interfering with partial present
|
||||
// logic, as well as being more efficient.
|
||||
self.render_impl(
|
||||
doc_id,
|
||||
&mut doc,
|
||||
None,
|
||||
).ok();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -3112,13 +3117,6 @@ impl Renderer {
|
|||
}
|
||||
|
||||
self.device.end_frame();
|
||||
// If we receive a `PublishDocument` message followed by this one
|
||||
// within the same update we need to cancel the frame because we
|
||||
// might have deleted the resources in use in the frame due to a
|
||||
// memory pressure event.
|
||||
if memory_pressure {
|
||||
self.active_documents.clear();
|
||||
}
|
||||
}
|
||||
ResultMsg::AppendNotificationRequests(mut notifications) => {
|
||||
// We need to know specifically if there are any pending
|
||||
|
@ -3320,7 +3318,7 @@ impl Renderer {
|
|||
fn get_passes_for_debugger(&self) -> String {
|
||||
let mut debug_passes = debug_server::PassList::new();
|
||||
|
||||
for &(_, ref render_doc) in &self.active_documents {
|
||||
for (_, render_doc) in &self.active_documents {
|
||||
for pass in &render_doc.frame.passes {
|
||||
let mut debug_targets = Vec::new();
|
||||
match pass.kind {
|
||||
|
@ -3350,7 +3348,7 @@ impl Renderer {
|
|||
fn get_render_tasks_for_debugger(&self) -> String {
|
||||
let mut debug_root = debug_server::RenderTaskList::new();
|
||||
|
||||
for &(_, ref render_doc) in &self.active_documents {
|
||||
for (_, render_doc) in &self.active_documents {
|
||||
let debug_node = debug_server::TreeNode::new("document render tasks");
|
||||
let mut builder = debug_server::TreeNodeBuilder::new(debug_node);
|
||||
|
||||
|
@ -3444,7 +3442,36 @@ impl Renderer {
|
|||
) -> Result<RenderResults, Vec<RendererError>> {
|
||||
self.device_size = Some(device_size);
|
||||
|
||||
let result = self.render_impl(Some(device_size));
|
||||
// TODO(gw): We want to make the active document that is
|
||||
// being rendered configurable via the public
|
||||
// API in future. For now, just select the last
|
||||
// added document as the active one to render
|
||||
// (Gecko only ever creates a single document
|
||||
// per renderer right now).
|
||||
let doc_id = self.active_documents.keys().last().cloned();
|
||||
|
||||
let result = match doc_id {
|
||||
Some(doc_id) => {
|
||||
// Remove the doc from the map to appease the borrow checker
|
||||
let mut doc = self.active_documents
|
||||
.remove(&doc_id)
|
||||
.unwrap();
|
||||
|
||||
let result = self.render_impl(
|
||||
doc_id,
|
||||
&mut doc,
|
||||
Some(device_size),
|
||||
);
|
||||
|
||||
self.active_documents.insert(doc_id, doc);
|
||||
|
||||
result
|
||||
}
|
||||
None => {
|
||||
self.last_time = precise_time_ns();
|
||||
Ok(RenderResults::default())
|
||||
}
|
||||
};
|
||||
|
||||
drain_filter(
|
||||
&mut self.notifications,
|
||||
|
@ -3573,18 +3600,15 @@ impl Renderer {
|
|||
// composite without a present will confuse partial present.
|
||||
fn render_impl(
|
||||
&mut self,
|
||||
doc_id: DocumentId,
|
||||
active_doc: &mut RenderedDocument,
|
||||
device_size: Option<DeviceIntSize>,
|
||||
) -> Result<RenderResults, Vec<RendererError>> {
|
||||
profile_scope!("render");
|
||||
let mut results = RenderResults::default();
|
||||
if self.active_documents.is_empty() {
|
||||
self.last_time = precise_time_ns();
|
||||
return Ok(results);
|
||||
}
|
||||
|
||||
self.profile.start_time(profiler::RENDERER_TIME);
|
||||
|
||||
let compositor_kind = self.active_documents[0].1.frame.composite_state.compositor_kind;
|
||||
let compositor_kind = active_doc.frame.composite_state.compositor_kind;
|
||||
// CompositorKind is updated
|
||||
if self.current_compositor_kind != compositor_kind {
|
||||
let enable = match (self.current_compositor_kind, compositor_kind) {
|
||||
|
@ -3655,72 +3679,59 @@ impl Renderer {
|
|||
self.update_debug_overlay(device_size);
|
||||
}
|
||||
|
||||
//Note: another borrowck dance
|
||||
let mut active_documents = mem::replace(&mut self.active_documents, Vec::default());
|
||||
// sort by the document layer id
|
||||
active_documents.sort_by_key(|&(_, ref render_doc)| render_doc.frame.layer);
|
||||
|
||||
#[cfg(feature = "replay")]
|
||||
self.texture_resolver.external_images.extend(
|
||||
self.owned_external_images.iter().map(|(key, value)| (*key, value.clone()))
|
||||
);
|
||||
|
||||
let last_document_index = active_documents.len() - 1;
|
||||
for (doc_index, (document_id, RenderedDocument { ref mut frame, ref mut profile, .. })) in active_documents.iter_mut().enumerate() {
|
||||
assert!(self.current_compositor_kind == frame.composite_state.compositor_kind);
|
||||
let frame = &mut active_doc.frame;
|
||||
let profile = &mut active_doc.profile;
|
||||
assert!(self.current_compositor_kind == frame.composite_state.compositor_kind);
|
||||
|
||||
if self.shared_texture_cache_cleared {
|
||||
assert!(self.documents_seen.contains(&document_id),
|
||||
"Cleared texture cache without sending new document frame.");
|
||||
}
|
||||
if self.shared_texture_cache_cleared {
|
||||
assert!(self.documents_seen.contains(&doc_id),
|
||||
"Cleared texture cache without sending new document frame.");
|
||||
}
|
||||
|
||||
if let Err(e) = self.prepare_gpu_cache(frame) {
|
||||
self.renderer_errors.push(e);
|
||||
continue;
|
||||
}
|
||||
assert!(frame.gpu_cache_frame_id <= self.gpu_cache_frame_id,
|
||||
"Received frame depends on a later GPU cache epoch ({:?}) than one we received last via `UpdateGpuCache` ({:?})",
|
||||
frame.gpu_cache_frame_id, self.gpu_cache_frame_id);
|
||||
match self.prepare_gpu_cache(frame) {
|
||||
Ok(..) => {
|
||||
assert!(frame.gpu_cache_frame_id <= self.gpu_cache_frame_id,
|
||||
"Received frame depends on a later GPU cache epoch ({:?}) than one we received last via `UpdateGpuCache` ({:?})",
|
||||
frame.gpu_cache_frame_id, self.gpu_cache_frame_id);
|
||||
|
||||
{
|
||||
profile_scope!("gl.flush");
|
||||
self.device.gl().flush(); // early start on gpu cache updates
|
||||
}
|
||||
|
||||
self.draw_frame(
|
||||
frame,
|
||||
device_size,
|
||||
&mut results,
|
||||
doc_index == 0,
|
||||
);
|
||||
|
||||
// TODO(nical): do this automatically by selecting counters in the wr profiler
|
||||
// Profile marker for the number of invalidated picture cache
|
||||
if thread_is_being_profiled() {
|
||||
let duration = Duration::new(0,0);
|
||||
if let Some(n) = self.profiler.get(profiler::RENDERED_PICTURE_TILES) {
|
||||
let message = (n as usize).to_string();
|
||||
add_text_marker(cstr!("NumPictureCacheInvalidated"), &message, duration);
|
||||
{
|
||||
profile_scope!("gl.flush");
|
||||
self.device.gl().flush(); // early start on gpu cache updates
|
||||
}
|
||||
}
|
||||
|
||||
if device_size.is_some() {
|
||||
self.draw_frame_debug_items(&frame.debug_items);
|
||||
}
|
||||
self.draw_frame(
|
||||
frame,
|
||||
device_size,
|
||||
&mut results,
|
||||
);
|
||||
|
||||
// If we're the last document, don't call end_pass here, because we'll
|
||||
// be moving on to drawing the debug overlays. See the comment above
|
||||
// the end_pass call in draw_frame about debug draw overlays
|
||||
// for a bit more context.
|
||||
if doc_index != last_document_index {
|
||||
self.texture_resolver.end_pass(&mut self.device, None, None);
|
||||
}
|
||||
// TODO(nical): do this automatically by selecting counters in the wr profiler
|
||||
// Profile marker for the number of invalidated picture cache
|
||||
if thread_is_being_profiled() {
|
||||
let duration = Duration::new(0,0);
|
||||
if let Some(n) = self.profiler.get(profiler::RENDERED_PICTURE_TILES) {
|
||||
let message = (n as usize).to_string();
|
||||
add_text_marker(cstr!("NumPictureCacheInvalidated"), &message, duration);
|
||||
}
|
||||
}
|
||||
|
||||
self.profile.merge(profile);
|
||||
if device_size.is_some() {
|
||||
self.draw_frame_debug_items(&frame.debug_items);
|
||||
}
|
||||
|
||||
self.profile.merge(profile);
|
||||
}
|
||||
Err(e) => {
|
||||
self.renderer_errors.push(e);
|
||||
}
|
||||
}
|
||||
|
||||
self.unlock_external_images();
|
||||
self.active_documents = active_documents;
|
||||
|
||||
let _gm = self.gpu_profiler.start_marker("end frame");
|
||||
self.gpu_profiler.end_frame();
|
||||
|
@ -4306,7 +4317,6 @@ impl Renderer {
|
|||
blits: &[BlitJob],
|
||||
render_tasks: &RenderTaskGraph,
|
||||
draw_target: DrawTarget,
|
||||
content_origin: &DeviceIntPoint,
|
||||
) {
|
||||
if blits.is_empty() {
|
||||
return;
|
||||
|
@ -4351,7 +4361,7 @@ impl Renderer {
|
|||
read_target.into(),
|
||||
read_target.to_framebuffer_rect(source_rect),
|
||||
draw_target,
|
||||
draw_target.to_framebuffer_rect(blit.target_rect.translate(-content_origin.to_vector())),
|
||||
draw_target.to_framebuffer_rect(blit.target_rect),
|
||||
TextureFilter::Linear,
|
||||
);
|
||||
}
|
||||
|
@ -4436,7 +4446,6 @@ impl Renderer {
|
|||
&mut self,
|
||||
target: &PictureCacheTarget,
|
||||
draw_target: DrawTarget,
|
||||
content_origin: DeviceIntPoint,
|
||||
projection: &default::Transform3D<f32>,
|
||||
render_tasks: &RenderTaskGraph,
|
||||
stats: &mut RendererStats,
|
||||
|
@ -4495,10 +4504,7 @@ impl Renderer {
|
|||
}
|
||||
other => {
|
||||
let scissor_rect = other.map(|rect| {
|
||||
draw_target.build_scissor_rect(
|
||||
Some(rect),
|
||||
content_origin,
|
||||
)
|
||||
draw_target.build_scissor_rect(Some(rect))
|
||||
});
|
||||
self.device.clear_target(clear_color, Some(1.0), scissor_rect);
|
||||
}
|
||||
|
@ -4509,7 +4515,6 @@ impl Renderer {
|
|||
self.draw_alpha_batch_container(
|
||||
&target.alpha_batch_container,
|
||||
draw_target,
|
||||
content_origin,
|
||||
framebuffer_kind,
|
||||
projection,
|
||||
render_tasks,
|
||||
|
@ -4525,7 +4530,6 @@ impl Renderer {
|
|||
&mut self,
|
||||
alpha_batch_container: &AlphaBatchContainer,
|
||||
draw_target: DrawTarget,
|
||||
content_origin: DeviceIntPoint,
|
||||
framebuffer_kind: FramebufferKind,
|
||||
projection: &default::Transform3D<f32>,
|
||||
render_tasks: &RenderTaskGraph,
|
||||
|
@ -4537,7 +4541,6 @@ impl Renderer {
|
|||
self.device.enable_scissor();
|
||||
let scissor_rect = draw_target.build_scissor_rect(
|
||||
alpha_batch_container.task_scissor_rect,
|
||||
content_origin,
|
||||
);
|
||||
self.device.set_scissor_rect(scissor_rect)
|
||||
}
|
||||
|
@ -5130,7 +5133,6 @@ impl Renderer {
|
|||
fn composite_simple(
|
||||
&mut self,
|
||||
composite_state: &CompositeState,
|
||||
clear_framebuffer: bool,
|
||||
draw_target: DrawTarget,
|
||||
projection: &default::Transform3D<f32>,
|
||||
results: &mut RenderResults,
|
||||
|
@ -5221,23 +5223,21 @@ impl Renderer {
|
|||
self.force_redraw = false;
|
||||
}
|
||||
|
||||
// Clear the framebuffer, if required
|
||||
if clear_framebuffer {
|
||||
let clear_color = self.clear_color.map(|color| color.to_array());
|
||||
// Clear the framebuffer
|
||||
let clear_color = self.clear_color.map(|color| color.to_array());
|
||||
|
||||
match partial_present_mode {
|
||||
Some(PartialPresentMode::Single { dirty_rect }) => {
|
||||
// We have a single dirty rect, so clear only that
|
||||
self.device.clear_target(clear_color,
|
||||
Some(1.0),
|
||||
Some(draw_target.to_framebuffer_rect(dirty_rect.to_i32())));
|
||||
}
|
||||
None => {
|
||||
// Partial present is disabled, so clear the entire framebuffer
|
||||
self.device.clear_target(clear_color,
|
||||
Some(1.0),
|
||||
None);
|
||||
}
|
||||
match partial_present_mode {
|
||||
Some(PartialPresentMode::Single { dirty_rect }) => {
|
||||
// We have a single dirty rect, so clear only that
|
||||
self.device.clear_target(clear_color,
|
||||
Some(1.0),
|
||||
Some(draw_target.to_framebuffer_rect(dirty_rect.to_i32())));
|
||||
}
|
||||
None => {
|
||||
// Partial present is disabled, so clear the entire framebuffer
|
||||
self.device.clear_target(clear_color,
|
||||
Some(1.0),
|
||||
None);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -5299,7 +5299,6 @@ impl Renderer {
|
|||
&mut self,
|
||||
draw_target: DrawTarget,
|
||||
target: &ColorRenderTarget,
|
||||
content_origin: DeviceIntPoint,
|
||||
clear_color: Option<[f32; 4]>,
|
||||
clear_depth: Option<f32>,
|
||||
render_tasks: &RenderTaskGraph,
|
||||
|
@ -5374,7 +5373,9 @@ impl Renderer {
|
|||
|
||||
// Handle any blits from the texture cache to this target.
|
||||
self.handle_blits(
|
||||
&target.blits, render_tasks, draw_target, &content_origin,
|
||||
&target.blits,
|
||||
render_tasks,
|
||||
draw_target,
|
||||
);
|
||||
|
||||
// Draw any blurs for this target.
|
||||
|
@ -5428,7 +5429,6 @@ impl Renderer {
|
|||
self.draw_alpha_batch_container(
|
||||
alpha_batch_container,
|
||||
draw_target,
|
||||
content_origin,
|
||||
framebuffer_kind,
|
||||
projection,
|
||||
render_tasks,
|
||||
|
@ -5722,7 +5722,9 @@ impl Renderer {
|
|||
|
||||
// Handle any blits to this texture from child tasks.
|
||||
self.handle_blits(
|
||||
&target.blits, render_tasks, draw_target, &DeviceIntPoint::zero(),
|
||||
&target.blits,
|
||||
render_tasks,
|
||||
draw_target,
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -6080,7 +6082,6 @@ impl Renderer {
|
|||
frame: &mut Frame,
|
||||
device_size: Option<DeviceIntSize>,
|
||||
results: &mut RenderResults,
|
||||
clear_framebuffer: bool,
|
||||
) {
|
||||
profile_scope!("draw_frame");
|
||||
|
||||
|
@ -6162,18 +6163,17 @@ impl Renderer {
|
|||
PictureCacheDebugInfo::new(),
|
||||
);
|
||||
|
||||
let offset = frame.content_origin.to_f32();
|
||||
let size = frame.device_rect.size.to_f32();
|
||||
let surface_origin_is_top_left = self.device.surface_origin_is_top_left();
|
||||
let (bottom, top) = if surface_origin_is_top_left {
|
||||
(offset.y, offset.y + size.height)
|
||||
(0.0, size.height)
|
||||
} else {
|
||||
(offset.y + size.height, offset.y)
|
||||
(size.height, 0.0)
|
||||
};
|
||||
|
||||
let projection = Transform3D::ortho(
|
||||
offset.x,
|
||||
offset.x + size.width,
|
||||
0.0,
|
||||
size.width,
|
||||
bottom,
|
||||
top,
|
||||
self.device.ortho_near_plane(),
|
||||
|
@ -6208,7 +6208,6 @@ impl Renderer {
|
|||
CompositorKind::Draw { max_partial_present_rects, draw_previous_partial_present_regions, .. } => {
|
||||
self.composite_simple(
|
||||
&frame.composite_state,
|
||||
clear_framebuffer,
|
||||
draw_target,
|
||||
&projection,
|
||||
results,
|
||||
|
@ -6303,7 +6302,6 @@ impl Renderer {
|
|||
self.draw_picture_cache_target(
|
||||
picture_target,
|
||||
draw_target,
|
||||
frame.content_origin,
|
||||
&projection,
|
||||
&frame.render_tasks,
|
||||
&mut results.stats,
|
||||
|
@ -6376,7 +6374,6 @@ impl Renderer {
|
|||
self.draw_color_target(
|
||||
draw_target,
|
||||
target,
|
||||
frame.content_origin,
|
||||
Some([0.0, 0.0, 0.0, 0.0]),
|
||||
clear_depth,
|
||||
&frame.render_tasks,
|
||||
|
|
|
@ -6,7 +6,7 @@ use api::{AsyncBlobImageRasterizer, BlobImageResult};
|
|||
use api::{DocumentId, PipelineId, ExternalEvent, BlobImageRequest};
|
||||
use api::{NotificationRequest, Checkpoint, IdNamespace, QualitySettings};
|
||||
use api::{PrimitiveKeyKind, SharedFontInstanceMap};
|
||||
use api::{DocumentLayer, GlyphDimensionRequest, GlyphIndexRequest};
|
||||
use api::{GlyphDimensionRequest, GlyphIndexRequest};
|
||||
use api::channel::{unbounded_channel, single_msg_channel, Receiver, Sender};
|
||||
use api::units::*;
|
||||
use crate::render_api::{ApiMsg, FrameMsg, SceneMsg, ResourceUpdate, TransactionMsg, MemoryReport};
|
||||
|
@ -89,7 +89,7 @@ pub struct LoadScene {
|
|||
/// Message to the scene builder thread.
|
||||
pub enum SceneBuilderRequest {
|
||||
Transactions(Vec<Box<TransactionMsg>>),
|
||||
AddDocument(DocumentId, DeviceIntSize, DocumentLayer),
|
||||
AddDocument(DocumentId, DeviceIntSize),
|
||||
DeleteDocument(DocumentId),
|
||||
GetGlyphDimensions(GlyphDimensionRequest),
|
||||
GetGlyphIndices(GlyphIndexRequest),
|
||||
|
@ -204,14 +204,13 @@ struct Document {
|
|||
}
|
||||
|
||||
impl Document {
|
||||
fn new(device_rect: DeviceIntRect, layer: DocumentLayer, device_pixel_ratio: f32) -> Self {
|
||||
fn new(device_rect: DeviceIntRect, device_pixel_ratio: f32) -> Self {
|
||||
Document {
|
||||
scene: Scene::new(),
|
||||
interners: Interners::default(),
|
||||
stats: SceneStats::empty(),
|
||||
view: SceneView {
|
||||
device_rect,
|
||||
layer,
|
||||
device_pixel_ratio,
|
||||
page_zoom_factor: 1.0,
|
||||
quality_settings: QualitySettings::default(),
|
||||
|
@ -315,10 +314,9 @@ impl SceneBuilderThread {
|
|||
}
|
||||
self.forward_built_transactions(built_txns);
|
||||
}
|
||||
Ok(SceneBuilderRequest::AddDocument(document_id, initial_size, layer)) => {
|
||||
Ok(SceneBuilderRequest::AddDocument(document_id, initial_size)) => {
|
||||
let old = self.documents.insert(document_id, Document::new(
|
||||
initial_size.into(),
|
||||
layer,
|
||||
self.default_device_pixel_ratio,
|
||||
));
|
||||
debug_assert!(old.is_none());
|
||||
|
|
|
@ -67,9 +67,6 @@ use peek_poke::PeekPoke;
|
|||
/// Width and height in device pixels of image tiles.
|
||||
pub type TileSize = u16;
|
||||
|
||||
/// Documents are rendered in the ascending order of their associated layer values.
|
||||
pub type DocumentLayer = i8;
|
||||
|
||||
/// Various settings that the caller can select based on desired tradeoffs
|
||||
/// between rendering quality and performance / power usage.
|
||||
#[derive(Copy, Clone, Deserialize, Serialize)]
|
||||
|
|
|
@ -1285,7 +1285,7 @@ impl<'a> RawtestHarness<'a> {
|
|||
|
||||
let layout_size = LayoutSize::new(120.0, 0.0);
|
||||
let window_size = DeviceIntSize::new(layout_size.width as i32, layout_size.height as i32);
|
||||
let doc_id = self.wrench.api.add_document(window_size, 1);
|
||||
let doc_id = self.wrench.api.add_document(window_size);
|
||||
|
||||
let mut builder = DisplayListBuilder::new(self.wrench.root_pipeline_id);
|
||||
let info = self.make_common_properties(LayoutRect::new(LayoutPoint::zero(),
|
||||
|
|
|
@ -294,7 +294,7 @@ impl Wrench {
|
|||
).unwrap();
|
||||
|
||||
let api = sender.create_api();
|
||||
let document_id = api.add_document(size, 0);
|
||||
let document_id = api.add_document(size);
|
||||
|
||||
let graphics_api = renderer.get_graphics_api_info();
|
||||
let zoom_factor = ZoomFactor::new(zoom_factor);
|
||||
|
|
Загрузка…
Ссылка в новой задаче