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

Side by Side Diff: content/test/test_render_view_host.cc

Issue 2383373002: Reduce SurfaceIdAllocator usage and tie SurfaceFactory to a single FrameSinkId (Closed)
Patch Set: Rebased Created 4 years, 2 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 | « content/test/test_render_view_host.h ('k') | services/ui/surfaces/compositor_frame_sink.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/test/test_render_view_host.h" 5 #include "content/test/test_render_view_host.h"
6 6
7 #include <memory> 7 #include <memory>
8 8
9 #include "base/strings/utf_string_conversions.h" 9 #include "base/strings/utf_string_conversions.h"
10 #include "build/build_config.h" 10 #include "build/build_config.h"
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
62 } 62 }
63 63
64 TestRenderWidgetHostView::TestRenderWidgetHostView(RenderWidgetHost* rwh) 64 TestRenderWidgetHostView::TestRenderWidgetHostView(RenderWidgetHost* rwh)
65 : rwh_(RenderWidgetHostImpl::From(rwh)), 65 : rwh_(RenderWidgetHostImpl::From(rwh)),
66 is_showing_(false), 66 is_showing_(false),
67 is_occluded_(false), 67 is_occluded_(false),
68 did_swap_compositor_frame_(false) { 68 did_swap_compositor_frame_(false) {
69 #if defined(OS_ANDROID) 69 #if defined(OS_ANDROID)
70 // Not all tests initialize or need a context provider factory. 70 // Not all tests initialize or need a context provider factory.
71 if (ContextProviderFactoryImpl::GetInstance()) { 71 if (ContextProviderFactoryImpl::GetInstance()) {
72 surface_id_allocator_.reset( 72 frame_sink_id_ = AllocateFrameSinkId();
73 new cc::SurfaceIdAllocator(AllocateFrameSinkId())); 73 surface_id_allocator_ =
74 GetSurfaceManager()->RegisterFrameSinkId( 74 base::MakeUnique<cc::SurfaceIdAllocator>(frame_sink_id_);
75 surface_id_allocator_->frame_sink_id()); 75 GetSurfaceManager()->RegisterFrameSinkId(frame_sink_id_);
76 } 76 }
77 #else 77 #else
78 // Not all tests initialize or need an image transport factory. 78 // Not all tests initialize or need an image transport factory.
79 if (ImageTransportFactory::GetInstance()) { 79 if (ImageTransportFactory::GetInstance()) {
80 surface_id_allocator_.reset( 80 frame_sink_id_ = AllocateFrameSinkId();
81 new cc::SurfaceIdAllocator(AllocateFrameSinkId())); 81 surface_id_allocator_ =
82 GetSurfaceManager()->RegisterFrameSinkId( 82 base::MakeUnique<cc::SurfaceIdAllocator>(frame_sink_id_);
83 surface_id_allocator_->frame_sink_id()); 83 GetSurfaceManager()->RegisterFrameSinkId(frame_sink_id_);
84 } 84 }
85 #endif 85 #endif
86 86
87 rwh_->SetView(this); 87 rwh_->SetView(this);
88 } 88 }
89 89
90 TestRenderWidgetHostView::~TestRenderWidgetHostView() { 90 TestRenderWidgetHostView::~TestRenderWidgetHostView() {
91 cc::SurfaceManager* manager = nullptr; 91 cc::SurfaceManager* manager = nullptr;
92 #if defined(OS_ANDROID) 92 #if defined(OS_ANDROID)
93 if (ContextProviderFactoryImpl::GetInstance()) 93 if (ContextProviderFactoryImpl::GetInstance())
94 manager = GetSurfaceManager(); 94 manager = GetSurfaceManager();
95 #else 95 #else
96 manager = GetSurfaceManager(); 96 manager = GetSurfaceManager();
97 #endif 97 #endif
98 if (manager) { 98 if (manager) {
99 manager->InvalidateFrameSinkId(surface_id_allocator_->frame_sink_id()); 99 manager->InvalidateFrameSinkId(frame_sink_id_);
100 } 100 }
101 } 101 }
102 102
103 RenderWidgetHost* TestRenderWidgetHostView::GetRenderWidgetHost() const { 103 RenderWidgetHost* TestRenderWidgetHostView::GetRenderWidgetHost() const {
104 return rwh_; 104 return rwh_;
105 } 105 }
106 106
107 gfx::Vector2dF TestRenderWidgetHostView::GetLastScrollOffset() const { 107 gfx::Vector2dF TestRenderWidgetHostView::GetLastScrollOffset() const {
108 return gfx::Vector2dF(); 108 return gfx::Vector2dF();
109 } 109 }
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
222 } 222 }
223 223
224 bool TestRenderWidgetHostView::LockMouse() { 224 bool TestRenderWidgetHostView::LockMouse() {
225 return false; 225 return false;
226 } 226 }
227 227
228 void TestRenderWidgetHostView::UnlockMouse() { 228 void TestRenderWidgetHostView::UnlockMouse() {
229 } 229 }
230 230
231 cc::FrameSinkId TestRenderWidgetHostView::GetFrameSinkId() { 231 cc::FrameSinkId TestRenderWidgetHostView::GetFrameSinkId() {
232 // See constructor. If a test needs this, its harness needs to construct an 232 return frame_sink_id_;
233 // ImageTransportFactory.
234 DCHECK(surface_id_allocator_);
235 return surface_id_allocator_->frame_sink_id();
236 } 233 }
237 234
238 TestRenderViewHost::TestRenderViewHost( 235 TestRenderViewHost::TestRenderViewHost(
239 SiteInstance* instance, 236 SiteInstance* instance,
240 std::unique_ptr<RenderWidgetHostImpl> widget, 237 std::unique_ptr<RenderWidgetHostImpl> widget,
241 RenderViewHostDelegate* delegate, 238 RenderViewHostDelegate* delegate,
242 int32_t main_frame_routing_id, 239 int32_t main_frame_routing_id,
243 bool swapped_out) 240 bool swapped_out)
244 : RenderViewHostImpl(instance, 241 : RenderViewHostImpl(instance,
245 std::move(widget), 242 std::move(widget),
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
351 348
352 TestRenderFrameHost* RenderViewHostImplTestHarness::main_test_rfh() { 349 TestRenderFrameHost* RenderViewHostImplTestHarness::main_test_rfh() {
353 return contents()->GetMainFrame(); 350 return contents()->GetMainFrame();
354 } 351 }
355 352
356 TestWebContents* RenderViewHostImplTestHarness::contents() { 353 TestWebContents* RenderViewHostImplTestHarness::contents() {
357 return static_cast<TestWebContents*>(web_contents()); 354 return static_cast<TestWebContents*>(web_contents());
358 } 355 }
359 356
360 } // namespace content 357 } // namespace content
OLDNEW
« no previous file with comments | « content/test/test_render_view_host.h ('k') | services/ui/surfaces/compositor_frame_sink.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698