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

Side by Side Diff: cc/trees/layer_tree_host_impl_unittest.cc

Issue 683113005: Update from chromium https://crrev.com/302282 (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 6 years, 1 month 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
« no previous file with comments | « cc/trees/layer_tree_host_impl.cc ('k') | cc/trees/layer_tree_host_pixeltest_masks.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2011 The Chromium Authors. All rights reserved. 1 // Copyright 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "cc/trees/layer_tree_host_impl.h" 5 #include "cc/trees/layer_tree_host_impl.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <cmath> 8 #include <cmath>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 2352 matching lines...) Expand 10 before | Expand all | Expand 10 after
2363 } 2363 }
2364 2364
2365 protected: 2365 protected:
2366 gfx::Size layer_size_; 2366 gfx::Size layer_size_;
2367 gfx::Size clip_size_; 2367 gfx::Size clip_size_;
2368 gfx::Size viewport_size_; 2368 gfx::Size viewport_size_;
2369 2369
2370 LayerTreeSettings settings_; 2370 LayerTreeSettings settings_;
2371 }; // class LayerTreeHostImplTopControlsTest 2371 }; // class LayerTreeHostImplTopControlsTest
2372 2372
2373 TEST_F(LayerTreeHostImplTopControlsTest,
2374 TopControlsDeltaOnlySentWithRootLayer) {
2375 CreateHostImpl(settings_, CreateOutputSurface());
2376
2377 host_impl_->active_tree()->set_top_controls_delta(-20.f);
2378
2379 // Because LTH::ApplyScrollAndScale doesn't know what to do with a scroll
2380 // delta packet when the root layer doesn't exist yet, make sure not to set
2381 // sent_top_controls_delta either to avoid the delta getting clobbered on the
2382 // next commit.
2383 scoped_ptr<ScrollAndScaleSet> scroll_info = host_impl_->ProcessScrollDeltas();
2384 EXPECT_EQ(scroll_info->top_controls_delta, 0.f);
2385 EXPECT_EQ(host_impl_->active_tree()->sent_top_controls_delta(), 0.f);
2386
2387 SetupTopControlsAndScrollLayer();
2388
2389 // After the root layer exists, it should be set normally.
2390 scroll_info = host_impl_->ProcessScrollDeltas();
2391 EXPECT_EQ(scroll_info->top_controls_delta, -20.f);
2392 EXPECT_EQ(host_impl_->active_tree()->sent_top_controls_delta(), -20.f);
2393 }
2394
2395 TEST_F(LayerTreeHostImplTopControlsTest, ScrollTopControlsByFractionalAmount) { 2373 TEST_F(LayerTreeHostImplTopControlsTest, ScrollTopControlsByFractionalAmount) {
2396 SetupTopControlsAndScrollLayerWithVirtualViewport( 2374 SetupTopControlsAndScrollLayerWithVirtualViewport(
2397 gfx::Size(10, 10), gfx::Size(10, 10), gfx::Size(10, 10)); 2375 gfx::Size(10, 10), gfx::Size(10, 10), gfx::Size(10, 10));
2398 DrawFrame(); 2376 DrawFrame();
2399 2377
2400 EXPECT_EQ(InputHandler::ScrollStarted, 2378 EXPECT_EQ(InputHandler::ScrollStarted,
2401 host_impl_->ScrollBegin(gfx::Point(), InputHandler::Gesture)); 2379 host_impl_->ScrollBegin(gfx::Point(), InputHandler::Gesture));
2402 2380
2403 // Make the test scroll delta a fractional amount, to verify that the 2381 // Make the test scroll delta a fractional amount, to verify that the
2404 // fixed container size delta is (1) non-zero, and (2) fractional, and 2382 // fixed container size delta is (1) non-zero, and (2) fractional, and
(...skipping 2011 matching lines...) Expand 10 before | Expand all | Expand 10 after
4416 gutter_quad_material_ = material; 4394 gutter_quad_material_ = material;
4417 } 4395 }
4418 void set_gutter_texture_size(const gfx::Size& gutter_texture_size) { 4396 void set_gutter_texture_size(const gfx::Size& gutter_texture_size) {
4419 gutter_texture_size_ = gutter_texture_size; 4397 gutter_texture_size_ = gutter_texture_size;
4420 } 4398 }
4421 4399
4422 protected: 4400 protected:
4423 size_t CountGutterQuads(const QuadList& quad_list) { 4401 size_t CountGutterQuads(const QuadList& quad_list) {
4424 size_t num_gutter_quads = 0; 4402 size_t num_gutter_quads = 0;
4425 for (const auto& quad : quad_list) { 4403 for (const auto& quad : quad_list) {
4426 num_gutter_quads += (quad.material == gutter_quad_material_) ? 1 : 0; 4404 num_gutter_quads += (quad->material == gutter_quad_material_) ? 1 : 0;
4427 } 4405 }
4428 return num_gutter_quads; 4406 return num_gutter_quads;
4429 } 4407 }
4430 4408
4431 void VerifyQuadsExactlyCoverViewport(const QuadList& quad_list) { 4409 void VerifyQuadsExactlyCoverViewport(const QuadList& quad_list) {
4432 LayerTestCommon::VerifyQuadsExactlyCoverRect( 4410 LayerTestCommon::VerifyQuadsExactlyCoverRect(
4433 quad_list, gfx::Rect(DipSizeToPixelSize(viewport_size_))); 4411 quad_list, gfx::Rect(DipSizeToPixelSize(viewport_size_)));
4434 } 4412 }
4435 4413
4436 // Make sure that the texture coordinates match their expectations. 4414 // Make sure that the texture coordinates match their expectations.
4437 void ValidateTextureDrawQuads(const QuadList& quad_list) { 4415 void ValidateTextureDrawQuads(const QuadList& quad_list) {
4438 for (const auto& quad : quad_list) { 4416 for (const auto& quad : quad_list) {
4439 if (quad.material != DrawQuad::TEXTURE_CONTENT) 4417 if (quad->material != DrawQuad::TEXTURE_CONTENT)
4440 continue; 4418 continue;
4441 const TextureDrawQuad* texture_quad = 4419 const TextureDrawQuad* texture_quad = TextureDrawQuad::MaterialCast(quad);
4442 TextureDrawQuad::MaterialCast(&quad);
4443 gfx::SizeF gutter_texture_size_pixels = gfx::ScaleSize( 4420 gfx::SizeF gutter_texture_size_pixels = gfx::ScaleSize(
4444 gutter_texture_size_, host_impl_->device_scale_factor()); 4421 gutter_texture_size_, host_impl_->device_scale_factor());
4445 EXPECT_EQ(texture_quad->uv_top_left.x(), 4422 EXPECT_EQ(texture_quad->uv_top_left.x(),
4446 texture_quad->rect.x() / gutter_texture_size_pixels.width()); 4423 texture_quad->rect.x() / gutter_texture_size_pixels.width());
4447 EXPECT_EQ(texture_quad->uv_top_left.y(), 4424 EXPECT_EQ(texture_quad->uv_top_left.y(),
4448 texture_quad->rect.y() / gutter_texture_size_pixels.height()); 4425 texture_quad->rect.y() / gutter_texture_size_pixels.height());
4449 EXPECT_EQ( 4426 EXPECT_EQ(
4450 texture_quad->uv_bottom_right.x(), 4427 texture_quad->uv_bottom_right.x(),
4451 texture_quad->rect.right() / gutter_texture_size_pixels.width()); 4428 texture_quad->rect.right() / gutter_texture_size_pixels.width());
4452 EXPECT_EQ( 4429 EXPECT_EQ(
(...skipping 3090 matching lines...) Expand 10 before | Expand all | Expand 10 after
7543 // surface. 7520 // surface.
7544 EXPECT_EQ(0, num_lost_surfaces_); 7521 EXPECT_EQ(0, num_lost_surfaces_);
7545 host_impl_->DidLoseOutputSurface(); 7522 host_impl_->DidLoseOutputSurface();
7546 EXPECT_EQ(1, num_lost_surfaces_); 7523 EXPECT_EQ(1, num_lost_surfaces_);
7547 host_impl_->DidLoseOutputSurface(); 7524 host_impl_->DidLoseOutputSurface();
7548 EXPECT_LE(1, num_lost_surfaces_); 7525 EXPECT_LE(1, num_lost_surfaces_);
7549 } 7526 }
7550 7527
7551 } // namespace 7528 } // namespace
7552 } // namespace cc 7529 } // namespace cc
OLDNEW
« no previous file with comments | « cc/trees/layer_tree_host_impl.cc ('k') | cc/trees/layer_tree_host_pixeltest_masks.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698