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

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

Issue 2834553002: Replace CompositorFrameSinkSupport::WillDrawSurface With RepeatingCallback (Closed)
Patch Set: Address Comments On Documentation Created 3 years, 8 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/memory/ptr_util.h" 9 #include "base/memory/ptr_util.h"
10 #include "base/trace_event/trace_event.h" 10 #include "base/trace_event/trace_event.h"
(...skipping 26 matching lines...) Expand all
37 37
38 void SurfaceFactory::EvictSurface() { 38 void SurfaceFactory::EvictSurface() {
39 if (!current_surface_) 39 if (!current_surface_)
40 return; 40 return;
41 Destroy(std::move(current_surface_)); 41 Destroy(std::move(current_surface_));
42 } 42 }
43 43
44 void SurfaceFactory::SubmitCompositorFrame( 44 void SurfaceFactory::SubmitCompositorFrame(
45 const LocalSurfaceId& local_surface_id, 45 const LocalSurfaceId& local_surface_id,
46 CompositorFrame frame, 46 CompositorFrame frame,
47 const DrawCallback& callback) { 47 const DrawCallback& callback,
48 const WillDrawCallback& will_draw_callback) {
48 TRACE_EVENT0("cc", "SurfaceFactory::SubmitCompositorFrame"); 49 TRACE_EVENT0("cc", "SurfaceFactory::SubmitCompositorFrame");
49 DCHECK(local_surface_id.is_valid()); 50 DCHECK(local_surface_id.is_valid());
50 51
51 for (ui::LatencyInfo& latency : frame.metadata.latency_info) { 52 for (ui::LatencyInfo& latency : frame.metadata.latency_info) {
52 if (latency.latency_components().size() > 0) { 53 if (latency.latency_components().size() > 0) {
53 latency.AddLatencyNumber(ui::DISPLAY_COMPOSITOR_RECEIVED_FRAME_COMPONENT, 54 latency.AddLatencyNumber(ui::DISPLAY_COMPOSITOR_RECEIVED_FRAME_COMPONENT,
54 0, 0); 55 0, 0);
55 } 56 }
56 } 57 }
57 58
58 std::unique_ptr<Surface> surface; 59 std::unique_ptr<Surface> surface;
59 bool create_new_surface = 60 bool create_new_surface =
60 (!current_surface_ || 61 (!current_surface_ ||
61 local_surface_id != current_surface_->surface_id().local_surface_id()); 62 local_surface_id != current_surface_->surface_id().local_surface_id());
62 if (!create_new_surface) { 63 if (!create_new_surface) {
63 surface = std::move(current_surface_); 64 surface = std::move(current_surface_);
64 } else { 65 } else {
65 surface = Create(local_surface_id); 66 surface = Create(local_surface_id);
66 } 67 }
67 surface->QueueFrame(std::move(frame), callback); 68 surface->QueueFrame(std::move(frame), callback, will_draw_callback);
68 69
69 if (current_surface_ && create_new_surface) { 70 if (current_surface_ && create_new_surface) {
70 surface->SetPreviousFrameSurface(current_surface_.get()); 71 surface->SetPreviousFrameSurface(current_surface_.get());
71 Destroy(std::move(current_surface_)); 72 Destroy(std::move(current_surface_));
72 } 73 }
73 current_surface_ = std::move(surface); 74 current_surface_ = std::move(surface);
74 } 75 }
75 76
76 void SurfaceFactory::RequestCopyOfSurface( 77 void SurfaceFactory::RequestCopyOfSurface(
77 std::unique_ptr<CopyOutputRequest> copy_request) { 78 std::unique_ptr<CopyOutputRequest> copy_request) {
78 if (!current_surface_) { 79 if (!current_surface_) {
79 copy_request->SendEmptyResult(); 80 copy_request->SendEmptyResult();
80 return; 81 return;
81 } 82 }
82 DCHECK(current_surface_->factory().get() == this); 83 DCHECK(current_surface_->factory().get() == this);
83 current_surface_->RequestCopyOfOutput(std::move(copy_request)); 84 current_surface_->RequestCopyOfOutput(std::move(copy_request));
84 manager_->SurfaceModified(current_surface_->surface_id()); 85 manager_->SurfaceModified(current_surface_->surface_id());
85 } 86 }
86 87
87 void SurfaceFactory::ClearSurface() { 88 void SurfaceFactory::ClearSurface() {
88 if (!current_surface_) 89 if (!current_surface_)
89 return; 90 return;
90 current_surface_->EvictFrame(); 91 current_surface_->EvictFrame();
91 manager_->SurfaceModified(current_surface_->surface_id()); 92 manager_->SurfaceModified(current_surface_->surface_id());
92 } 93 }
93 94
94 void SurfaceFactory::WillDrawSurface(const LocalSurfaceId& id,
95 const gfx::Rect& damage_rect) {
96 client_->WillDrawSurface(id, damage_rect);
97 }
98
99 void SurfaceFactory::ReceiveFromChild( 95 void SurfaceFactory::ReceiveFromChild(
100 const TransferableResourceArray& resources) { 96 const TransferableResourceArray& resources) {
101 holder_.ReceiveFromChild(resources); 97 holder_.ReceiveFromChild(resources);
102 } 98 }
103 99
104 void SurfaceFactory::RefResources(const TransferableResourceArray& resources) { 100 void SurfaceFactory::RefResources(const TransferableResourceArray& resources) {
105 holder_.RefResources(resources); 101 holder_.RefResources(resources);
106 } 102 }
107 103
108 void SurfaceFactory::UnrefResources(const ReturnedResourceArray& resources) { 104 void SurfaceFactory::UnrefResources(const ReturnedResourceArray& resources) {
(...skipping 15 matching lines...) Expand all
124 // SurfaceFactory stops observing new activations after the first one. 120 // SurfaceFactory stops observing new activations after the first one.
125 manager_->SurfaceCreated(SurfaceInfo( 121 manager_->SurfaceCreated(SurfaceInfo(
126 surface->surface_id(), frame.metadata.device_scale_factor, frame_size)); 122 surface->surface_id(), frame.metadata.device_scale_factor, frame_size));
127 } 123 }
128 // Fire SurfaceCreated first so that a temporary reference is added before it 124 // Fire SurfaceCreated first so that a temporary reference is added before it
129 // is potentially transformed into a real reference by the client. 125 // is potentially transformed into a real reference by the client.
130 client_->ReferencedSurfacesChanged(surface->surface_id().local_surface_id(), 126 client_->ReferencedSurfacesChanged(surface->surface_id().local_surface_id(),
131 surface->active_referenced_surfaces()); 127 surface->active_referenced_surfaces());
132 if (!manager_->SurfaceModified(surface->surface_id())) { 128 if (!manager_->SurfaceModified(surface->surface_id())) {
133 TRACE_EVENT_INSTANT0("cc", "Damage not visible.", TRACE_EVENT_SCOPE_THREAD); 129 TRACE_EVENT_INSTANT0("cc", "Damage not visible.", TRACE_EVENT_SCOPE_THREAD);
134 surface->RunDrawCallbacks(); 130 surface->RunDrawCallback();
135 } 131 }
136 } 132 }
137 133
138 void SurfaceFactory::OnSurfaceDependenciesChanged( 134 void SurfaceFactory::OnSurfaceDependenciesChanged(
139 Surface* surface, 135 Surface* surface,
140 const SurfaceDependencies& added_dependencies, 136 const SurfaceDependencies& added_dependencies,
141 const SurfaceDependencies& removed_dependencies) {} 137 const SurfaceDependencies& removed_dependencies) {}
142 138
143 void SurfaceFactory::OnSurfaceDiscarded(Surface* surface) {} 139 void SurfaceFactory::OnSurfaceDiscarded(Surface* surface) {}
144 140
145 std::unique_ptr<Surface> SurfaceFactory::Create( 141 std::unique_ptr<Surface> SurfaceFactory::Create(
146 const LocalSurfaceId& local_surface_id) { 142 const LocalSurfaceId& local_surface_id) {
147 seen_first_frame_activation_ = false; 143 seen_first_frame_activation_ = false;
148 std::unique_ptr<Surface> surface = 144 std::unique_ptr<Surface> surface =
149 manager_->CreateSurface(weak_factory_.GetWeakPtr(), local_surface_id); 145 manager_->CreateSurface(weak_factory_.GetWeakPtr(), local_surface_id);
150 surface->AddObserver(this); 146 surface->AddObserver(this);
151 return surface; 147 return surface;
152 } 148 }
153 149
154 void SurfaceFactory::Destroy(std::unique_ptr<Surface> surface) { 150 void SurfaceFactory::Destroy(std::unique_ptr<Surface> surface) {
155 surface->RemoveObserver(this); 151 surface->RemoveObserver(this);
156 manager_->DestroySurface(std::move(surface)); 152 manager_->DestroySurface(std::move(surface));
157 } 153 }
158 154
159 } // namespace cc 155 } // 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