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 gfx::Size surface_size = | 137 frame->metadata.latency_info.insert(frame->metadata.latency_info.end(), |
138 frame_data->render_pass_list.back()->output_rect.size(); | 138 stored_latency_info_.begin(), |
| 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 } |
139 | 145 |
140 gfx::Rect device_viewport_rect = gfx::Rect(current_surface_size_); | 146 gfx::Size surface_size; |
141 gfx::Rect device_clip_rect = device_viewport_rect; | 147 bool have_damage = false; |
142 bool disable_picture_quad_image_filtering = false; | 148 if (!frame_data->render_pass_list.empty()) { |
| 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); |
143 | 156 |
144 renderer_->DecideRenderPassAllocationsForFrame(frame_data->render_pass_list); | 157 if (should_draw) { |
145 renderer_->DrawFrame(&frame_data->render_pass_list, | 158 gfx::Rect device_viewport_rect = gfx::Rect(current_surface_size_); |
146 device_scale_factor_, | 159 gfx::Rect device_clip_rect = device_viewport_rect; |
147 device_viewport_rect, | 160 bool disable_picture_quad_image_filtering = false; |
148 device_clip_rect, | |
149 disable_picture_quad_image_filtering); | |
150 | 161 |
151 if (surface_size != current_surface_size_) { | 162 renderer_->DecideRenderPassAllocationsForFrame( |
| 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()); |
152 DidSwapBuffers(); | 175 DidSwapBuffers(); |
153 DidSwapBuffersComplete(); | 176 DidSwapBuffersComplete(); |
154 } else { | |
155 renderer_->SwapBuffers(frame->metadata); | |
156 } | 177 } |
157 | 178 |
158 return true; | 179 return true; |
159 } | 180 } |
160 | 181 |
161 void Display::DidSwapBuffers() { | 182 void Display::DidSwapBuffers() { |
162 client_->DidSwapBuffers(); | 183 client_->DidSwapBuffers(); |
163 } | 184 } |
164 | 185 |
165 void Display::DidSwapBuffersComplete() { | 186 void Display::DidSwapBuffersComplete() { |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
199 | 220 |
200 int Display::GetMaxFramesPending() { | 221 int Display::GetMaxFramesPending() { |
201 int max_frames_pending = | 222 int max_frames_pending = |
202 output_surface_ ? output_surface_->capabilities().max_frames_pending : 0; | 223 output_surface_ ? output_surface_->capabilities().max_frames_pending : 0; |
203 if (max_frames_pending <= 0) | 224 if (max_frames_pending <= 0) |
204 max_frames_pending = OutputSurface::DEFAULT_MAX_FRAMES_PENDING; | 225 max_frames_pending = OutputSurface::DEFAULT_MAX_FRAMES_PENDING; |
205 return max_frames_pending; | 226 return max_frames_pending; |
206 } | 227 } |
207 | 228 |
208 } // namespace cc | 229 } // namespace cc |
OLD | NEW |