Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(328)

Side by Side Diff: cc/layers/texture_layer_impl_unittest.cc

Issue 201153021: cc: Apply occlusion before creating quads in TextureLayerImpl. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: append-texture: year Created 6 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « cc/layers/texture_layer_impl.cc ('k') | cc/test/layer_test_common.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "cc/layers/texture_layer_impl.h"
6
7 #include "cc/output/context_provider.h"
8 #include "cc/output/output_surface.h"
9 #include "cc/test/layer_test_common.h"
10 #include "testing/gtest/include/gtest/gtest.h"
11
12 namespace cc {
13 namespace {
14
15 void IgnoreCallback(uint32 sync_point, bool lost) {}
16
17 TEST(TextureLayerImplTest, Occlusion) {
18 gfx::Size layer_size(1000, 1000);
19 gfx::Size viewport_size(1000, 1000);
20
21 LayerTestCommon::LayerImplTest impl;
22
23 gpu::Mailbox mailbox;
24 impl.output_surface()->context_provider()->ContextGL()->GenMailboxCHROMIUM(
25 mailbox.name);
26 TextureMailbox texture_mailbox(mailbox, GL_TEXTURE_2D, 0);
27
28 bool uses_mailbox = true;
29 TextureLayerImpl* texture_layer_impl =
30 impl.AddChildToRoot<TextureLayerImpl>(uses_mailbox);
31 texture_layer_impl->SetAnchorPoint(gfx::PointF());
32 texture_layer_impl->SetBounds(layer_size);
33 texture_layer_impl->SetContentBounds(layer_size);
34 texture_layer_impl->SetDrawsContent(true);
35 texture_layer_impl->SetTextureMailbox(
36 texture_mailbox,
37 SingleReleaseCallback::Create(base::Bind(&IgnoreCallback)));
38
39 impl.CalcDrawProps(viewport_size);
40
41 {
42 SCOPED_TRACE("No occlusion");
43 gfx::Rect occluded;
44 impl.AppendQuadsWithOcclusion(texture_layer_impl, occluded);
45
46 LayerTestCommon::VerifyQuadsExactlyCoverRect(impl.quad_list(),
47 gfx::Rect(layer_size));
48 EXPECT_EQ(1u, impl.quad_list().size());
49 }
50
51 {
52 SCOPED_TRACE("Full occlusion");
53 gfx::Rect occluded(texture_layer_impl->visible_content_rect());
54 impl.AppendQuadsWithOcclusion(texture_layer_impl, occluded);
55
56 LayerTestCommon::VerifyQuadsExactlyCoverRect(impl.quad_list(), gfx::Rect());
57 EXPECT_EQ(impl.quad_list().size(), 0u);
58 }
59
60 {
61 SCOPED_TRACE("Partial occlusion");
62 gfx::Rect occluded(200, 0, 800, 1000);
63 impl.AppendQuadsWithOcclusion(texture_layer_impl, occluded);
64
65 size_t partially_occluded_count = 0;
66 LayerTestCommon::VerifyQuadsCoverRectWithOcclusion(
67 impl.quad_list(),
68 gfx::Rect(layer_size),
69 occluded,
70 &partially_occluded_count);
71 // The layer outputs one quad, which is partially occluded.
72 EXPECT_EQ(1u, impl.quad_list().size());
73 EXPECT_EQ(1u, partially_occluded_count);
74 }
75 }
76
77 } // namespace
78 } // namespace cc
OLDNEW
« no previous file with comments | « cc/layers/texture_layer_impl.cc ('k') | cc/test/layer_test_common.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698