summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--cc/DEPS3
-rw-r--r--cc/cc.gyp4
-rw-r--r--cc/cc_tests.gyp1
-rw-r--r--cc/layer.h2
-rw-r--r--cc/layer_impl.h2
-rw-r--r--cc/layer_sorter.cc1
-rw-r--r--cc/layer_tiling_data.h2
-rw-r--r--cc/layer_tree_host.cc1
-rw-r--r--cc/layer_tree_host_impl.cc3
-rw-r--r--cc/layer_tree_host_impl_unittest.cc9
-rw-r--r--cc/layer_tree_host_unittest.cc118
-rw-r--r--cc/math_util.cc11
-rw-r--r--cc/math_util.h8
-rw-r--r--cc/occlusion_tracker.cc62
-rw-r--r--cc/occlusion_tracker.h6
-rw-r--r--cc/occlusion_tracker_unittest.cc408
-rw-r--r--cc/quad_culler.cc1
-rw-r--r--cc/region.cc109
-rw-r--r--cc/region.h125
-rw-r--r--cc/region_unittest.cc420
-rw-r--r--cc/render_surface_impl.cc2
-rw-r--r--cc/stubs/Region.h98
-rw-r--r--cc/test/layer_test_common.cc2
-rw-r--r--cc/test/occlusion_tracker_test_common.h9
-rw-r--r--cc/test/tiled_layer_test_common.h2
-rw-r--r--cc/tiled_layer.cc1
-rw-r--r--cc/tiled_layer_unittest.cc16
-rw-r--r--cc/tree_synchronizer_unittest.cc3
-rw-r--r--webkit/compositor_bindings/web_layer_impl.cc40
29 files changed, 954 insertions, 515 deletions
diff --git a/cc/DEPS b/cc/DEPS
index a669999..5ff5bd1 100644
--- a/cc/DEPS
+++ b/cc/DEPS
@@ -5,9 +5,6 @@ include_rules = [
"+third_party/khronos/GLES2/gl2ext.h",
"+ui/gfx",
"+media",
-# http://crbug.com/147395
- "+third_party/WebKit/Source/WebCore/platform/graphics/Region.h",
- "+Source/WebCore/platform/graphics/Region.h",
# http://crbug.com/154451
"+third_party/WebKit/Source/WTF/config.h",
"+Source/WTF/config.h",
diff --git a/cc/cc.gyp b/cc/cc.gyp
index b86e388..b4c0892 100644
--- a/cc/cc.gyp
+++ b/cc/cc.gyp
@@ -135,6 +135,8 @@
'quad_sink.h',
'rate_limiter.cc',
'rate_limiter.h',
+ 'region.cc',
+ 'region.h',
'render_pass.cc',
'render_pass.h',
'render_pass_draw_quad.cc',
@@ -271,8 +273,6 @@
],
'sources': [
'<@(cc_source_files)',
- 'stubs/Region.h',
-
'stubs/config.h',
],
},
diff --git a/cc/cc_tests.gyp b/cc/cc_tests.gyp
index cc96c31..5d741e9 100644
--- a/cc/cc_tests.gyp
+++ b/cc/cc_tests.gyp
@@ -34,6 +34,7 @@
'occlusion_tracker_unittest.cc',
'prioritized_resource_unittest.cc',
'quad_culler_unittest.cc',
+ 'region_unittest.cc',
'render_pass_unittest.cc',
'render_surface_filters_unittest.cc',
'render_surface_unittest.cc',
diff --git a/cc/layer.h b/cc/layer.h
index 963f17f..3d7178c 100644
--- a/cc/layer.h
+++ b/cc/layer.h
@@ -5,11 +5,11 @@
#ifndef CC_LAYER_H_
#define CC_LAYER_H_
-#include "Region.h"
#include "base/memory/ref_counted.h"
#include "cc/cc_export.h"
#include "cc/layer_animation_controller.h"
#include "cc/occlusion_tracker.h"
+#include "cc/region.h"
#include "cc/render_surface.h"
#include "third_party/skia/include/core/SkColor.h"
#include "ui/gfx/rect.h"
diff --git a/cc/layer_impl.h b/cc/layer_impl.h
index b382de0..f773c13 100644
--- a/cc/layer_impl.h
+++ b/cc/layer_impl.h
@@ -7,12 +7,12 @@
#include <string>
-#include "Region.h"
#include "base/logging.h"
#include "base/memory/scoped_ptr.h"
#include "cc/cc_export.h"
#include "cc/input_handler.h"
#include "cc/layer_animation_controller.h"
+#include "cc/region.h"
#include "cc/render_pass.h"
#include "cc/render_surface_impl.h"
#include "cc/resource_provider.h"
diff --git a/cc/layer_sorter.cc b/cc/layer_sorter.cc
index 2e37425..8cf9dcd 100644
--- a/cc/layer_sorter.cc
+++ b/cc/layer_sorter.cc
@@ -6,6 +6,7 @@
#include "cc/layer_sorter.h"
+#include <algorithm>
#include <deque>
#include <limits>
#include <vector>
diff --git a/cc/layer_tiling_data.h b/cc/layer_tiling_data.h
index 36a029a..07d3c40 100644
--- a/cc/layer_tiling_data.h
+++ b/cc/layer_tiling_data.h
@@ -10,10 +10,10 @@
#include "base/memory/scoped_ptr.h"
#include "cc/cc_export.h"
#include "cc/hash_pair.h"
+#include "cc/region.h"
#include "cc/scoped_ptr_hash_map.h"
#include "cc/tiling_data.h"
#include "ui/gfx/rect.h"
-#include "Region.h"
namespace cc {
diff --git a/cc/layer_tree_host.cc b/cc/layer_tree_host.cc
index dde7042..2dc15171 100644
--- a/cc/layer_tree_host.cc
+++ b/cc/layer_tree_host.cc
@@ -6,7 +6,6 @@
#include "cc/layer_tree_host.h"
-#include "Region.h"
#include "base/debug/trace_event.h"
#include "base/message_loop.h"
#include "cc/font_atlas.h"
diff --git a/cc/layer_tree_host_impl.cc b/cc/layer_tree_host_impl.cc
index 5675aba..3ae140f 100644
--- a/cc/layer_tree_host_impl.cc
+++ b/cc/layer_tree_host_impl.cc
@@ -6,6 +6,8 @@
#include "cc/layer_tree_host_impl.h"
+#include <algorithm>
+
#include "base/basictypes.h"
#include "base/debug/trace_event.h"
#include "cc/append_quads_data.h"
@@ -34,7 +36,6 @@
#include "cc/texture_uploader.h"
#include "ui/gfx/size_conversions.h"
#include "ui/gfx/vector2d_conversions.h"
-#include <algorithm>
using WebKit::WebTransformationMatrix;
diff --git a/cc/layer_tree_host_impl_unittest.cc b/cc/layer_tree_host_impl_unittest.cc
index 61c7d27..43628e5 100644
--- a/cc/layer_tree_host_impl_unittest.cc
+++ b/cc/layer_tree_host_impl_unittest.cc
@@ -6,6 +6,8 @@
#include "cc/layer_tree_host_impl.h"
+#include <cmath>
+
#include "base/bind.h"
#include "base/command_line.h"
#include "base/hash_tables.h"
@@ -16,6 +18,7 @@
#include "cc/io_surface_layer_impl.h"
#include "cc/layer_impl.h"
#include "cc/layer_tiling_data.h"
+#include "cc/math_util.h"
#include "cc/quad_sink.h"
#include "cc/render_pass_draw_quad.h"
#include "cc/scrollbar_geometry_fixed_thumb.h"
@@ -1449,7 +1452,7 @@ TEST_P(LayerTreeHostImplTest, scrollNonAxisAlignedRotatedLayer)
// The child layer should have scrolled down in its local coordinates an amount proportional to
// the angle between it and the input scroll delta.
- gfx::Vector2d expectedScrollDelta(0, gestureScrollDelta.y() * cosf(deg2rad(childLayerAngle)));
+ gfx::Vector2d expectedScrollDelta(0, gestureScrollDelta.y() * std::cos(MathUtil::Deg2Rad(childLayerAngle)));
scoped_ptr<ScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDeltas();
expectContains(*scrollInfo.get(), childLayerId, expectedScrollDelta);
@@ -1468,13 +1471,13 @@ TEST_P(LayerTreeHostImplTest, scrollNonAxisAlignedRotatedLayer)
// The child layer should have scrolled down in its local coordinates an amount proportional to
// the angle between it and the input scroll delta.
- gfx::Vector2d expectedScrollDelta(0, -gestureScrollDelta.x() * sinf(deg2rad(childLayerAngle)));
+ gfx::Vector2d expectedScrollDelta(0, -gestureScrollDelta.x() * std::sin(MathUtil::Deg2Rad(childLayerAngle)));
scoped_ptr<ScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDeltas();
expectContains(*scrollInfo.get(), childLayerId, expectedScrollDelta);
// The root layer should have scrolled more, since the input scroll delta was mostly
// orthogonal to the child layer's vertical scroll axis.
- gfx::Vector2d expectedRootScrollDelta(gestureScrollDelta.x() * pow(cosf(deg2rad(childLayerAngle)), 2), 0);
+ gfx::Vector2d expectedRootScrollDelta(gestureScrollDelta.x() * std::pow(std::cos(MathUtil::Deg2Rad(childLayerAngle)), 2), 0);
expectContains(*scrollInfo.get(), m_hostImpl->rootLayer()->id(), expectedRootScrollDelta);
}
}
diff --git a/cc/layer_tree_host_unittest.cc b/cc/layer_tree_host_unittest.cc
index 5d85f1c..f251e1c 100644
--- a/cc/layer_tree_host_unittest.cc
+++ b/cc/layer_tree_host_unittest.cc
@@ -1689,12 +1689,9 @@ public:
m_layerTreeHost->updateLayers(queue, std::numeric_limits<size_t>::max());
m_layerTreeHost->commitComplete();
- EXPECT_RECT_EQ(gfx::Rect(), grandChild->occludedScreenSpace().bounds());
- EXPECT_EQ(0u, Region::Iterator(grandChild->occludedScreenSpace()).size());
- EXPECT_RECT_EQ(gfx::Rect(30, 40, 170, 160), child->occludedScreenSpace().bounds());
- EXPECT_EQ(1u, Region::Iterator(child->occludedScreenSpace()).size());
- EXPECT_RECT_EQ(gfx::Rect(30, 40, 170, 160), rootLayer->occludedScreenSpace().bounds());
- EXPECT_EQ(1u, Region::Iterator(rootLayer->occludedScreenSpace()).size());
+ EXPECT_EQ(gfx::Rect().ToString(), grandChild->occludedScreenSpace().ToString());
+ EXPECT_EQ(gfx::Rect(30, 40, 170, 160).ToString(), child->occludedScreenSpace().ToString());
+ EXPECT_EQ(gfx::Rect(30, 40, 170, 160).ToString(), rootLayer->occludedScreenSpace().ToString());
// If the child layer is opaque, then it adds to the occlusion seen by the rootLayer.
setLayerPropertiesForTesting(rootLayer.get(), 0, identityMatrix, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(200, 200), true);
@@ -1706,12 +1703,9 @@ public:
m_layerTreeHost->updateLayers(queue, std::numeric_limits<size_t>::max());
m_layerTreeHost->commitComplete();
- EXPECT_RECT_EQ(gfx::Rect(), grandChild->occludedScreenSpace().bounds());
- EXPECT_EQ(0u, Region::Iterator(grandChild->occludedScreenSpace()).size());
- EXPECT_RECT_EQ(gfx::Rect(30, 40, 170, 160), child->occludedScreenSpace().bounds());
- EXPECT_EQ(1u, Region::Iterator(child->occludedScreenSpace()).size());
- EXPECT_RECT_EQ(gfx::Rect(30, 30, 170, 170), rootLayer->occludedScreenSpace().bounds());
- EXPECT_EQ(1u, Region::Iterator(rootLayer->occludedScreenSpace()).size());
+ EXPECT_EQ(gfx::Rect().ToString(), grandChild->occludedScreenSpace().ToString());
+ EXPECT_EQ(gfx::Rect(30, 40, 170, 160).ToString(), child->occludedScreenSpace().ToString());
+ EXPECT_EQ(gfx::Rect(30, 30, 170, 170).ToString(), rootLayer->occludedScreenSpace().ToString());
// Add a second child to the root layer and the regions should merge
setTestLayerPropertiesForTesting(rootLayer.get(), 0, identityMatrix, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(200, 200), true);
@@ -1724,14 +1718,10 @@ public:
m_layerTreeHost->updateLayers(queue, std::numeric_limits<size_t>::max());
m_layerTreeHost->commitComplete();
- EXPECT_RECT_EQ(gfx::Rect(), grandChild->occludedScreenSpace().bounds());
- EXPECT_EQ(0u, Region::Iterator(grandChild->occludedScreenSpace()).size());
- EXPECT_RECT_EQ(gfx::Rect(30, 40, 170, 160), child->occludedScreenSpace().bounds());
- EXPECT_EQ(1u, Region::Iterator(child->occludedScreenSpace()).size());
- EXPECT_RECT_EQ(gfx::Rect(30, 30, 170, 170), child2->occludedScreenSpace().bounds());
- EXPECT_EQ(1u, Region::Iterator(child2->occludedScreenSpace()).size());
- EXPECT_RECT_EQ(gfx::Rect(30, 20, 170, 180), rootLayer->occludedScreenSpace().bounds());
- EXPECT_EQ(2u, Region::Iterator(rootLayer->occludedScreenSpace()).size());
+ EXPECT_EQ(gfx::Rect().ToString(), grandChild->occludedScreenSpace().ToString());
+ EXPECT_EQ(gfx::Rect(30, 40, 170, 160).ToString(), child->occludedScreenSpace().ToString());
+ EXPECT_EQ(gfx::Rect(30, 30, 170, 170).ToString(), child2->occludedScreenSpace().ToString());
+ EXPECT_EQ(UnionRegions(gfx::Rect(30, 30, 170, 170), gfx::Rect(70, 20, 130, 180)).ToString(), rootLayer->occludedScreenSpace().ToString());
// Move the second child to be sure.
setTestLayerPropertiesForTesting(rootLayer.get(), 0, identityMatrix, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(200, 200), true);
@@ -1744,14 +1734,10 @@ public:
m_layerTreeHost->updateLayers(queue, std::numeric_limits<size_t>::max());
m_layerTreeHost->commitComplete();
- EXPECT_RECT_EQ(gfx::Rect(), grandChild->occludedScreenSpace().bounds());
- EXPECT_EQ(0u, Region::Iterator(grandChild->occludedScreenSpace()).size());
- EXPECT_RECT_EQ(gfx::Rect(30, 40, 170, 160), child->occludedScreenSpace().bounds());
- EXPECT_EQ(1u, Region::Iterator(child->occludedScreenSpace()).size());
- EXPECT_RECT_EQ(gfx::Rect(30, 30, 170, 170), child2->occludedScreenSpace().bounds());
- EXPECT_EQ(1u, Region::Iterator(child2->occludedScreenSpace()).size());
- EXPECT_RECT_EQ(gfx::Rect(10, 30, 190, 170), rootLayer->occludedScreenSpace().bounds());
- EXPECT_EQ(2u, Region::Iterator(rootLayer->occludedScreenSpace()).size());
+ EXPECT_EQ(gfx::Rect().ToString(), grandChild->occludedScreenSpace().ToString());
+ EXPECT_EQ(gfx::Rect(30, 40, 170, 160).ToString(), child->occludedScreenSpace().ToString());
+ EXPECT_EQ(gfx::Rect(30, 30, 170, 170).ToString(), child2->occludedScreenSpace().ToString());
+ EXPECT_EQ(UnionRegions(gfx::Rect(10, 70, 190, 130), gfx::Rect(30, 30, 170, 170)).ToString(), rootLayer->occludedScreenSpace().ToString());
// If the child layer has a mask on it, then it shouldn't contribute to occlusion on stuff below it
setLayerPropertiesForTesting(rootLayer.get(), 0, identityMatrix, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(200, 200), true);
@@ -1766,14 +1752,10 @@ public:
m_layerTreeHost->updateLayers(queue, std::numeric_limits<size_t>::max());
m_layerTreeHost->commitComplete();
- EXPECT_RECT_EQ(gfx::Rect(), grandChild->occludedScreenSpace().bounds());
- EXPECT_EQ(0u, Region::Iterator(grandChild->occludedScreenSpace()).size());
- EXPECT_RECT_EQ(gfx::Rect(30, 40, 170, 160), child->occludedScreenSpace().bounds());
- EXPECT_EQ(1u, Region::Iterator(child->occludedScreenSpace()).size());
- EXPECT_RECT_EQ(gfx::Rect(), child2->occludedScreenSpace().bounds());
- EXPECT_EQ(0u, Region::Iterator(child2->occludedScreenSpace()).size());
- EXPECT_RECT_EQ(gfx::Rect(10, 70, 190, 130), rootLayer->occludedScreenSpace().bounds());
- EXPECT_EQ(1u, Region::Iterator(rootLayer->occludedScreenSpace()).size());
+ EXPECT_EQ(gfx::Rect().ToString(), grandChild->occludedScreenSpace().ToString());
+ EXPECT_EQ(gfx::Rect(30, 40, 170, 160).ToString(), child->occludedScreenSpace().ToString());
+ EXPECT_EQ(gfx::Rect().ToString(), child2->occludedScreenSpace().ToString());
+ EXPECT_EQ(gfx::Rect(10, 70, 190, 130).ToString(), rootLayer->occludedScreenSpace().ToString());
// If the child layer with a mask is below child2, then child2 should contribute to occlusion on everything, and child shouldn't contribute to the rootLayer
setLayerPropertiesForTesting(rootLayer.get(), 0, identityMatrix, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(200, 200), true);
@@ -1788,14 +1770,10 @@ public:
m_layerTreeHost->updateLayers(queue, std::numeric_limits<size_t>::max());
m_layerTreeHost->commitComplete();
- EXPECT_RECT_EQ(gfx::Rect(), child2->occludedScreenSpace().bounds());
- EXPECT_EQ(0u, Region::Iterator(child2->occludedScreenSpace()).size());
- EXPECT_RECT_EQ(gfx::Rect(10, 70, 190, 130), grandChild->occludedScreenSpace().bounds());
- EXPECT_EQ(1u, Region::Iterator(grandChild->occludedScreenSpace()).size());
- EXPECT_RECT_EQ(gfx::Rect(10, 40, 190, 160), child->occludedScreenSpace().bounds());
- EXPECT_EQ(2u, Region::Iterator(child->occludedScreenSpace()).size());
- EXPECT_RECT_EQ(gfx::Rect(10, 70, 190, 130), rootLayer->occludedScreenSpace().bounds());
- EXPECT_EQ(1u, Region::Iterator(rootLayer->occludedScreenSpace()).size());
+ EXPECT_EQ(gfx::Rect().ToString(), child2->occludedScreenSpace().ToString());
+ EXPECT_EQ(gfx::Rect(10, 70, 190, 130).ToString(), grandChild->occludedScreenSpace().ToString());
+ EXPECT_EQ(UnionRegions(gfx::Rect(30, 40, 170, 160), gfx::Rect(10, 70, 190, 130)).ToString(), child->occludedScreenSpace().ToString());
+ EXPECT_EQ(gfx::Rect(10, 70, 190, 130), rootLayer->occludedScreenSpace());
// If the child layer has a non-opaque drawOpacity, then it shouldn't contribute to occlusion on stuff below it
setTestLayerPropertiesForTesting(rootLayer.get(), 0, identityMatrix, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(200, 200), true);
@@ -1811,14 +1789,10 @@ public:
m_layerTreeHost->updateLayers(queue, std::numeric_limits<size_t>::max());
m_layerTreeHost->commitComplete();
- EXPECT_RECT_EQ(gfx::Rect(), grandChild->occludedScreenSpace().bounds());
- EXPECT_EQ(0u, Region::Iterator(grandChild->occludedScreenSpace()).size());
- EXPECT_RECT_EQ(gfx::Rect(30, 40, 170, 160), child->occludedScreenSpace().bounds());
- EXPECT_EQ(1u, Region::Iterator(child->occludedScreenSpace()).size());
- EXPECT_RECT_EQ(gfx::Rect(), child2->occludedScreenSpace().bounds());
- EXPECT_EQ(0u, Region::Iterator(child2->occludedScreenSpace()).size());
- EXPECT_RECT_EQ(gfx::Rect(10, 70, 190, 130), rootLayer->occludedScreenSpace().bounds());
- EXPECT_EQ(1u, Region::Iterator(rootLayer->occludedScreenSpace()).size());
+ EXPECT_EQ(gfx::Rect().ToString(), grandChild->occludedScreenSpace().ToString());
+ EXPECT_EQ(gfx::Rect(30, 40, 170, 160).ToString(), child->occludedScreenSpace().ToString());
+ EXPECT_EQ(gfx::Rect().ToString(), child2->occludedScreenSpace().ToString());
+ EXPECT_EQ(gfx::Rect(10, 70, 190, 130).ToString(), rootLayer->occludedScreenSpace().ToString());
// If the child layer with non-opaque drawOpacity is below child2, then child2 should contribute to occlusion on everything, and child shouldn't contribute to the rootLayer
setTestLayerPropertiesForTesting(rootLayer.get(), 0, identityMatrix, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(200, 200), true);
@@ -1834,14 +1808,10 @@ public:
m_layerTreeHost->updateLayers(queue, std::numeric_limits<size_t>::max());
m_layerTreeHost->commitComplete();
- EXPECT_RECT_EQ(gfx::Rect(), child2->occludedScreenSpace().bounds());
- EXPECT_EQ(0u, Region::Iterator(child2->occludedScreenSpace()).size());
- EXPECT_RECT_EQ(gfx::Rect(10, 70, 190, 130), grandChild->occludedScreenSpace().bounds());
- EXPECT_EQ(1u, Region::Iterator(grandChild->occludedScreenSpace()).size());
- EXPECT_RECT_EQ(gfx::Rect(10, 40, 190, 160), child->occludedScreenSpace().bounds());
- EXPECT_EQ(2u, Region::Iterator(child->occludedScreenSpace()).size());
- EXPECT_RECT_EQ(gfx::Rect(10, 70, 190, 130), rootLayer->occludedScreenSpace().bounds());
- EXPECT_EQ(1u, Region::Iterator(rootLayer->occludedScreenSpace()).size());
+ EXPECT_EQ(gfx::Rect().ToString(), child2->occludedScreenSpace().ToString());
+ EXPECT_EQ(gfx::Rect(10, 70, 190, 130).ToString(), grandChild->occludedScreenSpace().ToString());
+ EXPECT_EQ(UnionRegions(gfx::Rect(30, 40, 170, 160), gfx::Rect(10, 70, 190, 130)).ToString(), child->occludedScreenSpace().ToString());
+ EXPECT_EQ(gfx::Rect(10, 70, 190, 130).ToString(), rootLayer->occludedScreenSpace().ToString());
// Kill the layerTreeHost immediately.
m_layerTreeHost->setRootLayer(0);
@@ -1897,14 +1867,10 @@ public:
m_layerTreeHost->updateLayers(queue, std::numeric_limits<size_t>::max());
m_layerTreeHost->commitComplete();
- EXPECT_RECT_EQ(gfx::Rect(), child2->occludedScreenSpace().bounds());
- EXPECT_EQ(0u, Region::Iterator(child2->occludedScreenSpace()).size());
- EXPECT_RECT_EQ(gfx::Rect(10, 70, 190, 130), grandChild->occludedScreenSpace().bounds());
- EXPECT_EQ(1u, Region::Iterator(grandChild->occludedScreenSpace()).size());
- EXPECT_RECT_EQ(gfx::Rect(10, 40, 190, 160), child->occludedScreenSpace().bounds());
- EXPECT_EQ(2u, Region::Iterator(child->occludedScreenSpace()).size());
- EXPECT_RECT_EQ(gfx::Rect(10, 70, 190, 130), rootLayer->occludedScreenSpace().bounds());
- EXPECT_EQ(1u, Region::Iterator(rootLayer->occludedScreenSpace()).size());
+ EXPECT_EQ(gfx::Rect().ToString(), child2->occludedScreenSpace().ToString());
+ EXPECT_EQ(gfx::Rect(10, 70, 190, 130).ToString(), grandChild->occludedScreenSpace().ToString());
+ EXPECT_EQ(UnionRegions(gfx::Rect(30, 40, 170, 30), gfx::Rect(10, 70, 190, 130)).ToString(), child->occludedScreenSpace().ToString());
+ EXPECT_EQ(gfx::Rect(10, 70, 190, 130).ToString(), rootLayer->occludedScreenSpace().ToString());
// If the child layer has a filter that moves pixels/changes alpha, and is below child2, then child should not inherit occlusion from outside its subtree,
// and should not contribute to the rootLayer
@@ -1924,14 +1890,10 @@ public:
m_layerTreeHost->updateLayers(queue, std::numeric_limits<size_t>::max());
m_layerTreeHost->commitComplete();
- EXPECT_RECT_EQ(gfx::Rect(), child2->occludedScreenSpace().bounds());
- EXPECT_EQ(0u, Region::Iterator(child2->occludedScreenSpace()).size());
- EXPECT_RECT_EQ(gfx::Rect(), grandChild->occludedScreenSpace().bounds());
- EXPECT_EQ(0u, Region::Iterator(grandChild->occludedScreenSpace()).size());
- EXPECT_RECT_EQ(gfx::Rect(30, 40, 170, 160), child->occludedScreenSpace().bounds());
- EXPECT_EQ(1u, Region::Iterator(child->occludedScreenSpace()).size());
- EXPECT_RECT_EQ(gfx::Rect(10, 70, 190, 130), rootLayer->occludedScreenSpace().bounds());
- EXPECT_EQ(1u, Region::Iterator(rootLayer->occludedScreenSpace()).size());
+ EXPECT_EQ(gfx::Rect().ToString(), child2->occludedScreenSpace().ToString());
+ EXPECT_EQ(gfx::Rect().ToString(), grandChild->occludedScreenSpace().ToString());
+ EXPECT_EQ(gfx::Rect(30, 40, 170, 160).ToString(), child->occludedScreenSpace().ToString());
+ EXPECT_EQ(gfx::Rect(10, 70, 190, 130).ToString(), rootLayer->occludedScreenSpace().ToString());
// Kill the layerTreeHost immediately.
m_layerTreeHost->setRootLayer(0);
@@ -1988,9 +1950,7 @@ public:
for (int i = 0; i < numSurfaces-1; ++i) {
gfx::Rect expectedOcclusion(i+1, i+1, 200-i-1, 200-i-1);
-
- EXPECT_RECT_EQ(expectedOcclusion, layers[i]->occludedScreenSpace().bounds());
- EXPECT_EQ(1u, Region::Iterator(layers[i]->occludedScreenSpace()).size());
+ EXPECT_EQ(expectedOcclusion.ToString(), layers[i]->occludedScreenSpace().ToString());
}
// Kill the layerTreeHost immediately.
diff --git a/cc/math_util.cc b/cc/math_util.cc
index 83d156c..f18b8401 100644
--- a/cc/math_util.cc
+++ b/cc/math_util.cc
@@ -20,6 +20,9 @@ using WebKit::WebTransformationMatrix;
namespace cc {
+const double MathUtil::PI_DOUBLE = 3.14159265358979323846;
+const float MathUtil::PI_FLOAT = 3.14159265358979323846f;
+
static HomogeneousCoordinate projectHomogeneousPoint(const WebTransformationMatrix& transform, const gfx::PointF& p)
{
// In this case, the layer we are trying to project onto is perpendicular to ray
@@ -380,18 +383,12 @@ gfx::Vector2dF MathUtil::computeTransform2dScaleComponents(const WebTransformati
return gfx::Vector2dF(xScale, yScale);
}
-static inline double rad2deg(double r)
-{
- double pi = 3.14159265358979323846;
- return r * 180.0 / pi;
-}
-
float MathUtil::smallestAngleBetweenVectors(gfx::Vector2dF v1, gfx::Vector2dF v2)
{
double dotProduct = gfx::DotProduct(v1, v2) / v1.Length() / v2.Length();
// Clamp to compensate for rounding errors.
dotProduct = std::max(-1.0, std::min(1.0, dotProduct));
- return static_cast<float>(rad2deg(std::acos(dotProduct)));
+ return static_cast<float>(Rad2Deg(std::acos(dotProduct)));
}
gfx::Vector2dF MathUtil::projectVector(gfx::Vector2dF source, gfx::Vector2dF destination)
diff --git a/cc/math_util.h b/cc/math_util.h
index 1caf659..fe17800 100644
--- a/cc/math_util.h
+++ b/cc/math_util.h
@@ -67,6 +67,14 @@ struct HomogeneousCoordinate {
class CC_EXPORT MathUtil {
public:
+ static const double PI_DOUBLE;
+ static const float PI_FLOAT;
+
+ static double Deg2Rad(double deg) { return deg * PI_DOUBLE / 180; }
+ static double Rad2Deg(double rad) { return rad * 180 / PI_DOUBLE; }
+
+ static float Deg2Rad(float deg) { return deg * PI_FLOAT / 180; }
+ static float Rad2Deg(float rad) { return rad * 180 / PI_FLOAT; }
// Background: WebTransformationMatrix code in WebCore does not do the right thing in
// mapRect / mapQuad / projectQuad when there is a perspective projection that causes
diff --git a/cc/occlusion_tracker.cc b/cc/occlusion_tracker.cc
index 2e953ce..50a453e 100644
--- a/cc/occlusion_tracker.cc
+++ b/cc/occlusion_tracker.cc
@@ -58,14 +58,14 @@ void OcclusionTrackerBase<LayerType, RenderSurfaceType>::leaveLayer(const LayerI
template<typename LayerType, typename RenderSurfaceType>
void OcclusionTrackerBase<LayerType, RenderSurfaceType>::enterRenderTarget(const LayerType* newTarget)
{
- if (!m_stack.isEmpty() && m_stack.last().target == newTarget)
+ if (!m_stack.empty() && m_stack.back().target == newTarget)
return;
- const LayerType* oldTarget = m_stack.isEmpty() ? 0 : m_stack.last().target;
+ const LayerType* oldTarget = m_stack.empty() ? 0 : m_stack.back().target;
const RenderSurfaceType* oldAncestorThatMovesPixels = !oldTarget ? 0 : oldTarget->renderSurface()->nearestAncestorThatMovesPixels();
const RenderSurfaceType* newAncestorThatMovesPixels = newTarget->renderSurface()->nearestAncestorThatMovesPixels();
- m_stack.append(StackObject(newTarget));
+ m_stack.push_back(StackObject(newTarget));
// We copy the screen occlusion into the new RenderSurfaceImpl subtree, but we never copy in the
// target occlusion, since we are looking at a new RenderSurfaceImpl target.
@@ -111,13 +111,13 @@ void OcclusionTrackerBase<LayerType, RenderSurfaceType>::finishedRenderTarget(co
// TODO(senorblanco): Make this smarter for SkImageFilter case: once
// SkImageFilters can report affectsOpacity(), call that.
if (finishedTarget->maskLayer() || !surfaceOpacityKnown(surface) || surface->drawOpacity() < 1 || finishedTarget->filters().hasFilterThatAffectsOpacity() || finishedTarget->filter()) {
- m_stack.last().occlusionInScreen = Region();
- m_stack.last().occlusionInTarget = Region();
+ m_stack.back().occlusionInScreen = Region();
+ m_stack.back().occlusionInTarget = Region();
} else {
if (!surfaceTransformsToTargetKnown(surface))
- m_stack.last().occlusionInTarget = Region();
+ m_stack.back().occlusionInTarget = Region();
if (!surfaceTransformsToScreenKnown(surface))
- m_stack.last().occlusionInScreen = Region();
+ m_stack.back().occlusionInScreen = Region();
}
}
@@ -150,7 +150,7 @@ static inline void reduceOcclusion(const gfx::Rect& affectedArea, const gfx::Rec
if (affectedArea.IsEmpty())
return;
- Region affectedOcclusion = intersect(occlusion, affectedArea);
+ Region affectedOcclusion = IntersectRegions(occlusion, affectedArea);
Region::Iterator affectedOcclusionRects(affectedOcclusion);
occlusion.Subtract(affectedArea);
@@ -234,17 +234,17 @@ void OcclusionTrackerBase<LayerType, RenderSurfaceType>::leaveToRenderTarget(con
// Merge the top of the stack down.
m_stack[lastIndex - 1].occlusionInScreen.Union(m_stack[lastIndex].occlusionInScreen);
m_stack[lastIndex - 1].occlusionInTarget.Union(oldTargetOcclusionInNewTarget);
- m_stack.removeLast();
+ m_stack.pop_back();
} else {
// Replace the top of the stack with the new pushed surface. Copy the occluded screen region to the top.
- m_stack.last().target = newTarget;
- m_stack.last().occlusionInTarget = oldTargetOcclusionInNewTarget;
+ m_stack.back().target = newTarget;
+ m_stack.back().occlusionInTarget = oldTargetOcclusionInNewTarget;
}
if (oldTarget->backgroundFilters().hasFilterThatMovesPixels()) {
- reduceOcclusionBelowSurface(oldTarget, unoccludedSurfaceRect, oldSurface->drawTransform(), newTarget, m_stack.last().occlusionInTarget, m_stack.last().occlusionInScreen);
+ reduceOcclusionBelowSurface(oldTarget, unoccludedSurfaceRect, oldSurface->drawTransform(), newTarget, m_stack.back().occlusionInTarget, m_stack.back().occlusionInScreen);
if (oldTarget->hasReplica())
- reduceOcclusionBelowSurface(oldTarget, unoccludedReplicaRect, oldSurface->replicaDrawTransform(), newTarget, m_stack.last().occlusionInTarget, m_stack.last().occlusionInScreen);
+ reduceOcclusionBelowSurface(oldTarget, unoccludedReplicaRect, oldSurface->replicaDrawTransform(), newTarget, m_stack.back().occlusionInTarget, m_stack.back().occlusionInScreen);
}
}
@@ -275,9 +275,9 @@ static inline void addOcclusionBehindLayer(Region& region, const LayerType* laye
template<typename LayerType, typename RenderSurfaceType>
void OcclusionTrackerBase<LayerType, RenderSurfaceType>::markOccludedBehindLayer(const LayerType* layer)
{
- DCHECK(!m_stack.isEmpty());
- DCHECK(layer->renderTarget() == m_stack.last().target);
- if (m_stack.isEmpty())
+ DCHECK(!m_stack.empty());
+ DCHECK(layer->renderTarget() == m_stack.back().target);
+ if (m_stack.empty())
return;
if (!layerOpacityKnown(layer) || layer->drawOpacity() < 1)
@@ -292,20 +292,20 @@ void OcclusionTrackerBase<LayerType, RenderSurfaceType>::markOccludedBehindLayer
gfx::Rect clipRectInTarget = layerClipRectInTarget(layer);
if (layerTransformsToTargetKnown(layer))
- addOcclusionBehindLayer<LayerType>(m_stack.last().occlusionInTarget, layer, layer->drawTransform(), opaqueContents, clipRectInTarget, m_minimumTrackingSize, 0);
+ addOcclusionBehindLayer<LayerType>(m_stack.back().occlusionInTarget, layer, layer->drawTransform(), opaqueContents, clipRectInTarget, m_minimumTrackingSize, 0);
// We must clip the occlusion within the layer's clipRectInTarget within screen space as well. If the clip rect can't be moved to screen space and
// remain rectilinear, then we don't add any occlusion in screen space.
if (layerTransformsToScreenKnown(layer)) {
- WebTransformationMatrix targetToScreenTransform = m_stack.last().target->renderSurface()->screenSpaceTransform();
+ WebTransformationMatrix targetToScreenTransform = m_stack.back().target->renderSurface()->screenSpaceTransform();
bool clipped;
gfx::QuadF clipQuadInScreen = MathUtil::mapQuad(targetToScreenTransform, gfx::QuadF(clipRectInTarget), clipped);
// FIXME: Find a rect interior to the transformed clip quad.
if (clipped || !clipQuadInScreen.IsRectilinear())
return;
gfx::Rect clipRectInScreen = gfx::IntersectRects(m_rootTargetRect, gfx::ToEnclosedRect(clipQuadInScreen.BoundingBox()));
- addOcclusionBehindLayer<LayerType>(m_stack.last().occlusionInScreen, layer, layer->screenSpaceTransform(), opaqueContents, clipRectInScreen, m_minimumTrackingSize, m_occludingScreenSpaceRects);
+ addOcclusionBehindLayer<LayerType>(m_stack.back().occlusionInScreen, layer, layer->screenSpaceTransform(), opaqueContents, clipRectInScreen, m_minimumTrackingSize, m_occludingScreenSpaceRects);
}
}
@@ -323,20 +323,20 @@ bool OcclusionTrackerBase<LayerType, RenderSurfaceType>::occluded(const LayerTyp
if (hasOcclusionFromOutsideTargetSurface)
*hasOcclusionFromOutsideTargetSurface = false;
- DCHECK(!m_stack.isEmpty());
- if (m_stack.isEmpty())
+ DCHECK(!m_stack.empty());
+ if (m_stack.empty())
return false;
if (contentRect.IsEmpty())
return true;
- DCHECK(renderTarget == m_stack.last().target);
+ DCHECK(renderTarget == m_stack.back().target);
- if (!implDrawTransformIsUnknown && testContentRectOccluded(contentRect, drawTransform, clippedRectInTarget, m_stack.last().occlusionInTarget))
+ if (!implDrawTransformIsUnknown && testContentRectOccluded(contentRect, drawTransform, clippedRectInTarget, m_stack.back().occlusionInTarget))
return true;
// renderTarget can be NULL in some tests.
bool transformToScreenKnown = renderTarget && !implDrawTransformIsUnknown && layerTransformsToScreenKnown(renderTarget);
- if (transformToScreenKnown && testContentRectOccluded(contentRect, renderTarget->renderSurface()->screenSpaceTransform() * drawTransform, m_rootTargetRect, m_stack.last().occlusionInScreen)) {
+ if (transformToScreenKnown && testContentRectOccluded(contentRect, renderTarget->renderSurface()->screenSpaceTransform() * drawTransform, m_rootTargetRect, m_stack.back().occlusionInScreen)) {
if (hasOcclusionFromOutsideTargetSurface)
*hasOcclusionFromOutsideTargetSurface = true;
return true;
@@ -370,26 +370,26 @@ static inline gfx::Rect computeUnoccludedContentRect(const gfx::Rect& contentRec
template<typename LayerType, typename RenderSurfaceType>
gfx::Rect OcclusionTrackerBase<LayerType, RenderSurfaceType>::unoccludedContentRect(const LayerType* renderTarget, const gfx::Rect& contentRect, const WebKit::WebTransformationMatrix& drawTransform, bool implDrawTransformIsUnknown, const gfx::Rect& clippedRectInTarget, bool* hasOcclusionFromOutsideTargetSurface) const
{
- DCHECK(!m_stack.isEmpty());
- if (m_stack.isEmpty())
+ DCHECK(!m_stack.empty());
+ if (m_stack.empty())
return contentRect;
if (contentRect.IsEmpty())
return contentRect;
DCHECK(renderTarget->renderTarget() == renderTarget);
DCHECK(renderTarget->renderSurface());
- DCHECK(renderTarget == m_stack.last().target);
+ DCHECK(renderTarget == m_stack.back().target);
// We want to return a rect that contains all the visible parts of |contentRect| in both screen space and in the target surface.
// So we find the visible parts of |contentRect| in each space, and take the intersection.
gfx::Rect unoccludedInScreen = contentRect;
if (layerTransformsToScreenKnown(renderTarget) && !implDrawTransformIsUnknown)
- unoccludedInScreen = computeUnoccludedContentRect(contentRect, renderTarget->renderSurface()->screenSpaceTransform() * drawTransform, m_rootTargetRect, m_stack.last().occlusionInScreen);
+ unoccludedInScreen = computeUnoccludedContentRect(contentRect, renderTarget->renderSurface()->screenSpaceTransform() * drawTransform, m_rootTargetRect, m_stack.back().occlusionInScreen);
gfx::Rect unoccludedInTarget = contentRect;
if (!implDrawTransformIsUnknown)
- unoccludedInTarget = computeUnoccludedContentRect(contentRect, drawTransform, clippedRectInTarget, m_stack.last().occlusionInTarget);
+ unoccludedInTarget = computeUnoccludedContentRect(contentRect, drawTransform, clippedRectInTarget, m_stack.back().occlusionInTarget);
if (hasOcclusionFromOutsideTargetSurface)
*hasOcclusionFromOutsideTargetSurface = (gfx::IntersectRects(unoccludedInScreen, unoccludedInTarget) != unoccludedInTarget);
@@ -400,7 +400,7 @@ gfx::Rect OcclusionTrackerBase<LayerType, RenderSurfaceType>::unoccludedContentR
template<typename LayerType, typename RenderSurfaceType>
gfx::Rect OcclusionTrackerBase<LayerType, RenderSurfaceType>::unoccludedContributingSurfaceContentRect(const LayerType* layer, bool forReplica, const gfx::Rect& contentRect, bool* hasOcclusionFromOutsideTargetSurface) const
{
- DCHECK(!m_stack.isEmpty());
+ DCHECK(!m_stack.empty());
// The layer is a contributing renderTarget so it should have a surface.
DCHECK(layer->renderSurface());
// The layer is a contributing renderTarget so its target should be itself.
@@ -408,7 +408,7 @@ gfx::Rect OcclusionTrackerBase<LayerType, RenderSurfaceType>::unoccludedContribu
// The layer should not be the root, else what is is contributing to?
DCHECK(layer->parent());
// This should be called while the layer is still considered the current target in the occlusion tracker.
- DCHECK(layer == m_stack.last().target);
+ DCHECK(layer == m_stack.back().target);
if (contentRect.IsEmpty())
return contentRect;
diff --git a/cc/occlusion_tracker.h b/cc/occlusion_tracker.h
index 10c86f8..bd4e198 100644
--- a/cc/occlusion_tracker.h
+++ b/cc/occlusion_tracker.h
@@ -5,10 +5,10 @@
#ifndef CC_OCCLUSION_TRACKER_H_
#define CC_OCCLUSION_TRACKER_H_
-#include "Region.h"
#include "base/basictypes.h"
#include "cc/cc_export.h"
#include "cc/layer_iterator.h"
+#include "cc/region.h"
#include "ui/gfx/rect.h"
namespace cc {
@@ -47,7 +47,7 @@ public:
OverdrawMetrics& overdrawMetrics() const { return *m_overdrawMetrics.get(); }
// Gives the region of the screen that is not occluded by something opaque.
- Region computeVisibleRegionInScreen() const { return subtract(Region(m_rootTargetRect), m_stack.last().occlusionInScreen); }
+ Region computeVisibleRegionInScreen() const { return SubtractRegions(m_rootTargetRect, m_stack.back().occlusionInScreen); }
void setMinimumTrackingSize(const gfx::Size& size) { m_minimumTrackingSize = size; }
@@ -70,7 +70,7 @@ protected:
// - When we visit a layer representing itself, we add its occlusion to the current subtree, which is at the top of the stack.
// - When we visit a layer representing a contributing surface, the current target will never be the top of the stack since we just came from the contributing surface.
// We merge the occlusion at the top of the stack with the new current subtree. This new target is pushed onto the stack if not already there.
- Vector<StackObject, 1> m_stack;
+ std::vector<StackObject> m_stack;
// Allow tests to override this.
virtual gfx::Rect layerClipRectInTarget(const LayerType*) const;
diff --git a/cc/occlusion_tracker_unittest.cc b/cc/occlusion_tracker_unittest.cc
index c47d66a..fe6afe1 100644
--- a/cc/occlusion_tracker_unittest.cc
+++ b/cc/occlusion_tracker_unittest.cc
@@ -6,7 +6,6 @@
#include "cc/occlusion_tracker.h"
-#include "Region.h"
#include "cc/layer.h"
#include "cc/layer_animation_controller.h"
#include "cc/layer_impl.h"
@@ -471,10 +470,8 @@ protected:
this->visitLayer(layer, occlusion);
this->enterLayer(parent, occlusion);
- EXPECT_RECT_EQ(gfx::Rect(30, 30, 70, 70), occlusion.occlusionInScreenSpace().bounds());
- EXPECT_EQ(1u, Region::Iterator(occlusion.occlusionInScreenSpace()).size());
- EXPECT_RECT_EQ(gfx::Rect(30, 30, 70, 70), occlusion.occlusionInTargetSurface().bounds());
- EXPECT_EQ(1u, Region::Iterator(occlusion.occlusionInTargetSurface()).size());
+ EXPECT_EQ(gfx::Rect(30, 30, 70, 70).ToString(), occlusion.occlusionInScreenSpace().ToString());
+ EXPECT_EQ(gfx::Rect(30, 30, 70, 70).ToString(), occlusion.occlusionInTargetSurface().ToString());
EXPECT_TRUE(occlusion.occludedLayer(parent, gfx::Rect(30, 30, 70, 70)));
EXPECT_FALSE(occlusion.occludedLayer(parent, gfx::Rect(29, 30, 70, 70)));
@@ -523,10 +520,8 @@ protected:
this->visitLayer(layer2, occlusion);
this->enterLayer(layer1, occlusion);
- EXPECT_RECT_EQ(gfx::Rect(20, 20, 50, 50), occlusion.occlusionInScreenSpace().bounds());
- EXPECT_EQ(1u, Region::Iterator(occlusion.occlusionInScreenSpace()).size());
- EXPECT_RECT_EQ(gfx::Rect(20, 20, 50, 50), occlusion.occlusionInTargetSurface().bounds());
- EXPECT_EQ(1u, Region::Iterator(occlusion.occlusionInTargetSurface()).size());
+ EXPECT_EQ(gfx::Rect(20, 20, 50, 50).ToString(), occlusion.occlusionInScreenSpace().ToString());
+ EXPECT_EQ(gfx::Rect(20, 20, 50, 50).ToString(), occlusion.occlusionInTargetSurface().ToString());
// This checks cases where the quads don't match their "containing"
// layers, e.g. in terms of transforms or clip rect. This is typical for
@@ -567,10 +562,8 @@ protected:
this->visitLayer(layer, occlusion);
this->enterLayer(parent, occlusion);
- EXPECT_RECT_EQ(gfx::Rect(30, 30, 70, 70), occlusion.occlusionInScreenSpace().bounds());
- EXPECT_EQ(1u, Region::Iterator(occlusion.occlusionInScreenSpace()).size());
- EXPECT_RECT_EQ(gfx::Rect(30, 30, 70, 70), occlusion.occlusionInTargetSurface().bounds());
- EXPECT_EQ(1u, Region::Iterator(occlusion.occlusionInTargetSurface()).size());
+ EXPECT_EQ(gfx::Rect(30, 30, 70, 70).ToString(), occlusion.occlusionInScreenSpace().ToString());
+ EXPECT_EQ(gfx::Rect(30, 30, 70, 70).ToString(), occlusion.occlusionInTargetSurface().ToString());
EXPECT_TRUE(occlusion.occludedLayer(parent, gfx::Rect(30, 30, 70, 70)));
EXPECT_FALSE(occlusion.occludedLayer(parent, gfx::Rect(29, 30, 70, 70)));
@@ -619,10 +612,8 @@ protected:
this->visitLayer(layer, occlusion);
this->enterLayer(parent, occlusion);
- EXPECT_RECT_EQ(gfx::Rect(50, 50, 50, 50), occlusion.occlusionInScreenSpace().bounds());
- EXPECT_EQ(1u, Region::Iterator(occlusion.occlusionInScreenSpace()).size());
- EXPECT_RECT_EQ(gfx::Rect(50, 50, 50, 50), occlusion.occlusionInTargetSurface().bounds());
- EXPECT_EQ(1u, Region::Iterator(occlusion.occlusionInTargetSurface()).size());
+ EXPECT_EQ(gfx::Rect(50, 50, 50, 50).ToString(), occlusion.occlusionInScreenSpace().ToString());
+ EXPECT_EQ(gfx::Rect(50, 50, 50, 50).ToString(), occlusion.occlusionInTargetSurface().ToString());
EXPECT_TRUE(occlusion.occludedLayer(parent, gfx::Rect(50, 50, 50, 50)));
EXPECT_FALSE(occlusion.occludedLayer(parent, gfx::Rect(49, 50, 50, 50)));
@@ -688,18 +679,14 @@ protected:
this->visitLayer(layer, occlusion);
this->enterContributingSurface(child, occlusion);
- EXPECT_RECT_EQ(gfx::Rect(30, 40, 70, 60), occlusion.occlusionInScreenSpace().bounds());
- EXPECT_EQ(1u, Region::Iterator(occlusion.occlusionInScreenSpace()).size());
- EXPECT_RECT_EQ(gfx::Rect(10, 430, 60, 70), occlusion.occlusionInTargetSurface().bounds());
- EXPECT_EQ(1u, Region::Iterator(occlusion.occlusionInTargetSurface()).size());
+ EXPECT_EQ(gfx::Rect(30, 40, 70, 60).ToString(), occlusion.occlusionInScreenSpace().ToString());
+ EXPECT_EQ(gfx::Rect(10, 430, 60, 70).ToString(), occlusion.occlusionInTargetSurface().ToString());
this->leaveContributingSurface(child, occlusion);
this->enterLayer(parent, occlusion);
- EXPECT_RECT_EQ(gfx::Rect(30, 40, 70, 60), occlusion.occlusionInScreenSpace().bounds());
- EXPECT_EQ(1u, Region::Iterator(occlusion.occlusionInScreenSpace()).size());
- EXPECT_RECT_EQ(gfx::Rect(30, 40, 70, 60), occlusion.occlusionInTargetSurface().bounds());
- EXPECT_EQ(1u, Region::Iterator(occlusion.occlusionInTargetSurface()).size());
+ EXPECT_EQ(gfx::Rect(30, 40, 70, 60).ToString(), occlusion.occlusionInScreenSpace().ToString());
+ EXPECT_EQ(gfx::Rect(30, 40, 70, 60).ToString(), occlusion.occlusionInTargetSurface().ToString());
EXPECT_TRUE(occlusion.occludedLayer(parent, gfx::Rect(30, 40, 70, 60)));
EXPECT_FALSE(occlusion.occludedLayer(parent, gfx::Rect(29, 40, 70, 60)));
@@ -770,10 +757,8 @@ protected:
this->visitLayer(occluder, occlusion);
this->enterLayer(layer2, occlusion);
- EXPECT_RECT_EQ(gfx::Rect(100, 100, 100, 100), occlusion.occlusionInScreenSpace().bounds());
- EXPECT_EQ(1u, Region::Iterator(occlusion.occlusionInScreenSpace()).size());
- EXPECT_TRUE(occlusion.occlusionInTargetSurface().IsEmpty());
- EXPECT_EQ(0u, Region::Iterator(occlusion.occlusionInTargetSurface()).size());
+ EXPECT_EQ(gfx::Rect(100, 100, 100, 100).ToString(), occlusion.occlusionInScreenSpace().ToString());
+ EXPECT_EQ(gfx::Rect().ToString(), occlusion.occlusionInTargetSurface().ToString());
EXPECT_RECT_EQ(gfx::Rect(0, 0, 25, 25), occlusion.unoccludedLayerContentRect(layer2, gfx::Rect(0, 0, 25, 25)));
EXPECT_RECT_EQ(gfx::Rect(10, 25, 15, 25), occlusion.unoccludedLayerContentRect(layer2, gfx::Rect(10, 25, 25, 25)));
@@ -810,33 +795,25 @@ protected:
this->visitLayer(child2, occlusion);
- EXPECT_RECT_EQ(gfx::Rect(30, 30, 60, 20), occlusion.occlusionInScreenSpace().bounds());
- EXPECT_EQ(1u, Region::Iterator(occlusion.occlusionInScreenSpace()).size());
- EXPECT_RECT_EQ(gfx::Rect(30, 30, 60, 20), occlusion.occlusionInTargetSurface().bounds());
- EXPECT_EQ(1u, Region::Iterator(occlusion.occlusionInTargetSurface()).size());
+ EXPECT_EQ(gfx::Rect(30, 30, 60, 20).ToString(), occlusion.occlusionInScreenSpace().ToString());
+ EXPECT_EQ(gfx::Rect(30, 30, 60, 20).ToString(), occlusion.occlusionInTargetSurface().ToString());
this->visitLayer(layer, occlusion);
- EXPECT_RECT_EQ(gfx::Rect(30, 30, 70, 70), occlusion.occlusionInScreenSpace().bounds());
- EXPECT_EQ(2u, Region::Iterator(occlusion.occlusionInScreenSpace()).size());
- EXPECT_RECT_EQ(gfx::Rect(10, 430, 60, 70), occlusion.occlusionInTargetSurface().bounds());
- EXPECT_EQ(1u, Region::Iterator(occlusion.occlusionInTargetSurface()).size());
+ EXPECT_EQ(UnionRegions(gfx::Rect(30, 30, 60, 10), gfx::Rect(30, 40, 70, 60)).ToString(), occlusion.occlusionInScreenSpace().ToString());
+ EXPECT_EQ(gfx::Rect(10, 430, 60, 70).ToString(), occlusion.occlusionInTargetSurface().ToString());
this->enterContributingSurface(child, occlusion);
- EXPECT_RECT_EQ(gfx::Rect(30, 30, 70, 70), occlusion.occlusionInScreenSpace().bounds());
- EXPECT_EQ(2u, Region::Iterator(occlusion.occlusionInScreenSpace()).size());
- EXPECT_RECT_EQ(gfx::Rect(10, 430, 60, 70), occlusion.occlusionInTargetSurface().bounds());
- EXPECT_EQ(1u, Region::Iterator(occlusion.occlusionInTargetSurface()).size());
+ EXPECT_EQ(UnionRegions(gfx::Rect(30, 30, 60, 10), gfx::Rect(30, 40, 70, 60)).ToString(), occlusion.occlusionInScreenSpace().ToString());
+ EXPECT_EQ(gfx::Rect(10, 430, 60, 70).ToString(), occlusion.occlusionInTargetSurface().ToString());
// Occlusion in |child2| should get merged with the |child| surface we are leaving now.
this->leaveContributingSurface(child, occlusion);
this->enterLayer(parent, occlusion);
- EXPECT_RECT_EQ(gfx::Rect(30, 30, 70, 70), occlusion.occlusionInScreenSpace().bounds());
- EXPECT_EQ(2u, Region::Iterator(occlusion.occlusionInScreenSpace()).size());
- EXPECT_RECT_EQ(gfx::Rect(30, 30, 70, 70), occlusion.occlusionInTargetSurface().bounds());
- EXPECT_EQ(2u, Region::Iterator(occlusion.occlusionInTargetSurface()).size());
+ EXPECT_EQ(UnionRegions(gfx::Rect(30, 30, 60, 10), gfx::Rect(30, 40, 70, 60)).ToString(), occlusion.occlusionInScreenSpace().ToString());
+ EXPECT_EQ(UnionRegions(gfx::Rect(30, 30, 60, 10), gfx::Rect(30, 40, 70, 60)).ToString(), occlusion.occlusionInTargetSurface().ToString());
EXPECT_FALSE(occlusion.occludedLayer(parent, gfx::Rect(30, 30, 70, 70)));
EXPECT_RECT_EQ(gfx::Rect(90, 30, 10, 10), occlusion.unoccludedLayerContentRect(parent, gfx::Rect(30, 30, 70, 70)));
@@ -925,10 +902,8 @@ protected:
this->visitLayer(layer, occlusion);
this->enterContributingSurface(child, occlusion);
- EXPECT_RECT_EQ(gfx::Rect(), occlusion.occlusionInScreenSpace().bounds());
- EXPECT_EQ(0u, Region::Iterator(occlusion.occlusionInScreenSpace()).size());
- EXPECT_RECT_EQ(clippedLayerInChild, occlusion.occlusionInTargetSurface().bounds());
- EXPECT_EQ(1u, Region::Iterator(occlusion.occlusionInTargetSurface()).size());
+ EXPECT_EQ(gfx::Rect().ToString(), occlusion.occlusionInScreenSpace().ToString());
+ EXPECT_EQ(clippedLayerInChild.ToString(), occlusion.occlusionInTargetSurface().ToString());
EXPECT_TRUE(occlusion.occludedLayer(child, clippedLayerInChild));
EXPECT_TRUE(occlusion.unoccludedLayerContentRect(child, clippedLayerInChild).IsEmpty());
@@ -952,10 +927,8 @@ protected:
this->leaveContributingSurface(child, occlusion);
this->enterLayer(parent, occlusion);
- EXPECT_RECT_EQ(gfx::Rect(), occlusion.occlusionInScreenSpace().bounds());
- EXPECT_EQ(0u, Region::Iterator(occlusion.occlusionInScreenSpace()).size());
- EXPECT_RECT_EQ(gfx::Rect(), occlusion.occlusionInTargetSurface().bounds());
- EXPECT_EQ(0u, Region::Iterator(occlusion.occlusionInTargetSurface()).size());
+ EXPECT_EQ(gfx::Rect().ToString(), occlusion.occlusionInScreenSpace().ToString());
+ EXPECT_EQ(gfx::Rect().ToString(), occlusion.occlusionInTargetSurface().ToString());
EXPECT_FALSE(occlusion.occludedLayer(parent, gfx::Rect(75, 55, 1, 1)));
EXPECT_RECT_EQ(gfx::Rect(75, 55, 1, 1), occlusion.unoccludedLayerContentRect(parent, gfx::Rect(75, 55, 1, 1)));
@@ -990,10 +963,8 @@ protected:
this->visitLayer(layer1, occlusion);
this->enterContributingSurface(child, occlusion);
- EXPECT_RECT_EQ(gfx::Rect(30, 40, 70, 60), occlusion.occlusionInScreenSpace().bounds());
- EXPECT_EQ(1u, Region::Iterator(occlusion.occlusionInScreenSpace()).size());
- EXPECT_RECT_EQ(gfx::Rect(10, 430, 60, 70), occlusion.occlusionInTargetSurface().bounds());
- EXPECT_EQ(1u, Region::Iterator(occlusion.occlusionInTargetSurface()).size());
+ EXPECT_EQ(gfx::Rect(30, 40, 70, 60).ToString(), occlusion.occlusionInScreenSpace().ToString());
+ EXPECT_EQ(gfx::Rect(10, 430, 60, 70).ToString(), occlusion.occlusionInTargetSurface().ToString());
EXPECT_TRUE(occlusion.occludedLayer(child, gfx::Rect(10, 430, 60, 70)));
EXPECT_FALSE(occlusion.occludedLayer(child, gfx::Rect(9, 430, 60, 70)));
@@ -1010,10 +981,8 @@ protected:
this->leaveContributingSurface(child, occlusion);
this->enterLayer(parent, occlusion);
- EXPECT_RECT_EQ(gfx::Rect(30, 40, 70, 60), occlusion.occlusionInScreenSpace().bounds());
- EXPECT_EQ(1u, Region::Iterator(occlusion.occlusionInScreenSpace()).size());
- EXPECT_RECT_EQ(gfx::Rect(30, 40, 70, 60), occlusion.occlusionInTargetSurface().bounds());
- EXPECT_EQ(1u, Region::Iterator(occlusion.occlusionInTargetSurface()).size());
+ EXPECT_EQ(gfx::Rect(30, 40, 70, 60).ToString(), occlusion.occlusionInScreenSpace().ToString());
+ EXPECT_EQ(gfx::Rect(30, 40, 70, 60).ToString(), occlusion.occlusionInTargetSurface().ToString());
EXPECT_TRUE(occlusion.occludedLayer(parent, gfx::Rect(30, 40, 70, 60)));
EXPECT_FALSE(occlusion.occludedLayer(parent, gfx::Rect(29, 40, 70, 60)));
@@ -1079,10 +1048,8 @@ protected:
this->visitLayer(layer2, occlusion);
this->enterContributingSurface(child2, occlusion);
- EXPECT_RECT_EQ(gfx::Rect(20, 30, 80, 70), occlusion.occlusionInScreenSpace().bounds());
- EXPECT_EQ(1u, Region::Iterator(occlusion.occlusionInScreenSpace()).size());
- EXPECT_RECT_EQ(gfx::Rect(-10, 420, 70, 80), occlusion.occlusionInTargetSurface().bounds());
- EXPECT_EQ(1u, Region::Iterator(occlusion.occlusionInTargetSurface()).size());
+ EXPECT_EQ(gfx::Rect(20, 30, 80, 70).ToString(), occlusion.occlusionInScreenSpace().ToString());
+ EXPECT_EQ(gfx::Rect(-10, 420, 70, 80).ToString(), occlusion.occlusionInTargetSurface().ToString());
EXPECT_TRUE(occlusion.occludedLayer(child2, gfx::Rect(-10, 420, 70, 80)));
EXPECT_FALSE(occlusion.occludedLayer(child2, gfx::Rect(-11, 420, 70, 80)));
@@ -1105,10 +1072,8 @@ protected:
this->visitLayer(layer1, occlusion);
this->enterContributingSurface(child1, occlusion);
- EXPECT_RECT_EQ(gfx::Rect(20, 20, 80, 80), occlusion.occlusionInScreenSpace().bounds());
- EXPECT_EQ(2u, Region::Iterator(occlusion.occlusionInScreenSpace()).size());
- EXPECT_RECT_EQ(gfx::Rect(-10, 430, 80, 70), occlusion.occlusionInTargetSurface().bounds());
- EXPECT_EQ(1u, Region::Iterator(occlusion.occlusionInTargetSurface()).size());
+ EXPECT_EQ(UnionRegions(gfx::Rect(30, 20, 70, 10), gfx::Rect(20, 30, 80, 70)).ToString(), occlusion.occlusionInScreenSpace().ToString());
+ EXPECT_EQ(gfx::Rect(-10, 430, 80, 70).ToString(), occlusion.occlusionInTargetSurface().ToString());
EXPECT_TRUE(occlusion.occludedLayer(child1, gfx::Rect(-10, 430, 80, 70)));
EXPECT_FALSE(occlusion.occludedLayer(child1, gfx::Rect(-11, 430, 80, 70)));
@@ -1122,10 +1087,8 @@ protected:
this->leaveContributingSurface(child1, occlusion);
this->enterLayer(parent, occlusion);
- EXPECT_RECT_EQ(gfx::Rect(20, 20, 80, 80), occlusion.occlusionInScreenSpace().bounds());
- EXPECT_EQ(2u, Region::Iterator(occlusion.occlusionInScreenSpace()).size());
- EXPECT_RECT_EQ(gfx::Rect(20, 20, 80, 80), occlusion.occlusionInTargetSurface().bounds());
- EXPECT_EQ(2u, Region::Iterator(occlusion.occlusionInTargetSurface()).size());
+ EXPECT_EQ(UnionRegions(gfx::Rect(30, 20, 70, 10), gfx::Rect(20, 30, 80, 70)).ToString(), occlusion.occlusionInScreenSpace().ToString());
+ EXPECT_EQ(UnionRegions(gfx::Rect(30, 20, 70, 10), gfx::Rect(20, 30, 80, 70)).ToString(), occlusion.occlusionInTargetSurface().ToString());
EXPECT_FALSE(occlusion.occludedLayer(parent, gfx::Rect(20, 20, 80, 80)));
@@ -1195,10 +1158,8 @@ protected:
this->visitLayer(layer2, occlusion);
this->enterLayer(child2, occlusion);
- EXPECT_RECT_EQ(gfx::Rect(20, 30, 80, 70), occlusion.occlusionInScreenSpace().bounds());
- EXPECT_EQ(1u, Region::Iterator(occlusion.occlusionInScreenSpace()).size());
- EXPECT_RECT_EQ(gfx::Rect(-10, 420, 70, 80), occlusion.occlusionInTargetSurface().bounds());
- EXPECT_EQ(1u, Region::Iterator(occlusion.occlusionInTargetSurface()).size());
+ EXPECT_EQ(gfx::Rect(20, 30, 80, 70).ToString(), occlusion.occlusionInScreenSpace().ToString());
+ EXPECT_EQ(gfx::Rect(-10, 420, 70, 80).ToString(), occlusion.occlusionInTargetSurface().ToString());
EXPECT_TRUE(occlusion.occludedLayer(child2, gfx::Rect(-10, 420, 70, 80)));
EXPECT_FALSE(occlusion.occludedLayer(child2, gfx::Rect(-11, 420, 70, 80)));
@@ -1216,10 +1177,8 @@ protected:
this->visitLayer(layer1, occlusion);
this->enterContributingSurface(child1, occlusion);
- EXPECT_RECT_EQ(gfx::Rect(10, 20, 90, 80), occlusion.occlusionInScreenSpace().bounds());
- EXPECT_EQ(1u, Region::Iterator(occlusion.occlusionInScreenSpace()).size());
- EXPECT_RECT_EQ(gfx::Rect(420, -20, 80, 90), occlusion.occlusionInTargetSurface().bounds());
- EXPECT_EQ(1u, Region::Iterator(occlusion.occlusionInTargetSurface()).size());
+ EXPECT_EQ(gfx::Rect(10, 20, 90, 80).ToString(), occlusion.occlusionInScreenSpace().ToString());
+ EXPECT_EQ(gfx::Rect(420, -20, 80, 90).ToString(), occlusion.occlusionInTargetSurface().ToString());
EXPECT_TRUE(occlusion.occludedLayer(child1, gfx::Rect(420, -20, 80, 90)));
EXPECT_FALSE(occlusion.occludedLayer(child1, gfx::Rect(419, -20, 80, 90)));
@@ -1235,10 +1194,8 @@ protected:
this->leaveContributingSurface(child1, occlusion);
this->enterLayer(parent, occlusion);
- EXPECT_RECT_EQ(gfx::Rect(10, 20, 90, 80), occlusion.occlusionInScreenSpace().bounds());
- EXPECT_EQ(1u, Region::Iterator(occlusion.occlusionInScreenSpace()).size());
- EXPECT_RECT_EQ(gfx::Rect(10, 20, 90, 80), occlusion.occlusionInTargetSurface().bounds());
- EXPECT_EQ(1u, Region::Iterator(occlusion.occlusionInTargetSurface()).size());
+ EXPECT_EQ(gfx::Rect(10, 20, 90, 80).ToString(), occlusion.occlusionInScreenSpace().ToString());
+ EXPECT_EQ(gfx::Rect(10, 20, 90, 80).ToString(), occlusion.occlusionInTargetSurface().ToString());
EXPECT_TRUE(occlusion.occludedLayer(parent, gfx::Rect(10, 20, 90, 80)));
EXPECT_FALSE(occlusion.occludedLayer(parent, gfx::Rect(9, 20, 90, 80)));
@@ -1324,17 +1281,13 @@ protected:
this->visitLayer(opaqueLayer, occlusion);
this->enterContributingSurface(opaqueLayer, occlusion);
- EXPECT_RECT_EQ(gfx::Rect(30, 30, 70, 70), occlusion.occlusionInScreenSpace().bounds());
- EXPECT_EQ(1u, Region::Iterator(occlusion.occlusionInScreenSpace()).size());
- EXPECT_RECT_EQ(gfx::Rect(0, 430, 70, 70), occlusion.occlusionInTargetSurface().bounds());
- EXPECT_EQ(1u, Region::Iterator(occlusion.occlusionInTargetSurface()).size());
+ EXPECT_EQ(gfx::Rect(30, 30, 70, 70).ToString(), occlusion.occlusionInScreenSpace().ToString());
+ EXPECT_EQ(gfx::Rect(0, 430, 70, 70).ToString(), occlusion.occlusionInTargetSurface().ToString());
// And it gets translated to the parent surface.
this->leaveContributingSurface(opaqueLayer, occlusion);
- EXPECT_RECT_EQ(gfx::Rect(30, 30, 70, 70), occlusion.occlusionInScreenSpace().bounds());
- EXPECT_EQ(1u, Region::Iterator(occlusion.occlusionInScreenSpace()).size());
- EXPECT_RECT_EQ(gfx::Rect(30, 30, 70, 70), occlusion.occlusionInTargetSurface().bounds());
- EXPECT_EQ(1u, Region::Iterator(occlusion.occlusionInTargetSurface()).size());
+ EXPECT_EQ(gfx::Rect(30, 30, 70, 70).ToString(), occlusion.occlusionInScreenSpace().ToString());
+ EXPECT_EQ(gfx::Rect(30, 30, 70, 70).ToString(), occlusion.occlusionInTargetSurface().ToString());
// The blur layer needs to throw away any occlusion from outside its subtree.
this->enterLayer(blurLayer, occlusion);
@@ -1350,10 +1303,8 @@ protected:
// But the opaque layer's occlusion is preserved on the parent.
this->leaveContributingSurface(blurLayer, occlusion);
this->enterLayer(parent, occlusion);
- EXPECT_RECT_EQ(gfx::Rect(30, 30, 70, 70), occlusion.occlusionInScreenSpace().bounds());
- EXPECT_EQ(1u, Region::Iterator(occlusion.occlusionInScreenSpace()).size());
- EXPECT_RECT_EQ(gfx::Rect(30, 30, 70, 70), occlusion.occlusionInTargetSurface().bounds());
- EXPECT_EQ(1u, Region::Iterator(occlusion.occlusionInTargetSurface()).size());
+ EXPECT_EQ(gfx::Rect(30, 30, 70, 70).ToString(), occlusion.occlusionInScreenSpace().ToString());
+ EXPECT_EQ(gfx::Rect(30, 30, 70, 70).ToString(), occlusion.occlusionInTargetSurface().ToString());
}
};
@@ -1375,17 +1326,14 @@ protected:
this->visitLayer(surface, occlusion);
- EXPECT_RECT_EQ(gfx::Rect(0, 100, 50, 50), occlusion.occlusionInScreenSpace().bounds());
- EXPECT_EQ(1u, Region::Iterator(occlusion.occlusionInScreenSpace()).size());
- EXPECT_RECT_EQ(gfx::Rect(0, 0, 50, 50), occlusion.occlusionInTargetSurface().bounds());
- EXPECT_EQ(1u, Region::Iterator(occlusion.occlusionInTargetSurface()).size());
+ EXPECT_EQ(gfx::Rect(0, 100, 50, 50).ToString(), occlusion.occlusionInScreenSpace().ToString());
+ EXPECT_EQ(gfx::Rect(0, 0, 50, 50).ToString(), occlusion.occlusionInTargetSurface().ToString());
this->visitContributingSurface(surface, occlusion);
this->enterLayer(parent, occlusion);
// The surface and replica should both be occluding the parent.
- EXPECT_RECT_EQ(gfx::Rect(0, 100, 100, 100), occlusion.occlusionInTargetSurface().bounds());
- EXPECT_EQ(2u, Region::Iterator(occlusion.occlusionInTargetSurface()).size());
+ EXPECT_EQ(UnionRegions(gfx::Rect(0, 100, 50, 50), gfx::Rect(50, 150, 50, 50)).ToString(), occlusion.occlusionInTargetSurface().ToString());
}
};
@@ -1408,17 +1356,14 @@ protected:
this->visitLayer(surface, occlusion);
- EXPECT_RECT_EQ(gfx::Rect(0, 100, 50, 50), occlusion.occlusionInScreenSpace().bounds());
- EXPECT_EQ(1u, Region::Iterator(occlusion.occlusionInScreenSpace()).size());
- EXPECT_RECT_EQ(gfx::Rect(0, 0, 50, 50), occlusion.occlusionInTargetSurface().bounds());
- EXPECT_EQ(1u, Region::Iterator(occlusion.occlusionInTargetSurface()).size());
+ EXPECT_EQ(gfx::Rect(0, 100, 50, 50).ToString(), occlusion.occlusionInScreenSpace().ToString());
+ EXPECT_EQ(gfx::Rect(0, 0, 50, 50).ToString(), occlusion.occlusionInTargetSurface().ToString());
this->visitContributingSurface(surface, occlusion);
this->enterLayer(parent, occlusion);
// The surface and replica should both be occluding the parent.
- EXPECT_RECT_EQ(gfx::Rect(0, 100, 100, 70), occlusion.occlusionInTargetSurface().bounds());
- EXPECT_EQ(2u, Region::Iterator(occlusion.occlusionInTargetSurface()).size());
+ EXPECT_EQ(UnionRegions(gfx::Rect(0, 100, 50, 50), gfx::Rect(50, 150, 50, 20)).ToString(), occlusion.occlusionInTargetSurface().ToString());
}
};
@@ -1441,17 +1386,14 @@ protected:
this->visitLayer(surface, occlusion);
- EXPECT_RECT_EQ(gfx::Rect(0, 100, 50, 50), occlusion.occlusionInScreenSpace().bounds());
- EXPECT_EQ(1u, Region::Iterator(occlusion.occlusionInScreenSpace()).size());
- EXPECT_RECT_EQ(gfx::Rect(0, 0, 50, 50), occlusion.occlusionInTargetSurface().bounds());
- EXPECT_EQ(1u, Region::Iterator(occlusion.occlusionInTargetSurface()).size());
+ EXPECT_EQ(gfx::Rect(0, 100, 50, 50).ToString(), occlusion.occlusionInScreenSpace().ToString());
+ EXPECT_EQ(gfx::Rect(0, 0, 50, 50).ToString(), occlusion.occlusionInTargetSurface().ToString());
this->visitContributingSurface(surface, occlusion);
this->enterLayer(parent, occlusion);
// The replica should not be occluding the parent, since it has a mask applied to it.
- EXPECT_RECT_EQ(gfx::Rect(0, 100, 50, 50), occlusion.occlusionInTargetSurface().bounds());
- EXPECT_EQ(1u, Region::Iterator(occlusion.occlusionInTargetSurface()).size());
+ EXPECT_EQ(gfx::Rect(0, 100, 50, 50).ToString(), occlusion.occlusionInTargetSurface().ToString());
}
};
@@ -1858,8 +1800,7 @@ protected:
this->visitContributingSurface(layer, occlusion);
this->enterLayer(parent, occlusion);
- EXPECT_TRUE(occlusion.occlusionInScreenSpace().bounds().IsEmpty());
- EXPECT_EQ(0u, Region::Iterator(occlusion.occlusionInScreenSpace()).size());
+ EXPECT_TRUE(occlusion.occlusionInScreenSpace().IsEmpty());
}
};
@@ -1883,8 +1824,7 @@ protected:
this->visitLayer(layer, occlusion);
this->enterLayer(parent, occlusion);
- EXPECT_RECT_EQ(gfx::Rect(100, 100, 100, 100), occlusion.occlusionInScreenSpace().bounds());
- EXPECT_EQ(1u, Region::Iterator(occlusion.occlusionInScreenSpace()).size());
+ EXPECT_EQ(gfx::Rect(100, 100, 100, 100).ToString(), occlusion.occlusionInScreenSpace().ToString());
EXPECT_FALSE(occlusion.occludedLayer(parent, gfx::Rect(0, 100, 100, 100)));
EXPECT_TRUE(occlusion.occludedLayer(parent, gfx::Rect(100, 100, 100, 100)));
@@ -1899,8 +1839,7 @@ protected:
this->visitLayer(layer, occlusion);
this->enterLayer(parent, occlusion);
- EXPECT_RECT_EQ(gfx::Rect(120, 120, 180, 180), occlusion.occlusionInScreenSpace().bounds());
- EXPECT_EQ(1u, Region::Iterator(occlusion.occlusionInScreenSpace()).size());
+ EXPECT_EQ(gfx::Rect(120, 120, 180, 180).ToString(), occlusion.occlusionInScreenSpace().ToString());
EXPECT_FALSE(occlusion.occludedLayer(parent, gfx::Rect(0, 100, 100, 100)));
EXPECT_FALSE(occlusion.occludedLayer(parent, gfx::Rect(100, 100, 100, 100)));
@@ -1915,8 +1854,7 @@ protected:
this->visitLayer(layer, occlusion);
this->enterLayer(parent, occlusion);
- EXPECT_RECT_EQ(gfx::Rect(250, 250, 50, 50), occlusion.occlusionInScreenSpace().bounds());
- EXPECT_EQ(1u, Region::Iterator(occlusion.occlusionInScreenSpace()).size());
+ EXPECT_EQ(gfx::Rect(250, 250, 50, 50).ToString(), occlusion.occlusionInScreenSpace().ToString());
EXPECT_FALSE(occlusion.occludedLayer(parent, gfx::Rect(0, 100, 100, 100)));
EXPECT_FALSE(occlusion.occludedLayer(parent, gfx::Rect(100, 100, 100, 100)));
@@ -2076,8 +2014,8 @@ protected:
// The |layer| is entirely behind the camera and should not occlude.
this->visitLayer(layer, occlusion);
this->enterLayer(parent, occlusion);
- EXPECT_EQ(0u, Region::Iterator(occlusion.occlusionInTargetSurface()).size());
- EXPECT_EQ(0u, Region::Iterator(occlusion.occlusionInScreenSpace()).size());
+ EXPECT_TRUE(occlusion.occlusionInTargetSurface().IsEmpty());
+ EXPECT_TRUE(occlusion.occlusionInScreenSpace().IsEmpty());
}
};
@@ -2109,10 +2047,8 @@ protected:
// Ensure that those pixels don't occlude things outside the clipRect.
this->visitLayer(layer, occlusion);
this->enterLayer(parent, occlusion);
- EXPECT_RECT_EQ(gfx::Rect(0, 0, 100, 100), occlusion.occlusionInTargetSurface().bounds());
- EXPECT_EQ(1u, Region::Iterator(occlusion.occlusionInTargetSurface()).size());
- EXPECT_RECT_EQ(gfx::Rect(0, 0, 100, 100), occlusion.occlusionInScreenSpace().bounds());
- EXPECT_EQ(1u, Region::Iterator(occlusion.occlusionInScreenSpace()).size());
+ EXPECT_EQ(gfx::Rect(0, 0, 100, 100).ToString(), occlusion.occlusionInTargetSurface().ToString());
+ EXPECT_EQ(gfx::Rect(0, 0, 100, 100).ToString(), occlusion.occlusionInScreenSpace().ToString());
}
};
@@ -2258,8 +2194,7 @@ protected:
this->visitLayer(surface2, occlusion);
this->enterContributingSurface(surface2, occlusion);
- EXPECT_RECT_EQ(gfx::Rect(0, 0, 50, 300), occlusion.occlusionInScreenSpace().bounds());
- EXPECT_EQ(1u, Region::Iterator(occlusion.occlusionInScreenSpace()).size());
+ EXPECT_EQ(gfx::Rect(0, 0, 50, 300).ToString(), occlusion.occlusionInScreenSpace().ToString());
this->leaveContributingSurface(surface2, occlusion);
this->enterLayer(surfaceChild2, occlusion);
@@ -2272,10 +2207,8 @@ protected:
this->leaveLayer(surfaceChild2, occlusion);
this->enterLayer(surfaceChild, occlusion);
EXPECT_FALSE(occlusion.occludedLayer(surfaceChild, gfx::Rect(0, 0, 100, 300)));
- EXPECT_RECT_EQ(gfx::Rect(0, 0, 50, 300), occlusion.occlusionInScreenSpace().bounds());
- EXPECT_EQ(1u, Region::Iterator(occlusion.occlusionInScreenSpace()).size());
- EXPECT_RECT_EQ(gfx::Rect(0, 0, 100, 300), occlusion.occlusionInTargetSurface().bounds());
- EXPECT_EQ(1u, Region::Iterator(occlusion.occlusionInTargetSurface()).size());
+ EXPECT_EQ(gfx::Rect(0, 0, 50, 300).ToString(), occlusion.occlusionInScreenSpace().ToString());
+ EXPECT_EQ(gfx::Rect(0, 0, 100, 300).ToString(), occlusion.occlusionInTargetSurface().ToString());
EXPECT_RECT_EQ(gfx::Rect(100, 0, 200, 300), occlusion.unoccludedLayerContentRect(surface, gfx::Rect(0, 0, 300, 300)));
// The surfaceChild is occluded by the surfaceChild2, but is moving relative its target and the screen, so it
@@ -2286,18 +2219,14 @@ protected:
this->leaveLayer(surfaceChild, occlusion);
this->enterLayer(surface, occlusion);
// The surfaceChild is moving in screen space but not relative to its target, so occlusion should happen in its target space only.
- EXPECT_RECT_EQ(gfx::Rect(0, 0, 50, 300), occlusion.occlusionInScreenSpace().bounds());
- EXPECT_EQ(1u, Region::Iterator(occlusion.occlusionInScreenSpace()).size());
- EXPECT_RECT_EQ(gfx::Rect(0, 0, 100, 300), occlusion.occlusionInTargetSurface().bounds());
- EXPECT_EQ(1u, Region::Iterator(occlusion.occlusionInTargetSurface()).size());
+ EXPECT_EQ(gfx::Rect(0, 0, 50, 300).ToString(), occlusion.occlusionInScreenSpace().ToString());
+ EXPECT_EQ(gfx::Rect(0, 0, 100, 300).ToString(), occlusion.occlusionInTargetSurface().ToString());
EXPECT_RECT_EQ(gfx::Rect(100, 0, 200, 300), occlusion.unoccludedLayerContentRect(surface, gfx::Rect(0, 0, 300, 300)));
this->leaveLayer(surface, occlusion);
// The surface's owning layer is moving in screen space but not relative to its target, so occlusion should happen in its target space only.
- EXPECT_RECT_EQ(gfx::Rect(0, 0, 50, 300), occlusion.occlusionInScreenSpace().bounds());
- EXPECT_EQ(1u, Region::Iterator(occlusion.occlusionInScreenSpace()).size());
- EXPECT_RECT_EQ(gfx::Rect(0, 0, 300, 300), occlusion.occlusionInTargetSurface().bounds());
- EXPECT_EQ(1u, Region::Iterator(occlusion.occlusionInTargetSurface()).size());
+ EXPECT_EQ(gfx::Rect(0, 0, 50, 300).ToString(), occlusion.occlusionInScreenSpace().ToString());
+ EXPECT_EQ(gfx::Rect(0, 0, 300, 300).ToString(), occlusion.occlusionInTargetSurface().ToString());
EXPECT_RECT_EQ(gfx::Rect(0, 0, 0, 0), occlusion.unoccludedLayerContentRect(surface, gfx::Rect(0, 0, 300, 300)));
this->enterContributingSurface(surface, occlusion);
@@ -2341,10 +2270,8 @@ protected:
this->visitLayer(surface2, occlusion);
this->visitContributingSurface(surface2, occlusion);
- EXPECT_RECT_EQ(gfx::Rect(50, 50, 200, 200), occlusion.occlusionInScreenSpace().bounds());
- EXPECT_EQ(1u, Region::Iterator(occlusion.occlusionInScreenSpace()).size());
- EXPECT_RECT_EQ(gfx::Rect(50, 50, 200, 200), occlusion.occlusionInTargetSurface().bounds());
- EXPECT_EQ(1u, Region::Iterator(occlusion.occlusionInTargetSurface()).size());
+ EXPECT_EQ(gfx::Rect(50, 50, 200, 200).ToString(), occlusion.occlusionInScreenSpace().ToString());
+ EXPECT_EQ(gfx::Rect(50, 50, 200, 200).ToString(), occlusion.occlusionInTargetSurface().ToString());
// Clear any stored occlusion.
occlusion.setOcclusionInScreenSpace(Region());
@@ -2353,10 +2280,8 @@ protected:
this->visitLayer(surface, occlusion);
this->visitContributingSurface(surface, occlusion);
- EXPECT_RECT_EQ(gfx::Rect(0, 0, 400, 400), occlusion.occlusionInScreenSpace().bounds());
- EXPECT_EQ(1u, Region::Iterator(occlusion.occlusionInScreenSpace()).size());
- EXPECT_RECT_EQ(gfx::Rect(0, 0, 400, 400), occlusion.occlusionInTargetSurface().bounds());
- EXPECT_EQ(1u, Region::Iterator(occlusion.occlusionInTargetSurface()).size());
+ EXPECT_EQ(gfx::Rect(0, 0, 400, 400).ToString(), occlusion.occlusionInScreenSpace().ToString());
+ EXPECT_EQ(gfx::Rect(0, 0, 400, 400).ToString(), occlusion.occlusionInTargetSurface().ToString());
}
};
@@ -2379,10 +2304,8 @@ protected:
this->visitLayer(surface, occlusion);
this->visitContributingSurface(surface, occlusion);
- EXPECT_RECT_EQ(gfx::Rect(0, 0, 300, 200), occlusion.occlusionInScreenSpace().bounds());
- EXPECT_EQ(1u, Region::Iterator(occlusion.occlusionInScreenSpace()).size());
- EXPECT_RECT_EQ(gfx::Rect(0, 0, 300, 200), occlusion.occlusionInTargetSurface().bounds());
- EXPECT_EQ(1u, Region::Iterator(occlusion.occlusionInTargetSurface()).size());
+ EXPECT_EQ(gfx::Rect(0, 0, 300, 200).ToString(), occlusion.occlusionInScreenSpace().ToString());
+ EXPECT_EQ(gfx::Rect(0, 0, 300, 200).ToString(), occlusion.occlusionInTargetSurface().ToString());
}
};
@@ -2406,17 +2329,13 @@ protected:
// |topmost| occludes the replica, but not the surface itself.
this->visitLayer(topmost, occlusion);
- EXPECT_RECT_EQ(gfx::Rect(0, 100, 100, 100), occlusion.occlusionInScreenSpace().bounds());
- EXPECT_EQ(1u, Region::Iterator(occlusion.occlusionInScreenSpace()).size());
- EXPECT_RECT_EQ(gfx::Rect(0, 100, 100, 100), occlusion.occlusionInTargetSurface().bounds());
- EXPECT_EQ(1u, Region::Iterator(occlusion.occlusionInTargetSurface()).size());
+ EXPECT_EQ(gfx::Rect(0, 100, 100, 100).ToString(), occlusion.occlusionInScreenSpace().ToString());
+ EXPECT_EQ(gfx::Rect(0, 100, 100, 100).ToString(), occlusion.occlusionInTargetSurface().ToString());
this->visitLayer(surface, occlusion);
- EXPECT_RECT_EQ(gfx::Rect(0, 0, 100, 200), occlusion.occlusionInScreenSpace().bounds());
- EXPECT_EQ(1u, Region::Iterator(occlusion.occlusionInScreenSpace()).size());
- EXPECT_RECT_EQ(gfx::Rect(0, 0, 100, 100), occlusion.occlusionInTargetSurface().bounds());
- EXPECT_EQ(1u, Region::Iterator(occlusion.occlusionInTargetSurface()).size());
+ EXPECT_EQ(gfx::Rect(0, 0, 100, 200).ToString(), occlusion.occlusionInScreenSpace().ToString());
+ EXPECT_EQ(gfx::Rect(0, 0, 100, 100).ToString(), occlusion.occlusionInTargetSurface().ToString());
this->enterContributingSurface(surface, occlusion);
@@ -2445,17 +2364,13 @@ protected:
// |topmost| occludes the surface, but not the entire surface's replica.
this->visitLayer(topmost, occlusion);
- EXPECT_RECT_EQ(gfx::Rect(0, 0, 100, 110), occlusion.occlusionInScreenSpace().bounds());
- EXPECT_EQ(1u, Region::Iterator(occlusion.occlusionInScreenSpace()).size());
- EXPECT_RECT_EQ(gfx::Rect(0, 0, 100, 110), occlusion.occlusionInTargetSurface().bounds());
- EXPECT_EQ(1u, Region::Iterator(occlusion.occlusionInTargetSurface()).size());
+ EXPECT_EQ(gfx::Rect(0, 0, 100, 110).ToString(), occlusion.occlusionInScreenSpace().ToString());
+ EXPECT_EQ(gfx::Rect(0, 0, 100, 110).ToString(), occlusion.occlusionInTargetSurface().ToString());
this->visitLayer(surface, occlusion);
- EXPECT_RECT_EQ(gfx::Rect(0, 0, 100, 110), occlusion.occlusionInScreenSpace().bounds());
- EXPECT_EQ(1u, Region::Iterator(occlusion.occlusionInScreenSpace()).size());
- EXPECT_RECT_EQ(gfx::Rect(0, 0, 100, 100), occlusion.occlusionInTargetSurface().bounds());
- EXPECT_EQ(1u, Region::Iterator(occlusion.occlusionInTargetSurface()).size());
+ EXPECT_EQ(gfx::Rect(0, 0, 100, 110).ToString(), occlusion.occlusionInScreenSpace().ToString());
+ EXPECT_EQ(gfx::Rect(0, 0, 100, 100).ToString(), occlusion.occlusionInTargetSurface().ToString());
this->enterContributingSurface(surface, occlusion);
@@ -2487,17 +2402,13 @@ protected:
this->visitLayer(overReplica, occlusion);
this->visitLayer(overSurface, occlusion);
- EXPECT_RECT_EQ(gfx::Rect(0, 0, 50, 200), occlusion.occlusionInScreenSpace().bounds());
- EXPECT_EQ(2u, Region::Iterator(occlusion.occlusionInScreenSpace()).size());
- EXPECT_RECT_EQ(gfx::Rect(0, 0, 50, 200), occlusion.occlusionInTargetSurface().bounds());
- EXPECT_EQ(2u, Region::Iterator(occlusion.occlusionInTargetSurface()).size());
+ EXPECT_EQ(UnionRegions(gfx::Rect(0, 0, 40, 100), gfx::Rect(0, 100, 50, 100)).ToString(), occlusion.occlusionInScreenSpace().ToString());
+ EXPECT_EQ(UnionRegions(gfx::Rect(0, 0, 40, 100), gfx::Rect(0, 100, 50, 100)).ToString(), occlusion.occlusionInTargetSurface().ToString());
this->visitLayer(surface, occlusion);
- EXPECT_RECT_EQ(gfx::Rect(0, 0, 100, 200), occlusion.occlusionInScreenSpace().bounds());
- EXPECT_EQ(2u, Region::Iterator(occlusion.occlusionInScreenSpace()).size());
- EXPECT_RECT_EQ(gfx::Rect(0, 0, 100, 100), occlusion.occlusionInTargetSurface().bounds());
- EXPECT_EQ(1u, Region::Iterator(occlusion.occlusionInTargetSurface()).size());
+ EXPECT_EQ(UnionRegions(gfx::Rect(0, 0, 100, 100), gfx::Rect(0, 100, 50, 100)).ToString(), occlusion.occlusionInScreenSpace().ToString());
+ EXPECT_EQ(gfx::Rect(0, 0, 100, 100).ToString(), occlusion.occlusionInTargetSurface().ToString());
this->enterContributingSurface(surface, occlusion);
@@ -2528,19 +2439,15 @@ protected:
// |topmost| occludes everything partially so we know occlusion is happening at all.
this->visitLayer(topmost, occlusion);
- EXPECT_RECT_EQ(gfx::Rect(0, 0, 100, 50), occlusion.occlusionInScreenSpace().bounds());
- EXPECT_EQ(1u, Region::Iterator(occlusion.occlusionInScreenSpace()).size());
- EXPECT_RECT_EQ(gfx::Rect(0, 0, 100, 50), occlusion.occlusionInTargetSurface().bounds());
- EXPECT_EQ(1u, Region::Iterator(occlusion.occlusionInTargetSurface()).size());
+ EXPECT_EQ(gfx::Rect(0, 0, 100, 50).ToString(), occlusion.occlusionInScreenSpace().ToString());
+ EXPECT_EQ(gfx::Rect(0, 0, 100, 50).ToString(), occlusion.occlusionInTargetSurface().ToString());
this->visitLayer(surfaceChild, occlusion);
// surfaceChild increases the occlusion in the screen by a narrow sliver.
- EXPECT_RECT_EQ(gfx::Rect(0, 0, 100, 60), occlusion.occlusionInScreenSpace().bounds());
- EXPECT_EQ(1u, Region::Iterator(occlusion.occlusionInScreenSpace()).size());
+ EXPECT_EQ(gfx::Rect(0, 0, 100, 60).ToString(), occlusion.occlusionInScreenSpace().ToString());
// In its own surface, surfaceChild is at 0,0 as is its occlusion.
- EXPECT_RECT_EQ(gfx::Rect(0, 0, 100, 50), occlusion.occlusionInTargetSurface().bounds());
- EXPECT_EQ(1u, Region::Iterator(occlusion.occlusionInTargetSurface()).size());
+ EXPECT_EQ(gfx::Rect(0, 0, 100, 50).ToString(), occlusion.occlusionInTargetSurface().ToString());
// The root layer always has a clipRect. So the parent of |surface| has a clipRect. However, the owning layer for |surface| does not
// mask to bounds, so it doesn't have a clipRect of its own. Thus the parent of |surfaceChild| exercises different code paths
@@ -2554,10 +2461,8 @@ protected:
// When the surfaceChild's occlusion is transformed up to its parent, make sure it is not clipped away inappropriately also.
this->enterLayer(surface, occlusion);
- EXPECT_RECT_EQ(gfx::Rect(0, 0, 100, 60), occlusion.occlusionInScreenSpace().bounds());
- EXPECT_EQ(1u, Region::Iterator(occlusion.occlusionInScreenSpace()).size());
- EXPECT_RECT_EQ(gfx::Rect(0, 10, 100, 50), occlusion.occlusionInTargetSurface().bounds());
- EXPECT_EQ(1u, Region::Iterator(occlusion.occlusionInTargetSurface()).size());
+ EXPECT_EQ(gfx::Rect(0, 0, 100, 60).ToString(), occlusion.occlusionInScreenSpace().ToString());
+ EXPECT_EQ(gfx::Rect(0, 10, 100, 50).ToString(), occlusion.occlusionInTargetSurface().ToString());
this->leaveLayer(surface, occlusion);
this->enterContributingSurface(surface, occlusion);
@@ -2629,18 +2534,14 @@ protected:
// |topmost| occludes everything partially so we know occlusion is happening at all.
this->visitLayer(topmost, occlusion);
- EXPECT_RECT_EQ(gfx::Rect(0, 0, 80, 50), occlusion.occlusionInScreenSpace().bounds());
- EXPECT_EQ(1u, Region::Iterator(occlusion.occlusionInScreenSpace()).size());
- EXPECT_RECT_EQ(gfx::Rect(0, 0, 80, 50), occlusion.occlusionInTargetSurface().bounds());
- EXPECT_EQ(1u, Region::Iterator(occlusion.occlusionInTargetSurface()).size());
+ EXPECT_EQ(gfx::Rect(0, 0, 80, 50).ToString(), occlusion.occlusionInScreenSpace().ToString());
+ EXPECT_EQ(gfx::Rect(0, 0, 80, 50).ToString(), occlusion.occlusionInTargetSurface().ToString());
// surfaceChild is not opaque and does not occlude, so we have a non-empty unoccluded area on surface.
this->visitLayer(surfaceChild, occlusion);
- EXPECT_RECT_EQ(gfx::Rect(0, 0, 80, 50), occlusion.occlusionInScreenSpace().bounds());
- EXPECT_EQ(1u, Region::Iterator(occlusion.occlusionInScreenSpace()).size());
- EXPECT_RECT_EQ(gfx::Rect(0, 0, 0, 0), occlusion.occlusionInTargetSurface().bounds());
- EXPECT_EQ(0u, Region::Iterator(occlusion.occlusionInTargetSurface()).size());
+ EXPECT_EQ(gfx::Rect(0, 0, 80, 50).ToString(), occlusion.occlusionInScreenSpace().ToString());
+ EXPECT_EQ(gfx::Rect(0, 0, 0, 0).ToString(), occlusion.occlusionInTargetSurface().ToString());
// The root layer always has a clipRect. So the parent of |surface| has a clipRect. However, the owning layer for |surface| does not
// mask to bounds, so it doesn't have a clipRect of its own. Thus the parent of |surfaceChild| exercises different code paths
@@ -2703,10 +2604,15 @@ protected:
this->visitLayer(occludingLayer2, occlusion);
this->visitLayer(occludingLayer1, occlusion);
- EXPECT_RECT_EQ(gfx::Rect(0, 0, 300, 150), occlusion.occlusionInScreenSpace().bounds());
- EXPECT_EQ(5u, Region::Iterator(occlusion.occlusionInScreenSpace()).size());
- EXPECT_RECT_EQ(gfx::Rect(0, 0, 300, 150), occlusion.occlusionInTargetSurface().bounds());
- EXPECT_EQ(5u, Region::Iterator(occlusion.occlusionInTargetSurface()).size());
+ Region expectedOcclusion;
+ expectedOcclusion.Union(gfx::Rect(0, 0, 300, 50));
+ expectedOcclusion.Union(gfx::Rect(0, 50, 50, 50));
+ expectedOcclusion.Union(gfx::Rect(100, 50, 100, 50));
+ expectedOcclusion.Union(gfx::Rect(250, 50, 50, 50));
+ expectedOcclusion.Union(gfx::Rect(0, 100, 300, 50));
+
+ EXPECT_EQ(expectedOcclusion.ToString(), occlusion.occlusionInScreenSpace().ToString());
+ EXPECT_EQ(expectedOcclusion.ToString(), occlusion.occlusionInTargetSurface().ToString());
// Everything outside the surface/replica is occluded but the surface/replica itself is not.
this->enterLayer(filteredSurface, occlusion);
@@ -2722,20 +2628,24 @@ protected:
this->leaveLayer(filteredSurface, occlusion);
// The filtered layer/replica does not occlude.
- EXPECT_RECT_EQ(gfx::Rect(0, 0, 300, 150), occlusion.occlusionInScreenSpace().bounds());
- EXPECT_EQ(5u, Region::Iterator(occlusion.occlusionInScreenSpace()).size());
- EXPECT_RECT_EQ(gfx::Rect(0, 0, 0, 0), occlusion.occlusionInTargetSurface().bounds());
- EXPECT_EQ(0u, Region::Iterator(occlusion.occlusionInTargetSurface()).size());
+ EXPECT_EQ(expectedOcclusion.ToString(), occlusion.occlusionInScreenSpace().ToString());
+ EXPECT_EQ(gfx::Rect().ToString(), occlusion.occlusionInTargetSurface().ToString());
// The surface has a background blur, so it needs pixels that are currently considered occluded in order to be drawn. So the pixels
// it needs should be removed some the occluded area so that when we get to the parent they are drawn.
this->visitContributingSurface(filteredSurface, occlusion);
this->enterLayer(parent, occlusion);
- EXPECT_RECT_EQ(gfx::Rect(0, 0, 300, 150), occlusion.occlusionInScreenSpace().bounds());
- EXPECT_EQ(5u, Region::Iterator(occlusion.occlusionInScreenSpace()).size());
- EXPECT_RECT_EQ(gfx::Rect(0, 0, 300, 150), occlusion.occlusionInTargetSurface().bounds());
- EXPECT_EQ(5u, Region::Iterator(occlusion.occlusionInTargetSurface()).size());
+
+ Region expectedBlurredOcclusion;
+ expectedBlurredOcclusion.Union(gfx::Rect(0, 0, 300, 50 - outsetTop));
+ expectedBlurredOcclusion.Union(gfx::Rect(0, 50 - outsetTop, 50 - outsetLeft, 50 + outsetTop + outsetBottom));
+ expectedBlurredOcclusion.Union(gfx::Rect(100 + outsetRight, 50 - outsetTop, 100 - outsetRight - outsetLeft, 50 + outsetTop + outsetBottom));
+ expectedBlurredOcclusion.Union(gfx::Rect(250 + outsetRight, 50 - outsetTop, 50 - outsetRight, 50 + outsetTop + outsetBottom));
+ expectedBlurredOcclusion.Union(gfx::Rect(0, 100 + outsetBottom, 300, 50 - outsetBottom));
+
+ EXPECT_EQ(expectedBlurredOcclusion.ToString(), occlusion.occlusionInScreenSpace().ToString());
+ EXPECT_EQ(expectedBlurredOcclusion.ToString(), occlusion.occlusionInTargetSurface().ToString());
gfx::Rect outsetRect;
gfx::Rect testRect;
@@ -2815,25 +2725,20 @@ protected:
occlusion.setLayerClipRect(gfx::Rect(0, 0, 1000, 1000));
this->visitLayer(occludingLayerAbove, occlusion);
- EXPECT_RECT_EQ(gfx::Rect(100 / 2, 100 / 2, 50 / 2, 50 / 2), occlusion.occlusionInScreenSpace().bounds());
- EXPECT_EQ(1u, Region::Iterator(occlusion.occlusionInScreenSpace()).size());
- EXPECT_RECT_EQ(gfx::Rect(100 / 2, 100 / 2, 50 / 2, 50 / 2), occlusion.occlusionInTargetSurface().bounds());
- EXPECT_EQ(1u, Region::Iterator(occlusion.occlusionInTargetSurface()).size());
+ EXPECT_EQ(gfx::Rect(100 / 2, 100 / 2, 50 / 2, 50 / 2).ToString(), occlusion.occlusionInScreenSpace().ToString());
+ EXPECT_EQ(gfx::Rect(100 / 2, 100 / 2, 50 / 2, 50 / 2).ToString(), occlusion.occlusionInTargetSurface().ToString());
this->visitLayer(filteredSurface2, occlusion);
this->visitContributingSurface(filteredSurface2, occlusion);
this->visitLayer(filteredSurface1, occlusion);
this->visitContributingSurface(filteredSurface1, occlusion);
- ASSERT_EQ(1u, Region::Iterator(occlusion.occlusionInScreenSpace()).size());
- ASSERT_EQ(1u, Region::Iterator(occlusion.occlusionInTargetSurface()).size());
-
// Test expectations in the target.
gfx::Rect expectedOcclusion = gfx::Rect(100 / 2 + outsetRight * 2, 100 / 2 + outsetBottom * 2, 50 / 2 - (outsetLeft + outsetRight) * 2, 50 / 2 - (outsetTop + outsetBottom) * 2);
- EXPECT_RECT_EQ(expectedOcclusion, Region::Iterator(occlusion.occlusionInTargetSurface()).rect());
+ EXPECT_EQ(expectedOcclusion.ToString(), occlusion.occlusionInTargetSurface().ToString());
// Test expectations in the screen are the same as in the target, as the render surface is 1:1 with the screen.
- EXPECT_RECT_EQ(expectedOcclusion, Region::Iterator(occlusion.occlusionInScreenSpace()).rect());
+ EXPECT_EQ(expectedOcclusion.ToString(), occlusion.occlusionInScreenSpace().ToString());
}
};
@@ -2881,10 +2786,15 @@ protected:
this->visitLayer(occludingLayer2, occlusion);
this->visitLayer(occludingLayer1, occlusion);
- EXPECT_RECT_EQ(gfx::Rect(0, 0, 300, 150), occlusion.occlusionInScreenSpace().bounds());
- EXPECT_EQ(5u, Region::Iterator(occlusion.occlusionInScreenSpace()).size());
- EXPECT_RECT_EQ(gfx::Rect(0, 0, 300, 150), occlusion.occlusionInTargetSurface().bounds());
- EXPECT_EQ(5u, Region::Iterator(occlusion.occlusionInTargetSurface()).size());
+ Region expectedOcclusion;
+ expectedOcclusion.Union(gfx::Rect(0, 0, 300, 50));
+ expectedOcclusion.Union(gfx::Rect(0, 50, 50, 50));
+ expectedOcclusion.Union(gfx::Rect(100, 50, 100, 50));
+ expectedOcclusion.Union(gfx::Rect(250, 50, 50, 50));
+ expectedOcclusion.Union(gfx::Rect(0, 100, 300, 50));
+
+ EXPECT_EQ(expectedOcclusion.ToString(), occlusion.occlusionInScreenSpace().ToString());
+ EXPECT_EQ(expectedOcclusion.ToString(), occlusion.occlusionInTargetSurface().ToString());
// Everything outside the surface/replica is occluded but the surface/replica itself is not.
this->enterLayer(filteredSurface, occlusion);
@@ -2900,18 +2810,24 @@ protected:
this->leaveLayer(filteredSurface, occlusion);
// The filtered layer/replica does not occlude.
- EXPECT_RECT_EQ(gfx::Rect(0, 0, 300, 150), occlusion.occlusionInScreenSpace().bounds());
- EXPECT_EQ(5u, Region::Iterator(occlusion.occlusionInScreenSpace()).size());
- EXPECT_RECT_EQ(gfx::Rect(0, 0, 0, 0), occlusion.occlusionInTargetSurface().bounds());
- EXPECT_EQ(0u, Region::Iterator(occlusion.occlusionInTargetSurface()).size());
+ EXPECT_EQ(expectedOcclusion.ToString(), occlusion.occlusionInScreenSpace().ToString());
+ EXPECT_EQ(gfx::Rect().ToString(), occlusion.occlusionInTargetSurface().ToString());
// The surface has a background blur, so it needs pixels that are currently considered occluded in order to be drawn. So the pixels
// it needs should be removed some the occluded area so that when we get to the parent they are drawn.
this->visitContributingSurface(filteredSurface, occlusion);
this->enterContributingSurface(clippingSurface, occlusion);
- EXPECT_RECT_EQ(gfx::Rect(0, 0, 300, 150), occlusion.occlusionInScreenSpace().bounds());
- EXPECT_EQ(5u, Region::Iterator(occlusion.occlusionInScreenSpace()).size());
+
+ Region expectedBlurredOcclusion;
+ expectedBlurredOcclusion.Union(gfx::Rect(0, 0, 300, 50 - outsetTop));
+ expectedBlurredOcclusion.Union(gfx::Rect(0, 50 - outsetTop, 50 - outsetLeft, 20 + outsetTop + outsetBottom));
+ expectedBlurredOcclusion.Union(gfx::Rect(100 + outsetRight, 50 - outsetTop, 100 - outsetRight - outsetLeft, 20 + outsetTop + outsetBottom));
+ expectedBlurredOcclusion.Union(gfx::Rect(250 + outsetRight, 50 - outsetTop, 50 - outsetRight, 20 + outsetTop + outsetBottom));
+ expectedBlurredOcclusion.Union(gfx::Rect(0, 100 + 5, 300, 50 - 5));
+
+ EXPECT_EQ(expectedBlurredOcclusion.ToString(), occlusion.occlusionInScreenSpace().ToString());
+ EXPECT_EQ(gfx::Rect().ToString(), occlusion.occlusionInTargetSurface().ToString());
gfx::Rect outsetRect;
gfx::Rect clippedOutsetRect;
@@ -3001,11 +2917,9 @@ protected:
gfx::Rect occlusionBehindSurface = gfx::Rect(60, 60, 30, 30);
gfx::Rect occlusionBehindReplica = gfx::Rect(210, 60, 30, 30);
- gfx::Rect expectedOpaqueBounds = gfx::UnionRects(occlusionBehindSurface, occlusionBehindReplica);
- EXPECT_RECT_EQ(expectedOpaqueBounds, occlusion.occlusionInScreenSpace().bounds());
- EXPECT_EQ(2u, Region::Iterator(occlusion.occlusionInScreenSpace()).size());
- EXPECT_RECT_EQ(expectedOpaqueBounds, occlusion.occlusionInTargetSurface().bounds());
- EXPECT_EQ(2u, Region::Iterator(occlusion.occlusionInTargetSurface()).size());
+ Region expectedOpaqueBounds = UnionRegions(occlusionBehindSurface, occlusionBehindReplica);
+ EXPECT_EQ(expectedOpaqueBounds.ToString(), occlusion.occlusionInScreenSpace().ToString());
+ EXPECT_EQ(expectedOpaqueBounds.ToString(), occlusion.occlusionInTargetSurface().ToString());
}
};
@@ -3050,11 +2964,9 @@ protected:
gfx::Rect occlusionAboveSurface = gfx::Rect(50, 50, 50, 50);
gfx::Rect occlusionAboveReplica = gfx::Rect(200, 50, 50, 50);
- gfx::Rect expectedOpaqueBounds = gfx::UnionRects(occlusionAboveSurface, occlusionAboveReplica);
- EXPECT_RECT_EQ(expectedOpaqueBounds, occlusion.occlusionInScreenSpace().bounds());
- EXPECT_EQ(2u, Region::Iterator(occlusion.occlusionInScreenSpace()).size());
- EXPECT_RECT_EQ(expectedOpaqueBounds, occlusion.occlusionInTargetSurface().bounds());
- EXPECT_EQ(2u, Region::Iterator(occlusion.occlusionInTargetSurface()).size());
+ Region expectedOpaqueRegion = UnionRegions(occlusionAboveSurface, occlusionAboveReplica);
+ EXPECT_EQ(expectedOpaqueRegion, occlusion.occlusionInScreenSpace());
+ EXPECT_EQ(expectedOpaqueRegion, occlusion.occlusionInTargetSurface());
}
};
@@ -3118,8 +3030,8 @@ protected:
expectedOcclusion.Union(occlusionBesideSurface);
expectedOcclusion.Union(occlusionBesideReplica);
- ASSERT_EQ(Region::Iterator(expectedOcclusion).size(), Region::Iterator(occlusion.occlusionInTargetSurface()).size());
- ASSERT_EQ(Region::Iterator(expectedOcclusion).size(), Region::Iterator(occlusion.occlusionInScreenSpace()).size());
+ ASSERT_EQ(expectedOcclusion, occlusion.occlusionInTargetSurface());
+ ASSERT_EQ(expectedOcclusion, occlusion.occlusionInScreenSpace());
Region::Iterator expectedRects(expectedOcclusion);
Region::Iterator screenSpaceRects(occlusion.occlusionInScreenSpace());
@@ -3156,18 +3068,14 @@ protected:
// The small layer is not tracked because it is too small.
this->visitLayer(small, occlusion);
- EXPECT_RECT_EQ(gfx::Rect(), occlusion.occlusionInScreenSpace().bounds());
- EXPECT_EQ(0u, Region::Iterator(occlusion.occlusionInScreenSpace()).size());
- EXPECT_RECT_EQ(gfx::Rect(), occlusion.occlusionInTargetSurface().bounds());
- EXPECT_EQ(0u, Region::Iterator(occlusion.occlusionInTargetSurface()).size());
+ EXPECT_EQ(gfx::Rect().ToString(), occlusion.occlusionInScreenSpace().ToString());
+ EXPECT_EQ(gfx::Rect().ToString(), occlusion.occlusionInTargetSurface().ToString());
// The large layer is tracked as it is large enough.
this->visitLayer(large, occlusion);
- EXPECT_RECT_EQ(gfx::Rect(gfx::Point(), trackingSize), occlusion.occlusionInScreenSpace().bounds());
- EXPECT_EQ(1u, Region::Iterator(occlusion.occlusionInScreenSpace()).size());
- EXPECT_RECT_EQ(gfx::Rect(gfx::Point(), trackingSize), occlusion.occlusionInTargetSurface().bounds());
- EXPECT_EQ(1u, Region::Iterator(occlusion.occlusionInTargetSurface()).size());
+ EXPECT_EQ(gfx::Rect(gfx::Point(), trackingSize).ToString(), occlusion.occlusionInScreenSpace().ToString());
+ EXPECT_EQ(gfx::Rect(gfx::Point(), trackingSize).ToString(), occlusion.occlusionInTargetSurface().ToString());
}
};
diff --git a/cc/quad_culler.cc b/cc/quad_culler.cc
index a149795..d2636e6 100644
--- a/cc/quad_culler.cc
+++ b/cc/quad_culler.cc
@@ -6,7 +6,6 @@
#include "cc/quad_culler.h"
-#include "Region.h"
#include "cc/append_quads_data.h"
#include "cc/debug_border_draw_quad.h"
#include "cc/layer_impl.h"
diff --git a/cc/region.cc b/cc/region.cc
new file mode 100644
index 0000000..7a5e83c
--- /dev/null
+++ b/cc/region.cc
@@ -0,0 +1,109 @@
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "config.h"
+
+#include "cc/region.h"
+
+namespace cc {
+
+// TODO(danakj) Use method from ui/gfx/skia_utils.h when it exists.
+static inline SkIRect ToSkIRect(gfx::Rect rect)
+{
+ return SkIRect::MakeXYWH(rect.x(), rect.y(), rect.width(), rect.height());
+}
+
+Region::Region() {
+}
+
+Region::Region(const Region& region)
+ : skregion_(region.skregion_) {
+}
+
+Region::Region(gfx::Rect rect)
+ : skregion_(ToSkIRect(rect)) {
+}
+
+Region::~Region() {
+}
+
+const Region& Region::operator=(gfx::Rect rect) {
+ skregion_ = SkRegion(ToSkIRect(rect));
+ return *this;
+}
+
+const Region& Region::operator=(const Region& region) {
+ skregion_ = region.skregion_;
+ return *this;
+}
+
+bool Region::IsEmpty() const {
+ return skregion_.isEmpty();
+}
+
+bool Region::Contains(gfx::Point point) const {
+ return skregion_.contains(point.x(), point.y());
+}
+
+bool Region::Contains(gfx::Rect rect) const {
+ return skregion_.contains(ToSkIRect(rect));
+}
+
+bool Region::Contains(const Region& region) const {
+ return skregion_.contains(region.skregion_);
+}
+
+bool Region::Intersects(gfx::Rect rect) const {
+ return skregion_.intersects(ToSkIRect(rect));
+}
+
+bool Region::Intersects(const Region& region) const {
+ return skregion_.intersects(region.skregion_);
+}
+
+void Region::Subtract(gfx::Rect rect) {
+ skregion_.op(ToSkIRect(rect), SkRegion::kDifference_Op);
+}
+
+void Region::Subtract(const Region& region) {
+ skregion_.op(region.skregion_, SkRegion::kDifference_Op);
+}
+
+void Region::Union(gfx::Rect rect) {
+ skregion_.op(ToSkIRect(rect), SkRegion::kUnion_Op);
+}
+
+void Region::Union(const Region& region) {
+ skregion_.op(region.skregion_, SkRegion::kUnion_Op);
+}
+
+void Region::Intersect(gfx::Rect rect) {
+ skregion_.op(ToSkIRect(rect), SkRegion::kIntersect_Op);
+}
+
+void Region::Intersect(const Region& region) {
+ skregion_.op(region.skregion_, SkRegion::kIntersect_Op);
+}
+
+std::string Region::ToString() const {
+ if (IsEmpty())
+ return gfx::Rect().ToString();
+
+ std::string result;
+ for (Iterator it(*this); it.has_rect(); it.next()) {
+ if (!result.empty())
+ result += " | ";
+ result += it.rect().ToString();
+ }
+ return result;
+}
+
+Region::Iterator::Iterator(const Region& region)
+ : it_(region.skregion_) {
+}
+
+Region::Iterator::~Iterator() {
+}
+
+} // namespace cc
diff --git a/cc/region.h b/cc/region.h
new file mode 100644
index 0000000..49ad5f3
--- /dev/null
+++ b/cc/region.h
@@ -0,0 +1,125 @@
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CC_REGION_H_
+#define CC_REGION_H_
+
+#include <string>
+
+#include "base/logging.h"
+#include "cc/cc_export.h"
+#include "third_party/skia/include/core/SkRegion.h"
+#include "ui/gfx/rect.h"
+
+namespace cc {
+
+class CC_EXPORT Region {
+ public:
+ Region();
+ Region(const Region& region);
+ Region(gfx::Rect rect);
+ ~Region();
+
+ const Region& operator=(gfx::Rect rect);
+ const Region& operator=(const Region& region);
+
+ bool IsEmpty() const;
+
+ bool Contains(gfx::Point point) const;
+ bool Contains(gfx::Rect rect) const;
+ bool Contains(const Region& region) const;
+
+ bool Intersects(gfx::Rect rect) const;
+ bool Intersects(const Region& region) const;
+
+ void Subtract(gfx::Rect rect);
+ void Subtract(const Region& region);
+ void Union(gfx::Rect rect);
+ void Union(const Region& region);
+ void Intersect(gfx::Rect rect);
+ void Intersect(const Region& region);
+
+ bool Equals(const Region& other) const { return skregion_ == other.skregion_; }
+
+ gfx::Rect bounds() const {
+ SkIRect r = skregion_.getBounds();
+ // TODO(danakj) Use method from ui/gfx/skia_utils.h when it exists.
+ return gfx::Rect(r.x(), r.y(), r.width(), r.height());
+ }
+
+ std::string ToString() const;
+
+ class CC_EXPORT Iterator {
+ public:
+ Iterator(const Region& region);
+ ~Iterator();
+
+ gfx::Rect rect() const {
+ SkIRect r = it_.rect();
+ // TODO(danakj) Use method from ui/gfx/skia_utils.h when it exists.
+ return gfx::Rect(r.x(), r.y(), r.width(), r.height());
+ }
+
+ void next() {
+ it_.next();
+ }
+ bool has_rect() const {
+ return !it_.done();
+ }
+
+ private:
+ SkRegion::Iterator it_;
+ };
+
+ private:
+ SkRegion skregion_;
+};
+
+inline bool operator==(const Region& a, const Region& b) {
+ return a.Equals(b);
+}
+
+inline bool operator!=(const Region& a, const Region& b) {
+ return !(a == b);
+}
+
+inline Region SubtractRegions(const Region& a, const Region& b) {
+ Region result = a;
+ result.Subtract(b);
+ return result;
+}
+
+inline Region SubtractRegions(const Region& a, gfx::Rect b) {
+ Region result = a;
+ result.Subtract(b);
+ return result;
+}
+
+inline Region IntersectRegions(const Region& a, const Region& b) {
+ Region result = a;
+ result.Intersect(b);
+ return result;
+}
+
+inline Region IntersectRegions(const Region& a, gfx::Rect b) {
+ Region result = a;
+ result.Intersect(b);
+ return result;
+}
+
+inline Region UnionRegions(const Region& a, const Region& b) {
+ Region result = a;
+ result.Union(b);
+ return result;
+}
+
+inline Region UnionRegions(const Region& a, gfx::Rect b) {
+ Region result = a;
+ result.Union(b);
+ return result;
+}
+
+} // namespace cc
+
+#endif // CC_REGION_H_
diff --git a/cc/region_unittest.cc b/cc/region_unittest.cc
new file mode 100644
index 0000000..2fd52d6
--- /dev/null
+++ b/cc/region_unittest.cc
@@ -0,0 +1,420 @@
+// Copyright 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "config.h"
+
+#include "cc/region.h"
+
+#include "testing/gtest/include/gtest/gtest.h"
+
+using namespace cc;
+
+namespace {
+
+#define TEST_INSIDE_RECT(r, x, y, w, h) \
+ EXPECT_TRUE(r.Contains(gfx::Point(x, y))); \
+ EXPECT_TRUE(r.Contains(gfx::Point(x + w - 1, y))); \
+ EXPECT_TRUE(r.Contains(gfx::Point(x, y + h - 1))); \
+ EXPECT_TRUE(r.Contains(gfx::Point(x + w - 1, y + h - 1))); \
+ EXPECT_TRUE(r.Contains(gfx::Point(x, y + h / 2))); \
+ EXPECT_TRUE(r.Contains(gfx::Point(x + w - 1, y + h / 2))); \
+ EXPECT_TRUE(r.Contains(gfx::Point(x + w / 2, y))); \
+ EXPECT_TRUE(r.Contains(gfx::Point(x + w / 2, y + h - 1))); \
+ EXPECT_TRUE(r.Contains(gfx::Point(x + w / 2, y + h / 2))); \
+
+#define TEST_LEFT_OF_RECT(r, x, y, w, h) \
+ EXPECT_FALSE(r.Contains(gfx::Point(x - 1, y))); \
+ EXPECT_FALSE(r.Contains(gfx::Point(x - 1, y + h - 1))); \
+
+#define TEST_RIGHT_OF_RECT(r, x, y, w, h) \
+ EXPECT_FALSE(r.Contains(gfx::Point(x + w, y))); \
+ EXPECT_FALSE(r.Contains(gfx::Point(x + w, y + h - 1))); \
+
+#define TEST_TOP_OF_RECT(r, x, y, w, h) \
+ EXPECT_FALSE(r.Contains(gfx::Point(x, y - 1))); \
+ EXPECT_FALSE(r.Contains(gfx::Point(x + w - 1, y - 1))); \
+
+#define TEST_BOTTOM_OF_RECT(r, x, y, w, h) \
+ EXPECT_FALSE(r.Contains(gfx::Point(x, y + h))); \
+ EXPECT_FALSE(r.Contains(gfx::Point(x + w - 1, y + h))); \
+
+TEST(RegionTest, ContainsPoint) {
+ Region r;
+
+ EXPECT_FALSE(r.Contains(gfx::Point(0, 0)));
+
+ r.Union(gfx::Rect(35, 35, 1, 1));
+ TEST_INSIDE_RECT(r, 35, 35, 1, 1);
+ TEST_LEFT_OF_RECT(r, 35, 35, 1, 1);
+ TEST_RIGHT_OF_RECT(r, 35, 35, 1, 1);
+ TEST_TOP_OF_RECT(r, 35, 35, 1, 1);
+ TEST_BOTTOM_OF_RECT(r, 35, 35, 1, 1);
+
+ r.Union(gfx::Rect(30, 30, 10, 10));
+ TEST_INSIDE_RECT(r, 30, 30, 10, 10);
+ TEST_LEFT_OF_RECT(r, 30, 30, 10, 10);
+ TEST_RIGHT_OF_RECT(r, 30, 30, 10, 10);
+ TEST_TOP_OF_RECT(r, 30, 30, 10, 10);
+ TEST_BOTTOM_OF_RECT(r, 30, 30, 10, 10);
+
+ r.Union(gfx::Rect(31, 40, 10, 10));
+ EXPECT_FALSE(r.Contains(gfx::Point(30, 40)));
+ EXPECT_TRUE(r.Contains(gfx::Point(31, 40)));
+ EXPECT_FALSE(r.Contains(gfx::Point(40, 39)));
+ EXPECT_TRUE(r.Contains(gfx::Point(40, 40)));
+
+ TEST_INSIDE_RECT(r, 30, 30, 10, 10);
+ TEST_LEFT_OF_RECT(r, 30, 30, 10, 10);
+ TEST_RIGHT_OF_RECT(r, 30, 30, 10, 10);
+ TEST_TOP_OF_RECT(r, 30, 30, 10, 10);
+ TEST_INSIDE_RECT(r, 31, 40, 10, 10);
+ TEST_LEFT_OF_RECT(r, 31, 40, 10, 10);
+ TEST_RIGHT_OF_RECT(r, 31, 40, 10, 10);
+ TEST_BOTTOM_OF_RECT(r, 31, 40, 10, 10);
+
+ r.Union(gfx::Rect(42, 40, 10, 10));
+
+ TEST_INSIDE_RECT(r, 42, 40, 10, 10);
+ TEST_LEFT_OF_RECT(r, 42, 40, 10, 10);
+ TEST_RIGHT_OF_RECT(r, 42, 40, 10, 10);
+ TEST_TOP_OF_RECT(r, 42, 40, 10, 10);
+ TEST_BOTTOM_OF_RECT(r, 42, 40, 10, 10);
+
+ TEST_INSIDE_RECT(r, 30, 30, 10, 10);
+ TEST_LEFT_OF_RECT(r, 30, 30, 10, 10);
+ TEST_RIGHT_OF_RECT(r, 30, 30, 10, 10);
+ TEST_TOP_OF_RECT(r, 30, 30, 10, 10);
+ TEST_INSIDE_RECT(r, 31, 40, 10, 10);
+ TEST_LEFT_OF_RECT(r, 31, 40, 10, 10);
+ TEST_RIGHT_OF_RECT(r, 31, 40, 10, 10);
+ TEST_BOTTOM_OF_RECT(r, 31, 40, 10, 10);
+}
+
+TEST(RegionTest, EmptySpan) {
+ Region r;
+ r.Union(gfx::Rect(5, 0, 10, 10));
+ r.Union(gfx::Rect(0, 5, 10, 10));
+ r.Subtract(gfx::Rect(7, 7, 10, 0));
+
+ for (Region::Iterator it(r); it.has_rect(); it.next())
+ EXPECT_FALSE(it.rect().IsEmpty());
+}
+
+#define TEST_NO_INTERSECT(a, b) { \
+ Region ar = a; \
+ Region br = b; \
+ EXPECT_FALSE(ar.Intersects(br)); \
+ EXPECT_FALSE(br.Intersects(ar)); \
+ EXPECT_FALSE(ar.Intersects(b)); \
+ EXPECT_FALSE(br.Intersects(a)); \
+}
+
+#define TEST_INTERSECT(a, b) { \
+ Region ar = a; \
+ Region br = b; \
+ EXPECT_TRUE(ar.Intersects(br)); \
+ EXPECT_TRUE(br.Intersects(ar)); \
+ EXPECT_TRUE(ar.Intersects(b)); \
+ EXPECT_TRUE(br.Intersects(a)); \
+}
+
+TEST(RegionTest, IntersectsRegion) {
+ Region r;
+
+ TEST_NO_INTERSECT(gfx::Rect(), gfx::Rect());
+ TEST_NO_INTERSECT(gfx::Rect(), gfx::Rect(0, 0, 1, 1));
+ TEST_NO_INTERSECT(gfx::Rect(), gfx::Rect(1, 1, 1, 1));
+
+ TEST_NO_INTERSECT(gfx::Rect(-1, -1, 2, 2), gfx::Rect());
+
+ r.Union(gfx::Rect(0, 0, 1, 1));
+ TEST_NO_INTERSECT(r, gfx::Rect());
+ TEST_INTERSECT(r, gfx::Rect(0, 0, 1, 1));
+ TEST_INTERSECT(r, gfx::Rect(0, 0, 2, 2));
+ TEST_INTERSECT(r, gfx::Rect(-1, 0, 2, 2));
+ TEST_INTERSECT(r, gfx::Rect(-1, -1, 2, 2));
+ TEST_INTERSECT(r, gfx::Rect(0, -1, 2, 2));
+ TEST_INTERSECT(r, gfx::Rect(-1, -1, 3, 3));
+
+ r.Union(gfx::Rect(0, 0, 3, 3));
+ r.Union(gfx::Rect(10, 0, 3, 3));
+ r.Union(gfx::Rect(0, 10, 13, 3));
+ TEST_NO_INTERSECT(r, gfx::Rect());
+ TEST_INTERSECT(r, gfx::Rect(1, 1, 1, 1));
+ TEST_INTERSECT(r, gfx::Rect(0, 0, 2, 2));
+ TEST_INTERSECT(r, gfx::Rect(1, 0, 2, 2));
+ TEST_INTERSECT(r, gfx::Rect(1, 1, 2, 2));
+ TEST_INTERSECT(r, gfx::Rect(0, 1, 2, 2));
+ TEST_INTERSECT(r, gfx::Rect(0, 0, 3, 3));
+ TEST_INTERSECT(r, gfx::Rect(-1, -1, 2, 2));
+ TEST_INTERSECT(r, gfx::Rect(2, -1, 2, 2));
+ TEST_INTERSECT(r, gfx::Rect(2, 2, 2, 2));
+ TEST_INTERSECT(r, gfx::Rect(-1, 2, 2, 2));
+
+ TEST_INTERSECT(r, gfx::Rect(11, 1, 1, 1));
+ TEST_INTERSECT(r, gfx::Rect(10, 0, 2, 2));
+ TEST_INTERSECT(r, gfx::Rect(11, 0, 2, 2));
+ TEST_INTERSECT(r, gfx::Rect(11, 1, 2, 2));
+ TEST_INTERSECT(r, gfx::Rect(10, 1, 2, 2));
+ TEST_INTERSECT(r, gfx::Rect(10, 0, 3, 3));
+ TEST_INTERSECT(r, gfx::Rect(9, -1, 2, 2));
+ TEST_INTERSECT(r, gfx::Rect(12, -1, 2, 2));
+ TEST_INTERSECT(r, gfx::Rect(12, 2, 2, 2));
+ TEST_INTERSECT(r, gfx::Rect(9, 2, 2, 2));
+
+ TEST_INTERSECT(r, gfx::Rect(0, -1, 13, 5));
+ TEST_INTERSECT(r, gfx::Rect(1, -1, 11, 5));
+ TEST_INTERSECT(r, gfx::Rect(2, -1, 9, 5));
+ TEST_INTERSECT(r, gfx::Rect(2, -1, 8, 5));
+ TEST_INTERSECT(r, gfx::Rect(3, -1, 8, 5));
+ TEST_NO_INTERSECT(r, gfx::Rect(3, -1, 7, 5));
+
+ TEST_INTERSECT(r, gfx::Rect(0, 1, 13, 1));
+ TEST_INTERSECT(r, gfx::Rect(1, 1, 11, 1));
+ TEST_INTERSECT(r, gfx::Rect(2, 1, 9, 1));
+ TEST_INTERSECT(r, gfx::Rect(2, 1, 8, 1));
+ TEST_INTERSECT(r, gfx::Rect(3, 1, 8, 1));
+ TEST_NO_INTERSECT(r, gfx::Rect(3, 1, 7, 1));
+
+ TEST_INTERSECT(r, gfx::Rect(0, 0, 13, 13));
+ TEST_INTERSECT(r, gfx::Rect(0, 1, 13, 11));
+ TEST_INTERSECT(r, gfx::Rect(0, 2, 13, 9));
+ TEST_INTERSECT(r, gfx::Rect(0, 2, 13, 8));
+ TEST_INTERSECT(r, gfx::Rect(0, 3, 13, 8));
+ TEST_NO_INTERSECT(r, gfx::Rect(0, 3, 13, 7));
+}
+
+TEST(RegionTest, ReadPastFullSpanVectorInIntersectsTest) {
+ Region r;
+
+ // This region has enough spans to fill its allocated Vector exactly.
+ r.Union(gfx::Rect(400, 300, 1, 800));
+ r.Union(gfx::Rect(785, 585, 1, 1));
+ r.Union(gfx::Rect(787, 585, 1, 1));
+ r.Union(gfx::Rect(0, 587, 16, 162));
+ r.Union(gfx::Rect(26, 590, 300, 150));
+ r.Union(gfx::Rect(196, 750, 1, 1));
+ r.Union(gfx::Rect(0, 766, 1, 1));
+ r.Union(gfx::Rect(0, 782, 1, 1));
+ r.Union(gfx::Rect(745, 798, 1, 1));
+ r.Union(gfx::Rect(795, 882, 10, 585));
+ r.Union(gfx::Rect(100, 1499, 586, 1));
+ r.Union(gfx::Rect(100, 1500, 585, 784));
+ // This query rect goes past the bottom of the Region, causing the
+ // test to reach the last span and try go past it. It should not read
+ // memory off the end of the span Vector.
+ TEST_NO_INTERSECT(r, gfx::Rect(0, 2184, 1, 150));
+}
+
+#define TEST_NO_CONTAINS(a, b) \
+ { \
+ Region ar = a; \
+ Region br = b; \
+ EXPECT_FALSE(ar.Contains(br)); \
+ EXPECT_FALSE(ar.Contains(b)); \
+ }
+
+#define TEST_CONTAINS(a, b) \
+ { \
+ Region ar = a; \
+ Region br = b; \
+ EXPECT_TRUE(ar.Contains(br)); \
+ EXPECT_TRUE(ar.Contains(b)); \
+ }
+
+TEST(RegionTest, ContainsRegion) {
+ TEST_NO_CONTAINS(gfx::Rect(), gfx::Rect());
+ TEST_NO_CONTAINS(gfx::Rect(), gfx::Rect(0, 0, 1, 1));
+ TEST_NO_CONTAINS(gfx::Rect(), gfx::Rect(1, 1, 1, 1));
+
+ TEST_NO_CONTAINS(gfx::Rect(10, 10, 1, 1), gfx::Rect(11, 10, 1, 1));
+ TEST_NO_CONTAINS(gfx::Rect(10, 10, 1, 1), gfx::Rect(10, 11, 1, 1));
+ TEST_NO_CONTAINS(gfx::Rect(10, 10, 1, 1), gfx::Rect(9, 10, 1, 1));
+ TEST_NO_CONTAINS(gfx::Rect(10, 10, 1, 1), gfx::Rect(10, 9, 1, 1));
+ TEST_NO_CONTAINS(gfx::Rect(10, 10, 1, 1), gfx::Rect(9, 9, 2, 2));
+ TEST_NO_CONTAINS(gfx::Rect(10, 10, 1, 1), gfx::Rect(10, 9, 2, 2));
+ TEST_NO_CONTAINS(gfx::Rect(10, 10, 1, 1), gfx::Rect(9, 10, 2, 2));
+ TEST_NO_CONTAINS(gfx::Rect(10, 10, 1, 1), gfx::Rect(10, 10, 2, 2));
+ TEST_NO_CONTAINS(gfx::Rect(10, 10, 1, 1), gfx::Rect(9, 9, 3, 3));
+
+ Region hLines;
+ for (int i = 10; i < 20; i += 2)
+ hLines.Union(gfx::Rect(i, 10, 1, 10));
+
+ TEST_CONTAINS(gfx::Rect(10, 10, 9, 10), hLines);
+ TEST_NO_CONTAINS(gfx::Rect(10, 10, 9, 9), hLines);
+ TEST_NO_CONTAINS(gfx::Rect(10, 11, 9, 9), hLines);
+ TEST_NO_CONTAINS(gfx::Rect(10, 10, 8, 10), hLines);
+ TEST_NO_CONTAINS(gfx::Rect(11, 10, 8, 10), hLines);
+
+ Region vLines;
+ for (int i = 10; i < 20; i += 2)
+ vLines.Union(gfx::Rect(10, i, 10, 1));
+
+ TEST_CONTAINS(gfx::Rect(10, 10, 10, 9), vLines);
+ TEST_NO_CONTAINS(gfx::Rect(10, 10, 9, 9), vLines);
+ TEST_NO_CONTAINS(gfx::Rect(11, 10, 9, 9), vLines);
+ TEST_NO_CONTAINS(gfx::Rect(10, 10, 10, 8), vLines);
+ TEST_NO_CONTAINS(gfx::Rect(10, 11, 10, 8), vLines);
+
+ Region grid;
+ for (int i = 10; i < 20; i += 2)
+ for (int j = 10; j < 20; j += 2)
+ grid.Union(gfx::Rect(i, j, 1, 1));
+
+ TEST_CONTAINS(gfx::Rect(10, 10, 9, 9), grid);
+ TEST_NO_CONTAINS(gfx::Rect(10, 10, 9, 8), grid);
+ TEST_NO_CONTAINS(gfx::Rect(10, 11, 9, 8), grid);
+ TEST_NO_CONTAINS(gfx::Rect(10, 10, 8, 9), grid);
+ TEST_NO_CONTAINS(gfx::Rect(11, 10, 8, 9), grid);
+
+ TEST_CONTAINS(hLines, hLines);
+ TEST_CONTAINS(vLines, vLines);
+ TEST_NO_CONTAINS(vLines, hLines);
+ TEST_NO_CONTAINS(hLines, vLines);
+ TEST_CONTAINS(grid, grid);
+ TEST_CONTAINS(hLines, grid);
+ TEST_CONTAINS(vLines, grid);
+ TEST_NO_CONTAINS(grid, hLines);
+ TEST_NO_CONTAINS(grid, vLines);
+
+ for (int i = 10; i < 20; i += 2)
+ TEST_CONTAINS(hLines, gfx::Rect(i, 10, 1, 10));
+
+ for (int i = 10; i < 20; i += 2)
+ TEST_CONTAINS(vLines, gfx::Rect(10, i, 10, 1));
+
+ for (int i = 10; i < 20; i += 2)
+ for (int j = 10; j < 20; j += 2)
+ TEST_CONTAINS(grid, gfx::Rect(i, j, 1, 1));
+
+ Region container;
+ container.Union(gfx::Rect(0, 0, 40, 20));
+ container.Union(gfx::Rect(0, 20, 41, 20));
+ TEST_CONTAINS(container, gfx::Rect(5, 5, 30, 30));
+
+ container = Region();
+ container.Union(gfx::Rect(0, 0, 10, 10));
+ container.Union(gfx::Rect(0, 30, 10, 10));
+ container.Union(gfx::Rect(30, 30, 10, 10));
+ container.Union(gfx::Rect(30, 0, 10, 10));
+ TEST_NO_CONTAINS(container, gfx::Rect(5, 5, 30, 30));
+
+ container = Region();
+ container.Union(gfx::Rect(0, 0, 10, 10));
+ container.Union(gfx::Rect(0, 30, 10, 10));
+ container.Union(gfx::Rect(30, 0, 10, 40));
+ TEST_NO_CONTAINS(container, gfx::Rect(5, 5, 30, 30));
+
+ container = Region();
+ container.Union(gfx::Rect(30, 0, 10, 10));
+ container.Union(gfx::Rect(30, 30, 10, 10));
+ container.Union(gfx::Rect(0, 0, 10, 40));
+ TEST_NO_CONTAINS(container, gfx::Rect(5, 5, 30, 30));
+
+ container = Region();
+ container.Union(gfx::Rect(0, 0, 10, 40));
+ container.Union(gfx::Rect(30, 0, 10, 40));
+ TEST_NO_CONTAINS(container, gfx::Rect(5, 5, 30, 30));
+
+ container = Region();
+ container.Union(gfx::Rect(0, 0, 40, 40));
+ TEST_NO_CONTAINS(container, gfx::Rect(10, -1, 20, 10));
+
+ container = Region();
+ container.Union(gfx::Rect(0, 0, 40, 40));
+ TEST_NO_CONTAINS(container, gfx::Rect(10, 31, 20, 10));
+
+ container = Region();
+ container.Union(gfx::Rect(0, 0, 40, 20));
+ container.Union(gfx::Rect(0, 20, 41, 20));
+ TEST_NO_CONTAINS(container, gfx::Rect(-1, 10, 10, 20));
+
+ container = Region();
+ container.Union(gfx::Rect(0, 0, 40, 20));
+ container.Union(gfx::Rect(0, 20, 41, 20));
+ TEST_NO_CONTAINS(container, gfx::Rect(31, 10, 10, 20));
+
+ container = Region();
+ container.Union(gfx::Rect(0, 0, 40, 40));
+ container.Subtract(gfx::Rect(0, 20, 60, 0));
+ TEST_NO_CONTAINS(container, gfx::Rect(31, 10, 10, 20));
+
+ container = Region();
+ container.Union(gfx::Rect(0, 0, 60, 20));
+ container.Union(gfx::Rect(30, 20, 10, 20));
+ TEST_NO_CONTAINS(container, gfx::Rect(0, 0, 10, 39));
+ TEST_NO_CONTAINS(container, gfx::Rect(0, 0, 10, 40));
+ TEST_NO_CONTAINS(container, gfx::Rect(0, 0, 10, 41));
+ TEST_NO_CONTAINS(container, gfx::Rect(29, 0, 10, 39));
+ TEST_CONTAINS(container, gfx::Rect(30, 0, 10, 40));
+ TEST_NO_CONTAINS(container, gfx::Rect(31, 0, 10, 41));
+ TEST_NO_CONTAINS(container, gfx::Rect(49, 0, 10, 39));
+ TEST_NO_CONTAINS(container, gfx::Rect(50, 0, 10, 40));
+ TEST_NO_CONTAINS(container, gfx::Rect(51, 0, 10, 41));
+
+ container = Region();
+ container.Union(gfx::Rect(30, 0, 10, 20));
+ container.Union(gfx::Rect(0, 20, 60, 20));
+ TEST_NO_CONTAINS(container, gfx::Rect(0, 0, 10, 39));
+ TEST_NO_CONTAINS(container, gfx::Rect(0, 0, 10, 40));
+ TEST_NO_CONTAINS(container, gfx::Rect(0, 0, 10, 41));
+ TEST_NO_CONTAINS(container, gfx::Rect(29, 0, 10, 39));
+ TEST_CONTAINS(container, gfx::Rect(30, 0, 10, 40));
+ TEST_NO_CONTAINS(container, gfx::Rect(31, 0, 10, 41));
+ TEST_NO_CONTAINS(container, gfx::Rect(49, 0, 10, 39));
+ TEST_NO_CONTAINS(container, gfx::Rect(50, 0, 10, 40));
+ TEST_NO_CONTAINS(container, gfx::Rect(51, 0, 10, 41));
+}
+
+TEST(RegionTest, Union) {
+ Region r;
+ Region r2;
+
+ // A rect uniting a contained rect does not change the region.
+ r2 = r = gfx::Rect(0, 0, 50, 50);
+ r2.Union(gfx::Rect(20, 20, 10, 10));
+ EXPECT_EQ(r, r2);
+
+ // A rect uniting a containing rect gives back the containing rect.
+ r = gfx::Rect(0, 0, 50, 50);
+ r.Union(gfx::Rect(0, 0, 100, 100));
+ EXPECT_EQ(Region(gfx::Rect(0, 0, 100, 100)), r);
+
+ // A complex region uniting a contained rect does not change the region.
+ r = gfx::Rect(0, 0, 50, 50);
+ r.Union(gfx::Rect(100, 0, 50, 50));
+ r2 = r;
+ r2.Union(gfx::Rect(20, 20, 10, 10));
+ EXPECT_EQ(r, r2);
+
+ // A complex region uniting a containing rect gives back the containing rect.
+ r = gfx::Rect(0, 0, 50, 50);
+ r.Union(gfx::Rect(100, 0, 50, 50));
+ r.Union(gfx::Rect(0, 0, 500, 500));
+ EXPECT_EQ(Region(gfx::Rect(0, 0, 500, 500)), r);
+}
+
+TEST(RegionTest, IsEmpty) {
+ EXPECT_TRUE(Region().IsEmpty());
+ EXPECT_TRUE(Region(gfx::Rect()).IsEmpty());
+ EXPECT_TRUE(Region(Region()).IsEmpty());
+ EXPECT_TRUE(Region(gfx::Rect(10, 10, 10, 0)).IsEmpty());
+ EXPECT_TRUE(Region(gfx::Rect(10, 10, 0, 10)).IsEmpty());
+ EXPECT_TRUE(Region(gfx::Rect(-10, 10, 10, 0)).IsEmpty());
+ EXPECT_TRUE(Region(gfx::Rect(-10, 10, 0, 10)).IsEmpty());
+ EXPECT_FALSE(Region(gfx::Rect(-1, -1, 1, 1)).IsEmpty());
+ EXPECT_FALSE(Region(gfx::Rect(0, 0, 1, 1)).IsEmpty());
+ EXPECT_FALSE(Region(gfx::Rect(0, 0, 2, 2)).IsEmpty());
+
+ EXPECT_TRUE(SkIRect::MakeXYWH(10, 10, 10, 0).isEmpty());
+ EXPECT_TRUE(SkIRect::MakeXYWH(10, 10, 0, 10).isEmpty());
+ EXPECT_TRUE(SkIRect::MakeXYWH(-10, 10, 10, 0).isEmpty());
+ EXPECT_TRUE(SkIRect::MakeXYWH(-10, 10, 0, 10).isEmpty());
+ EXPECT_FALSE(SkIRect::MakeXYWH(-1, -1, 1, 1).isEmpty());
+ EXPECT_FALSE(SkIRect::MakeXYWH(0, 0, 1, 1).isEmpty());
+ EXPECT_FALSE(SkIRect::MakeXYWH(0, 0, 2, 2).isEmpty());
+}
+
+} // namespace
diff --git a/cc/render_surface_impl.cc b/cc/render_surface_impl.cc
index 0ed8ede..a321424 100644
--- a/cc/render_surface_impl.cc
+++ b/cc/render_surface_impl.cc
@@ -6,6 +6,8 @@
#include "cc/render_surface_impl.h"
+#include <algorithm>
+
#include "base/logging.h"
#include "base/stringprintf.h"
#include "cc/damage_tracker.h"
diff --git a/cc/stubs/Region.h b/cc/stubs/Region.h
deleted file mode 100644
index 9f886ac..0000000
--- a/cc/stubs/Region.h
+++ /dev/null
@@ -1,98 +0,0 @@
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef CC_STUBS_REGION_H_
-#define CC_STUBS_REGION_H_
-
-#if INSIDE_WEBKIT_BUILD
-#include "Source/WebCore/platform/graphics/Region.h"
-#else
-#include "third_party/WebKit/Source/WebCore/platform/graphics/Region.h"
-#endif
-#include "base/logging.h"
-#include "ui/gfx/rect.h"
-
-namespace cc {
-
-class Region : public WebCore::Region {
-public:
- Region() { }
-
- Region(const WebCore::Region& region)
- : WebCore::Region(region)
- {
- }
-
- Region(const gfx::Rect& rect)
- : WebCore::Region(WebCore::IntRect(rect.x(), rect.y(), rect.width(), rect.height()))
- {
- }
-
- bool IsEmpty() const { return isEmpty(); }
-
- bool Contains(const gfx::Point& point) const { return contains(WebCore::IntPoint(point.x(), point.y())); }
- bool Contains(const gfx::Rect& rect) const { return contains(WebCore::IntRect(rect.x(), rect.y(), rect.width(), rect.height())); }
- void Subtract(const gfx::Rect& rect) { subtract(WebCore::IntRect(rect.x(), rect.y(), rect.width(), rect.height())); }
- void Subtract(const Region& region) { subtract(region); }
- void Union(const gfx::Rect& rect) { unite(WebCore::IntRect(rect.x(), rect.y(), rect.width(), rect.height())); }
- void Union(const Region& region) { unite(region); }
- void Intersect(const gfx::Rect& rect) { intersect(WebCore::IntRect(rect.x(), rect.y(), rect.width(), rect.height())); }
- void Intersect(const Region& region) { intersect(region); }
-
- gfx::Rect bounds() const
- {
- WebCore::IntRect bounds = WebCore::Region::bounds();
- return gfx::Rect(bounds.x(), bounds.y(), bounds.width(), bounds.height());
- }
-
- class Iterator {
- public:
- Iterator(const Region& region);
- ~Iterator();
-
- gfx::Rect rect() const {
- DCHECK(has_rect());
- if (!has_rect())
- return gfx::Rect();
- return gfx::Rect(m_rects[m_pos].x(), m_rects[m_pos].y(), m_rects[m_pos].width(), m_rects[m_pos].height());
- }
-
- void next() { ++m_pos; }
- bool has_rect() const { return m_pos < m_rects.size(); }
-
- // It is expensive to construct the iterator just to get this size. Only
- // do this for testing.
- size_t size() const { return m_rects.size(); }
- private:
- size_t m_pos;
- Vector<WebCore::IntRect> m_rects;
- };
-
-private:
- bool isEmpty() const { return WebCore::Region::isEmpty(); }
- bool contains(const WebCore::IntPoint& point) const { return WebCore::Region::contains(point); }
- bool contains(const WebCore::IntRect& rect) const { return WebCore::Region::contains(rect); }
- void subtract(const WebCore::IntRect& rect) { return WebCore::Region::subtract(rect); }
- void subtract(const Region& region) { return WebCore::Region::subtract(region); }
- void unite(const WebCore::IntRect& rect) { return WebCore::Region::unite(rect); }
- void unite(const Region& region) { return WebCore::Region::unite(region); }
- void intersect(const WebCore::IntRect& rect) { return WebCore::Region::intersect(rect); }
- void intersect(const Region& region) { return WebCore::Region::intersect(region); }
- Vector<WebCore::IntRect> rects() const { return WebCore::Region::rects(); }
-};
-
-inline Region subtract(const Region& region, const gfx::Rect& rect) { return WebCore::intersect(region, WebCore::IntRect(rect.x(), rect.y(), rect.width(), rect.height())); }
-inline Region intersect(const Region& region, const gfx::Rect& rect) { return WebCore::intersect(region, WebCore::IntRect(rect.x(), rect.y(), rect.width(), rect.height())); }
-
-inline Region::Iterator::Iterator(const Region& region)
- : m_pos(0)
- , m_rects(region.rects())
-{
-}
-
-inline Region::Iterator::~Iterator() { }
-
-}
-
-#endif // CC_STUBS_REGION_H_
diff --git a/cc/test/layer_test_common.cc b/cc/test/layer_test_common.cc
index 3fe716f..d26cfc3 100644
--- a/cc/test/layer_test_common.cc
+++ b/cc/test/layer_test_common.cc
@@ -6,9 +6,9 @@
#include "cc/test/layer_test_common.h"
-#include "Region.h"
#include "cc/draw_quad.h"
#include "cc/math_util.h"
+#include "cc/region.h"
#include "cc/render_pass.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "ui/gfx/rect.h"
diff --git a/cc/test/occlusion_tracker_test_common.h b/cc/test/occlusion_tracker_test_common.h
index 7619ad8..8186553 100644
--- a/cc/test/occlusion_tracker_test_common.h
+++ b/cc/test/occlusion_tracker_test_common.h
@@ -5,7 +5,6 @@
#ifndef CC_TEST_OCCLUSION_TRACKER_TEST_COMMON_H_
#define CC_TEST_OCCLUSION_TRACKER_TEST_COMMON_H_
-#include "Region.h"
#include "cc/occlusion_tracker.h"
#include "cc/render_surface.h"
#include "cc/render_surface_impl.h"
@@ -21,11 +20,11 @@ public:
{
}
- cc::Region occlusionInScreenSpace() const { return cc::OcclusionTrackerBase<LayerType, RenderSurfaceType>::m_stack.last().occlusionInScreen; }
- cc::Region occlusionInTargetSurface() const { return cc::OcclusionTrackerBase<LayerType, RenderSurfaceType>::m_stack.last().occlusionInTarget; }
+ cc::Region occlusionInScreenSpace() const { return cc::OcclusionTrackerBase<LayerType, RenderSurfaceType>::m_stack.back().occlusionInScreen; }
+ cc::Region occlusionInTargetSurface() const { return cc::OcclusionTrackerBase<LayerType, RenderSurfaceType>::m_stack.back().occlusionInTarget; }
- void setOcclusionInScreenSpace(const cc::Region& region) { cc::OcclusionTrackerBase<LayerType, RenderSurfaceType>::m_stack.last().occlusionInScreen = region; }
- void setOcclusionInTargetSurface(const cc::Region& region) { cc::OcclusionTrackerBase<LayerType, RenderSurfaceType>::m_stack.last().occlusionInTarget = region; }
+ void setOcclusionInScreenSpace(const cc::Region& region) { cc::OcclusionTrackerBase<LayerType, RenderSurfaceType>::m_stack.back().occlusionInScreen = region; }
+ void setOcclusionInTargetSurface(const cc::Region& region) { cc::OcclusionTrackerBase<LayerType, RenderSurfaceType>::m_stack.back().occlusionInTarget = region; }
};
typedef TestOcclusionTrackerBase<cc::Layer, cc::RenderSurface> TestOcclusionTracker;
diff --git a/cc/test/tiled_layer_test_common.h b/cc/test/tiled_layer_test_common.h
index 2a8875b..8079f1d 100644
--- a/cc/test/tiled_layer_test_common.h
+++ b/cc/test/tiled_layer_test_common.h
@@ -5,9 +5,9 @@
#ifndef CC_TEST_TILED_LAYER_TEST_COMMON_H_
#define CC_TEST_TILED_LAYER_TEST_COMMON_H_
-#include "Region.h"
#include "cc/layer_updater.h"
#include "cc/prioritized_resource.h"
+#include "cc/region.h"
#include "cc/resource_provider.h"
#include "cc/resource_update_queue.h"
#include "cc/texture_copier.h"
diff --git a/cc/tiled_layer.cc b/cc/tiled_layer.cc
index 72d23a7..b152bfa 100644
--- a/cc/tiled_layer.cc
+++ b/cc/tiled_layer.cc
@@ -6,7 +6,6 @@
#include "cc/tiled_layer.h"
-#include "Region.h"
#include "base/basictypes.h"
#include "cc/geometry.h"
#include "cc/layer_impl.h"
diff --git a/cc/tiled_layer_unittest.cc b/cc/tiled_layer_unittest.cc
index 8e62bb7..c0bbdb2 100644
--- a/cc/tiled_layer_unittest.cc
+++ b/cc/tiled_layer_unittest.cc
@@ -34,10 +34,10 @@ public:
, m_layerClipRectInTarget(gfx::Rect(0, 0, 1000, 1000))
{
// Pretend we have visited a render surface.
- m_stack.append(StackObject());
+ m_stack.push_back(StackObject());
}
- void setOcclusion(const Region& occlusion) { m_stack.last().occlusionInTarget = occlusion; }
+ void setOcclusion(const Region& occlusion) { m_stack.back().occlusionInTarget = occlusion; }
protected:
virtual gfx::Rect layerClipRectInTarget(const Layer* layer) const OVERRIDE { return m_layerClipRectInTarget; }
@@ -1270,8 +1270,7 @@ TEST_F(TiledLayerTest, visibleContentOpaqueRegion)
layer->update(*m_queue.get(), &occluded, m_stats);
updateTextures();
opaqueContents = layer->visibleContentOpaqueRegion();
- EXPECT_RECT_EQ(gfx::IntersectRects(opaquePaintRect, visibleBounds), opaqueContents.bounds());
- EXPECT_EQ(1u, Region::Iterator(opaqueContents).size());
+ EXPECT_EQ(gfx::IntersectRects(opaquePaintRect, visibleBounds).ToString(), opaqueContents.ToString());
EXPECT_NEAR(occluded.overdrawMetrics().pixelsPainted(), 20000 * 2, 1);
EXPECT_NEAR(occluded.overdrawMetrics().pixelsUploadedOpaque(), 17100, 1);
@@ -1283,8 +1282,7 @@ TEST_F(TiledLayerTest, visibleContentOpaqueRegion)
layer->update(*m_queue.get(), &occluded, m_stats);
updateTextures();
opaqueContents = layer->visibleContentOpaqueRegion();
- EXPECT_RECT_EQ(gfx::IntersectRects(opaquePaintRect, visibleBounds), opaqueContents.bounds());
- EXPECT_EQ(1u, Region::Iterator(opaqueContents).size());
+ EXPECT_EQ(gfx::IntersectRects(opaquePaintRect, visibleBounds).ToString(), opaqueContents.ToString());
EXPECT_NEAR(occluded.overdrawMetrics().pixelsPainted(), 20000 * 2, 1);
EXPECT_NEAR(occluded.overdrawMetrics().pixelsUploadedOpaque(), 17100, 1);
@@ -1298,8 +1296,7 @@ TEST_F(TiledLayerTest, visibleContentOpaqueRegion)
layer->update(*m_queue.get(), &occluded, m_stats);
updateTextures();
opaqueContents = layer->visibleContentOpaqueRegion();
- EXPECT_RECT_EQ(gfx::IntersectRects(opaquePaintRect, visibleBounds), opaqueContents.bounds());
- EXPECT_EQ(1u, Region::Iterator(opaqueContents).size());
+ EXPECT_EQ(gfx::IntersectRects(opaquePaintRect, visibleBounds).ToString(), opaqueContents.ToString());
EXPECT_NEAR(occluded.overdrawMetrics().pixelsPainted(), 20000 * 2 + 1, 1);
EXPECT_NEAR(occluded.overdrawMetrics().pixelsUploadedOpaque(), 17100, 1);
@@ -1313,8 +1310,7 @@ TEST_F(TiledLayerTest, visibleContentOpaqueRegion)
layer->update(*m_queue.get(), &occluded, m_stats);
updateTextures();
opaqueContents = layer->visibleContentOpaqueRegion();
- EXPECT_RECT_EQ(gfx::IntersectRects(gfx::Rect(10, 100, 90, 100), visibleBounds), opaqueContents.bounds());
- EXPECT_EQ(1u, Region::Iterator(opaqueContents).size());
+ EXPECT_EQ(gfx::IntersectRects(gfx::Rect(10, 100, 90, 100), visibleBounds).ToString(), opaqueContents.ToString());
EXPECT_NEAR(occluded.overdrawMetrics().pixelsPainted(), 20000 * 2 + 1 + 1, 1);
EXPECT_NEAR(occluded.overdrawMetrics().pixelsUploadedOpaque(), 17100, 1);
diff --git a/cc/tree_synchronizer_unittest.cc b/cc/tree_synchronizer_unittest.cc
index 7741967..ab60d6f 100644
--- a/cc/tree_synchronizer_unittest.cc
+++ b/cc/tree_synchronizer_unittest.cc
@@ -6,7 +6,8 @@
#include "cc/tree_synchronizer.h"
-#include "Region.h"
+#include <algorithm>
+
#include "cc/layer.h"
#include "cc/layer_animation_controller.h"
#include "cc/layer_impl.h"
diff --git a/webkit/compositor_bindings/web_layer_impl.cc b/webkit/compositor_bindings/web_layer_impl.cc
index 9d3f137..0201598 100644
--- a/webkit/compositor_bindings/web_layer_impl.cc
+++ b/webkit/compositor_bindings/web_layer_impl.cc
@@ -5,7 +5,6 @@
#include "config.h"
#include "web_layer_impl.h"
-#include "Region.h"
#include "SkMatrix44.h"
#ifdef LOG
#undef LOG
@@ -13,6 +12,7 @@
#include "base/string_util.h"
#include "cc/active_animation.h"
#include "cc/layer.h"
+#include "cc/region.h"
#include "third_party/WebKit/Source/Platform/chromium/public/WebFloatPoint.h"
#include "third_party/WebKit/Source/Platform/chromium/public/WebFloatRect.h"
#include "third_party/WebKit/Source/Platform/chromium/public/WebSize.h"
@@ -403,29 +403,41 @@ void WebLayerImpl::setNonFastScrollableRegion(const WebVector<WebRect>& rects)
WebVector<WebRect> WebLayerImpl::nonFastScrollableRegion() const
{
- cc::Region::Iterator regionRects(m_layer->nonFastScrollableRegion());
- WebVector<WebRect> result(regionRects.size());
- for (size_t i = 0; regionRects.has_rect(); regionRects.next(), ++i)
+ size_t numRects = 0;
+ for (cc::Region::Iterator regionRects(m_layer->nonFastScrollableRegion()); regionRects.has_rect(); regionRects.next())
+ ++numRects;
+
+ WebVector<WebRect> result(numRects);
+ size_t i = 0;
+ for (cc::Region::Iterator regionRects(m_layer->nonFastScrollableRegion()); regionRects.has_rect(); regionRects.next()) {
result[i] = regionRects.rect();
+ ++i;
+ }
return result;
}
void WebLayerImpl::setTouchEventHandlerRegion(const WebVector<WebRect>& rects)
{
- cc::Region region;
- for (size_t i = 0; i < rects.size(); ++i)
- region.Union(rects[i]);
- m_layer->setTouchEventHandlerRegion(region);
-
+ cc::Region region;
+ for (size_t i = 0; i < rects.size(); ++i)
+ region.Union(rects[i]);
+ m_layer->setTouchEventHandlerRegion(region);
}
WebVector<WebRect> WebLayerImpl::touchEventHandlerRegion() const
{
- cc::Region::Iterator regionRects(m_layer->touchEventHandlerRegion());
- WebVector<WebRect> result(regionRects.size());
- for (size_t i = 0; regionRects.has_rect(); regionRects.next(), ++i)
- result[i] = regionRects.rect();
- return result;
+ size_t numRects = 0;
+ for (cc::Region::Iterator regionRects(m_layer->touchEventHandlerRegion()); regionRects.has_rect(); regionRects.next())
+ ++numRects;
+
+
+ WebVector<WebRect> result(numRects);
+ size_t i = 0;
+ for (cc::Region::Iterator regionRects(m_layer->touchEventHandlerRegion()); regionRects.has_rect(); regionRects.next()) {
+ result[i] = regionRects.rect();
+ ++i;
+ }
+ return result;
}
void WebLayerImpl::setIsContainerForFixedPositionLayers(bool enable)