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

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

Issue 23572033: cc: Add test for AA quads due to precision loss (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Don't bother converting a literal Created 7 years, 3 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
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 <cmath> 7 #include <cmath>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/command_line.h" 10 #include "base/command_line.h"
(...skipping 18 matching lines...) Expand all
29 #include "cc/output/compositor_frame_metadata.h" 29 #include "cc/output/compositor_frame_metadata.h"
30 #include "cc/output/gl_renderer.h" 30 #include "cc/output/gl_renderer.h"
31 #include "cc/quads/render_pass_draw_quad.h" 31 #include "cc/quads/render_pass_draw_quad.h"
32 #include "cc/quads/solid_color_draw_quad.h" 32 #include "cc/quads/solid_color_draw_quad.h"
33 #include "cc/quads/texture_draw_quad.h" 33 #include "cc/quads/texture_draw_quad.h"
34 #include "cc/quads/tile_draw_quad.h" 34 #include "cc/quads/tile_draw_quad.h"
35 #include "cc/resources/layer_tiling_data.h" 35 #include "cc/resources/layer_tiling_data.h"
36 #include "cc/test/animation_test_common.h" 36 #include "cc/test/animation_test_common.h"
37 #include "cc/test/fake_output_surface.h" 37 #include "cc/test/fake_output_surface.h"
38 #include "cc/test/fake_output_surface_client.h" 38 #include "cc/test/fake_output_surface_client.h"
39 #include "cc/test/fake_picture_layer_impl.h"
40 #include "cc/test/fake_picture_pile_impl.h"
39 #include "cc/test/fake_proxy.h" 41 #include "cc/test/fake_proxy.h"
40 #include "cc/test/fake_rendering_stats_instrumentation.h" 42 #include "cc/test/fake_rendering_stats_instrumentation.h"
41 #include "cc/test/fake_video_frame_provider.h" 43 #include "cc/test/fake_video_frame_provider.h"
42 #include "cc/test/geometry_test_utils.h" 44 #include "cc/test/geometry_test_utils.h"
43 #include "cc/test/layer_test_common.h" 45 #include "cc/test/layer_test_common.h"
44 #include "cc/test/render_pass_test_common.h" 46 #include "cc/test/render_pass_test_common.h"
45 #include "cc/trees/layer_tree_impl.h" 47 #include "cc/trees/layer_tree_impl.h"
46 #include "cc/trees/single_thread_proxy.h" 48 #include "cc/trees/single_thread_proxy.h"
47 #include "media/base/media.h" 49 #include "media/base/media.h"
48 #include "testing/gmock/include/gmock/gmock.h" 50 #include "testing/gmock/include/gmock/gmock.h"
49 #include "testing/gtest/include/gtest/gtest.h" 51 #include "testing/gtest/include/gtest/gtest.h"
52 #include "ui/gfx/rect_conversions.h"
50 #include "ui/gfx/size_conversions.h" 53 #include "ui/gfx/size_conversions.h"
51 #include "ui/gfx/vector2d_conversions.h" 54 #include "ui/gfx/vector2d_conversions.h"
52 55
53 using ::testing::Mock; 56 using ::testing::Mock;
54 using ::testing::Return; 57 using ::testing::Return;
55 using ::testing::AnyNumber; 58 using ::testing::AnyNumber;
56 using ::testing::AtLeast; 59 using ::testing::AtLeast;
57 using ::testing::_; 60 using ::testing::_;
58 using media::VideoFrame; 61 using media::VideoFrame;
59 62
(...skipping 5982 matching lines...) Expand 10 before | Expand all | Expand 10 after
6042 // by 20/50 and 10/50 6045 // by 20/50 and 10/50
6043 EXPECT_EQ(gfx::ScaleRect(gfx::RectF(20.f, 10.f, 10.f, 20.f), 6046 EXPECT_EQ(gfx::ScaleRect(gfx::RectF(20.f, 10.f, 10.f, 20.f),
6044 1.f / 50.f).ToString(), 6047 1.f / 50.f).ToString(),
6045 render_pass_quad->mask_uv_rect.ToString()); 6048 render_pass_quad->mask_uv_rect.ToString());
6046 6049
6047 host_impl_->DrawLayers(&frame, base::TimeTicks::Now()); 6050 host_impl_->DrawLayers(&frame, base::TimeTicks::Now());
6048 host_impl_->DidDrawAllLayers(frame); 6051 host_impl_->DidDrawAllLayers(frame);
6049 } 6052 }
6050 } 6053 }
6051 6054
6055 class FakeGLRenderer: public GLRenderer {
danakj 2013/09/07 00:54:59 nit: GLRendererWithSetupQuadForAntialiasing (this
enne (OOO) 2013/09/07 01:25:18 Done.
6056 public:
6057 using GLRenderer::SetupQuadForAntialiasing;
6058 };
6059
6060 TEST_F(LayerTreeHostImplTest, FarAwayQuadsDontNeedAA) {
6061 // Due to precision issues (especially on Android), sometimes far
6062 // away quads can end up thinking they need AA.
6063 float device_scale_factor = 4.f / 3.f;
6064 host_impl_->SetDeviceScaleFactor(device_scale_factor);
6065 gfx::Size root_size(2000, 1000);
6066 gfx::Size device_viewport_size =
6067 gfx::ToCeiledSize(gfx::ScaleSize(root_size, device_scale_factor));
6068 host_impl_->SetViewportSize(device_viewport_size);
6069
6070 host_impl_->CreatePendingTree();
6071 host_impl_->pending_tree()
6072 ->SetPageScaleFactorAndLimits(1.f, 1.f / 16.f, 16.f);
6073
6074 scoped_ptr<LayerImpl> scoped_root =
6075 LayerImpl::Create(host_impl_->pending_tree(), 1);
6076 LayerImpl* root = scoped_root.get();
6077
6078 host_impl_->pending_tree()->SetRootLayer(scoped_root.Pass());
6079
6080 scoped_ptr<LayerImpl> scoped_scrolling_layer =
6081 LayerImpl::Create(host_impl_->pending_tree(), 2);
6082 LayerImpl* scrolling_layer = scoped_scrolling_layer.get();
6083 root->AddChild(scoped_scrolling_layer.Pass());
6084
6085 gfx::Size content_layer_bounds(100000, 100);
6086 gfx::Size pile_tile_size(3000, 3000);
6087 scoped_refptr<FakePicturePileImpl> pile(FakePicturePileImpl::CreateFilledPile(
6088 pile_tile_size, content_layer_bounds));
6089
6090 scoped_ptr<FakePictureLayerImpl> scoped_content_layer =
6091 FakePictureLayerImpl::CreateWithPile(host_impl_->pending_tree(), 3, pile);
6092 LayerImpl* content_layer = scoped_content_layer.get();
6093 scrolling_layer->AddChild(scoped_content_layer.PassAs<LayerImpl>());
6094 content_layer->SetBounds(content_layer_bounds);
6095 content_layer->SetDrawsContent(true);
6096
6097 root->SetBounds(root_size);
6098
6099 gfx::Vector2d scroll_offset(100000, 0);
6100 scrolling_layer->SetScrollable(true);
6101 scrolling_layer->SetMaxScrollOffset(scroll_offset);
6102 scrolling_layer->SetScrollOffset(scroll_offset);
6103
6104 host_impl_->ActivatePendingTree();
6105
6106 host_impl_->active_tree()->UpdateDrawProperties();
6107 ASSERT_EQ(1u, host_impl_->active_tree()->RenderSurfaceLayerList().size());
6108
6109 LayerTreeHostImpl::FrameData frame;
6110 EXPECT_TRUE(host_impl_->PrepareToDraw(&frame, gfx::Rect()));
6111
6112 ASSERT_EQ(1u, frame.render_passes.size());
6113 ASSERT_LE(1u, frame.render_passes[0]->quad_list.size());
6114 const DrawQuad* quad = frame.render_passes[0]->quad_list[0];
6115
6116 float edge[24];
6117 gfx::QuadF device_layer_quad;
6118 bool antialiased = FakeGLRenderer::SetupQuadForAntialiasing(
6119 quad->quadTransform(), quad, &device_layer_quad, edge);
6120 EXPECT_FALSE(antialiased);
6121
6122 host_impl_->DrawLayers(&frame, base::TimeTicks::Now());
6123 host_impl_->DidDrawAllLayers(frame);
6124 }
6125
6126
6052 class CompositorFrameMetadataTest : public LayerTreeHostImplTest { 6127 class CompositorFrameMetadataTest : public LayerTreeHostImplTest {
6053 public: 6128 public:
6054 CompositorFrameMetadataTest() 6129 CompositorFrameMetadataTest()
6055 : swap_buffers_complete_(0) {} 6130 : swap_buffers_complete_(0) {}
6056 6131
6057 virtual void OnSwapBuffersCompleteOnImplThread() OVERRIDE { 6132 virtual void OnSwapBuffersCompleteOnImplThread() OVERRIDE {
6058 swap_buffers_complete_++; 6133 swap_buffers_complete_++;
6059 } 6134 }
6060 6135
6061 int swap_buffers_complete_; 6136 int swap_buffers_complete_;
(...skipping 314 matching lines...) Expand 10 before | Expand all | Expand 10 after
6376 EXPECT_EQ(0u, host_impl_->ResourceIdForUIResource(ui_resource_id)); 6451 EXPECT_EQ(0u, host_impl_->ResourceIdForUIResource(ui_resource_id));
6377 EXPECT_EQ(0u, context3d->NumTextures()); 6452 EXPECT_EQ(0u, context3d->NumTextures());
6378 6453
6379 // Should not change state for multiple deletion on one UIResourceId 6454 // Should not change state for multiple deletion on one UIResourceId
6380 host_impl_->DeleteUIResource(ui_resource_id); 6455 host_impl_->DeleteUIResource(ui_resource_id);
6381 EXPECT_EQ(0u, context3d->NumTextures()); 6456 EXPECT_EQ(0u, context3d->NumTextures());
6382 } 6457 }
6383 6458
6384 } // namespace 6459 } // namespace
6385 } // namespace cc 6460 } // namespace cc
OLDNEW
« cc/trees/layer_tree_host_common.cc ('K') | « cc/trees/layer_tree_host_common.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698