| Index: cc/layers/texture_layer_impl_unittest.cc
|
| diff --git a/cc/layers/texture_layer_impl_unittest.cc b/cc/layers/texture_layer_impl_unittest.cc
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..664c19049df5f74b561a99ffc342b5bc1f90fd96
|
| --- /dev/null
|
| +++ b/cc/layers/texture_layer_impl_unittest.cc
|
| @@ -0,0 +1,78 @@
|
| +// 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 "cc/layers/texture_layer_impl.h"
|
| +
|
| +#include "cc/output/context_provider.h"
|
| +#include "cc/output/output_surface.h"
|
| +#include "cc/test/layer_test_common.h"
|
| +#include "testing/gtest/include/gtest/gtest.h"
|
| +
|
| +namespace cc {
|
| +namespace {
|
| +
|
| +void IgnoreCallback(uint32 sync_point, bool lost) {}
|
| +
|
| +TEST(TextureLayerImplTest, Occlusion) {
|
| + gfx::Size layer_size(1000, 1000);
|
| + gfx::Size viewport_size(1000, 1000);
|
| +
|
| + LayerTestCommon::LayerImplTest impl;
|
| +
|
| + gpu::Mailbox mailbox;
|
| + impl.output_surface()->context_provider()->ContextGL()->GenMailboxCHROMIUM(
|
| + mailbox.name);
|
| + TextureMailbox texture_mailbox(mailbox, GL_TEXTURE_2D, 0);
|
| +
|
| + bool uses_mailbox = true;
|
| + TextureLayerImpl* texture_layer_impl =
|
| + impl.AddChildToRoot<TextureLayerImpl>(uses_mailbox);
|
| + texture_layer_impl->SetAnchorPoint(gfx::PointF());
|
| + texture_layer_impl->SetBounds(layer_size);
|
| + texture_layer_impl->SetContentBounds(layer_size);
|
| + texture_layer_impl->SetDrawsContent(true);
|
| + texture_layer_impl->SetTextureMailbox(
|
| + texture_mailbox,
|
| + SingleReleaseCallback::Create(base::Bind(&IgnoreCallback)));
|
| +
|
| + impl.CalcDrawProps(viewport_size);
|
| +
|
| + {
|
| + SCOPED_TRACE("No occlusion");
|
| + gfx::Rect occluded;
|
| + impl.AppendQuadsWithOcclusion(texture_layer_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(texture_layer_impl->visible_content_rect());
|
| + impl.AppendQuadsWithOcclusion(texture_layer_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.AppendQuadsWithOcclusion(texture_layer_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
|
|
|