<commit_before>/* 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/. */

use channel::{self, MsgSender, Payload, PayloadSenderHelperMethods, PayloadSender};
#[cfg(feature = "webgl")]
use offscreen_gl_context::{GLContextAttributes, GLLimits};
use std::cell::Cell;
use std::fmt;
use std::marker::PhantomData;
use {AuxiliaryLists, AuxiliaryListsDescriptor, BuiltDisplayList, BuiltDisplayListDescriptor};
use {ColorF, DeviceIntPoint, DeviceIntSize, DeviceUintRect, DeviceUintSize, FontKey};
use {GlyphDimensions, GlyphKey, ImageData, ImageDescriptor, ImageKey, LayoutPoint, LayoutSize};
use {LayoutTransform, NativeFontHandle, ScrollLayerId, WorldPoint};
#[cfg(feature = "webgl")]
use {WebGLCommand, WebGLContextId};

pub type TileSize = u16;

#[derive(Clone, Deserialize, Serialize)]
pub enum ApiMsg {
    AddRawFont(FontKey, Vec<u8>),
    AddNativeFont(FontKey, NativeFontHandle),
    DeleteFont(FontKey),
    /// Gets the glyph dimensions
    GetGlyphDimensions(Vec<GlyphKey>, MsgSender<Vec<Option<GlyphDimensions>>>),
    /// Adds an image from the resource cache.
    AddImage(ImageKey, ImageDescriptor, ImageData, Option<TileSize>),
    /// Updates the the resource cache with the new image data.
    UpdateImage(ImageKey, ImageDescriptor, ImageData, Option<DeviceUintRect>),
    /// Drops an image from the resource cache.
    DeleteImage(ImageKey),
    CloneApi(MsgSender<IdNamespace>),
    /// Supplies a new frame to WebRender.
    ///
    /// After receiving this message, WebRender will read the display list, followed by the
    /// auxiliary lists, from the payload channel.
    SetDisplayList(Option<ColorF>,
                   Epoch,
                   PipelineId,
                   LayoutSize,
                   BuiltDisplayListDescriptor,
                   AuxiliaryListsDescriptor,
                   bool),
    SetPageZoom(ZoomFactor),
    SetPinchZoom(ZoomFactor),
    SetPan(DeviceIntPoint),
    SetRootPipeline(PipelineId),
    SetWindowParameters(DeviceUintSize, DeviceUintRect),
    Scroll(ScrollLocation, WorldPoint, ScrollEventPhase),
    ScrollLayerWithId(LayoutPoint, ScrollLayerId),
    TickScrollingBounce,
    TranslatePointToLayerSpace(WorldPoint, MsgSender<(LayoutPoint, PipelineId)>),
    GetScrollLayerState(MsgSender<Vec<ScrollLayerState>>),
    RequestWebGLContext(DeviceIntSize, GLContextAttributes, MsgSender<Result<(WebGLContextId, GLLimits), String>>),
    ResizeWebGLContext(WebGLContextId, DeviceIntSize),
    WebGLCommand(WebGLContextId, WebGLCommand),
    GenerateFrame(Option<DynamicProperties>),
    // WebVR commands that must be called in the WebGL render thread.
    VRCompositorCommand(WebGLContextId, VRCompositorCommand),
    /// An opaque handle that must be passed to the render notifier. It is used by Gecko
    /// to forward gecko-specific messages to the render thread preserving the ordering
    /// within the other messages.
    ExternalEvent(ExternalEvent),
    ShutDown,
}

impl fmt::Debug for ApiMsg {
    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
        match *self {
            ApiMsg::AddRawFont(..) => { write!(f, "ApiMsg::AddRawFont") }
            ApiMsg::AddNativeFont(..) => { write!(f, "ApiMsg::AddNativeFont") }
            ApiMsg::DeleteFont(..) => { write!(f, "ApiMsg::DeleteFont") }
            ApiMsg::GetGlyphDimensions(..) => { write!(f, "ApiMsg::GetGlyphDimensions") }
            ApiMsg::AddImage(..) => { write!(f, "ApiMsg::AddImage") }
            ApiMsg::UpdateImage(..) => { write!(f, "ApiMsg::UpdateImage") }
            ApiMsg::DeleteImage(..) => { write!(f, "ApiMsg::DeleteImage") }
            ApiMsg::CloneApi(..) => { write!(f, "ApiMsg::CloneApi") }
            ApiMsg::SetDisplayList(..) => { write!(f, "ApiMsg::SetDisplayList") }
            ApiMsg::SetRootPipeline(..) => { write!(f, "ApiMsg::SetRootPipeline") }
            ApiMsg::Scroll(..) => { write!(f, "ApiMsg::Scroll") }
            ApiMsg::ScrollLayerWithId(..) => { write!(f, "ApiMsg::ScrollLayerWithId") }
            ApiMsg::TickScrollingBounce => { write!(f, "ApiMsg::TickScrollingBounce") }
            ApiMsg::TranslatePointToLayerSpace(..) => { write!(f, "ApiMsg::TranslatePointToLayerSpace") }
            ApiMsg::GetScrollLayerState(..) => { write!(f, "ApiMsg::GetScrollLayerState") }
            ApiMsg::RequestWebGLContext(..) => { write!(f, "ApiMsg::RequestWebGLContext") }
            ApiMsg::ResizeWebGLContext(..) => { write!(f, "ApiMsg::ResizeWebGLContext") }
            ApiMsg::WebGLCommand(..) => { write!(f, "ApiMsg::WebGLCommand") }
            ApiMsg::GenerateFrame(..) => { write!(f, "ApiMsg::GenerateFrame") }
            ApiMsg::VRCompositorCommand(..) => { write!(f, "ApiMsg::VRCompositorCommand") }
            ApiMsg::ExternalEvent(..) => { write!(f, "ApiMsg::ExternalEvent") }
            ApiMsg::ShutDown => { write!(f, "ApiMsg::ShutDown") }
            ApiMsg::SetPageZoom(..) => { write!(f, "ApiMsg::SetPageZoom") }
            ApiMsg::SetPinchZoom(..) => { write!(f, "ApiMsg::SetPinchZoom") }
            ApiMsg::SetPan(..) => { write!(f, "ApiMsg::SetPan") }
            ApiMsg::SetWindowParameters(..) => { write!(f, "ApiMsg::SetWindowParameters") }
        }
    }
}

#[repr(C)]
#[derive(Clone, Copy, Debug, Deserialize, Eq, Hash, Ord, PartialEq, PartialOrd, Serialize)]
pub struct Epoch(pub u32);
<commit_msg>webrender_traits: Improve Debug for ApiMsg.<commit_after>/* 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/. */

use channel::{self, MsgSender, Payload, PayloadSenderHelperMethods, PayloadSender};
#[cfg(feature = "webgl")]
use offscreen_gl_context::{GLContextAttributes, GLLimits};
use std::cell::Cell;
use std::fmt;
use std::marker::PhantomData;
use {AuxiliaryLists, AuxiliaryListsDescriptor, BuiltDisplayList, BuiltDisplayListDescriptor};
use {ColorF, DeviceIntPoint, DeviceIntSize, DeviceUintRect, DeviceUintSize, FontKey};
use {GlyphDimensions, GlyphKey, ImageData, ImageDescriptor, ImageKey, LayoutPoint, LayoutSize};
use {LayoutTransform, NativeFontHandle, ScrollLayerId, WorldPoint};
#[cfg(feature = "webgl")]
use {WebGLCommand, WebGLContextId};

pub type TileSize = u16;

#[derive(Clone, Deserialize, Serialize)]
pub enum ApiMsg {
    AddRawFont(FontKey, Vec<u8>),
    AddNativeFont(FontKey, NativeFontHandle),
    DeleteFont(FontKey),
    /// Gets the glyph dimensions
    GetGlyphDimensions(Vec<GlyphKey>, MsgSender<Vec<Option<GlyphDimensions>>>),
    /// Adds an image from the resource cache.
    AddImage(ImageKey, ImageDescriptor, ImageData, Option<TileSize>),
    /// Updates the the resource cache with the new image data.
    UpdateImage(ImageKey, ImageDescriptor, ImageData, Option<DeviceUintRect>),
    /// Drops an image from the resource cache.
    DeleteImage(ImageKey),
    CloneApi(MsgSender<IdNamespace>),
    /// Supplies a new frame to WebRender.
    ///
    /// After receiving this message, WebRender will read the display list, followed by the
    /// auxiliary lists, from the payload channel.
    SetDisplayList(Option<ColorF>,
                   Epoch,
                   PipelineId,
                   LayoutSize,
                   BuiltDisplayListDescriptor,
                   AuxiliaryListsDescriptor,
                   bool),
    SetPageZoom(ZoomFactor),
    SetPinchZoom(ZoomFactor),
    SetPan(DeviceIntPoint),
    SetRootPipeline(PipelineId),
    SetWindowParameters(DeviceUintSize, DeviceUintRect),
    Scroll(ScrollLocation, WorldPoint, ScrollEventPhase),
    ScrollLayerWithId(LayoutPoint, ScrollLayerId),
    TickScrollingBounce,
    TranslatePointToLayerSpace(WorldPoint, MsgSender<(LayoutPoint, PipelineId)>),
    GetScrollLayerState(MsgSender<Vec<ScrollLayerState>>),
    RequestWebGLContext(DeviceIntSize, GLContextAttributes, MsgSender<Result<(WebGLContextId, GLLimits), String>>),
    ResizeWebGLContext(WebGLContextId, DeviceIntSize),
    WebGLCommand(WebGLContextId, WebGLCommand),
    GenerateFrame(Option<DynamicProperties>),
    // WebVR commands that must be called in the WebGL render thread.
    VRCompositorCommand(WebGLContextId, VRCompositorCommand),
    /// An opaque handle that must be passed to the render notifier. It is used by Gecko
    /// to forward gecko-specific messages to the render thread preserving the ordering
    /// within the other messages.
    ExternalEvent(ExternalEvent),
    ShutDown,
}

impl fmt::Debug for ApiMsg {
    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
        f.write_str(match *self {
            ApiMsg::AddRawFont(..) => "ApiMsg::AddRawFont",
            ApiMsg::AddNativeFont(..) => "ApiMsg::AddNativeFont",
            ApiMsg::DeleteFont(..) => "ApiMsg::DeleteFont",
            ApiMsg::GetGlyphDimensions(..) => "ApiMsg::GetGlyphDimensions",
            ApiMsg::AddImage(..) => "ApiMsg::AddImage",
            ApiMsg::UpdateImage(..) => "ApiMsg::UpdateImage",
            ApiMsg::DeleteImage(..) => "ApiMsg::DeleteImage",
            ApiMsg::CloneApi(..) => "ApiMsg::CloneApi",
            ApiMsg::SetDisplayList(..) => "ApiMsg::SetDisplayList",
            ApiMsg::SetRootPipeline(..) => "ApiMsg::SetRootPipeline",
            ApiMsg::Scroll(..) => "ApiMsg::Scroll",
            ApiMsg::ScrollLayerWithId(..) => "ApiMsg::ScrollLayerWithId",
            ApiMsg::TickScrollingBounce => "ApiMsg::TickScrollingBounce",
            ApiMsg::TranslatePointToLayerSpace(..) => "ApiMsg::TranslatePointToLayerSpace",
            ApiMsg::GetScrollLayerState(..) => "ApiMsg::GetScrollLayerState",
            ApiMsg::RequestWebGLContext(..) => "ApiMsg::RequestWebGLContext",
            ApiMsg::ResizeWebGLContext(..) => "ApiMsg::ResizeWebGLContext",
            ApiMsg::WebGLCommand(..) => "ApiMsg::WebGLCommand",
            ApiMsg::GenerateFrame(..) => "ApiMsg::GenerateFrame",
            ApiMsg::VRCompositorCommand(..) => "ApiMsg::VRCompositorCommand",
            ApiMsg::ExternalEvent(..) => "ApiMsg::ExternalEvent",
            ApiMsg::ShutDown => "ApiMsg::ShutDown",
            ApiMsg::SetPageZoom(..) => "ApiMsg::SetPageZoom",
            ApiMsg::SetPinchZoom(..) => "ApiMsg::SetPinchZoom",
            ApiMsg::SetPan(..) => "ApiMsg::SetPan",
            ApiMsg::SetWindowParameters(..) => "ApiMsg::SetWindowParameters",
        })
    }
}

#[repr(C)]
#[derive(Clone, Copy, Debug, Deserialize, Eq, Hash, Ord, PartialEq, PartialOrd, Serialize)]
pub struct Epoch(pub u32);

{'fraction_non_alphanumeric': 0.13851956624233852, 'fraction_numerical': 0.0016973125884016972, 'mean_word_length': 3.690844758956214, 'pattern_counts': {'":': 0, '<': 33, '<?xml version=': 0, '>': 87, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '93981', 'n_tokens_mistral': 3175, 'n_tokens_neox': 3130, 'n_words': 670}