Commit 92dfa6fc authored by danakj@chromium.org's avatar danakj@chromium.org

cc: Add an occlusion perf test with more than 1 opaque layer.

In this case add 10 layers. This roughly describes a complex chromeos
desktop environment I hope.

On an N4:
*RESULT occlusion_tracker_time: unoccluded_content_rect_fully_occluded= 13.10741901397705 us
*RESULT occlusion_tracker_time: unoccluded_content_rect_10_opaque_layers= 27.276884078979492 us

R=enne@chromium.org, enne
BUG=

Review URL: https://codereview.chromium.org/165413002

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@251466 0039d316-1c4b-4281-b951-d872f2087c98
parent 8aa142d2
...@@ -14,6 +14,7 @@ ...@@ -14,6 +14,7 @@
#include "cc/test/lap_timer.h" #include "cc/test/lap_timer.h"
#include "cc/trees/layer_tree_host_impl.h" #include "cc/trees/layer_tree_host_impl.h"
#include "cc/trees/layer_tree_impl.h" #include "cc/trees/layer_tree_impl.h"
#include "cc/trees/single_thread_proxy.h"
#include "testing/gtest/include/gtest/gtest.h" #include "testing/gtest/include/gtest/gtest.h"
#include "testing/perf/perf_test.h" #include "testing/perf/perf_test.h"
...@@ -29,7 +30,8 @@ class OcclusionTrackerPerfTest : public testing::Test { ...@@ -29,7 +30,8 @@ class OcclusionTrackerPerfTest : public testing::Test {
OcclusionTrackerPerfTest() OcclusionTrackerPerfTest()
: timer_(kWarmupRuns, : timer_(kWarmupRuns,
base::TimeDelta::FromMilliseconds(kTimeLimitMillis), base::TimeDelta::FromMilliseconds(kTimeLimitMillis),
kTimeCheckInterval) {} kTimeCheckInterval),
impl_(&proxy_) {}
void CreateHost() { void CreateHost() {
LayerTreeSettings settings; LayerTreeSettings settings;
host_impl_ = LayerTreeHostImpl::Create( host_impl_ = LayerTreeHostImpl::Create(
...@@ -60,11 +62,11 @@ class OcclusionTrackerPerfTest : public testing::Test { ...@@ -60,11 +62,11 @@ class OcclusionTrackerPerfTest : public testing::Test {
std::string test_name_; std::string test_name_;
FakeLayerTreeHostImplClient client_; FakeLayerTreeHostImplClient client_;
FakeProxy proxy_; FakeProxy proxy_;
DebugScopedSetImplThread impl_;
FakeRenderingStatsInstrumentation stats_; FakeRenderingStatsInstrumentation stats_;
scoped_ptr<LayerTreeHostImpl> host_impl_; scoped_ptr<LayerTreeHostImpl> host_impl_;
}; };
// Simulates a page with several large, transformed and animated layers.
TEST_F(OcclusionTrackerPerfTest, UnoccludedContentRect_FullyOccluded) { TEST_F(OcclusionTrackerPerfTest, UnoccludedContentRect_FullyOccluded) {
SetTestName("unoccluded_content_rect_fully_occluded"); SetTestName("unoccluded_content_rect_fully_occluded");
...@@ -133,5 +135,79 @@ TEST_F(OcclusionTrackerPerfTest, UnoccludedContentRect_FullyOccluded) { ...@@ -133,5 +135,79 @@ TEST_F(OcclusionTrackerPerfTest, UnoccludedContentRect_FullyOccluded) {
PrintResults(); PrintResults();
} }
TEST_F(OcclusionTrackerPerfTest, UnoccludedContentRect_10OpaqueLayers) {
static const int kNumOpaqueLayers = 10;
SetTestName("unoccluded_content_rect_10_opaque_layers");
gfx::Rect viewport_rect(768, 1038);
OcclusionTrackerBase<LayerImpl, LayerImpl::RenderSurfaceType> tracker(
viewport_rect, false);
CreateHost();
host_impl_->SetViewportSize(viewport_rect.size());
for (int i = 0; i < kNumOpaqueLayers; ++i) {
scoped_ptr<SolidColorLayerImpl> opaque_layer =
SolidColorLayerImpl::Create(active_tree(), 2 + i);
opaque_layer->SetBackgroundColor(SK_ColorRED);
opaque_layer->SetContentsOpaque(true);
opaque_layer->SetDrawsContent(true);
opaque_layer->SetBounds(
gfx::Size(viewport_rect.width() / 2, viewport_rect.height() / 2));
opaque_layer->SetContentBounds(
gfx::Size(viewport_rect.width() / 2, viewport_rect.height() / 2));
opaque_layer->SetPosition(gfx::Point(i, i));
active_tree()->root_layer()->AddChild(opaque_layer.PassAs<LayerImpl>());
}
active_tree()->UpdateDrawProperties();
const LayerImplList& rsll = active_tree()->RenderSurfaceLayerList();
ASSERT_EQ(1u, rsll.size());
EXPECT_EQ(static_cast<size_t>(kNumOpaqueLayers),
rsll[0]->render_surface()->layer_list().size());
LayerIterator<LayerImpl> begin = LayerIterator<LayerImpl>::Begin(&rsll);
LayerIterator<LayerImpl> end = LayerIterator<LayerImpl>::End(&rsll);
// The opaque_layers add occlusion.
for (int i = 0; i < kNumOpaqueLayers - 1; ++i) {
LayerIteratorPosition<LayerImpl> pos = begin;
tracker.EnterLayer(pos);
tracker.LeaveLayer(pos);
++begin;
}
LayerIteratorPosition<LayerImpl> pos = begin;
tracker.EnterLayer(pos);
tracker.LeaveLayer(pos);
gfx::Transform transform_to_target;
transform_to_target.Translate(0, 96);
bool impl_draw_transform_is_unknown = false;
do {
for (int x = 0; x < viewport_rect.width(); x += 256) {
for (int y = 0; y < viewport_rect.height(); y += 256) {
gfx::Rect query_content_rect(x, y, 256, 256);
gfx::Rect unoccluded =
tracker.UnoccludedContentRect(pos.target_render_surface_layer,
query_content_rect,
transform_to_target,
impl_draw_transform_is_unknown);
}
}
timer_.NextLap();
} while (!timer_.HasTimeLimitExpired());
++begin;
LayerIteratorPosition<LayerImpl> next = begin;
EXPECT_EQ(active_tree()->root_layer(), next.current_layer);
++begin;
EXPECT_EQ(end, begin);
PrintResults();
}
} // namespace } // namespace
} // namespace cc } // namespace cc
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment