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

Side by Side Diff: cc/test/test_delegating_output_surface.cc

Issue 2144733005: [WIP] cc: Plumb SurfaceId from clients Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Ensure only SurfaceFactoy and tests can update hierarchy 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/surfaces/surfaces_pixeltest.cc ('k') | cc/trees/layer_tree_host.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 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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/test/test_delegating_output_surface.h" 5 #include "cc/test/test_delegating_output_surface.h"
6 6
7 #include <stdint.h> 7 #include <stdint.h>
8 #include <utility> 8 #include <utility>
9 9
10 #include "cc/output/begin_frame_args.h" 10 #include "cc/output/begin_frame_args.h"
11 #include "cc/test/begin_frame_args_test.h" 11 #include "cc/test/begin_frame_args_test.h"
12 12
13 static constexpr uint32_t kCompositorClientId = 1; 13 static constexpr uint32_t kCompositorClientId = 1;
14 14
15 namespace cc { 15 namespace cc {
16 16
17 TestDelegatingOutputSurface::TestDelegatingOutputSurface( 17 TestDelegatingOutputSurface::TestDelegatingOutputSurface(
18 scoped_refptr<ContextProvider> compositor_context_provider, 18 scoped_refptr<ContextProvider> compositor_context_provider,
19 scoped_refptr<ContextProvider> worker_context_provider, 19 scoped_refptr<ContextProvider> worker_context_provider,
20 std::unique_ptr<Display> display, 20 std::unique_ptr<Display> display,
21 bool context_shared_with_compositor, 21 bool context_shared_with_compositor,
22 bool allow_force_reclaim_resources) 22 bool allow_force_reclaim_resources)
23 : OutputSurface(std::move(compositor_context_provider), 23 : OutputSurface(std::move(compositor_context_provider),
24 std::move(worker_context_provider), 24 std::move(worker_context_provider),
25 nullptr), 25 nullptr),
26 surface_manager_(new SurfaceManager), 26 surface_manager_(new SurfaceManager),
27 surface_id_allocator_(new SurfaceIdAllocator(kCompositorClientId)), 27 surface_id_allocator_(new SurfaceIdAllocator(kCompositorClientId)),
28 surface_factory_(new SurfaceFactory(surface_manager_.get(), this)), 28 surface_factory_(new SurfaceFactory(kCompositorClientId,
29 surface_manager_.get(),
30 this)),
29 display_(std::move(display)), 31 display_(std::move(display)),
30 weak_ptrs_(this) { 32 weak_ptrs_(this) {
31 CHECK(display_); 33 CHECK(display_);
32 capabilities_.delegated_rendering = true; 34 capabilities_.delegated_rendering = true;
33 capabilities_.can_force_reclaim_resources = allow_force_reclaim_resources; 35 capabilities_.can_force_reclaim_resources = allow_force_reclaim_resources;
34 capabilities_.delegated_sync_points_required = 36 capabilities_.delegated_sync_points_required =
35 !context_shared_with_compositor; 37 !context_shared_with_compositor;
36
37 surface_id_allocator_->RegisterSurfaceClientId(surface_manager_.get());
38 } 38 }
39 39
40 TestDelegatingOutputSurface::~TestDelegatingOutputSurface() {} 40 TestDelegatingOutputSurface::~TestDelegatingOutputSurface() {}
41 41
42 bool TestDelegatingOutputSurface::BindToClient(OutputSurfaceClient* client) { 42 bool TestDelegatingOutputSurface::BindToClient(OutputSurfaceClient* client) {
43 if (!OutputSurface::BindToClient(client)) 43 if (!OutputSurface::BindToClient(client))
44 return false; 44 return false;
45 45
46 // We want the Display's output surface to hear about lost context, and since 46 // We want the Display's output surface to hear about lost context, and since
47 // this shares a context with it (when delegated_sync_points_required is 47 // this shares a context with it (when delegated_sync_points_required is
48 // false), we should not be listening for lost context callbacks on the 48 // false), we should not be listening for lost context callbacks on the
49 // context here. 49 // context here.
50 if (!capabilities_.delegated_sync_points_required && context_provider()) 50 if (!capabilities_.delegated_sync_points_required && context_provider())
51 context_provider()->SetLostContextCallback(base::Closure()); 51 context_provider()->SetLostContextCallback(base::Closure());
52 52
53 surface_manager_->RegisterSurfaceFactoryClient(
54 surface_id_allocator_->client_id(), this);
55 display_->Initialize(&display_client_, surface_manager_.get(), 53 display_->Initialize(&display_client_, surface_manager_.get(),
56 surface_id_allocator_->client_id()); 54 surface_id_allocator_->client_id());
57 return true; 55 return true;
58 } 56 }
59 57
60 void TestDelegatingOutputSurface::DetachFromClient() { 58 void TestDelegatingOutputSurface::DetachFromClient() {
61 if (!delegated_surface_id_.is_null()) 59 if (!delegated_surface_id_.is_null())
62 surface_factory_->Destroy(delegated_surface_id_); 60 surface_factory_->Destroy(delegated_surface_id_);
63 surface_manager_->UnregisterSurfaceFactoryClient(
64 surface_id_allocator_->client_id());
65 61
66 display_ = nullptr; 62 display_ = nullptr;
67 surface_factory_ = nullptr; 63 surface_factory_ = nullptr;
68 surface_id_allocator_ = nullptr; 64 surface_id_allocator_ = nullptr;
69 surface_manager_ = nullptr; 65 surface_manager_ = nullptr;
70 weak_ptrs_.InvalidateWeakPtrs(); 66 weak_ptrs_.InvalidateWeakPtrs();
71 OutputSurface::DetachFromClient(); 67 OutputSurface::DetachFromClient();
72 } 68 }
73 69
74 void TestDelegatingOutputSurface::SwapBuffers(CompositorFrame frame) { 70 void TestDelegatingOutputSurface::SwapBuffers(CompositorFrame frame) {
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
120 const ReturnedResourceArray& resources) { 116 const ReturnedResourceArray& resources) {
121 client_->ReclaimResources(resources); 117 client_->ReclaimResources(resources);
122 } 118 }
123 119
124 void TestDelegatingOutputSurface::SetBeginFrameSource( 120 void TestDelegatingOutputSurface::SetBeginFrameSource(
125 BeginFrameSource* begin_frame_source) { 121 BeginFrameSource* begin_frame_source) {
126 client_->SetBeginFrameSource(begin_frame_source); 122 client_->SetBeginFrameSource(begin_frame_source);
127 } 123 }
128 124
129 } // namespace cc 125 } // namespace cc
OLDNEW
« no previous file with comments | « cc/surfaces/surfaces_pixeltest.cc ('k') | cc/trees/layer_tree_host.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698