OLD | NEW |
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/layers/tiled_layer.h" | 5 #include "cc/layers/tiled_layer.h" |
6 | 6 |
7 #include <limits> | 7 #include <limits> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "cc/debug/overdraw_metrics.h" | 10 #include "cc/debug/overdraw_metrics.h" |
11 #include "cc/resources/bitmap_content_layer_updater.h" | 11 #include "cc/resources/bitmap_content_layer_updater.h" |
12 #include "cc/resources/layer_painter.h" | 12 #include "cc/resources/layer_painter.h" |
13 #include "cc/resources/prioritized_resource_manager.h" | 13 #include "cc/resources/prioritized_resource_manager.h" |
14 #include "cc/resources/resource_update_controller.h" | 14 #include "cc/resources/resource_update_controller.h" |
15 #include "cc/test/animation_test_common.h" | 15 #include "cc/test/animation_test_common.h" |
16 #include "cc/test/fake_layer_tree_host_client.h" | 16 #include "cc/test/fake_layer_tree_host_client.h" |
17 #include "cc/test/fake_layer_tree_host_impl.h" | 17 #include "cc/test/fake_layer_tree_host_impl.h" |
18 #include "cc/test/fake_output_surface.h" | 18 #include "cc/test/fake_output_surface.h" |
| 19 #include "cc/test/fake_output_surface_client.h" |
19 #include "cc/test/fake_proxy.h" | 20 #include "cc/test/fake_proxy.h" |
20 #include "cc/test/fake_rendering_stats_instrumentation.h" | 21 #include "cc/test/fake_rendering_stats_instrumentation.h" |
21 #include "cc/test/geometry_test_utils.h" | 22 #include "cc/test/geometry_test_utils.h" |
22 #include "cc/test/tiled_layer_test_common.h" | 23 #include "cc/test/tiled_layer_test_common.h" |
23 #include "cc/trees/single_thread_proxy.h" | 24 #include "cc/trees/single_thread_proxy.h" |
24 #include "testing/gtest/include/gtest/gtest.h" | 25 #include "testing/gtest/include/gtest/gtest.h" |
25 #include "ui/gfx/rect_conversions.h" | 26 #include "ui/gfx/rect_conversions.h" |
26 #include "ui/gfx/transform.h" | 27 #include "ui/gfx/transform.h" |
27 | 28 |
28 namespace cc { | 29 namespace cc { |
(...skipping 11 matching lines...) Expand all Loading... |
40 | 41 |
41 void SetOcclusion(const Region& occlusion) { | 42 void SetOcclusion(const Region& occlusion) { |
42 stack_.back().occlusion_from_inside_target = occlusion; | 43 stack_.back().occlusion_from_inside_target = occlusion; |
43 } | 44 } |
44 }; | 45 }; |
45 | 46 |
46 class TiledLayerTest : public testing::Test { | 47 class TiledLayerTest : public testing::Test { |
47 public: | 48 public: |
48 TiledLayerTest() | 49 TiledLayerTest() |
49 : proxy_(NULL), | 50 : proxy_(NULL), |
50 output_surface_(CreateFakeOutputSurface()), | 51 output_surface_(FakeOutputSurface::Create3d()), |
51 queue_(make_scoped_ptr(new ResourceUpdateQueue)), | 52 queue_(make_scoped_ptr(new ResourceUpdateQueue)), |
52 fake_layer_impl_tree_host_client_(FakeLayerTreeHostClient::DIRECT_3D), | 53 fake_layer_impl_tree_host_client_(FakeLayerTreeHostClient::DIRECT_3D), |
53 occlusion_(NULL) { | 54 occlusion_(NULL) { |
54 settings_.max_partial_texture_updates = std::numeric_limits<size_t>::max(); | 55 settings_.max_partial_texture_updates = std::numeric_limits<size_t>::max(); |
55 settings_.layer_transforms_should_scale_layer_contents = true; | 56 settings_.layer_transforms_should_scale_layer_contents = true; |
56 } | 57 } |
57 | 58 |
58 virtual void SetUp() { | 59 virtual void SetUp() { |
59 layer_tree_host_ = LayerTreeHost::Create(&fake_layer_impl_tree_host_client_, | 60 layer_tree_host_ = LayerTreeHost::Create(&fake_layer_impl_tree_host_client_, |
60 settings_, | 61 settings_, |
61 NULL); | 62 NULL); |
62 proxy_ = layer_tree_host_->proxy(); | 63 proxy_ = layer_tree_host_->proxy(); |
63 resource_manager_ = PrioritizedResourceManager::Create(proxy_); | 64 resource_manager_ = PrioritizedResourceManager::Create(proxy_); |
64 layer_tree_host_->InitializeOutputSurfaceIfNeeded(); | 65 layer_tree_host_->InitializeOutputSurfaceIfNeeded(); |
65 layer_tree_host_->SetRootLayer(Layer::Create()); | 66 layer_tree_host_->SetRootLayer(Layer::Create()); |
66 | 67 |
| 68 CHECK(output_surface_->BindToClient(&output_surface_client_)); |
| 69 |
67 DebugScopedSetImplThreadAndMainThreadBlocked | 70 DebugScopedSetImplThreadAndMainThreadBlocked |
68 impl_thread_and_main_thread_blocked(proxy_); | 71 impl_thread_and_main_thread_blocked(proxy_); |
69 resource_provider_ = ResourceProvider::Create(output_surface_.get(), 0); | 72 resource_provider_ = ResourceProvider::Create(output_surface_.get(), 0); |
70 host_impl_ = make_scoped_ptr(new FakeLayerTreeHostImpl(proxy_)); | 73 host_impl_ = make_scoped_ptr(new FakeLayerTreeHostImpl(proxy_)); |
71 } | 74 } |
72 | 75 |
73 virtual ~TiledLayerTest() { | 76 virtual ~TiledLayerTest() { |
74 ResourceManagerClearAllMemory(resource_manager_.get(), | 77 ResourceManagerClearAllMemory(resource_manager_.get(), |
75 resource_provider_.get()); | 78 resource_provider_.get()); |
76 | 79 |
77 DebugScopedSetImplThreadAndMainThreadBlocked | 80 DebugScopedSetImplThreadAndMainThreadBlocked |
78 impl_thread_and_main_thread_blocked(proxy_); | 81 impl_thread_and_main_thread_blocked(proxy_); |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
176 LayerPushPropertiesTo(layer1.get(), layer_impl1.get()); | 179 LayerPushPropertiesTo(layer1.get(), layer_impl1.get()); |
177 if (layer2.get()) | 180 if (layer2.get()) |
178 LayerPushPropertiesTo(layer2.get(), layer_impl2.get()); | 181 LayerPushPropertiesTo(layer2.get(), layer_impl2.get()); |
179 | 182 |
180 return needs_update; | 183 return needs_update; |
181 } | 184 } |
182 | 185 |
183 public: | 186 public: |
184 Proxy* proxy_; | 187 Proxy* proxy_; |
185 LayerTreeSettings settings_; | 188 LayerTreeSettings settings_; |
| 189 FakeOutputSurfaceClient output_surface_client_; |
186 scoped_ptr<OutputSurface> output_surface_; | 190 scoped_ptr<OutputSurface> output_surface_; |
187 scoped_ptr<ResourceProvider> resource_provider_; | 191 scoped_ptr<ResourceProvider> resource_provider_; |
188 scoped_ptr<ResourceUpdateQueue> queue_; | 192 scoped_ptr<ResourceUpdateQueue> queue_; |
189 PriorityCalculator priority_calculator_; | 193 PriorityCalculator priority_calculator_; |
190 FakeLayerTreeHostClient fake_layer_impl_tree_host_client_; | 194 FakeLayerTreeHostClient fake_layer_impl_tree_host_client_; |
191 scoped_ptr<LayerTreeHost> layer_tree_host_; | 195 scoped_ptr<LayerTreeHost> layer_tree_host_; |
192 scoped_ptr<FakeLayerTreeHostImpl> host_impl_; | 196 scoped_ptr<FakeLayerTreeHostImpl> host_impl_; |
193 scoped_ptr<PrioritizedResourceManager> resource_manager_; | 197 scoped_ptr<PrioritizedResourceManager> resource_manager_; |
194 TestOcclusionTracker* occlusion_; | 198 TestOcclusionTracker* occlusion_; |
195 }; | 199 }; |
(...skipping 1737 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1933 // Invalidate the entire layer in layer space. When painting, the rect given | 1937 // Invalidate the entire layer in layer space. When painting, the rect given |
1934 // to webkit should match the layer's bounds. | 1938 // to webkit should match the layer's bounds. |
1935 layer->SetNeedsDisplayRect(layer_rect); | 1939 layer->SetNeedsDisplayRect(layer_rect); |
1936 layer->Update(queue_.get(), NULL); | 1940 layer->Update(queue_.get(), NULL); |
1937 | 1941 |
1938 EXPECT_RECT_EQ(layer_rect, layer->tracking_layer_painter()->PaintedRect()); | 1942 EXPECT_RECT_EQ(layer_rect, layer->tracking_layer_painter()->PaintedRect()); |
1939 } | 1943 } |
1940 | 1944 |
1941 } // namespace | 1945 } // namespace |
1942 } // namespace cc | 1946 } // namespace cc |
OLD | NEW |