servo: Merge #11343 - Privatize some things in compositing (from servo:privatize-compositing); r=nox
authorMs2ger <Ms2ger@gmail.com>
Mon, 23 May 2016 15:36:43 -0700
changeset 477050 991c1d1ae720faf88ed20654bcc33b8728726382
parent 477049 fe405785fbd4ad0d10a67d4cb4882859ec3e138a
child 477051 7a67362768d5448d6ec0c3613046501df947ad93
push id44079
push userbmo:gps@mozilla.com
push dateSat, 04 Feb 2017 00:14:49 +0000
reviewersnox
servo: Merge #11343 - Privatize some things in compositing (from servo:privatize-compositing); r=nox Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `__` with appropriate data: - [x] `./mach build -d` does not report any errors - [x] `./mach test-tidy --faster` does not report any errors - [ ] These changes fix #__ (github issue number if applicable). Either: - [ ] There are tests for these changes OR - [x] These changes do not require tests because refactoring Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. Source-Repo: https://github.com/servo/servo Source-Revision: a636b7127ebb40d1e22347bb253cd767cf9c522d
servo/components/compositing/compositor.rs
servo/components/compositing/delayed_composition.rs
--- a/servo/components/compositing/compositor.rs
+++ b/servo/components/compositing/compositor.rs
@@ -53,39 +53,39 @@ use url::Url;
 use util::geometry::{PagePx, ScreenPx, ViewportPx};
 use util::print_tree::PrintTree;
 use util::{opts, prefs};
 use webrender;
 use webrender_traits::{self, ScrollEventPhase};
 use windowing::{self, MouseWindowEvent, WindowEvent, WindowMethods, WindowNavigateMsg};
 
 #[derive(Debug, PartialEq)]
-pub enum UnableToComposite {
+enum UnableToComposite {
     NoContext,
     WindowUnprepared,
     NotReadyToPaintImage(NotReadyToPaint),
 }
 
 #[derive(Debug, PartialEq)]
-pub enum NotReadyToPaint {
+enum NotReadyToPaint {
     LayerHasOutstandingPaintMessages,
     MissingRoot,
     PendingSubpages(usize),
     AnimationsActive,
     JustNotifiedConstellation,
     WaitingOnConstellation,
 }
 
 const BUFFER_MAP_SIZE: usize = 10000000;
 
 // Default viewport constraints
 const MAX_ZOOM: f32 = 8.0;
 const MIN_ZOOM: f32 = 0.1;
 
-pub trait ConvertPipelineIdFromWebRender {
+trait ConvertPipelineIdFromWebRender {
     fn from_webrender(&self) -> PipelineId;
 }
 
 impl ConvertPipelineIdFromWebRender for webrender_traits::PipelineId {
     fn from_webrender(&self) -> PipelineId {
         PipelineId {
             namespace_id: PipelineNamespaceId(self.0),
             index: PipelineIndex(self.1),
@@ -216,17 +216,17 @@ pub struct IOCompositor<Window: WindowMe
     /// The webrender renderer, if enabled.
     webrender: Option<webrender::Renderer>,
 
     /// The webrender interface, if enabled.
     webrender_api: Option<webrender_traits::RenderApi>,
 }
 
 #[derive(Copy, Clone)]
-pub struct ScrollZoomEvent {
+struct ScrollZoomEvent {
     /// Change the pinch zoom level by this factor
     magnification: f32,
     /// Scroll by this offset
     delta: TypedPoint2D<DevicePixel, f32>,
     /// Apply changes to the frame at this location
     cursor: TypedPoint2D<DevicePixel, i32>,
     /// The scroll event phase.
     phase: ScrollEventPhase,
@@ -248,17 +248,17 @@ enum ShutdownState {
 
 struct HitTestResult {
     /// The topmost layer containing the requested point
     layer: Rc<Layer<CompositorData>>,
     /// The point in client coordinates of the innermost window or frame containing `layer`
     point: TypedPoint2D<LayerPixel, f32>,
 }
 
-pub struct PipelineDetails {
+struct PipelineDetails {
     /// The pipeline associated with this PipelineDetails object.
     pipeline: Option<CompositionPipeline>,
 
     /// The current layout epoch that this pipeline wants to draw.
     current_epoch: Epoch,
 
     /// Whether animations are running
     animations_running: bool,
@@ -274,17 +274,17 @@ impl PipelineDetails {
             current_epoch: Epoch(0),
             animations_running: false,
             animation_callbacks_running: false,
         }
     }
 }
 
 #[derive(Clone, Copy, PartialEq, Debug)]
-pub enum CompositeTarget {
+enum CompositeTarget {
     /// Normal composition to a window
     Window,
 
     /// Compose as normal, but also return a PNG of the composed output
     WindowAndPng,
 
     /// Compose to a PNG, write it to disk, and then exit the browser (used for reftests)
     PngFile
@@ -341,17 +341,17 @@ fn initialize_png(width: usize, height: 
 
     RenderTargetInfo {
         framebuffer_ids: framebuffer_ids,
         texture_ids: texture_ids,
         renderbuffer_ids: renderbuffer_ids
     }
 }
 
-pub fn reporter_name() -> String {
+fn reporter_name() -> String {
     "compositor-reporter".to_owned()
 }
 
 struct RenderNotifier {
     compositor_proxy: Box<CompositorProxy>,
     constellation_chan: Sender<ConstellationMsg>,
 }
 
@@ -480,28 +480,28 @@ impl<Window: WindowMethods> IOCompositor
         compositor.update_zoom_transform();
 
         // Tell the constellation about the initial window size.
         compositor.send_window_size(WindowSizeType::Initial);
 
         compositor
     }
 
-    pub fn start_shutting_down(&mut self) {
+    fn start_shutting_down(&mut self) {
         debug!("Compositor sending Exit message to Constellation");
         if let Err(e) = self.constellation_chan.send(ConstellationMsg::Exit) {
             warn!("Sending exit message to constellation failed ({}).", e);
         }
 
         self.mem_profiler_chan.send(mem::ProfilerMsg::UnregisterReporter(reporter_name()));
 
         self.shutdown_state = ShutdownState::ShuttingDown;
     }
 
-    pub fn finish_shutting_down(&mut self) {
+    fn finish_shutting_down(&mut self) {
         debug!("Compositor received message that constellation shutdown is complete");
 
         // Clear out the compositor layers so that painting threads can destroy the buffers.
         if let Some(ref root_layer) = self.scene.root {
             root_layer.forget_all_tiles();
         }
 
         // Drain compositor port, sometimes messages contain channels that are blocking
@@ -785,19 +785,17 @@ impl<Window: WindowMethods> IOCompositor
                 self.pipeline_details(pipeline_id).animations_running = false;
             }
             AnimationState::NoAnimationCallbacksPresent => {
                 self.pipeline_details(pipeline_id).animation_callbacks_running = false;
             }
         }
     }
 
-    pub fn pipeline_details (&mut self,
-                                              pipeline_id: PipelineId)
-                                              -> &mut PipelineDetails {
+    fn pipeline_details(&mut self, pipeline_id: PipelineId) -> &mut PipelineDetails {
         if !self.pipeline_details.contains_key(&pipeline_id) {
             self.pipeline_details.insert(pipeline_id, PipelineDetails::new());
         }
         self.pipeline_details.get_mut(&pipeline_id).expect("Insert then get failed!")
     }
 
     pub fn pipeline(&self, pipeline_id: PipelineId) -> Option<&CompositionPipeline> {
         match self.pipeline_details.get(&pipeline_id) {
@@ -1119,21 +1117,21 @@ impl<Window: WindowMethods> IOCompositor
         };
 
         let msg = ConstellationMsg::FrameSize(*subpage_pipeline_id, layer_properties.rect.size);
         if let Err(e) = self.constellation_chan.send(msg) {
             warn!("Sending subpage resize to constellation failed ({}).", e);
         }
     }
 
-    pub fn move_layer(&self,
-                      pipeline_id: PipelineId,
-                      layer_id: LayerId,
-                      origin: TypedPoint2D<LayerPixel, f32>)
-                      -> bool {
+    fn move_layer(&self,
+                  pipeline_id: PipelineId,
+                  layer_id: LayerId,
+                  origin: TypedPoint2D<LayerPixel, f32>)
+                  -> bool {
         match self.find_layer_with_pipeline_and_layer_id(pipeline_id, layer_id) {
             Some(ref layer) => {
                 if layer.wants_scroll_events() == WantsScrollEventsFlag::WantsScrollEvents {
                     layer.clamp_scroll_offset_and_scroll_layer(Point2D::typed(0f32, 0f32) - origin);
                 }
                 true
             }
             None => false,
@@ -2076,18 +2074,19 @@ impl<Window: WindowMethods> IOCompositor
         }
     }
 
     /// Composite either to the screen or to a png image or both.
     /// Returns Ok if composition was performed or Err if it was not possible to composite
     /// for some reason. If CompositeTarget is Window or Png no image data is returned;
     /// in the latter case the image is written directly to a file. If CompositeTarget
     /// is WindowAndPng Ok(Some(png::Image)) is returned.
-    pub fn composite_specific_target(&mut self, target: CompositeTarget) -> Result<Option<Image>, UnableToComposite> {
-
+    fn composite_specific_target(&mut self,
+                                 target: CompositeTarget)
+                                 -> Result<Option<Image>, UnableToComposite> {
         if self.context.is_none() && self.webrender.is_none() {
             return Err(UnableToComposite::NoContext)
         }
         let (width, height) =
             (self.window_size.width.get() as usize, self.window_size.height.get() as usize);
         if !self.window.prepare_for_composite(width, height) {
             return Err(UnableToComposite::WindowUnprepared)
         }
--- a/servo/components/compositing/delayed_composition.rs
+++ b/servo/components/compositing/delayed_composition.rs
@@ -16,17 +16,17 @@ use util::time::duration_from_nanosecond
 /// The amount of time in nanoseconds that we give to the painting thread to paint. When this
 /// expires, we give up and composite anyway.
 static TIMEOUT: u64 = 12_000_000;
 
 pub struct DelayedCompositionTimerProxy {
     sender: Sender<ToDelayedCompositionTimerMsg>,
 }
 
-pub struct DelayedCompositionTimer {
+struct DelayedCompositionTimer {
     compositor_proxy: Box<CompositorProxy>,
     receiver: Receiver<ToDelayedCompositionTimerMsg>,
 }
 
 enum ToDelayedCompositionTimerMsg {
     Exit,
     ScheduleComposite(u64),
 }
@@ -51,17 +51,17 @@ impl DelayedCompositionTimerProxy {
     }
 
     pub fn shutdown(&mut self) {
         self.sender.send(ToDelayedCompositionTimerMsg::Exit).unwrap()
     }
 }
 
 impl DelayedCompositionTimer {
-    pub fn run(&mut self) {
+    fn run(&mut self) {
         'outer: loop {
             let mut timestamp;
             loop {
                 match self.receiver.recv() {
                     Ok(ToDelayedCompositionTimerMsg::ScheduleComposite(this_timestamp)) => {
                         timestamp = this_timestamp;
                         break
                     }