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

Side by Side Diff: content/renderer/gpu/render_widget_compositor_unittest.cc

Issue 2208693003: Revert of cc: Make LayerTreeTests use a DelegatingRenderer and Display. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 4 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
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "content/renderer/gpu/render_widget_compositor.h" 5 #include "content/renderer/gpu/render_widget_compositor.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/location.h" 9 #include "base/location.h"
10 #include "base/macros.h" 10 #include "base/macros.h"
11 #include "base/memory/ptr_util.h" 11 #include "base/memory/ptr_util.h"
12 #include "base/run_loop.h" 12 #include "base/run_loop.h"
13 #include "base/single_thread_task_runner.h" 13 #include "base/single_thread_task_runner.h"
14 #include "base/threading/thread_task_runner_handle.h" 14 #include "base/threading/thread_task_runner_handle.h"
15 #include "cc/output/begin_frame_args.h" 15 #include "cc/output/begin_frame_args.h"
16 #include "cc/output/copy_output_request.h" 16 #include "cc/output/copy_output_request.h"
17 #include "cc/test/failure_output_surface.h"
17 #include "cc/test/fake_external_begin_frame_source.h" 18 #include "cc/test/fake_external_begin_frame_source.h"
18 #include "cc/test/fake_output_surface.h"
19 #include "cc/test/test_context_provider.h"
20 #include "cc/trees/layer_tree_host.h" 19 #include "cc/trees/layer_tree_host.h"
21 #include "components/scheduler/renderer/renderer_scheduler.h" 20 #include "components/scheduler/renderer/renderer_scheduler.h"
22 #include "content/public/test/mock_render_thread.h" 21 #include "content/public/test/mock_render_thread.h"
23 #include "content/renderer/render_widget.h" 22 #include "content/renderer/render_widget.h"
24 #include "content/test/fake_compositor_dependencies.h" 23 #include "content/test/fake_compositor_dependencies.h"
25 #include "content/test/fake_renderer_scheduler.h" 24 #include "content/test/fake_renderer_scheduler.h"
26 #include "gpu/GLES2/gl2extchromium.h"
27 #include "testing/gmock/include/gmock/gmock.h" 25 #include "testing/gmock/include/gmock/gmock.h"
28 #include "testing/gtest/include/gtest/gtest.h" 26 #include "testing/gtest/include/gtest/gtest.h"
29 #include "third_party/WebKit/public/platform/WebScreenInfo.h" 27 #include "third_party/WebKit/public/platform/WebScreenInfo.h"
30 28
31 using testing::AllOf; 29 using testing::AllOf;
32 using testing::Field; 30 using testing::Field;
33 31
34 namespace content { 32 namespace content {
35 namespace { 33 namespace {
36 34
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
75 public: 73 public:
76 FakeRenderWidgetCompositorDelegate() = default; 74 FakeRenderWidgetCompositorDelegate() = default;
77 75
78 std::unique_ptr<cc::OutputSurface> CreateOutputSurface( 76 std::unique_ptr<cc::OutputSurface> CreateOutputSurface(
79 bool fallback) override { 77 bool fallback) override {
80 EXPECT_EQ( 78 EXPECT_EQ(
81 num_requests_since_last_success_ > 79 num_requests_since_last_success_ >
82 RenderWidgetCompositor::OUTPUT_SURFACE_RETRIES_BEFORE_FALLBACK, 80 RenderWidgetCompositor::OUTPUT_SURFACE_RETRIES_BEFORE_FALLBACK,
83 fallback); 81 fallback);
84 last_create_was_fallback_ = fallback; 82 last_create_was_fallback_ = fallback;
85
86 bool success = num_failures_ >= num_failures_before_success_; 83 bool success = num_failures_ >= num_failures_before_success_;
87 if (!success && use_null_output_surface_) 84 if (success) {
88 return nullptr; 85 std::unique_ptr<cc::TestWebGraphicsContext3D> context =
89 86 cc::TestWebGraphicsContext3D::Create();
90 auto context_provider = cc::TestContextProvider::Create(); 87 // Image support required for synchronous compositing.
91 if (!success) { 88 context->set_support_image(true);
92 context_provider->UnboundTestContext3d()->loseContextCHROMIUM( 89 // Create delegating surface so that max_pending_frames = 1.
93 GL_GUILTY_CONTEXT_RESET_ARB, GL_INNOCENT_CONTEXT_RESET_ARB); 90 return cc::FakeOutputSurface::CreateDelegating3d(std::move(context));
94 } 91 }
95 92 return use_null_output_surface_
96 // Create delegating surface so that max_pending_frames = 1. 93 ? nullptr
97 return cc::FakeOutputSurface::CreateDelegating3d( 94 : base::WrapUnique(new cc::FailureOutputSurface(true));
98 std::move(context_provider));
99 } 95 }
100 96
101 std::unique_ptr<cc::BeginFrameSource> CreateExternalBeginFrameSource() 97 std::unique_ptr<cc::BeginFrameSource> CreateExternalBeginFrameSource()
102 override { 98 override {
103 double refresh_rate = 200.0; 99 double refresh_rate = 200.0;
104 bool tick_automatically = true; 100 bool tick_automatically = true;
105 return base::MakeUnique<cc::FakeExternalBeginFrameSource>( 101 return base::MakeUnique<cc::FakeExternalBeginFrameSource>(
106 refresh_rate, tick_automatically); 102 refresh_rate, tick_automatically);
107 } 103 }
108 104
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after
298 } 294 }
299 295
300 TEST_F(RenderWidgetCompositorOutputSurfaceTest, FallbackSuccessNormalSuccess) { 296 TEST_F(RenderWidgetCompositorOutputSurfaceTest, FallbackSuccessNormalSuccess) {
301 // The first success is a fallback, but the next should not be a fallback. 297 // The first success is a fallback, but the next should not be a fallback.
302 RunTest(false, RenderWidgetCompositor::OUTPUT_SURFACE_RETRIES_BEFORE_FALLBACK, 298 RunTest(false, RenderWidgetCompositor::OUTPUT_SURFACE_RETRIES_BEFORE_FALLBACK,
303 1, 1); 299 1, 1);
304 } 300 }
305 301
306 } // namespace 302 } // namespace
307 } // namespace content 303 } // namespace content
OLDNEW
« no previous file with comments | « content/renderer/android/synchronous_compositor_output_surface.h ('k') | content/test/layouttest_support.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698