Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(164)

Side by Side Diff: media/capture/content/thread_safe_capture_oracle.cc

Issue 1439533004: Remove dead code paths around PIXEL_STORAGE_TEXTURE in capture pipeline. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: mcasas's second round comments REBASE Created 5 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « media/capture/content/screen_capture_device_core.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "base/basictypes.h" 7 #include "base/basictypes.h"
8 #include "base/bind.h" 8 #include "base/bind.h"
9 #include "base/bits.h"
9 #include "base/logging.h" 10 #include "base/logging.h"
10 #include "base/memory/scoped_ptr.h" 11 #include "base/memory/scoped_ptr.h"
11 #include "base/synchronization/lock.h" 12 #include "base/synchronization/lock.h"
12 #include "base/time/time.h" 13 #include "base/time/time.h"
13 #include "base/trace_event/trace_event.h" 14 #include "base/trace_event/trace_event.h"
14 #include "media/base/video_capture_types.h" 15 #include "media/base/video_capture_types.h"
15 #include "media/base/video_frame.h" 16 #include "media/base/video_frame.h"
16 #include "media/base/video_frame_metadata.h" 17 #include "media/base/video_frame_metadata.h"
17 #include "media/base/video_util.h" 18 #include "media/base/video_util.h"
18 #include "ui/gfx/geometry/rect.h" 19 #include "ui/gfx/geometry/rect.h"
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
56 const base::TimeTicks capture_begin_time = base::TimeTicks::Now(); 57 const base::TimeTicks capture_begin_time = base::TimeTicks::Now();
57 58
58 base::AutoLock guard(lock_); 59 base::AutoLock guard(lock_);
59 60
60 if (!client_) 61 if (!client_)
61 return false; // Capture is stopped. 62 return false; // Capture is stopped.
62 63
63 const bool should_capture = 64 const bool should_capture =
64 oracle_.ObserveEventAndDecideCapture(event, damage_rect, event_time); 65 oracle_.ObserveEventAndDecideCapture(event, damage_rect, event_time);
65 const gfx::Size visible_size = oracle_.capture_size(); 66 const gfx::Size visible_size = oracle_.capture_size();
66 // Always round up the coded size to multiple of 16 pixels. 67 // TODO(miu): Clients should request exact padding, instead of this
67 // See http://crbug.com/402151. 68 // memory-wasting hack to make frames that are compatible with all HW
68 const gfx::Size coded_size((visible_size.width() + 15) & ~15, 69 // encoders. http://crbug.com/555911
69 (visible_size.height() + 15) & ~15); 70 const gfx::Size coded_size(base::bits::Align(visible_size.width(), 16),
71 base::bits::Align(visible_size.height(), 16));
70 72
71 scoped_ptr<media::VideoCaptureDevice::Client::Buffer> output_buffer( 73 scoped_ptr<media::VideoCaptureDevice::Client::Buffer> output_buffer(
72 client_->ReserveOutputBuffer(coded_size, 74 client_->ReserveOutputBuffer(coded_size,
73 (params_.requested_format.pixel_storage != 75 params_.requested_format.pixel_format,
74 media::PIXEL_STORAGE_TEXTURE)
75 ? media::PIXEL_FORMAT_I420
76 : media::PIXEL_FORMAT_ARGB,
77 params_.requested_format.pixel_storage)); 76 params_.requested_format.pixel_storage));
78 // Get the current buffer pool utilization and attenuate it: The utilization 77 // Get the current buffer pool utilization and attenuate it: The utilization
79 // reported to the oracle is in terms of a maximum sustainable amount (not the 78 // reported to the oracle is in terms of a maximum sustainable amount (not the
80 // absolute maximum). 79 // absolute maximum).
81 const double attenuated_utilization = 80 const double attenuated_utilization =
82 client_->GetBufferPoolUtilization() * 81 client_->GetBufferPoolUtilization() *
83 (100.0 / kTargetMaxPoolUtilizationPercent); 82 (100.0 / kTargetMaxPoolUtilizationPercent);
84 83
85 const char* event_name = 84 const char* event_name =
86 (event == VideoCaptureOracle::kTimerPoll 85 (event == VideoCaptureOracle::kTimerPoll
(...skipping 16 matching lines...) Expand all
103 TRACE_EVENT_SCOPE_THREAD, "trigger", event_name); 102 TRACE_EVENT_SCOPE_THREAD, "trigger", event_name);
104 } 103 }
105 return false; 104 return false;
106 } else if (!should_capture && !output_buffer.get()) { 105 } else if (!should_capture && !output_buffer.get()) {
107 // We decided not to capture, but we wouldn't have been able to if we wanted 106 // We decided not to capture, but we wouldn't have been able to if we wanted
108 // to because no output buffer was available. 107 // to because no output buffer was available.
109 TRACE_EVENT_INSTANT1("gpu.capture", "NearlyPipelineLimited", 108 TRACE_EVENT_INSTANT1("gpu.capture", "NearlyPipelineLimited",
110 TRACE_EVENT_SCOPE_THREAD, "trigger", event_name); 109 TRACE_EVENT_SCOPE_THREAD, "trigger", event_name);
111 return false; 110 return false;
112 } 111 }
112
113 const int frame_number = oracle_.RecordCapture(attenuated_utilization); 113 const int frame_number = oracle_.RecordCapture(attenuated_utilization);
114 TRACE_EVENT_ASYNC_BEGIN2("gpu.capture", "Capture", output_buffer.get(), 114 TRACE_EVENT_ASYNC_BEGIN2("gpu.capture", "Capture", output_buffer.get(),
115 "frame_number", frame_number, "trigger", event_name); 115 "frame_number", frame_number, "trigger", event_name);
116 // Texture frames wrap a texture mailbox, which we don't have at the moment. 116
117 // We do not construct those frames. 117 DCHECK_EQ(media::PIXEL_STORAGE_CPU, params_.requested_format.pixel_storage);
118 if (params_.requested_format.pixel_storage != media::PIXEL_STORAGE_TEXTURE) { 118 *storage = VideoFrame::WrapExternalSharedMemory(
119 *storage = VideoFrame::WrapExternalData( 119 params_.requested_format.pixel_format, coded_size,
120 media::PIXEL_FORMAT_I420, coded_size, gfx::Rect(visible_size), 120 gfx::Rect(visible_size), visible_size,
121 visible_size, static_cast<uint8*>(output_buffer->data()), 121 static_cast<uint8*>(output_buffer->data()), output_buffer->mapped_size(),
122 output_buffer->mapped_size(), base::TimeDelta()); 122 base::SharedMemory::NULLHandle(), 0u, base::TimeDelta());
123 DCHECK(*storage); 123 DCHECK(*storage);
124 }
125 *callback = 124 *callback =
126 base::Bind(&ThreadSafeCaptureOracle::DidCaptureFrame, this, frame_number, 125 base::Bind(&ThreadSafeCaptureOracle::DidCaptureFrame, this, frame_number,
127 base::Passed(&output_buffer), capture_begin_time, 126 base::Passed(&output_buffer), capture_begin_time,
128 oracle_.estimated_frame_duration()); 127 oracle_.estimated_frame_duration());
129 return true; 128 return true;
130 } 129 }
131 130
132 gfx::Size ThreadSafeCaptureOracle::GetCaptureSize() const { 131 gfx::Size ThreadSafeCaptureOracle::GetCaptureSize() const {
133 base::AutoLock guard(lock_); 132 base::AutoLock guard(lock_);
134 return oracle_.capture_size(); 133 return oracle_.capture_size();
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
196 // destructor. |metadata| is still valid for read-access at this point. 195 // destructor. |metadata| is still valid for read-access at this point.
197 double utilization = -1.0; 196 double utilization = -1.0;
198 if (metadata->GetDouble(media::VideoFrameMetadata::RESOURCE_UTILIZATION, 197 if (metadata->GetDouble(media::VideoFrameMetadata::RESOURCE_UTILIZATION,
199 &utilization)) { 198 &utilization)) {
200 base::AutoLock guard(lock_); 199 base::AutoLock guard(lock_);
201 oracle_.RecordConsumerFeedback(frame_number, utilization); 200 oracle_.RecordConsumerFeedback(frame_number, utilization);
202 } 201 }
203 } 202 }
204 203
205 } // namespace media 204 } // namespace media
OLDNEW
« no previous file with comments | « media/capture/content/screen_capture_device_core.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698