Upstream version 7.36.149.0
[platform/framework/web/crosswalk.git] / src / cc / debug / debug_rect_history.cc
index e165aed..e8792e7 100644 (file)
@@ -12,6 +12,7 @@
 #include "cc/trees/damage_tracker.h"
 #include "cc/trees/layer_tree_host.h"
 #include "cc/trees/layer_tree_host_common.h"
+#include "ui/gfx/geometry/rect_conversions.h"
 
 namespace cc {
 
@@ -41,6 +42,9 @@ void DebugRectHistory::SaveDebugRectsForCurrentFrame(
   if (debug_state.show_wheel_event_handler_rects)
     SaveWheelEventHandlerRects(root_layer);
 
+  if (debug_state.show_scroll_event_handler_rects)
+    SaveScrollEventHandlerRects(root_layer);
+
   if (debug_state.show_non_fast_scrollable_rects)
     SaveNonFastScrollableRects(root_layer);
 
@@ -77,12 +81,12 @@ void DebugRectHistory::SavePaintRects(LayerImpl* layer) {
                         static_cast<float>(layer->bounds().width());
     float height_scale = layer->content_bounds().height() /
                          static_cast<float>(layer->bounds().height());
-    gfx::RectF update_content_rect =
-        gfx::ScaleRect(layer->update_rect(), width_scale, height_scale);
+    gfx::Rect update_content_rect = gfx::ScaleToEnclosingRect(
+        gfx::ToEnclosingRect(layer->update_rect()), width_scale, height_scale);
     debug_rects_.push_back(
         DebugRect(PAINT_RECT_TYPE,
-                  MathUtil::MapClippedRect(layer->screen_space_transform(),
-                                           update_content_rect)));
+                  MathUtil::MapEnclosingClippedRect(
+                      layer->screen_space_transform(), update_content_rect)));
   }
 
   for (unsigned i = 0; i < layer->children().size(); ++i)
@@ -112,13 +116,14 @@ void DebugRectHistory::SavePropertyChangedRects(
       if (layer == hud_layer)
         continue;
 
-      if (layer->LayerPropertyChanged()) {
-        debug_rects_.push_back(
-            DebugRect(PROPERTY_CHANGED_RECT_TYPE,
-                      MathUtil::MapEnclosingClippedRect(
-                          layer->screen_space_transform(),
-                          gfx::Rect(layer->content_bounds()))));
-      }
+      if (!layer->LayerPropertyChanged())
+        continue;
+
+      debug_rects_.push_back(
+          DebugRect(PROPERTY_CHANGED_RECT_TYPE,
+                    MathUtil::MapEnclosingClippedRect(
+                        layer->screen_space_transform(),
+                        gfx::Rect(layer->content_bounds()))));
     }
   }
 }
@@ -134,7 +139,7 @@ void DebugRectHistory::SaveSurfaceDamageRects(
 
     debug_rects_.push_back(DebugRect(
         SURFACE_DAMAGE_RECT_TYPE,
-        MathUtil::MapClippedRect(
+        MathUtil::MapEnclosingClippedRect(
             render_surface->screen_space_transform(),
             render_surface->damage_tracker()->current_damage_rect())));
   }
@@ -149,15 +154,16 @@ void DebugRectHistory::SaveScreenSpaceRects(
     RenderSurfaceImpl* render_surface = render_surface_layer->render_surface();
     DCHECK(render_surface);
 
-    debug_rects_.push_back(DebugRect(
-        SCREEN_SPACE_RECT_TYPE,
-        MathUtil::MapClippedRect(render_surface->screen_space_transform(),
-                                 render_surface->content_rect())));
+    debug_rects_.push_back(
+        DebugRect(SCREEN_SPACE_RECT_TYPE,
+                  MathUtil::MapEnclosingClippedRect(
+                      render_surface->screen_space_transform(),
+                      render_surface->content_rect())));
 
     if (render_surface_layer->replica_layer()) {
       debug_rects_.push_back(
           DebugRect(REPLICA_SCREEN_SPACE_RECT_TYPE,
-                    MathUtil::MapClippedRect(
+                    MathUtil::MapEnclosingClippedRect(
                         render_surface->replica_screen_space_transform(),
                         render_surface->content_rect())));
     }
@@ -189,13 +195,12 @@ void DebugRectHistory::SaveTouchEventHandlerRectsCallback(LayerImpl* layer) {
   for (Region::Iterator iter(layer->touch_event_handler_region());
        iter.has_rect();
        iter.next()) {
-    gfx::RectF touch_rect = gfx::ScaleRect(iter.rect(),
-                                           layer->contents_scale_x(),
-                                           layer->contents_scale_y());
-    debug_rects_.push_back(DebugRect(TOUCH_EVENT_HANDLER_RECT_TYPE,
-                                     MathUtil::MapClippedRect(
-                                         layer->screen_space_transform(),
-                                         touch_rect)));
+    gfx::Rect touch_rect = gfx::ScaleToEnclosingRect(
+        iter.rect(), layer->contents_scale_x(), layer->contents_scale_y());
+    debug_rects_.push_back(
+        DebugRect(TOUCH_EVENT_HANDLER_RECT_TYPE,
+                  MathUtil::MapEnclosingClippedRect(
+                      layer->screen_space_transform(), touch_rect)));
   }
 }
 
@@ -210,12 +215,35 @@ void DebugRectHistory::SaveWheelEventHandlerRectsCallback(LayerImpl* layer) {
   if (!layer->have_wheel_event_handlers())
     return;
 
-  gfx::RectF wheel_rect = gfx::RectF(layer->content_bounds());
-  wheel_rect.Scale(layer->contents_scale_x(), layer->contents_scale_y());
-  debug_rects_.push_back(DebugRect(WHEEL_EVENT_HANDLER_RECT_TYPE,
-                                   MathUtil::MapClippedRect(
-                                       layer->screen_space_transform(),
-                                       wheel_rect)));
+  gfx::Rect wheel_rect =
+      gfx::ScaleToEnclosingRect(gfx::Rect(layer->content_bounds()),
+                                layer->contents_scale_x(),
+                                layer->contents_scale_y());
+  debug_rects_.push_back(
+      DebugRect(WHEEL_EVENT_HANDLER_RECT_TYPE,
+                MathUtil::MapEnclosingClippedRect(
+                    layer->screen_space_transform(), wheel_rect)));
+}
+
+void DebugRectHistory::SaveScrollEventHandlerRects(LayerImpl* layer) {
+  LayerTreeHostCommon::CallFunctionForSubtree<LayerImpl>(
+      layer,
+      base::Bind(&DebugRectHistory::SaveScrollEventHandlerRectsCallback,
+                 base::Unretained(this)));
+}
+
+void DebugRectHistory::SaveScrollEventHandlerRectsCallback(LayerImpl* layer) {
+  if (!layer->have_scroll_event_handlers())
+    return;
+
+  gfx::Rect scroll_rect =
+      gfx::ScaleToEnclosingRect(gfx::Rect(layer->content_bounds()),
+                                layer->contents_scale_x(),
+                                layer->contents_scale_y());
+  debug_rects_.push_back(
+      DebugRect(SCROLL_EVENT_HANDLER_RECT_TYPE,
+                MathUtil::MapEnclosingClippedRect(
+                    layer->screen_space_transform(), scroll_rect)));
 }
 
 void DebugRectHistory::SaveNonFastScrollableRects(LayerImpl* layer) {
@@ -229,13 +257,12 @@ void DebugRectHistory::SaveNonFastScrollableRectsCallback(LayerImpl* layer) {
   for (Region::Iterator iter(layer->non_fast_scrollable_region());
        iter.has_rect();
        iter.next()) {
-    gfx::RectF scroll_rect = gfx::ScaleRect(iter.rect(),
-                                            layer->contents_scale_x(),
-                                            layer->contents_scale_y());
-    debug_rects_.push_back(DebugRect(NON_FAST_SCROLLABLE_RECT_TYPE,
-                                     MathUtil::MapClippedRect(
-                                         layer->screen_space_transform(),
-                                         scroll_rect)));
+    gfx::Rect scroll_rect = gfx::ScaleToEnclosingRect(
+        iter.rect(), layer->contents_scale_x(), layer->contents_scale_y());
+    debug_rects_.push_back(
+        DebugRect(NON_FAST_SCROLLABLE_RECT_TYPE,
+                  MathUtil::MapEnclosingClippedRect(
+                      layer->screen_space_transform(), scroll_rect)));
   }
 }
 
@@ -255,11 +282,12 @@ void DebugRectHistory::SaveLayerAnimationBoundsRects(
     if (!LayerUtils::GetAnimationBounds(**it, &inflated_bounds))
       continue;
 
-    debug_rects_.push_back(DebugRect(ANIMATION_BOUNDS_RECT_TYPE,
-                                     gfx::RectF(inflated_bounds.x(),
-                                                inflated_bounds.y(),
-                                                inflated_bounds.width(),
-                                                inflated_bounds.height())));
+    debug_rects_.push_back(
+        DebugRect(ANIMATION_BOUNDS_RECT_TYPE,
+                  gfx::ToEnclosingRect(gfx::RectF(inflated_bounds.x(),
+                                                  inflated_bounds.y(),
+                                                  inflated_bounds.width(),
+                                                  inflated_bounds.height()))));
   }
 }