| 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/debug/trace_event.h" | 7 #include "base/debug/trace_event.h" |
| 8 #include "base/message_loop/message_loop.h" | 8 #include "base/message_loop/message_loop.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 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 111 | 111 |
| 112 // TODO(skyostil): We should hold a BlockingTaskRunner::CapturePostTasks | 112 // TODO(skyostil): We should hold a BlockingTaskRunner::CapturePostTasks |
| 113 // while Aggregate is called to immediately run release callbacks afterward. | 113 // while Aggregate is called to immediately run release callbacks afterward. |
| 114 scoped_ptr<CompositorFrame> frame = | 114 scoped_ptr<CompositorFrame> frame = |
| 115 aggregator_->Aggregate(current_surface_id_); | 115 aggregator_->Aggregate(current_surface_id_); |
| 116 if (!frame) | 116 if (!frame) |
| 117 return false; | 117 return false; |
| 118 | 118 |
| 119 TRACE_EVENT0("cc", "Display::Draw"); | 119 TRACE_EVENT0("cc", "Display::Draw"); |
| 120 benchmark_instrumentation::IssueDisplayRenderingStatsEvent(); | 120 benchmark_instrumentation::IssueDisplayRenderingStatsEvent(); |
| 121 |
| 122 // Run callbacks early to allow pipelining. |
| 123 for (const auto& id_entry : aggregator_->previous_contained_surfaces()) { |
| 124 Surface* surface = manager_->GetSurfaceForId(id_entry.first); |
| 125 if (surface) |
| 126 surface->RunDrawCallbacks(); |
| 127 } |
| 121 DelegatedFrameData* frame_data = frame->delegated_frame_data.get(); | 128 DelegatedFrameData* frame_data = frame->delegated_frame_data.get(); |
| 122 | 129 |
| 123 gfx::Size surface_size = | 130 gfx::Size surface_size = |
| 124 frame_data->render_pass_list.back()->output_rect.size(); | 131 frame_data->render_pass_list.back()->output_rect.size(); |
| 125 | 132 |
| 126 gfx::Rect device_viewport_rect = gfx::Rect(current_surface_size_); | 133 gfx::Rect device_viewport_rect = gfx::Rect(current_surface_size_); |
| 127 gfx::Rect device_clip_rect = device_viewport_rect; | 134 gfx::Rect device_clip_rect = device_viewport_rect; |
| 128 bool disable_picture_quad_image_filtering = false; | 135 bool disable_picture_quad_image_filtering = false; |
| 129 | 136 |
| 130 renderer_->DecideRenderPassAllocationsForFrame(frame_data->render_pass_list); | 137 renderer_->DecideRenderPassAllocationsForFrame(frame_data->render_pass_list); |
| 131 renderer_->DrawFrame(&frame_data->render_pass_list, | 138 renderer_->DrawFrame(&frame_data->render_pass_list, |
| 132 device_scale_factor_, | 139 device_scale_factor_, |
| 133 device_viewport_rect, | 140 device_viewport_rect, |
| 134 device_clip_rect, | 141 device_clip_rect, |
| 135 disable_picture_quad_image_filtering); | 142 disable_picture_quad_image_filtering); |
| 136 | 143 |
| 137 bool disable_swap = surface_size != current_surface_size_; | 144 if (surface_size != current_surface_size_) { |
| 138 if (disable_swap) { | |
| 139 DidSwapBuffers(); | 145 DidSwapBuffers(); |
| 146 DidSwapBuffersComplete(); |
| 140 } else { | 147 } else { |
| 141 renderer_->SwapBuffers(frame->metadata); | 148 renderer_->SwapBuffers(frame->metadata); |
| 142 } | 149 } |
| 143 | 150 |
| 144 for (SurfaceAggregator::SurfaceIndexMap::iterator it = | |
| 145 aggregator_->previous_contained_surfaces().begin(); | |
| 146 it != aggregator_->previous_contained_surfaces().end(); | |
| 147 ++it) { | |
| 148 Surface* surface = manager_->GetSurfaceForId(it->first); | |
| 149 if (surface) | |
| 150 surface->RunDrawCallbacks(); | |
| 151 } | |
| 152 if (disable_swap) | |
| 153 DidSwapBuffersComplete(); | |
| 154 return true; | 151 return true; |
| 155 } | 152 } |
| 156 | 153 |
| 157 void Display::DidSwapBuffers() { | 154 void Display::DidSwapBuffers() { |
| 158 client_->DidSwapBuffers(); | 155 client_->DidSwapBuffers(); |
| 159 } | 156 } |
| 160 | 157 |
| 161 void Display::DidSwapBuffersComplete() { | 158 void Display::DidSwapBuffersComplete() { |
| 162 client_->DidSwapBuffersComplete(); | 159 client_->DidSwapBuffersComplete(); |
| 163 } | 160 } |
| 164 | 161 |
| 165 void Display::CommitVSyncParameters(base::TimeTicks timebase, | 162 void Display::CommitVSyncParameters(base::TimeTicks timebase, |
| 166 base::TimeDelta interval) { | 163 base::TimeDelta interval) { |
| 167 client_->CommitVSyncParameters(timebase, interval); | 164 client_->CommitVSyncParameters(timebase, interval); |
| 168 } | 165 } |
| 169 | 166 |
| 170 void Display::SetMemoryPolicy(const ManagedMemoryPolicy& policy) { | 167 void Display::SetMemoryPolicy(const ManagedMemoryPolicy& policy) { |
| 171 client_->SetMemoryPolicy(policy); | 168 client_->SetMemoryPolicy(policy); |
| 172 } | 169 } |
| 173 | 170 |
| 174 void Display::OnSurfaceDamaged(SurfaceId surface) { | 171 void Display::OnSurfaceDamaged(SurfaceId surface) { |
| 175 if (aggregator_ && aggregator_->previous_contained_surfaces().count(surface)) | 172 if (aggregator_ && |
| 173 aggregator_->previous_contained_surfaces().count(surface)) { |
| 174 aggregator_->ReleaseResources(surface); |
| 176 client_->DisplayDamaged(); | 175 client_->DisplayDamaged(); |
| 176 } |
| 177 } | 177 } |
| 178 | 178 |
| 179 SurfaceId Display::CurrentSurfaceId() { | 179 SurfaceId Display::CurrentSurfaceId() { |
| 180 return current_surface_id_; | 180 return current_surface_id_; |
| 181 } | 181 } |
| 182 | 182 |
| 183 int Display::GetMaxFramesPending() { | 183 int Display::GetMaxFramesPending() { |
| 184 if (!output_surface_) | 184 if (!output_surface_) |
| 185 return OutputSurface::DEFAULT_MAX_FRAMES_PENDING; | 185 return OutputSurface::DEFAULT_MAX_FRAMES_PENDING; |
| 186 return output_surface_->capabilities().max_frames_pending; | 186 return output_surface_->capabilities().max_frames_pending; |
| 187 } | 187 } |
| 188 | 188 |
| 189 } // namespace cc | 189 } // namespace cc |
| OLD | NEW |