diff options
author | vollick <vollick@chromium.org> | 2016-01-08 20:33:36 -0800 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2016-01-09 04:34:20 +0000 |
commit | 060013352fb1695e8135bf36832477cf25d5eec2 (patch) | |
tree | f28d09688a4e9efaa873b80731832e30fb64c2b7 | |
parent | 63d541db1c2b2eee4cbaf4635a74a438c155d152 (diff) | |
download | chromium_src-060013352fb1695e8135bf36832477cf25d5eec2.zip chromium_src-060013352fb1695e8135bf36832477cf25d5eec2.tar.gz chromium_src-060013352fb1695e8135bf36832477cf25d5eec2.tar.bz2 |
Check display_list_ in HasDiscardableImagesInRect
It turns out that this can be NULL.
BUG=575623
CQ_INCLUDE_TRYBOTS=tryserver.blink:linux_blink_rel
Review URL: https://codereview.chromium.org/1575553002
Cr-Commit-Position: refs/heads/master@{#368522}
-rw-r--r-- | cc/layers/picture_layer_unittest.cc | 82 | ||||
-rw-r--r-- | cc/playback/display_list_raster_source.cc | 2 |
2 files changed, 83 insertions, 1 deletions
diff --git a/cc/layers/picture_layer_unittest.cc b/cc/layers/picture_layer_unittest.cc index df72639..1ce7567 100644 --- a/cc/layers/picture_layer_unittest.cc +++ b/cc/layers/picture_layer_unittest.cc @@ -7,6 +7,7 @@ #include <stddef.h> #include "base/thread_task_runner_handle.h" +#include "cc/layers/append_quads_data.h" #include "cc/layers/content_layer_client.h" #include "cc/layers/empty_content_layer_client.h" #include "cc/layers/layer_settings.h" @@ -15,10 +16,12 @@ #include "cc/proto/layer.pb.h" #include "cc/test/fake_display_list_recording_source.h" #include "cc/test/fake_layer_tree_host.h" +#include "cc/test/fake_output_surface.h" #include "cc/test/fake_picture_layer.h" #include "cc/test/fake_picture_layer_impl.h" #include "cc/test/fake_proxy.h" #include "cc/test/layer_tree_settings_for_testing.h" +#include "cc/test/skia_common.h" #include "cc/test/test_shared_bitmap_manager.h" #include "cc/test/test_task_graph_runner.h" #include "cc/trees/single_thread_proxy.h" @@ -200,6 +203,85 @@ TEST(PictureLayerTest, NoTilesIfEmptyBounds) { EXPECT_FALSE(layer_impl->raster_source()->HasRecordings()); } +TEST(PictureLayerTest, ClearVisibleRectWhenNoTiling) { + gfx::Size layer_size(50, 50); + FakeContentLayerClient client; + client.set_bounds(layer_size); + skia::RefPtr<SkImage> image = CreateDiscardableImage(layer_size); + client.add_draw_image(image.get(), gfx::Point(), SkPaint()); + scoped_refptr<PictureLayer> layer = + PictureLayer::Create(LayerSettings(), &client); + layer->SetBounds(gfx::Size(10, 10)); + + FakeLayerTreeHostClient host_client(FakeLayerTreeHostClient::DIRECT_3D); + TestTaskGraphRunner task_graph_runner; + scoped_ptr<FakeLayerTreeHost> host = + FakeLayerTreeHost::Create(&host_client, &task_graph_runner); + host->SetRootLayer(layer); + layer->SetIsDrawable(true); + layer->SavePaintProperties(); + layer->Update(); + + EXPECT_EQ(0, host->source_frame_number()); + host->CommitComplete(); + EXPECT_EQ(1, host->source_frame_number()); + + layer->SavePaintProperties(); + layer->Update(); + + FakeImplTaskRunnerProvider impl_task_runner_provider; + + TestSharedBitmapManager shared_bitmap_manager; + scoped_ptr<OutputSurface> output_surface(FakeOutputSurface::Create3d()); + LayerTreeSettings layer_tree_settings = LayerTreeSettingsForTesting(); + layer_tree_settings.image_decode_tasks_enabled = true; + FakeLayerTreeHostImpl host_impl(layer_tree_settings, + &impl_task_runner_provider, + &shared_bitmap_manager, &task_graph_runner); + host_impl.SetVisible(true); + EXPECT_TRUE(host_impl.InitializeRenderer(output_surface.get())); + + host_impl.CreatePendingTree(); + host_impl.pending_tree()->SetRootLayer( + FakePictureLayerImpl::Create(host_impl.pending_tree(), 1)); + + FakePictureLayerImpl* layer_impl = static_cast<FakePictureLayerImpl*>( + host_impl.pending_tree()->root_layer()); + + layer->PushPropertiesTo(layer_impl); + + host->CommitComplete(); + EXPECT_EQ(2, host->source_frame_number()); + + host_impl.ActivateSyncTree(); + + // By updating the draw proprties on the active tree, we will set the viewport + // rect for tile priorities to something non-empty. + const bool can_use_lcd_text = false; + host_impl.active_tree()->property_trees()->needs_rebuild = true; + host_impl.active_tree()->BuildPropertyTreesForTesting(); + host_impl.active_tree()->UpdateDrawProperties(can_use_lcd_text); + + layer->SetBounds(gfx::Size(11, 11)); + layer->SavePaintProperties(); + + host_impl.CreatePendingTree(); + layer_impl = static_cast<FakePictureLayerImpl*>( + host_impl.pending_tree()->root_layer()); + + // We should now have invalid contents and should therefore clear the + // recording source. + layer->PushPropertiesTo(layer_impl); + + host_impl.ActivateSyncTree(); + + scoped_ptr<RenderPass> render_pass = RenderPass::Create(); + AppendQuadsData data; + host_impl.active_tree()->root_layer()->WillDraw(DRAW_MODE_SOFTWARE, nullptr); + host_impl.active_tree()->root_layer()->AppendQuads(render_pass.get(), &data); + host_impl.active_tree()->root_layer()->DidDraw(nullptr); +} + TEST(PictureLayerTest, SuitableForGpuRasterization) { scoped_ptr<FakeDisplayListRecordingSource> recording_source_owned( new FakeDisplayListRecordingSource); diff --git a/cc/playback/display_list_raster_source.cc b/cc/playback/display_list_raster_source.cc index e94b9f6..eac4916 100644 --- a/cc/playback/display_list_raster_source.cc +++ b/cc/playback/display_list_raster_source.cc @@ -245,7 +245,7 @@ void DisplayListRasterSource::GetDiscardableImagesInRect( bool DisplayListRasterSource::HasDiscardableImageInRect( const gfx::Rect& layer_rect) const { - return display_list_->HasDiscardableImageInRect(layer_rect); + return display_list_ && display_list_->HasDiscardableImageInRect(layer_rect); } bool DisplayListRasterSource::CoversRect(const gfx::Rect& layer_rect) const { |