OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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/output/output_surface.h" | 5 #include "cc/output/output_surface.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <set> | 8 #include <set> |
9 #include <string> | 9 #include <string> |
10 #include <vector> | 10 #include <vector> |
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
170 DCHECK(!context_provider_.get()); | 170 DCHECK(!context_provider_.get()); |
171 } | 171 } |
172 | 172 |
173 void OutputSurface::SetUpContext3d() { | 173 void OutputSurface::SetUpContext3d() { |
174 DCHECK(context_provider_.get()); | 174 DCHECK(context_provider_.get()); |
175 DCHECK(client_); | 175 DCHECK(client_); |
176 | 176 |
177 context_provider_->SetLostContextCallback( | 177 context_provider_->SetLostContextCallback( |
178 base::Bind(&OutputSurface::DidLoseOutputSurface, | 178 base::Bind(&OutputSurface::DidLoseOutputSurface, |
179 base::Unretained(this))); | 179 base::Unretained(this))); |
180 context_provider_->ContextSupport()->SetSwapBuffersCompleteCallback( | |
181 base::Bind(&OutputSurface::OnSwapBuffersComplete, | |
182 base::Unretained(this))); | |
183 context_provider_->SetMemoryPolicyChangedCallback( | 180 context_provider_->SetMemoryPolicyChangedCallback( |
184 base::Bind(&OutputSurface::SetMemoryPolicy, | 181 base::Bind(&OutputSurface::SetMemoryPolicy, |
185 base::Unretained(this))); | 182 base::Unretained(this))); |
186 } | 183 } |
187 | 184 |
188 void OutputSurface::ReleaseContextProvider() { | 185 void OutputSurface::ReleaseContextProvider() { |
189 DCHECK(client_); | 186 DCHECK(client_); |
190 DCHECK(context_provider_.get()); | 187 DCHECK(context_provider_.get()); |
191 ResetContext3d(); | 188 ResetContext3d(); |
192 } | 189 } |
193 | 190 |
194 void OutputSurface::ResetContext3d() { | 191 void OutputSurface::ResetContext3d() { |
195 if (context_provider_.get()) { | 192 if (context_provider_.get()) { |
196 while (!pending_gpu_latency_query_ids_.empty()) { | 193 while (!pending_gpu_latency_query_ids_.empty()) { |
197 unsigned query_id = pending_gpu_latency_query_ids_.front(); | 194 unsigned query_id = pending_gpu_latency_query_ids_.front(); |
198 pending_gpu_latency_query_ids_.pop_front(); | 195 pending_gpu_latency_query_ids_.pop_front(); |
199 context_provider_->ContextGL()->DeleteQueriesEXT(1, &query_id); | 196 context_provider_->ContextGL()->DeleteQueriesEXT(1, &query_id); |
200 } | 197 } |
201 while (!available_gpu_latency_query_ids_.empty()) { | 198 while (!available_gpu_latency_query_ids_.empty()) { |
202 unsigned query_id = available_gpu_latency_query_ids_.front(); | 199 unsigned query_id = available_gpu_latency_query_ids_.front(); |
203 available_gpu_latency_query_ids_.pop_front(); | 200 available_gpu_latency_query_ids_.pop_front(); |
204 context_provider_->ContextGL()->DeleteQueriesEXT(1, &query_id); | 201 context_provider_->ContextGL()->DeleteQueriesEXT(1, &query_id); |
205 } | 202 } |
206 context_provider_->SetLostContextCallback( | 203 context_provider_->SetLostContextCallback( |
207 ContextProvider::LostContextCallback()); | 204 ContextProvider::LostContextCallback()); |
208 context_provider_->SetMemoryPolicyChangedCallback( | 205 context_provider_->SetMemoryPolicyChangedCallback( |
209 ContextProvider::MemoryPolicyChangedCallback()); | 206 ContextProvider::MemoryPolicyChangedCallback()); |
210 if (gpu::ContextSupport* support = context_provider_->ContextSupport()) | |
211 support->SetSwapBuffersCompleteCallback(base::Closure()); | |
212 } | 207 } |
213 context_provider_ = NULL; | 208 context_provider_ = NULL; |
214 } | 209 } |
215 | 210 |
216 void OutputSurface::EnsureBackbuffer() { | 211 void OutputSurface::EnsureBackbuffer() { |
217 if (software_device_) | 212 if (software_device_) |
218 software_device_->EnsureBackbuffer(); | 213 software_device_->EnsureBackbuffer(); |
219 } | 214 } |
220 | 215 |
221 void OutputSurface::DiscardBackbuffer() { | 216 void OutputSurface::DiscardBackbuffer() { |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
259 DCHECK(frame->gl_frame_data); | 254 DCHECK(frame->gl_frame_data); |
260 | 255 |
261 UpdateAndMeasureGpuLatency(); | 256 UpdateAndMeasureGpuLatency(); |
262 if (frame->gl_frame_data->sub_buffer_rect == | 257 if (frame->gl_frame_data->sub_buffer_rect == |
263 gfx::Rect(frame->gl_frame_data->size)) { | 258 gfx::Rect(frame->gl_frame_data->size)) { |
264 context_provider_->ContextSupport()->Swap(); | 259 context_provider_->ContextSupport()->Swap(); |
265 } else { | 260 } else { |
266 context_provider_->ContextSupport()->PartialSwapBuffers( | 261 context_provider_->ContextSupport()->PartialSwapBuffers( |
267 frame->gl_frame_data->sub_buffer_rect); | 262 frame->gl_frame_data->sub_buffer_rect); |
268 } | 263 } |
| 264 uint32_t sync_point = |
| 265 context_provider_->ContextGL()->InsertSyncPointCHROMIUM(); |
| 266 context_provider_->ContextSupport()->SignalSyncPoint( |
| 267 sync_point, |
| 268 base::Bind(&OutputSurface::OnSwapBuffersComplete, |
| 269 weak_ptr_factory_.GetWeakPtr())); |
269 | 270 |
270 client_->DidSwapBuffers(); | 271 client_->DidSwapBuffers(); |
271 } | 272 } |
272 | 273 |
273 base::TimeDelta OutputSurface::GpuLatencyEstimate() { | 274 base::TimeDelta OutputSurface::GpuLatencyEstimate() { |
274 if (context_provider_.get() && !capabilities_.adjust_deadline_for_parent) | 275 if (context_provider_.get() && !capabilities_.adjust_deadline_for_parent) |
275 return gpu_latency_history_.Percentile(kGpuLatencyEstimationPercentile); | 276 return gpu_latency_history_.Percentile(kGpuLatencyEstimationPercentile); |
276 else | 277 else |
277 return base::TimeDelta(); | 278 return base::TimeDelta(); |
278 } | 279 } |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
360 TRACE_EVENT1("cc", "OutputSurface::SetMemoryPolicy", | 361 TRACE_EVENT1("cc", "OutputSurface::SetMemoryPolicy", |
361 "bytes_limit_when_visible", policy.bytes_limit_when_visible); | 362 "bytes_limit_when_visible", policy.bytes_limit_when_visible); |
362 // Just ignore the memory manager when it says to set the limit to zero | 363 // Just ignore the memory manager when it says to set the limit to zero |
363 // bytes. This will happen when the memory manager thinks that the renderer | 364 // bytes. This will happen when the memory manager thinks that the renderer |
364 // is not visible (which the renderer knows better). | 365 // is not visible (which the renderer knows better). |
365 if (policy.bytes_limit_when_visible) | 366 if (policy.bytes_limit_when_visible) |
366 client_->SetMemoryPolicy(policy); | 367 client_->SetMemoryPolicy(policy); |
367 } | 368 } |
368 | 369 |
369 } // namespace cc | 370 } // namespace cc |
OLD | NEW |