diff options
author | danakj@chromium.org <danakj@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-03-21 18:41:10 +0000 |
---|---|---|
committer | danakj@chromium.org <danakj@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-03-21 18:41:10 +0000 |
commit | ba0f8d96f0b836e450aba1828769c4313278d3d1 (patch) | |
tree | 46baad36af7345108a66dd2e18a9f80292d365f1 /cc/layers/render_surface_impl_unittest.cc | |
parent | 6cde1bf32a99da8b48e73f0d9e27bdd939a4e47c (diff) | |
download | chromium_src-ba0f8d96f0b836e450aba1828769c4313278d3d1.zip chromium_src-ba0f8d96f0b836e450aba1828769c4313278d3d1.tar.gz chromium_src-ba0f8d96f0b836e450aba1828769c4313278d3d1.tar.bz2 |
cc: Apply occlusion before creating quads in RenderSurfaceImpl.
This makes the AppendQuads method query occlusion directly and subtract
it from the quads it would create before they are created, skipping
quads that are completely occluded and avoiding a malloc/free for them.
Depends on: https://codereview.chromium.org/205443002/
Depends on: https://codereview.chromium.org/203463015/
R=enne
BUG=344962
Review URL: https://codereview.chromium.org/205503002
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@258633 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'cc/layers/render_surface_impl_unittest.cc')
-rw-r--r-- | cc/layers/render_surface_impl_unittest.cc | 68 |
1 files changed, 68 insertions, 0 deletions
diff --git a/cc/layers/render_surface_impl_unittest.cc b/cc/layers/render_surface_impl_unittest.cc new file mode 100644 index 0000000..20c2afb --- /dev/null +++ b/cc/layers/render_surface_impl_unittest.cc @@ -0,0 +1,68 @@ +// Copyright 2014 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 "cc/layers/render_surface_impl.h" + +#include "cc/test/layer_test_common.h" +#include "testing/gtest/include/gtest/gtest.h" + +namespace cc { +namespace { + +TEST(RenderSurfaceLayerImplTest, Occlusion) { + gfx::Size layer_size(1000, 1000); + gfx::Size viewport_size(1000, 1000); + + LayerTestCommon::LayerImplTest impl; + + LayerImpl* owning_layer_impl = impl.AddChildToRoot<LayerImpl>(); + owning_layer_impl->SetAnchorPoint(gfx::PointF()); + owning_layer_impl->SetBounds(layer_size); + owning_layer_impl->SetContentBounds(layer_size); + owning_layer_impl->SetDrawsContent(true); + owning_layer_impl->SetForceRenderSurface(true); + + impl.CalcDrawProps(viewport_size); + + RenderSurfaceImpl* render_surface_impl = owning_layer_impl->render_surface(); + ASSERT_TRUE(render_surface_impl); + + { + SCOPED_TRACE("No occlusion"); + gfx::Rect occluded; + impl.AppendSurfaceQuadsWithOcclusion(render_surface_impl, occluded); + + LayerTestCommon::VerifyQuadsExactlyCoverRect(impl.quad_list(), + gfx::Rect(layer_size)); + EXPECT_EQ(1u, impl.quad_list().size()); + } + + { + SCOPED_TRACE("Full occlusion"); + gfx::Rect occluded(owning_layer_impl->visible_content_rect()); + impl.AppendSurfaceQuadsWithOcclusion(render_surface_impl, occluded); + + LayerTestCommon::VerifyQuadsExactlyCoverRect(impl.quad_list(), gfx::Rect()); + EXPECT_EQ(impl.quad_list().size(), 0u); + } + + { + SCOPED_TRACE("Partial occlusion"); + gfx::Rect occluded(200, 0, 800, 1000); + impl.AppendSurfaceQuadsWithOcclusion(render_surface_impl, occluded); + + size_t partially_occluded_count = 0; + LayerTestCommon::VerifyQuadsCoverRectWithOcclusion( + impl.quad_list(), + gfx::Rect(layer_size), + occluded, + &partially_occluded_count); + // The layer outputs one quad, which is partially occluded. + EXPECT_EQ(1u, impl.quad_list().size()); + EXPECT_EQ(1u, partially_occluded_count); + } +} + +} // namespace +} // namespace cc |