Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(747)

Side by Side Diff: cc/trees/layer_tree_host_unittest.cc

Issue 2149843003: Fix MultiPictureDraw issues with GpuImageDecodeController (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « cc/test/skia_common.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 29 matching lines...) Expand all
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_internals_for_test.h" 48 #include "cc/test/layer_internals_for_test.h"
49 #include "cc/test/layer_tree_test.h" 49 #include "cc/test/layer_tree_test.h"
50 #include "cc/test/skia_common.h"
50 #include "cc/test/test_shared_bitmap_manager.h" 51 #include "cc/test/test_shared_bitmap_manager.h"
51 #include "cc/test/test_web_graphics_context_3d.h" 52 #include "cc/test/test_web_graphics_context_3d.h"
52 #include "cc/trees/effect_node.h" 53 #include "cc/trees/effect_node.h"
53 #include "cc/trees/layer_tree_host_impl.h" 54 #include "cc/trees/layer_tree_host_impl.h"
54 #include "cc/trees/layer_tree_impl.h" 55 #include "cc/trees/layer_tree_impl.h"
55 #include "cc/trees/single_thread_proxy.h" 56 #include "cc/trees/single_thread_proxy.h"
56 #include "cc/trees/transform_node.h" 57 #include "cc/trees/transform_node.h"
57 #include "gpu/GLES2/gl2extchromium.h" 58 #include "gpu/GLES2/gl2extchromium.h"
58 #include "testing/gmock/include/gmock/gmock.h" 59 #include "testing/gmock/include/gmock/gmock.h"
59 #include "third_party/khronos/GLES2/gl2.h" 60 #include "third_party/khronos/GLES2/gl2.h"
60 #include "third_party/khronos/GLES2/gl2ext.h" 61 #include "third_party/khronos/GLES2/gl2ext.h"
61 #include "third_party/skia/include/core/SkPicture.h" 62 #include "third_party/skia/include/core/SkPicture.h"
63 #include "third_party/skia/include/gpu/GrContext.h"
62 #include "ui/gfx/geometry/point_conversions.h" 64 #include "ui/gfx/geometry/point_conversions.h"
63 #include "ui/gfx/geometry/size_conversions.h" 65 #include "ui/gfx/geometry/size_conversions.h"
64 #include "ui/gfx/geometry/vector2d_conversions.h" 66 #include "ui/gfx/geometry/vector2d_conversions.h"
65 67
66 using testing::_; 68 using testing::_;
67 using testing::AnyNumber; 69 using testing::AnyNumber;
68 using testing::AtLeast; 70 using testing::AtLeast;
69 using testing::Mock; 71 using testing::Mock;
70 72
71 namespace cc { 73 namespace cc {
(...skipping 6720 matching lines...) Expand 10 before | Expand all | Expand 10 after
6792 2.0f, 6794 2.0f,
6793 fake_output_surface()->last_sent_frame()->metadata.device_scale_factor); 6795 fake_output_surface()->last_sent_frame()->metadata.device_scale_factor);
6794 EndTest(); 6796 EndTest();
6795 } 6797 }
6796 6798
6797 void AfterTest() override {} 6799 void AfterTest() override {}
6798 }; 6800 };
6799 6801
6800 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostTestPaintedDeviceScaleFactor); 6802 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostTestPaintedDeviceScaleFactor);
6801 6803
6804 // The GPU image decode controller hands images off to Skia for rasterization.
6805 // When used with large images, the images in question could be deleted before
6806 // Skia was done with them, causing a crash. This test performs an end-to-end
6807 // check of large image rasterization to ensure we do not hit this crash.
6808 // Note that this code path won't always hit the crash, even when incorrect
6809 // behavior occurs, so this is more of a sanity check.
6810 // TODO(ericrk): We should improve this so that we can reliably detect the
6811 // crash.
6812 class GpuRasterizationSucceedsWithLargeImage : public LayerTreeHostTest {
6813 protected:
6814 GpuRasterizationSucceedsWithLargeImage()
6815 : viewport_size_(1024, 2048), large_image_size_(20000, 10) {}
6816
6817 void InitializeSettings(LayerTreeSettings* settings) override {
6818 settings->gpu_rasterization_enabled = true;
6819 settings->gpu_rasterization_forced = true;
6820
6821 /// Set to 0 to force at-raster GPU image decode.
6822 settings->gpu_decoded_image_budget_bytes = 0;
6823 }
6824
6825 void SetupTree() override {
6826 client_.set_fill_with_nonsolid_color(true);
6827
6828 std::unique_ptr<FakeRecordingSource> recording =
6829 FakeRecordingSource::CreateFilledRecordingSource(
6830 gfx::Size(10000, 10000));
6831
6832 recording->add_draw_image(CreateDiscardableImage(large_image_size_),
6833 gfx::Point(0, 0));
6834 recording->SetGenerateDiscardableImagesMetadata(true);
6835 recording->Rerecord();
6836
6837 scoped_refptr<FakePictureLayer> root =
6838 FakePictureLayer::CreateWithRecordingSource(&client_,
6839 std::move(recording));
6840 root->SetBounds(gfx::Size(10000, 10000));
6841 client_.set_bounds(root->bounds());
6842 root->SetContentsOpaque(true);
6843
6844 layer_tree_host()->SetRootLayer(root);
6845 LayerTreeHostTest::SetupTree();
6846 layer_tree_host()->SetViewportSize(viewport_size_);
6847 client_.set_bounds(root->bounds());
6848 }
6849
6850 void InitializedRendererOnThread(LayerTreeHostImpl* host_impl,
6851 bool success) override {
6852 // Check that our large_image_size_ is greater than max texture size. We do
6853 // this here to ensure that our otuput surface exists.
6854
6855 // Retrieve max texture size from Skia.
6856 ContextProvider* context_provider =
6857 host_impl->output_surface()->context_provider();
6858 ASSERT_TRUE(context_provider);
6859 ContextProvider::ScopedContextLock context_lock(context_provider);
6860
6861 GrContext* gr_context = context_provider->GrContext();
6862 ASSERT_TRUE(gr_context);
6863 const uint32_t max_texture_size = gr_context->caps()->maxTextureSize();
6864 ASSERT_GT(static_cast<uint32_t>(large_image_size_.width()),
6865 max_texture_size);
6866 }
6867
6868 void BeginTest() override { PostSetNeedsCommitToMainThread(); }
6869
6870 void DidCommit() override { EndTest(); }
6871
6872 void AfterTest() override {}
6873
6874 private:
6875 FakeContentLayerClient client_;
6876 const gfx::Size viewport_size_;
6877 const gfx::Size large_image_size_;
6878 };
6879
6880 SINGLE_AND_MULTI_THREAD_TEST_F(GpuRasterizationSucceedsWithLargeImage);
6881
6802 } // namespace 6882 } // namespace
6803 } // namespace cc 6883 } // namespace cc
OLDNEW
« no previous file with comments | « cc/test/skia_common.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698