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

Side by Side Diff: cc/surfaces/surface_factory.cc

Issue 1673783004: Hook up BeginFrameSource to SurfaceFactoryClient via SurfaceManager (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Register id namespace on Android Created 4 years, 9 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_client.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 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"
(...skipping 11 matching lines...) Expand all
22 holder_(client), 22 holder_(client),
23 needs_sync_points_(true) { 23 needs_sync_points_(true) {
24 } 24 }
25 25
26 SurfaceFactory::~SurfaceFactory() { 26 SurfaceFactory::~SurfaceFactory() {
27 if (!surface_map_.empty()) { 27 if (!surface_map_.empty()) {
28 LOG(ERROR) << "SurfaceFactory has " << surface_map_.size() 28 LOG(ERROR) << "SurfaceFactory has " << surface_map_.size()
29 << " entries in map on destruction."; 29 << " entries in map on destruction.";
30 } 30 }
31 DestroyAll(); 31 DestroyAll();
32 client_->SetBeginFrameSource(SurfaceId(), nullptr);
33 } 32 }
34 33
35 void SurfaceFactory::DestroyAll() { 34 void SurfaceFactory::DestroyAll() {
36 for (auto& pair : surface_map_) 35 for (auto& pair : surface_map_)
37 manager_->Destroy(std::move(pair.second)); 36 manager_->Destroy(std::move(pair.second));
38 surface_map_.clear(); 37 surface_map_.clear();
39 } 38 }
40 39
41 void SurfaceFactory::Create(SurfaceId surface_id) { 40 void SurfaceFactory::Create(SurfaceId surface_id) {
42 scoped_ptr<Surface> surface(new Surface(surface_id, this)); 41 scoped_ptr<Surface> surface(new Surface(surface_id, this));
43 manager_->RegisterSurface(surface.get()); 42 manager_->RegisterSurface(surface.get());
44 DCHECK(!surface_map_.count(surface_id)); 43 DCHECK(!surface_map_.count(surface_id));
45 surface_map_[surface_id] = std::move(surface); 44 surface_map_[surface_id] = std::move(surface);
46 } 45 }
47 46
48 void SurfaceFactory::Destroy(SurfaceId surface_id) { 47 void SurfaceFactory::Destroy(SurfaceId surface_id) {
49 OwningSurfaceMap::iterator it = surface_map_.find(surface_id); 48 OwningSurfaceMap::iterator it = surface_map_.find(surface_id);
50 DCHECK(it != surface_map_.end()); 49 DCHECK(it != surface_map_.end());
51 DCHECK(it->second->factory().get() == this); 50 DCHECK(it->second->factory().get() == this);
52 scoped_ptr<Surface> surface(std::move(it->second)); 51 scoped_ptr<Surface> surface(std::move(it->second));
53 surface_map_.erase(it); 52 surface_map_.erase(it);
54 manager_->Destroy(std::move(surface)); 53 manager_->Destroy(std::move(surface));
55 } 54 }
56 55
57 void SurfaceFactory::SetBeginFrameSource(SurfaceId surface_id,
58 BeginFrameSource* begin_frame_source) {
59 client_->SetBeginFrameSource(surface_id, begin_frame_source);
60 }
61
62 void SurfaceFactory::SubmitCompositorFrame(SurfaceId surface_id, 56 void SurfaceFactory::SubmitCompositorFrame(SurfaceId surface_id,
63 scoped_ptr<CompositorFrame> frame, 57 scoped_ptr<CompositorFrame> frame,
64 const DrawCallback& callback) { 58 const DrawCallback& callback) {
65 TRACE_EVENT0("cc", "SurfaceFactory::SubmitCompositorFrame"); 59 TRACE_EVENT0("cc", "SurfaceFactory::SubmitCompositorFrame");
66 OwningSurfaceMap::iterator it = surface_map_.find(surface_id); 60 OwningSurfaceMap::iterator it = surface_map_.find(surface_id);
67 DCHECK(it != surface_map_.end()); 61 DCHECK(it != surface_map_.end());
68 DCHECK(it->second->factory().get() == this); 62 DCHECK(it->second->factory().get() == this);
69 it->second->QueueFrame(std::move(frame), callback); 63 it->second->QueueFrame(std::move(frame), callback);
70 if (!manager_->SurfaceModified(surface_id)) { 64 if (!manager_->SurfaceModified(surface_id)) {
71 TRACE_EVENT_INSTANT0("cc", "Damage not visible.", TRACE_EVENT_SCOPE_THREAD); 65 TRACE_EVENT_INSTANT0("cc", "Damage not visible.", TRACE_EVENT_SCOPE_THREAD);
(...skipping 26 matching lines...) Expand all
98 92
99 void SurfaceFactory::RefResources(const TransferableResourceArray& resources) { 93 void SurfaceFactory::RefResources(const TransferableResourceArray& resources) {
100 holder_.RefResources(resources); 94 holder_.RefResources(resources);
101 } 95 }
102 96
103 void SurfaceFactory::UnrefResources(const ReturnedResourceArray& resources) { 97 void SurfaceFactory::UnrefResources(const ReturnedResourceArray& resources) {
104 holder_.UnrefResources(resources); 98 holder_.UnrefResources(resources);
105 } 99 }
106 100
107 } // namespace cc 101 } // namespace cc
OLDNEW
« no previous file with comments | « cc/surfaces/surface_factory.h ('k') | cc/surfaces/surface_factory_client.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698