OLD | NEW |
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/display.h" | 5 #include "cc/surfaces/display.h" |
6 | 6 |
7 #include "base/message_loop/message_loop.h" | 7 #include "base/message_loop/message_loop.h" |
8 #include "base/trace_event/trace_event.h" | 8 #include "base/trace_event/trace_event.h" |
9 #include "cc/debug/benchmark_instrumentation.h" | 9 #include "cc/debug/benchmark_instrumentation.h" |
10 #include "cc/output/compositor_frame.h" | 10 #include "cc/output/compositor_frame.h" |
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
127 benchmark_instrumentation::IssueDisplayRenderingStatsEvent(); | 127 benchmark_instrumentation::IssueDisplayRenderingStatsEvent(); |
128 | 128 |
129 // Run callbacks early to allow pipelining. | 129 // Run callbacks early to allow pipelining. |
130 for (const auto& id_entry : aggregator_->previous_contained_surfaces()) { | 130 for (const auto& id_entry : aggregator_->previous_contained_surfaces()) { |
131 Surface* surface = manager_->GetSurfaceForId(id_entry.first); | 131 Surface* surface = manager_->GetSurfaceForId(id_entry.first); |
132 if (surface) | 132 if (surface) |
133 surface->RunDrawCallbacks(SurfaceDrawStatus::DRAWN); | 133 surface->RunDrawCallbacks(SurfaceDrawStatus::DRAWN); |
134 } | 134 } |
135 DelegatedFrameData* frame_data = frame->delegated_frame_data.get(); | 135 DelegatedFrameData* frame_data = frame->delegated_frame_data.get(); |
136 | 136 |
137 frame->metadata.latency_info.insert(frame->metadata.latency_info.end(), | 137 gfx::Size surface_size = |
138 stored_latency_info_.begin(), | 138 frame_data->render_pass_list.back()->output_rect.size(); |
139 stored_latency_info_.end()); | |
140 stored_latency_info_.clear(); | |
141 bool have_copy_requests = false; | |
142 for (const auto* pass : frame_data->render_pass_list) { | |
143 have_copy_requests |= !pass->copy_requests.empty(); | |
144 } | |
145 | 139 |
146 gfx::Size surface_size; | 140 gfx::Rect device_viewport_rect = gfx::Rect(current_surface_size_); |
147 bool have_damage = false; | 141 gfx::Rect device_clip_rect = device_viewport_rect; |
148 if (!frame_data->render_pass_list.empty()) { | 142 bool disable_picture_quad_image_filtering = false; |
149 surface_size = frame_data->render_pass_list.back()->output_rect.size(); | |
150 have_damage = | |
151 !frame_data->render_pass_list.back()->damage_rect.size().IsEmpty(); | |
152 } | |
153 bool avoid_swap = surface_size != current_surface_size_; | |
154 bool should_draw = !frame->metadata.latency_info.empty() || | |
155 have_copy_requests || (have_damage && !avoid_swap); | |
156 | 143 |
157 if (should_draw) { | 144 renderer_->DecideRenderPassAllocationsForFrame(frame_data->render_pass_list); |
158 gfx::Rect device_viewport_rect = gfx::Rect(current_surface_size_); | 145 renderer_->DrawFrame(&frame_data->render_pass_list, |
159 gfx::Rect device_clip_rect = device_viewport_rect; | 146 device_scale_factor_, |
160 bool disable_picture_quad_image_filtering = false; | 147 device_viewport_rect, |
| 148 device_clip_rect, |
| 149 disable_picture_quad_image_filtering); |
161 | 150 |
162 renderer_->DecideRenderPassAllocationsForFrame( | 151 if (surface_size != current_surface_size_) { |
163 frame_data->render_pass_list); | |
164 renderer_->DrawFrame(&frame_data->render_pass_list, device_scale_factor_, | |
165 device_viewport_rect, device_clip_rect, | |
166 disable_picture_quad_image_filtering); | |
167 } | |
168 | |
169 if (should_draw && !avoid_swap) { | |
170 renderer_->SwapBuffers(frame->metadata); | |
171 } else { | |
172 stored_latency_info_.insert(stored_latency_info_.end(), | |
173 frame->metadata.latency_info.begin(), | |
174 frame->metadata.latency_info.end()); | |
175 DidSwapBuffers(); | 152 DidSwapBuffers(); |
176 DidSwapBuffersComplete(); | 153 DidSwapBuffersComplete(); |
| 154 } else { |
| 155 renderer_->SwapBuffers(frame->metadata); |
177 } | 156 } |
178 | 157 |
179 return true; | 158 return true; |
180 } | 159 } |
181 | 160 |
182 void Display::DidSwapBuffers() { | 161 void Display::DidSwapBuffers() { |
183 client_->DidSwapBuffers(); | 162 client_->DidSwapBuffers(); |
184 } | 163 } |
185 | 164 |
186 void Display::DidSwapBuffersComplete() { | 165 void Display::DidSwapBuffersComplete() { |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
220 | 199 |
221 int Display::GetMaxFramesPending() { | 200 int Display::GetMaxFramesPending() { |
222 int max_frames_pending = | 201 int max_frames_pending = |
223 output_surface_ ? output_surface_->capabilities().max_frames_pending : 0; | 202 output_surface_ ? output_surface_->capabilities().max_frames_pending : 0; |
224 if (max_frames_pending <= 0) | 203 if (max_frames_pending <= 0) |
225 max_frames_pending = OutputSurface::DEFAULT_MAX_FRAMES_PENDING; | 204 max_frames_pending = OutputSurface::DEFAULT_MAX_FRAMES_PENDING; |
226 return max_frames_pending; | 205 return max_frames_pending; |
227 } | 206 } |
228 | 207 |
229 } // namespace cc | 208 } // namespace cc |
OLD | NEW |