| 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/trees/layer_tree_host.h" | 5 #include "cc/trees/layer_tree_host.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <algorithm> | 10 #include <algorithm> |
| (...skipping 28 matching lines...) Expand all Loading... |
| 39 #include "cc/test/fake_output_surface.h" | 39 #include "cc/test/fake_output_surface.h" |
| 40 #include "cc/test/fake_painted_scrollbar_layer.h" | 40 #include "cc/test/fake_painted_scrollbar_layer.h" |
| 41 #include "cc/test/fake_picture_layer.h" | 41 #include "cc/test/fake_picture_layer.h" |
| 42 #include "cc/test/fake_picture_layer_impl.h" | 42 #include "cc/test/fake_picture_layer_impl.h" |
| 43 #include "cc/test/fake_proxy.h" | 43 #include "cc/test/fake_proxy.h" |
| 44 #include "cc/test/fake_recording_source.h" | 44 #include "cc/test/fake_recording_source.h" |
| 45 #include "cc/test/fake_scoped_ui_resource.h" | 45 #include "cc/test/fake_scoped_ui_resource.h" |
| 46 #include "cc/test/fake_video_frame_provider.h" | 46 #include "cc/test/fake_video_frame_provider.h" |
| 47 #include "cc/test/geometry_test_utils.h" | 47 #include "cc/test/geometry_test_utils.h" |
| 48 #include "cc/test/layer_tree_test.h" | 48 #include "cc/test/layer_tree_test.h" |
| 49 #include "cc/test/skia_common.h" |
| 49 #include "cc/test/test_shared_bitmap_manager.h" | 50 #include "cc/test/test_shared_bitmap_manager.h" |
| 50 #include "cc/test/test_web_graphics_context_3d.h" | 51 #include "cc/test/test_web_graphics_context_3d.h" |
| 51 #include "cc/trees/layer_tree_host_impl.h" | 52 #include "cc/trees/layer_tree_host_impl.h" |
| 52 #include "cc/trees/layer_tree_impl.h" | 53 #include "cc/trees/layer_tree_impl.h" |
| 53 #include "cc/trees/single_thread_proxy.h" | 54 #include "cc/trees/single_thread_proxy.h" |
| 54 #include "gpu/GLES2/gl2extchromium.h" | 55 #include "gpu/GLES2/gl2extchromium.h" |
| 55 #include "testing/gmock/include/gmock/gmock.h" | 56 #include "testing/gmock/include/gmock/gmock.h" |
| 56 #include "third_party/khronos/GLES2/gl2.h" | 57 #include "third_party/khronos/GLES2/gl2.h" |
| 57 #include "third_party/khronos/GLES2/gl2ext.h" | 58 #include "third_party/khronos/GLES2/gl2ext.h" |
| 58 #include "third_party/skia/include/core/SkPicture.h" | 59 #include "third_party/skia/include/core/SkPicture.h" |
| 60 #include "third_party/skia/include/gpu/GrContext.h" |
| 59 #include "ui/gfx/geometry/point_conversions.h" | 61 #include "ui/gfx/geometry/point_conversions.h" |
| 60 #include "ui/gfx/geometry/size_conversions.h" | 62 #include "ui/gfx/geometry/size_conversions.h" |
| 61 #include "ui/gfx/geometry/vector2d_conversions.h" | 63 #include "ui/gfx/geometry/vector2d_conversions.h" |
| 62 | 64 |
| 63 using testing::_; | 65 using testing::_; |
| 64 using testing::AnyNumber; | 66 using testing::AnyNumber; |
| 65 using testing::AtLeast; | 67 using testing::AtLeast; |
| 66 using testing::Mock; | 68 using testing::Mock; |
| 67 | 69 |
| 68 namespace cc { | 70 namespace cc { |
| (...skipping 6620 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6689 EXPECT_EQ(2.0f, host_impl->active_tree()->painted_device_scale_factor()); | 6691 EXPECT_EQ(2.0f, host_impl->active_tree()->painted_device_scale_factor()); |
| 6690 EXPECT_EQ(1.0f, host_impl->active_tree()->device_scale_factor()); | 6692 EXPECT_EQ(1.0f, host_impl->active_tree()->device_scale_factor()); |
| 6691 EndTest(); | 6693 EndTest(); |
| 6692 } | 6694 } |
| 6693 | 6695 |
| 6694 void AfterTest() override {} | 6696 void AfterTest() override {} |
| 6695 }; | 6697 }; |
| 6696 | 6698 |
| 6697 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostTestPaintedDeviceScaleFactor); | 6699 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostTestPaintedDeviceScaleFactor); |
| 6698 | 6700 |
| 6701 // The GPU image decode controller hands images off to Skia for rasterization. |
| 6702 // When used with large images, the images in question could be deleted before |
| 6703 // Skia was done with them, causing a crash. This test performs an end-to-end |
| 6704 // check of large image rasterization to ensure we do not hit this crash. |
| 6705 // Note that this code path won't always hit the crash, even when incorrect |
| 6706 // behavior occurs, so this is more of a sanity check. |
| 6707 // TODO(ericrk): We should improve this so that we can reliably detect the |
| 6708 // crash. |
| 6709 class GpuRasterizationSucceedsWithLargeImage : public LayerTreeHostTest { |
| 6710 protected: |
| 6711 GpuRasterizationSucceedsWithLargeImage() |
| 6712 : viewport_size_(1024, 2048), large_image_size_(20000, 10) {} |
| 6713 |
| 6714 void InitializeSettings(LayerTreeSettings* settings) override { |
| 6715 settings->gpu_rasterization_enabled = true; |
| 6716 settings->gpu_rasterization_forced = true; |
| 6717 |
| 6718 /// Set to 0 to force at-raster GPU image decode. |
| 6719 settings->gpu_decoded_image_budget_bytes = 0; |
| 6720 } |
| 6721 |
| 6722 void SetupTree() override { |
| 6723 client_.set_fill_with_nonsolid_color(true); |
| 6724 |
| 6725 std::unique_ptr<FakeRecordingSource> recording = |
| 6726 FakeRecordingSource::CreateFilledRecordingSource( |
| 6727 gfx::Size(10000, 10000)); |
| 6728 |
| 6729 recording->add_draw_image(CreateDiscardableImage(large_image_size_), |
| 6730 gfx::Point(0, 0)); |
| 6731 recording->SetGenerateDiscardableImagesMetadata(true); |
| 6732 recording->Rerecord(); |
| 6733 |
| 6734 scoped_refptr<FakePictureLayer> root = |
| 6735 FakePictureLayer::CreateWithRecordingSource(&client_, |
| 6736 std::move(recording)); |
| 6737 root->SetBounds(gfx::Size(10000, 10000)); |
| 6738 client_.set_bounds(root->bounds()); |
| 6739 root->SetContentsOpaque(true); |
| 6740 |
| 6741 layer_tree_host()->SetRootLayer(root); |
| 6742 LayerTreeHostTest::SetupTree(); |
| 6743 layer_tree_host()->SetViewportSize(viewport_size_); |
| 6744 client_.set_bounds(root->bounds()); |
| 6745 } |
| 6746 |
| 6747 void InitializedRendererOnThread(LayerTreeHostImpl* host_impl, |
| 6748 bool success) override { |
| 6749 // Check that our large_image_size_ is greater than max texture size. We do |
| 6750 // this here to ensure that our otuput surface exists. |
| 6751 |
| 6752 // Retrieve max texture size from Skia. |
| 6753 ContextProvider* context_provider = |
| 6754 host_impl->output_surface()->context_provider(); |
| 6755 ASSERT_TRUE(context_provider); |
| 6756 ContextProvider::ScopedContextLock context_lock(context_provider); |
| 6757 |
| 6758 GrContext* gr_context = context_provider->GrContext(); |
| 6759 ASSERT_TRUE(gr_context); |
| 6760 const uint32_t max_texture_size = gr_context->caps()->maxTextureSize(); |
| 6761 ASSERT_GT(static_cast<uint32_t>(large_image_size_.width()), |
| 6762 max_texture_size); |
| 6763 } |
| 6764 |
| 6765 void BeginTest() override { PostSetNeedsCommitToMainThread(); } |
| 6766 |
| 6767 void DidCommit() override { EndTest(); } |
| 6768 |
| 6769 void AfterTest() override {} |
| 6770 |
| 6771 private: |
| 6772 FakeContentLayerClient client_; |
| 6773 const gfx::Size viewport_size_; |
| 6774 const gfx::Size large_image_size_; |
| 6775 }; |
| 6776 |
| 6777 SINGLE_AND_MULTI_THREAD_TEST_F(GpuRasterizationSucceedsWithLargeImage); |
| 6778 |
| 6699 } // namespace | 6779 } // namespace |
| 6700 } // namespace cc | 6780 } // namespace cc |
| OLD | NEW |