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

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: 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
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/logging.h" 9 #include "base/logging.h"
10 #include "base/memory/scoped_ptr.h" 10 #include "base/memory/scoped_ptr.h"
(...skipping 23 matching lines...) Expand all
34 const VideoCaptureParams& params, 34 const VideoCaptureParams& params,
35 bool enable_auto_throttling) 35 bool enable_auto_throttling)
36 : client_(client.Pass()), 36 : client_(client.Pass()),
37 oracle_(base::TimeDelta::FromMicroseconds(static_cast<int64>( 37 oracle_(base::TimeDelta::FromMicroseconds(static_cast<int64>(
38 1000000.0 / params.requested_format.frame_rate + 38 1000000.0 / params.requested_format.frame_rate +
39 0.5 /* to round to nearest int */)), 39 0.5 /* to round to nearest int */)),
40 params.requested_format.frame_size, 40 params.requested_format.frame_size,
41 params.resolution_change_policy, 41 params.resolution_change_policy,
42 enable_auto_throttling), 42 enable_auto_throttling),
43 params_(params) { 43 params_(params) {
44 } 44 }
mcasas 2015/11/13 19:13:57 What about DCHECK_EQ(PIXEL_FORMAT_I420, params
miu 2015/11/14 03:43:48 Nothing operates on the pixels here, so I'd prefer
45 45
46 ThreadSafeCaptureOracle::~ThreadSafeCaptureOracle() { 46 ThreadSafeCaptureOracle::~ThreadSafeCaptureOracle() {
47 } 47 }
48 48
49 bool ThreadSafeCaptureOracle::ObserveEventAndDecideCapture( 49 bool ThreadSafeCaptureOracle::ObserveEventAndDecideCapture(
50 VideoCaptureOracle::Event event, 50 VideoCaptureOracle::Event event,
51 const gfx::Rect& damage_rect, 51 const gfx::Rect& damage_rect,
52 base::TimeTicks event_time, 52 base::TimeTicks event_time,
53 scoped_refptr<VideoFrame>* storage, 53 scoped_refptr<VideoFrame>* storage,
54 CaptureFrameCallback* callback) { 54 CaptureFrameCallback* callback) {
55 // Grab the current time before waiting to acquire the |lock_|. 55 // Grab the current time before waiting to acquire the |lock_|.
56 const base::TimeTicks capture_begin_time = base::TimeTicks::Now(); 56 const base::TimeTicks capture_begin_time = base::TimeTicks::Now();
57 57
58 base::AutoLock guard(lock_); 58 base::AutoLock guard(lock_);
59 59
60 if (!client_) 60 if (!client_)
61 return false; // Capture is stopped. 61 return false; // Capture is stopped.
62 62
63 const bool should_capture = 63 const bool should_capture =
64 oracle_.ObserveEventAndDecideCapture(event, damage_rect, event_time); 64 oracle_.ObserveEventAndDecideCapture(event, damage_rect, event_time);
65 const gfx::Size visible_size = oracle_.capture_size(); 65 const gfx::Size visible_size = oracle_.capture_size();
66 // Always round up the coded size to multiple of 16 pixels. 66 // Always round up the coded size to multiple of 16 pixels.
67 // See http://crbug.com/402151. 67 // See http://crbug.com/402151.
68 const gfx::Size coded_size((visible_size.width() + 15) & ~15, 68 const gfx::Size coded_size((visible_size.width() + 15) & ~15,
69 (visible_size.height() + 15) & ~15); 69 (visible_size.height() + 15) & ~15);
mcasas 2015/11/13 19:13:57 Suggest replacing these interesting bit operations
miu 2015/11/14 03:43:48 Done. Also, re-opened a new bug since the origina
70 70
71 scoped_ptr<media::VideoCaptureDevice::Client::Buffer> output_buffer( 71 scoped_ptr<media::VideoCaptureDevice::Client::Buffer> output_buffer(
72 client_->ReserveOutputBuffer(coded_size, 72 client_->ReserveOutputBuffer(coded_size,
73 (params_.requested_format.pixel_storage != 73 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)); 74 params_.requested_format.pixel_storage));
78 // Get the current buffer pool utilization and attenuate it: The utilization 75 // 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 76 // reported to the oracle is in terms of a maximum sustainable amount (not the
80 // absolute maximum). 77 // absolute maximum).
81 const double attenuated_utilization = 78 const double attenuated_utilization =
82 client_->GetBufferPoolUtilization() * 79 client_->GetBufferPoolUtilization() *
83 (100.0 / kTargetMaxPoolUtilizationPercent); 80 (100.0 / kTargetMaxPoolUtilizationPercent);
84 81
85 const char* event_name = 82 const char* event_name =
86 (event == VideoCaptureOracle::kTimerPoll 83 (event == VideoCaptureOracle::kTimerPoll
(...skipping 19 matching lines...) Expand all
106 } else if (!should_capture && !output_buffer.get()) { 103 } else if (!should_capture && !output_buffer.get()) {
107 // We decided not to capture, but we wouldn't have been able to if we wanted 104 // We decided not to capture, but we wouldn't have been able to if we wanted
108 // to because no output buffer was available. 105 // to because no output buffer was available.
109 TRACE_EVENT_INSTANT1("gpu.capture", "NearlyPipelineLimited", 106 TRACE_EVENT_INSTANT1("gpu.capture", "NearlyPipelineLimited",
110 TRACE_EVENT_SCOPE_THREAD, "trigger", event_name); 107 TRACE_EVENT_SCOPE_THREAD, "trigger", event_name);
111 return false; 108 return false;
112 } 109 }
113 const int frame_number = oracle_.RecordCapture(attenuated_utilization); 110 const int frame_number = oracle_.RecordCapture(attenuated_utilization);
114 TRACE_EVENT_ASYNC_BEGIN2("gpu.capture", "Capture", output_buffer.get(), 111 TRACE_EVENT_ASYNC_BEGIN2("gpu.capture", "Capture", output_buffer.get(),
115 "frame_number", frame_number, "trigger", event_name); 112 "frame_number", frame_number, "trigger", event_name);
116 // Texture frames wrap a texture mailbox, which we don't have at the moment. 113 *storage = VideoFrame::WrapExternalData(
117 // We do not construct those frames. 114 params_.requested_format.pixel_format, coded_size,
118 if (params_.requested_format.pixel_storage != media::PIXEL_STORAGE_TEXTURE) { 115 gfx::Rect(visible_size), visible_size,
119 *storage = VideoFrame::WrapExternalData( 116 static_cast<uint8*>(output_buffer->data()), output_buffer->mapped_size(),
120 media::PIXEL_FORMAT_I420, coded_size, gfx::Rect(visible_size), 117 base::TimeDelta());
121 visible_size, static_cast<uint8*>(output_buffer->data()), 118 DCHECK(*storage);
122 output_buffer->mapped_size(), base::TimeDelta());
123 DCHECK(*storage);
124 }
125 *callback = 119 *callback =
126 base::Bind(&ThreadSafeCaptureOracle::DidCaptureFrame, this, frame_number, 120 base::Bind(&ThreadSafeCaptureOracle::DidCaptureFrame, this, frame_number,
127 base::Passed(&output_buffer), capture_begin_time, 121 base::Passed(&output_buffer), capture_begin_time,
128 oracle_.estimated_frame_duration()); 122 oracle_.estimated_frame_duration());
129 return true; 123 return true;
130 } 124 }
131 125
132 gfx::Size ThreadSafeCaptureOracle::GetCaptureSize() const { 126 gfx::Size ThreadSafeCaptureOracle::GetCaptureSize() const {
133 base::AutoLock guard(lock_); 127 base::AutoLock guard(lock_);
134 return oracle_.capture_size(); 128 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. 190 // destructor. |metadata| is still valid for read-access at this point.
197 double utilization = -1.0; 191 double utilization = -1.0;
198 if (metadata->GetDouble(media::VideoFrameMetadata::RESOURCE_UTILIZATION, 192 if (metadata->GetDouble(media::VideoFrameMetadata::RESOURCE_UTILIZATION,
199 &utilization)) { 193 &utilization)) {
200 base::AutoLock guard(lock_); 194 base::AutoLock guard(lock_);
201 oracle_.RecordConsumerFeedback(frame_number, utilization); 195 oracle_.RecordConsumerFeedback(frame_number, utilization);
202 } 196 }
203 } 197 }
204 198
205 } // namespace media 199 } // namespace media
OLDNEW
« media/base/video_frame.cc ('K') | « 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