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

Side by Side Diff: cc/surfaces/surface_factory.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/surface_factory.h ('k') | cc/surfaces/surface_factory_unittest.cc » ('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 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 "cc/surfaces/surface_factory.h" 5 #include "cc/surfaces/surface_factory.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/trace_event/trace_event.h" 9 #include "base/trace_event/trace_event.h"
10 #include "cc/output/compositor_frame.h" 10 #include "cc/output/compositor_frame.h"
11 #include "cc/output/copy_output_request.h" 11 #include "cc/output/copy_output_request.h"
12 #include "cc/surfaces/surface.h" 12 #include "cc/surfaces/surface.h"
13 #include "cc/surfaces/surface_factory_client.h" 13 #include "cc/surfaces/surface_factory_client.h"
14 #include "cc/surfaces/surface_manager.h" 14 #include "cc/surfaces/surface_manager.h"
15 #include "ui/gfx/geometry/size.h" 15 #include "ui/gfx/geometry/size.h"
16 16
17 namespace cc { 17 namespace cc {
18 SurfaceFactory::SurfaceFactory(SurfaceManager* manager, 18
19 SurfaceFactory::SurfaceFactory(uint32_t client_id,
20 SurfaceManager* manager,
19 SurfaceFactoryClient* client) 21 SurfaceFactoryClient* client)
20 : manager_(manager), 22 : client_id_(client_id),
23 parent_client_id_(0),
24 manager_(manager),
21 client_(client), 25 client_(client),
22 holder_(client), 26 holder_(client),
23 needs_sync_points_(true) { 27 needs_sync_points_(true) {
28 manager_->RegisterClient(client_id_, client);
24 } 29 }
25 30
26 SurfaceFactory::~SurfaceFactory() { 31 SurfaceFactory::~SurfaceFactory() {
27 if (!surface_map_.empty()) { 32 if (!surface_map_.empty()) {
28 LOG(ERROR) << "SurfaceFactory has " << surface_map_.size() 33 LOG(ERROR) << "SurfaceFactory has " << surface_map_.size()
29 << " entries in map on destruction."; 34 << " entries in map on destruction.";
30 } 35 }
31 DestroyAll(); 36 DestroyAll();
37 if (manager_) {
38 if (parent_client_id_) {
39 manager_->UnregisterSurfaceNamespaceHierarchy(parent_client_id_,
40 client_id_);
41 }
42 manager_->UnregisterClient(client_id_);
43 }
44 }
45
46 void SurfaceFactory::SetParent(uint32_t parent_client_id) {
47 if (parent_client_id_) {
48 manager_->UnregisterSurfaceNamespaceHierarchy(parent_client_id_,
49 client_id_);
50 }
51 parent_client_id_ = parent_client_id;
52 if (parent_client_id_)
53 manager_->RegisterSurfaceNamespaceHierarchy(parent_client_id_, client_id_);
32 } 54 }
33 55
34 void SurfaceFactory::DestroyAll() { 56 void SurfaceFactory::DestroyAll() {
35 if (manager_) { 57 if (manager_) {
36 for (auto& pair : surface_map_) 58 for (auto& pair : surface_map_)
37 manager_->Destroy(std::move(pair.second)); 59 manager_->Destroy(std::move(pair.second));
38 } 60 }
39 surface_map_.clear(); 61 surface_map_.clear();
40 } 62 }
41 63
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
105 127
106 void SurfaceFactory::RefResources(const TransferableResourceArray& resources) { 128 void SurfaceFactory::RefResources(const TransferableResourceArray& resources) {
107 holder_.RefResources(resources); 129 holder_.RefResources(resources);
108 } 130 }
109 131
110 void SurfaceFactory::UnrefResources(const ReturnedResourceArray& resources) { 132 void SurfaceFactory::UnrefResources(const ReturnedResourceArray& resources) {
111 holder_.UnrefResources(resources); 133 holder_.UnrefResources(resources);
112 } 134 }
113 135
114 } // namespace cc 136 } // namespace cc
OLDNEW
« no previous file with comments | « cc/surfaces/surface_factory.h ('k') | cc/surfaces/surface_factory_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698