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" |
(...skipping 1116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1127 layer->fake_layer_updater()->ClearUpdateCount(); | 1127 layer->fake_layer_updater()->ClearUpdateCount(); |
1128 LayerPushPropertiesTo(layer.get(), layer_impl.get()); | 1128 LayerPushPropertiesTo(layer.get(), layer_impl.get()); |
1129 } | 1129 } |
1130 layer_tree_host_->CommitComplete(); | 1130 layer_tree_host_->CommitComplete(); |
1131 | 1131 |
1132 ResourceManagerClearAllMemory(layer_tree_host_->contents_texture_manager(), | 1132 ResourceManagerClearAllMemory(layer_tree_host_->contents_texture_manager(), |
1133 resource_provider_.get()); | 1133 resource_provider_.get()); |
1134 layer_tree_host_->SetRootLayer(NULL); | 1134 layer_tree_host_->SetRootLayer(NULL); |
1135 } | 1135 } |
1136 | 1136 |
1137 TEST_F(TiledLayerPartialUpdateTest, \ | |
danakj
2013/12/02 15:06:52
no \ needed
| |
1138 VerifyUpdateRectIsPreparedFromOriginalDirtyRects) { | |
1139 // Create one 300 x 200 tiled layer with 3 x 2 tiles. | |
1140 gfx::Rect layer_bounds(0, 0, 300, 200); | |
1141 gfx::Rect dirty_rect(75, 75, 50, 50); | |
1142 gfx::Rect expected_paint_rect(0, 0, 200, 200); | |
1143 | |
1144 scoped_refptr<FakeTiledLayer> layer = make_scoped_refptr( | |
1145 new FakeTiledLayer(layer_tree_host_->contents_texture_manager())); | |
1146 | |
1147 layer->SetBounds(layer_bounds.size()); | |
1148 layer->SetPosition(gfx::PointF(0, 0)); | |
1149 layer->draw_properties().visible_content_rect = layer_bounds; | |
1150 layer_tree_host_->SetRootLayer(layer); | |
1151 layer_tree_host_->SetViewportSize(gfx::Size(300, 200)); | |
1152 | |
1153 // Simulate delegating renderer scenario by not allowing partial texture | |
1154 // updates by default. | |
1155 const_cast<RendererCapabilities&>(layer_tree_host_->proxy()-> | |
1156 GetRendererCapabilities()).allow_partial_texture_updates = false; | |
1157 | |
1158 // Update all tiles in first update. | |
1159 layer->InvalidateContentRect(layer_bounds); | |
1160 layer_tree_host_->UpdateLayers(queue_.get()); | |
1161 UpdateTextures(); | |
1162 | |
1163 // Now update_rect should contain only dirty_rect. | |
1164 layer->InvalidateContentRect(dirty_rect); | |
1165 layer_tree_host_->UpdateLayers(queue_.get()); | |
1166 UpdateTextures(); | |
1167 | |
1168 gfx::Rect paint_rect = layer->fake_layer_updater()->last_update_rect(); | |
1169 EXPECT_FLOAT_RECT_EQ(static_cast<gfx::RectF>(dirty_rect), | |
1170 layer->update_rect()); | |
1171 EXPECT_RECT_EQ(expected_paint_rect, paint_rect); | |
1172 EXPECT_FALSE(dirty_rect.Contains(paint_rect)); | |
1173 | |
1174 ResourceManagerClearAllMemory(layer_tree_host_->contents_texture_manager(), | |
1175 resource_provider_.get()); | |
1176 layer_tree_host_->SetRootLayer(NULL); | |
1177 } | |
1178 | |
1137 TEST_F(TiledLayerTest, TilesPaintedWithoutOcclusion) { | 1179 TEST_F(TiledLayerTest, TilesPaintedWithoutOcclusion) { |
1138 scoped_refptr<FakeTiledLayer> layer = | 1180 scoped_refptr<FakeTiledLayer> layer = |
1139 make_scoped_refptr(new FakeTiledLayer(resource_manager_.get())); | 1181 make_scoped_refptr(new FakeTiledLayer(resource_manager_.get())); |
1140 RenderSurfaceLayerList render_surface_layer_list; | 1182 RenderSurfaceLayerList render_surface_layer_list; |
1141 | 1183 |
1142 layer_tree_host_->root_layer()->AddChild(layer); | 1184 layer_tree_host_->root_layer()->AddChild(layer); |
1143 | 1185 |
1144 // The tile size is 100x100, so this invalidates and then paints two tiles. | 1186 // The tile size is 100x100, so this invalidates and then paints two tiles. |
1145 layer->SetBounds(gfx::Size(100, 200)); | 1187 layer->SetBounds(gfx::Size(100, 200)); |
1146 CalcDrawProps(&render_surface_layer_list); | 1188 CalcDrawProps(&render_surface_layer_list); |
(...skipping 800 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1947 // Invalidate the entire layer in layer space. When painting, the rect given | 1989 // Invalidate the entire layer in layer space. When painting, the rect given |
1948 // to webkit should match the layer's bounds. | 1990 // to webkit should match the layer's bounds. |
1949 layer->SetNeedsDisplayRect(layer_rect); | 1991 layer->SetNeedsDisplayRect(layer_rect); |
1950 layer->Update(queue_.get(), NULL); | 1992 layer->Update(queue_.get(), NULL); |
1951 | 1993 |
1952 EXPECT_RECT_EQ(layer_rect, layer->tracking_layer_painter()->PaintedRect()); | 1994 EXPECT_RECT_EQ(layer_rect, layer->tracking_layer_painter()->PaintedRect()); |
1953 } | 1995 } |
1954 | 1996 |
1955 } // namespace | 1997 } // namespace |
1956 } // namespace cc | 1998 } // namespace cc |
OLD | NEW |