| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/picture_layer.h" | 5 #include "cc/layers/picture_layer.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include "base/thread_task_runner_handle.h" | 9 #include "base/thread_task_runner_handle.h" |
| 10 #include "cc/layers/append_quads_data.h" | 10 #include "cc/layers/append_quads_data.h" |
| (...skipping 29 matching lines...) Expand all Loading... |
| 40 recording_source_viewport), | 40 recording_source_viewport), |
| 41 recording_source_viewport)); | 41 recording_source_viewport)); |
| 42 } | 42 } |
| 43 | 43 |
| 44 FakeDisplayListRecordingSource* recording_source() { | 44 FakeDisplayListRecordingSource* recording_source() { |
| 45 return static_cast<FakeDisplayListRecordingSource*>( | 45 return static_cast<FakeDisplayListRecordingSource*>( |
| 46 recording_source_.get()); | 46 recording_source_.get()); |
| 47 } | 47 } |
| 48 | 48 |
| 49 void set_invalidation(const Region& invalidation) { | 49 void set_invalidation(const Region& invalidation) { |
| 50 *invalidation_.region() = invalidation; | 50 last_updated_invalidation_ = invalidation; |
| 51 } | 51 } |
| 52 | 52 |
| 53 void set_last_updated_visible_layer_rect(const gfx::Rect& rect) { | 53 void set_last_updated_visible_layer_rect(const gfx::Rect& rect) { |
| 54 last_updated_visible_layer_rect_ = rect; | 54 last_updated_visible_layer_rect_ = rect; |
| 55 } | 55 } |
| 56 | 56 |
| 57 void set_update_source_frame_number(int number) { | 57 void set_update_source_frame_number(int number) { |
| 58 update_source_frame_number_ = number; | 58 update_source_frame_number_ = number; |
| 59 } | 59 } |
| 60 | 60 |
| (...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 215 scoped_ptr<FakePictureLayerImpl> layer_impl = | 215 scoped_ptr<FakePictureLayerImpl> layer_impl = |
| 216 FakePictureLayerImpl::Create(host_impl.pending_tree(), 1); | 216 FakePictureLayerImpl::Create(host_impl.pending_tree(), 1); |
| 217 | 217 |
| 218 layer->PushPropertiesTo(layer_impl.get()); | 218 layer->PushPropertiesTo(layer_impl.get()); |
| 219 EXPECT_FALSE(layer_impl->CanHaveTilings()); | 219 EXPECT_FALSE(layer_impl->CanHaveTilings()); |
| 220 EXPECT_TRUE(layer_impl->bounds() == gfx::Size(0, 0)); | 220 EXPECT_TRUE(layer_impl->bounds() == gfx::Size(0, 0)); |
| 221 EXPECT_EQ(gfx::Size(), layer_impl->raster_source()->GetSize()); | 221 EXPECT_EQ(gfx::Size(), layer_impl->raster_source()->GetSize()); |
| 222 EXPECT_FALSE(layer_impl->raster_source()->HasRecordings()); | 222 EXPECT_FALSE(layer_impl->raster_source()->HasRecordings()); |
| 223 } | 223 } |
| 224 | 224 |
| 225 TEST(PictureLayerTest, InvalidateRasterAfterUpdate) { |
| 226 gfx::Size layer_size(50, 50); |
| 227 FakeContentLayerClient client; |
| 228 client.set_bounds(layer_size); |
| 229 scoped_refptr<PictureLayer> layer = PictureLayer::Create(&client); |
| 230 layer->SetBounds(gfx::Size(50, 50)); |
| 231 |
| 232 FakeLayerTreeHostClient host_client(FakeLayerTreeHostClient::DIRECT_3D); |
| 233 TestTaskGraphRunner task_graph_runner; |
| 234 scoped_ptr<FakeLayerTreeHost> host = |
| 235 FakeLayerTreeHost::Create(&host_client, &task_graph_runner); |
| 236 host->SetRootLayer(layer); |
| 237 layer->SetIsDrawable(true); |
| 238 layer->SavePaintProperties(); |
| 239 |
| 240 gfx::Rect invalidation_bounds(layer_size); |
| 241 |
| 242 // The important two lines are the following: |
| 243 layer->SetNeedsDisplayRect(invalidation_bounds); |
| 244 layer->Update(); |
| 245 |
| 246 host->CommitComplete(); |
| 247 FakeImplTaskRunnerProvider impl_task_runner_provider; |
| 248 TestSharedBitmapManager shared_bitmap_manager; |
| 249 scoped_ptr<OutputSurface> output_surface(FakeOutputSurface::Create3d()); |
| 250 LayerTreeSettings layer_tree_settings = LayerTreeSettings(); |
| 251 layer_tree_settings.image_decode_tasks_enabled = true; |
| 252 FakeLayerTreeHostImpl host_impl(layer_tree_settings, |
| 253 &impl_task_runner_provider, |
| 254 &shared_bitmap_manager, &task_graph_runner); |
| 255 host_impl.SetVisible(true); |
| 256 host_impl.InitializeRenderer(output_surface.get()); |
| 257 host_impl.CreatePendingTree(); |
| 258 host_impl.pending_tree()->SetRootLayer( |
| 259 FakePictureLayerImpl::Create(host_impl.pending_tree(), 1)); |
| 260 FakePictureLayerImpl* layer_impl = static_cast<FakePictureLayerImpl*>( |
| 261 host_impl.pending_tree()->root_layer()); |
| 262 layer->PushPropertiesTo(layer_impl); |
| 263 |
| 264 EXPECT_EQ(invalidation_bounds, |
| 265 layer_impl->GetPendingInvalidation()->bounds()); |
| 266 } |
| 267 |
| 268 TEST(PictureLayerTest, InvalidateRasterWithoutUpdate) { |
| 269 gfx::Size layer_size(50, 50); |
| 270 FakeContentLayerClient client; |
| 271 client.set_bounds(layer_size); |
| 272 scoped_refptr<PictureLayer> layer = PictureLayer::Create(&client); |
| 273 layer->SetBounds(gfx::Size(50, 50)); |
| 274 |
| 275 FakeLayerTreeHostClient host_client(FakeLayerTreeHostClient::DIRECT_3D); |
| 276 TestTaskGraphRunner task_graph_runner; |
| 277 scoped_ptr<FakeLayerTreeHost> host = |
| 278 FakeLayerTreeHost::Create(&host_client, &task_graph_runner); |
| 279 host->SetRootLayer(layer); |
| 280 layer->SetIsDrawable(true); |
| 281 layer->SavePaintProperties(); |
| 282 |
| 283 gfx::Rect invalidation_bounds(layer_size); |
| 284 |
| 285 // The important line is the following (note that we do not call Update): |
| 286 layer->SetNeedsDisplayRect(invalidation_bounds); |
| 287 |
| 288 host->CommitComplete(); |
| 289 FakeImplTaskRunnerProvider impl_task_runner_provider; |
| 290 TestSharedBitmapManager shared_bitmap_manager; |
| 291 scoped_ptr<OutputSurface> output_surface(FakeOutputSurface::Create3d()); |
| 292 LayerTreeSettings layer_tree_settings = LayerTreeSettings(); |
| 293 layer_tree_settings.image_decode_tasks_enabled = true; |
| 294 FakeLayerTreeHostImpl host_impl(layer_tree_settings, |
| 295 &impl_task_runner_provider, |
| 296 &shared_bitmap_manager, &task_graph_runner); |
| 297 host_impl.SetVisible(true); |
| 298 host_impl.InitializeRenderer(output_surface.get()); |
| 299 host_impl.CreatePendingTree(); |
| 300 host_impl.pending_tree()->SetRootLayer( |
| 301 FakePictureLayerImpl::Create(host_impl.pending_tree(), 1)); |
| 302 FakePictureLayerImpl* layer_impl = static_cast<FakePictureLayerImpl*>( |
| 303 host_impl.pending_tree()->root_layer()); |
| 304 layer->PushPropertiesTo(layer_impl); |
| 305 |
| 306 EXPECT_EQ(gfx::Rect(), layer_impl->GetPendingInvalidation()->bounds()); |
| 307 } |
| 308 |
| 225 TEST(PictureLayerTest, ClearVisibleRectWhenNoTiling) { | 309 TEST(PictureLayerTest, ClearVisibleRectWhenNoTiling) { |
| 226 gfx::Size layer_size(50, 50); | 310 gfx::Size layer_size(50, 50); |
| 227 FakeContentLayerClient client; | 311 FakeContentLayerClient client; |
| 228 client.set_bounds(layer_size); | 312 client.set_bounds(layer_size); |
| 229 skia::RefPtr<SkImage> image = CreateDiscardableImage(layer_size); | 313 skia::RefPtr<SkImage> image = CreateDiscardableImage(layer_size); |
| 230 client.add_draw_image(image.get(), gfx::Point(), SkPaint()); | 314 client.add_draw_image(image.get(), gfx::Point(), SkPaint()); |
| 231 scoped_refptr<PictureLayer> layer = | 315 scoped_refptr<PictureLayer> layer = |
| 232 PictureLayer::Create(LayerSettings(), &client); | 316 PictureLayer::Create(LayerSettings(), &client); |
| 233 layer->SetBounds(gfx::Size(10, 10)); | 317 layer->SetBounds(gfx::Size(10, 10)); |
| 234 | 318 |
| (...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 393 // Do a main frame, record the picture layers. The frame number has changed | 477 // Do a main frame, record the picture layers. The frame number has changed |
| 394 // non-monotonically. | 478 // non-monotonically. |
| 395 layer->SetNeedsDisplay(); | 479 layer->SetNeedsDisplay(); |
| 396 host2->Composite(base::TimeTicks::Now()); | 480 host2->Composite(base::TimeTicks::Now()); |
| 397 EXPECT_EQ(3, layer->update_count()); | 481 EXPECT_EQ(3, layer->update_count()); |
| 398 EXPECT_EQ(1, host2->source_frame_number()); | 482 EXPECT_EQ(1, host2->source_frame_number()); |
| 399 } | 483 } |
| 400 | 484 |
| 401 } // namespace | 485 } // namespace |
| 402 } // namespace cc | 486 } // namespace cc |
| OLD | NEW |