Quellcodebibliothek Statistik Leitseite products/Sources/formale Sprachen/C/Firefox/gfx/wr/examples/   (Netbeans IDE Version 28©)  Datei vom 27.6.2026 mit Größe 3 kB image not shown  

Quelle  document.rs

  Sprache: Rust
 

/* This Source Code Form is subject to the terms of the Mozilla Public
 * 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/. */


extern crate euclid;
extern crate gleam;
extern crate glutin;
extern crate webrender;
extern crate winit;

#[path = "common/boilerplate.rs"]
mod boilerplate;

use crate::boilerplate::Example;
use euclid::Scale;
use webrender::api::*;
use webrender::render_api::*;
use webrender::api::units::*;

// This example creates multiple documents overlapping each other with
// specified layer indices.

struct Document {
    id: DocumentId,
    pipeline_id: PipelineId,
    content_rect: LayoutRect,
    color: ColorF,
}

struct App {
    documents: Vec<Document>,
}

impl App {
    fn init(
        &mut self,
        api: &mut RenderApi,
        device_pixel_ratio: f32,
    ) {
        let init_data = vec![
            (
                PipelineId(10),
                ColorF::new(0.01.00.01.0),
                DeviceIntPoint::new(00),
            ),
            (
                PipelineId(20),
                ColorF::new(1.01.00.01.0),
                DeviceIntPoint::new(2000),
            ),
            (
                PipelineId(30),
                ColorF::new(1.00.00.01.0),
                DeviceIntPoint::new(200200),
            ),
            (
                PipelineId(40),
                ColorF::new(1.00.01.01.0),
                DeviceIntPoint::new(0200),
            ),
        ];

        for (pipeline_id, color, offset) in init_data {
            let size = DeviceIntSize::new(250250);
            let bounds = DeviceIntRect::from_origin_and_size(offset, size);

            let document_id = api.add_document(size);
            let mut txn = Transaction::new();
            txn.set_root_pipeline(pipeline_id);
            api.send_transaction(document_id, txn);

            self.documents.push(Document {
                id: document_id,
                pipeline_id,
                content_rect: LayoutRect::from_size(
                    bounds.size().to_f32() / Scale::new(device_pixel_ratio),
                ),
                color,
            });
        }
    }
}

impl Example for App {
    fn render(
        &mut self,
        api: &mut RenderApi,
        _base_builder: &mut DisplayListBuilder,
        _txn: &mut Transaction,
        _device_size: DeviceIntSize,
        _pipeline_id: PipelineId,
        _: DocumentId,
    ) {
        if self.documents.is_empty() {
            // this is the first run, hack around the boilerplate,
            // which assumes an example only needs one document
            self.init(api, 1.0);
        }

        for doc in &self.documents {
            let space_and_clip = SpaceAndClipInfo::root_scroll(doc.pipeline_id);
            let mut builder = DisplayListBuilder::new(
                doc.pipeline_id,
            );
            builder.begin();
            let local_rect = LayoutRect::from_size(doc.content_rect.size());

            builder.push_simple_stacking_context(
                space_and_clip.spatial_id,
                PrimitiveFlags::IS_BACKFACE_VISIBLE,
            );
            builder.push_rect(
                &CommonItemProperties::new(local_rect, space_and_clip),
                local_rect,
                doc.color,
            );
            builder.pop_stacking_context();

            let mut txn = Transaction::new();
            txn.set_display_list(
                Epoch(0),
                builder.end(),
            );
            txn.generate_frame(0truefalse, RenderReasons::empty());
            api.send_transaction(doc.id, txn);
        }
    }
}

fn main() {
    let mut app = App {
        documents: Vec::new(),
    };
    boilerplate::main_wrapper(&mut app, None);
}

Messung V0.5 in Prozent
C=97 H=100 G=98

¤ Dauer der Verarbeitung: 0.14 Sekunden  (vorverarbeitet am  2026-08-25) ¤

*© Formatika GbR, Deutschland






Wurzel

Suchen

PVS Prover

Isabelle Prover

NIST Cobol Testsuite

Cephes Mathematical Library

Vienna Development Method

Haftungshinweis

Die Informationen auf dieser Webseite wurden nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit, noch Qualität der bereit gestellten Informationen zugesichert.

Bemerkung:

Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.