| 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 "media/capture/content/thread_safe_capture_oracle.h" | 5 #include "media/capture/content/thread_safe_capture_oracle.h" |
| 6 | 6 |
| 7 #include <stdint.h> | 7 #include <stdint.h> |
| 8 | 8 |
| 9 #include <memory> | 9 #include <memory> |
| 10 #include <utility> | 10 #include <utility> |
| (...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 124 } // End of critical section. | 124 } // End of critical section. |
| 125 | 125 |
| 126 if (attenuated_utilization >= 1.0) { | 126 if (attenuated_utilization >= 1.0) { |
| 127 TRACE_EVENT_INSTANT2( | 127 TRACE_EVENT_INSTANT2( |
| 128 "gpu.capture", "NearlyPipelineLimited", TRACE_EVENT_SCOPE_THREAD, | 128 "gpu.capture", "NearlyPipelineLimited", TRACE_EVENT_SCOPE_THREAD, |
| 129 "trigger", VideoCaptureOracle::EventAsString(event), | 129 "trigger", VideoCaptureOracle::EventAsString(event), |
| 130 "atten_util_percent", | 130 "atten_util_percent", |
| 131 base::saturated_cast<int>(attenuated_utilization * 100.0 + 0.5)); | 131 base::saturated_cast<int>(attenuated_utilization * 100.0 + 0.5)); |
| 132 } | 132 } |
| 133 | 133 |
| 134 TRACE_EVENT_ASYNC_BEGIN2("gpu.capture", "Capture", output_buffer.id(), | 134 TRACE_EVENT_ASYNC_BEGIN2("gpu.capture", "Capture", output_buffer.id, |
| 135 "frame_number", frame_number, "trigger", | 135 "frame_number", frame_number, "trigger", |
| 136 VideoCaptureOracle::EventAsString(event)); | 136 VideoCaptureOracle::EventAsString(event)); |
| 137 | 137 |
| 138 auto output_buffer_access = | 138 auto output_buffer_access = |
| 139 output_buffer.handle_provider()->GetHandleForInProcessAccess(); | 139 output_buffer.handle_provider->GetHandleForInProcessAccess(); |
| 140 DCHECK_EQ(media::PIXEL_STORAGE_CPU, params_.requested_format.pixel_storage); | 140 DCHECK_EQ(media::PIXEL_STORAGE_CPU, params_.requested_format.pixel_storage); |
| 141 *storage = VideoFrame::WrapExternalSharedMemory( | 141 *storage = VideoFrame::WrapExternalSharedMemory( |
| 142 params_.requested_format.pixel_format, coded_size, | 142 params_.requested_format.pixel_format, coded_size, |
| 143 gfx::Rect(visible_size), visible_size, output_buffer_access->data(), | 143 gfx::Rect(visible_size), visible_size, output_buffer_access->data(), |
| 144 output_buffer_access->mapped_size(), base::SharedMemory::NULLHandle(), 0u, | 144 output_buffer_access->mapped_size(), base::SharedMemory::NULLHandle(), 0u, |
| 145 base::TimeDelta()); | 145 base::TimeDelta()); |
| 146 // If creating the VideoFrame wrapper failed, call DidCaptureFrame() with | 146 // If creating the VideoFrame wrapper failed, call DidCaptureFrame() with |
| 147 // !success to execute the required post-capture steps (tracing, notification | 147 // !success to execute the required post-capture steps (tracing, notification |
| 148 // of failure to VideoCaptureOracle, etc.). | 148 // of failure to VideoCaptureOracle, etc.). |
| 149 if (!(*storage)) { | 149 if (!(*storage)) { |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 199 } | 199 } |
| 200 | 200 |
| 201 void ThreadSafeCaptureOracle::DidCaptureFrame( | 201 void ThreadSafeCaptureOracle::DidCaptureFrame( |
| 202 int frame_number, | 202 int frame_number, |
| 203 VideoCaptureDevice::Client::Buffer buffer, | 203 VideoCaptureDevice::Client::Buffer buffer, |
| 204 base::TimeTicks capture_begin_time, | 204 base::TimeTicks capture_begin_time, |
| 205 base::TimeDelta estimated_frame_duration, | 205 base::TimeDelta estimated_frame_duration, |
| 206 scoped_refptr<VideoFrame> frame, | 206 scoped_refptr<VideoFrame> frame, |
| 207 base::TimeTicks reference_time, | 207 base::TimeTicks reference_time, |
| 208 bool success) { | 208 bool success) { |
| 209 TRACE_EVENT_ASYNC_END2("gpu.capture", "Capture", buffer.id(), "success", | 209 TRACE_EVENT_ASYNC_END2("gpu.capture", "Capture", buffer.id, "success", |
| 210 success, "timestamp", | 210 success, "timestamp", |
| 211 reference_time.ToInternalValue()); | 211 reference_time.ToInternalValue()); |
| 212 | 212 |
| 213 base::AutoLock guard(lock_); | 213 base::AutoLock guard(lock_); |
| 214 | 214 |
| 215 if (!oracle_.CompleteCapture(frame_number, success, &reference_time)) | 215 if (!oracle_.CompleteCapture(frame_number, success, &reference_time)) |
| 216 return; | 216 return; |
| 217 | 217 |
| 218 TRACE_EVENT_INSTANT0("gpu.capture", "CaptureSucceeded", | 218 TRACE_EVENT_INSTANT0("gpu.capture", "CaptureSucceeded", |
| 219 TRACE_EVENT_SCOPE_THREAD); | 219 TRACE_EVENT_SCOPE_THREAD); |
| (...skipping 22 matching lines...) Expand all Loading... |
| 242 } | 242 } |
| 243 | 243 |
| 244 void ThreadSafeCaptureOracle::OnConsumerReportingUtilization( | 244 void ThreadSafeCaptureOracle::OnConsumerReportingUtilization( |
| 245 int frame_number, | 245 int frame_number, |
| 246 double utilization) { | 246 double utilization) { |
| 247 base::AutoLock guard(lock_); | 247 base::AutoLock guard(lock_); |
| 248 oracle_.RecordConsumerFeedback(frame_number, utilization); | 248 oracle_.RecordConsumerFeedback(frame_number, utilization); |
| 249 } | 249 } |
| 250 | 250 |
| 251 } // namespace media | 251 } // namespace media |
| OLD | NEW |