Logging for image_rsource
authorKartikaya Gupta <kgupta@mozilla.com>
Fri, 01 Jun 2018 11:24:05 -0400
changeset 1528990 bb62118114c6283a23d07b860c3a0eb9d24b5b27
parent 1528649 9900cebb1f9000bd05731ba67736b7c51f7eb812
child 1528991 0919751458bc2db546a9a3dc2aac55143e7d23a2
push id276056
push userkgupta@mozilla.com
push dateFri, 01 Jun 2018 15:24:49 +0000
treeherdertry@0919751458bc [default view] [failures only]
milestone62.0a1
Logging for image_rsource
gfx/webrender/src/resource_cache.rs
--- a/gfx/webrender/src/resource_cache.rs
+++ b/gfx/webrender/src/resource_cache.rs
@@ -513,27 +513,29 @@ impl ResourceCache {
         let resource = ImageResource {
             descriptor,
             data,
             epoch: Epoch(0),
             tiling,
             dirty_rect,
         };
 
+        println!("Adding image template {:?}", image_key);
         self.resources.image_templates.insert(image_key, resource);
     }
 
     pub fn update_image_template(
         &mut self,
         image_key: ImageKey,
         descriptor: ImageDescriptor,
         mut data: ImageData,
         dirty_rect: Option<DeviceUintRect>,
     ) {
         let max_texture_size = self.max_texture_size();
+        println!("Updating image template {:?}", image_key);
         let image = match self.resources.image_templates.get_mut(image_key) {
             Some(res) => res,
             None => panic!("Attempt to update non-existent image"),
         };
 
         let mut tiling = image.tiling;
         if tiling.is_none() && Self::should_tile(max_texture_size, &descriptor, &data) {
             tiling = Some(DEFAULT_TILE_SIZE);
@@ -555,18 +557,20 @@ impl ResourceCache {
                 (Some(rect), Some(prev_rect)) => Some(rect.union(&prev_rect)),
                 (Some(rect), None) => Some(rect),
                 (None, _) => None,
             },
         };
     }
 
     pub fn delete_image_template(&mut self, image_key: ImageKey) {
+        println!("Deleting image template {:?}", image_key);
         let value = self.resources.image_templates.remove(image_key);
 
+        println!("clearing image_cache entries with key in delete_image_templates {:?}", image_key);
         self.cached_images
             .clear_keys(|request| request.key == image_key);
 
         match value {
             Some(image) => if image.data.is_blob() {
                 self.blob_image_renderer.as_mut().unwrap().delete(image_key);
             },
             None => {
@@ -578,44 +582,48 @@ impl ResourceCache {
 
     pub fn request_image(
         &mut self,
         request: ImageRequest,
         gpu_cache: &mut GpuCache,
     ) {
         debug_assert_eq!(self.state, State::AddResources);
 
+        println!("Requesting image template {:?} for image", request.key);
         let template = match self.resources.image_templates.get(request.key) {
             Some(template) => template,
             None => {
                 warn!("ERROR: Trying to render deleted / non-existent key");
                 debug!("key={:?}", request.key);
                 return
             }
         };
 
         // Images that don't use the texture cache can early out.
         if !template.data.uses_texture_cache() {
+            println!("bailing in request_image entry with {:?} (doesn't use texcache)", request);
             return;
         }
 
         let side_size =
             template.tiling.map_or(cmp::max(template.descriptor.size.width, template.descriptor.size.height),
                                    |tile_size| tile_size as u32);
         if side_size > self.texture_cache.max_texture_size() {
             // The image or tiling size is too big for hardware texture size.
             warn!("Dropping image, image:(w:{},h:{}, tile:{}) is too big for hardware!",
                   template.descriptor.size.width, template.descriptor.size.height, template.tiling.unwrap_or(0));
+            println!("inserting image_cache entry with {:?} (OverLimitSize)", request);
             self.cached_images.insert(request, Err(ImageCacheError::OverLimitSize));
             return;
         }
 
         // If this image exists in the texture cache, *and* the epoch
         // in the cache matches that of the template, then it is
         // valid to use as-is.
+        println!("inserting image_cache entry with {:?}", request);
         let (entry, needs_update) = match self.cached_images.entry(request) {
             Occupied(entry) => {
                 let info = entry.into_mut();
                 let needs_update = info.as_mut().unwrap().epoch != template.epoch;
                 info.as_mut().unwrap().epoch = template.epoch;
                 (info, needs_update)
             }
             Vacant(entry) => (
@@ -832,16 +840,17 @@ impl ResourceCache {
     pub fn get_cached_image(
         &self,
         request: ImageRequest,
     ) -> Result<CacheItem, ()> {
         debug_assert_eq!(self.state, State::QueryResources);
 
         // TODO(Jerry): add a debug option to visualize the corresponding area for
         // the Err() case of CacheItem.
+        println!("get_cached_image({:?})", request);
         match *self.cached_images.get(&request) {
             Ok(ref image_info) => {
                 Ok(self.texture_cache.get(&image_info.texture_cache_handle))
             }
             Err(_) => {
                 Err(())
             }
         }
@@ -1021,16 +1030,17 @@ impl ResourceCache {
                     ) {
                         TextureFilter::Trilinear
                     } else {
                         TextureFilter::Linear
                     }
                 }
             };
 
+            println!("update_cached_image updating {:?}", request);
             let entry = self.cached_images.get_mut(&request).as_mut().unwrap();
             self.texture_cache.update(
                 &mut entry.texture_cache_handle,
                 descriptor,
                 filter,
                 Some(image_data),
                 [0.0; 3],
                 dirty_rect,
@@ -1044,16 +1054,17 @@ impl ResourceCache {
 
     pub fn end_frame(&mut self) {
         debug_assert_eq!(self.state, State::QueryResources);
         self.state = State::Idle;
     }
 
     pub fn clear(&mut self, what: ClearCache) {
         if what.contains(ClearCache::IMAGES) {
+            println!("clearing image_cache via clear()");
             self.cached_images.clear();
         }
         if what.contains(ClearCache::GLYPHS) {
             self.cached_glyphs.clear();
         }
         if what.contains(ClearCache::GLYPH_DIMENSIONS) {
             self.cached_glyph_dimensions.clear();
         }
@@ -1061,16 +1072,17 @@ impl ResourceCache {
             self.cached_render_tasks.clear();
         }
         if what.contains(ClearCache::TEXTURE_CACHE) {
             self.texture_cache.clear();
         }
     }
 
     pub fn clear_namespace(&mut self, namespace: IdNamespace) {
+        println!("clearing namespace {:?}", namespace);
         self.resources
             .image_templates
             .images
             .retain(|key, _| key.0 != namespace);
         self.cached_images
             .clear_keys(|request| request.key.0 == namespace);
 
         self.resources.font_instances