Chromium Code Reviews| Index: cc/trees/layer_tree_host_unittest.cc |
| diff --git a/cc/trees/layer_tree_host_unittest.cc b/cc/trees/layer_tree_host_unittest.cc |
| index 256befef3c74a85bc1f7baddb01e2c8986d88de0..b19bb58f42864a5be81313502a7a14aaca06e5e1 100644 |
| --- a/cc/trees/layer_tree_host_unittest.cc |
| +++ b/cc/trees/layer_tree_host_unittest.cc |
| @@ -47,6 +47,7 @@ |
| #include "cc/test/geometry_test_utils.h" |
| #include "cc/test/layer_internals_for_test.h" |
| #include "cc/test/layer_tree_test.h" |
| +#include "cc/test/skia_common.h" |
| #include "cc/test/test_shared_bitmap_manager.h" |
| #include "cc/test/test_web_graphics_context_3d.h" |
| #include "cc/trees/effect_node.h" |
| @@ -6783,5 +6784,63 @@ class LayerTreeHostTestPaintedDeviceScaleFactor : public LayerTreeHostTest { |
| SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostTestPaintedDeviceScaleFactor); |
| +// The GPU image decode controller hands images off to Skia for rasterization. |
| +// When used with large images, the images in question could be deleted before |
| +// Skia was done with them, causing a crash. This test performs an end-to-end |
| +// check of large image rasterization to ensure we do not hit this crash. |
| +// Note that this code path won't always hit the crash, even when incorrect |
| +// behavior occurs, so this is more of a sanity check. |
| +// TODO(ericrk): We should improve this so that we can reliably detect the |
| +// crash. |
| +class GpuRasterizationSucceedsWithLargeImage : public LayerTreeHostTest { |
| + protected: |
| + GpuRasterizationSucceedsWithLargeImage() : viewport_size_(1024, 2048) {} |
| + |
| + void InitializeSettings(LayerTreeSettings* settings) override { |
| + settings->gpu_rasterization_enabled = true; |
| + settings->gpu_rasterization_forced = true; |
| + |
| + /// Set to 0 to force at-raster GPU image decode. |
| + settings->gpu_decoded_image_budget_bytes = 0; |
| + } |
| + |
| + void SetupTree() override { |
| + client_.set_fill_with_nonsolid_color(true); |
| + |
| + std::unique_ptr<FakeRecordingSource> recording = |
| + FakeRecordingSource::CreateFilledRecordingSource( |
| + gfx::Size(10000, 10000)); |
| + // Add an image that will be larger than max texture size. |
|
vmpstr
2016/07/14 22:07:48
Is there a way to assert that this size is bigger
ericrk
2016/07/14 23:15:46
Added.
|
| + recording->add_draw_image(CreateDiscardableImage(gfx::Size(20000, 10)), |
| + gfx::Point(0, 0)); |
| + recording->SetGenerateDiscardableImagesMetadata(true); |
| + recording->Rerecord(); |
| + |
| + scoped_refptr<FakePictureLayer> root = |
| + FakePictureLayer::CreateWithRecordingSource(&client_, |
| + std::move(recording)); |
| + root->SetBounds(gfx::Size(10000, 10000)); |
| + client_.set_bounds(root->bounds()); |
| + root->SetContentsOpaque(true); |
| + |
| + layer_tree_host()->SetRootLayer(root); |
| + LayerTreeHostTest::SetupTree(); |
| + layer_tree_host()->SetViewportSize(viewport_size_); |
| + client_.set_bounds(root->bounds()); |
| + } |
| + |
| + void BeginTest() override { PostSetNeedsCommitToMainThread(); } |
| + |
| + void DidCommit() override { EndTest(); } |
| + |
| + void AfterTest() override {} |
| + |
| + private: |
| + FakeContentLayerClient client_; |
| + gfx::Size viewport_size_; |
| +}; |
| + |
| +SINGLE_AND_MULTI_THREAD_TEST_F(GpuRasterizationSucceedsWithLargeImage); |
| + |
| } // namespace |
| } // namespace cc |