Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 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 "content/browser/media/capture/desktop_capture_device_aura.h" | 5 #include "content/browser/media/capture/desktop_capture_device_aura.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "base/metrics/histogram.h" | 8 #include "base/metrics/histogram.h" |
| 9 #include "base/timer/timer.h" | 9 #include "base/timer/timer.h" |
| 10 #include "cc/output/copy_output_request.h" | 10 #include "cc/output/copy_output_request.h" |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 101 // VideoCaptureFrameSource overrides. | 101 // VideoCaptureFrameSource overrides. |
| 102 virtual bool Start(const scoped_refptr<ThreadSafeCaptureOracle>& oracle_proxy, | 102 virtual bool Start(const scoped_refptr<ThreadSafeCaptureOracle>& oracle_proxy, |
| 103 const media::VideoCaptureParams& params) OVERRIDE; | 103 const media::VideoCaptureParams& params) OVERRIDE; |
| 104 virtual void Stop(const base::Closure& callback) OVERRIDE; | 104 virtual void Stop(const base::Closure& callback) OVERRIDE; |
| 105 | 105 |
| 106 // Implements aura::WindowObserver. | 106 // Implements aura::WindowObserver. |
| 107 virtual void OnWindowBoundsChanged(aura::Window* window, | 107 virtual void OnWindowBoundsChanged(aura::Window* window, |
| 108 const gfx::Rect& old_bounds, | 108 const gfx::Rect& old_bounds, |
| 109 const gfx::Rect& new_bounds) OVERRIDE; | 109 const gfx::Rect& new_bounds) OVERRIDE; |
| 110 virtual void OnWindowDestroyed(aura::Window* window) OVERRIDE; | 110 virtual void OnWindowDestroyed(aura::Window* window) OVERRIDE; |
| 111 virtual void OnWindowAddedToRootWindow(aura::Window* window) OVERRIDE; | |
| 112 virtual void OnWindowRemovingFromRootWindow(aura::Window* window, | |
| 113 aura::Window* new_root) OVERRIDE; | |
| 111 | 114 |
| 112 // Implements ui::CompositorObserver. | 115 // Implements ui::CompositorObserver. |
| 113 virtual void OnCompositingDidCommit(ui::Compositor* compositor) OVERRIDE {} | 116 virtual void OnCompositingDidCommit(ui::Compositor* compositor) OVERRIDE {} |
| 114 virtual void OnCompositingStarted(ui::Compositor* compositor, | 117 virtual void OnCompositingStarted(ui::Compositor* compositor, |
| 115 base::TimeTicks start_time) OVERRIDE {} | 118 base::TimeTicks start_time) OVERRIDE {} |
| 116 virtual void OnCompositingEnded(ui::Compositor* compositor) OVERRIDE; | 119 virtual void OnCompositingEnded(ui::Compositor* compositor) OVERRIDE; |
| 117 virtual void OnCompositingAborted(ui::Compositor* compositor) OVERRIDE {} | 120 virtual void OnCompositingAborted(ui::Compositor* compositor) OVERRIDE {} |
| 118 virtual void OnCompositingLockStateChanged( | 121 virtual void OnCompositingLockStateChanged( |
| 119 ui::Compositor* compositor) OVERRIDE {} | 122 ui::Compositor* compositor) OVERRIDE {} |
| 120 | 123 |
| (...skipping 24 matching lines...) Expand all Loading... | |
| 145 // |region_in_frame| defines the desktop bound in the captured frame. | 148 // |region_in_frame| defines the desktop bound in the captured frame. |
| 146 // Returns the current cursor position in captured frame. | 149 // Returns the current cursor position in captured frame. |
| 147 gfx::Point UpdateCursorState(const gfx::Rect& region_in_frame); | 150 gfx::Point UpdateCursorState(const gfx::Rect& region_in_frame); |
| 148 | 151 |
| 149 // Clears cursor state. | 152 // Clears cursor state. |
| 150 void ClearCursorState(); | 153 void ClearCursorState(); |
| 151 | 154 |
| 152 // The window associated with the desktop. | 155 // The window associated with the desktop. |
| 153 aura::Window* desktop_window_; | 156 aura::Window* desktop_window_; |
| 154 | 157 |
| 155 // The layer associated with the desktop. | |
| 156 ui::Layer* desktop_layer_; | |
| 157 | |
| 158 // The timer that kicks off period captures. | 158 // The timer that kicks off period captures. |
| 159 base::Timer timer_; | 159 base::Timer timer_; |
| 160 | 160 |
| 161 // The id of the window being captured. | 161 // The id of the window being captured. |
| 162 DesktopMediaID window_id_; | 162 DesktopMediaID window_id_; |
| 163 | 163 |
| 164 // Makes all the decisions about which frames to copy, and how. | 164 // Makes all the decisions about which frames to copy, and how. |
| 165 scoped_refptr<ThreadSafeCaptureOracle> oracle_proxy_; | 165 scoped_refptr<ThreadSafeCaptureOracle> oracle_proxy_; |
| 166 | 166 |
| 167 // The capture parameters for this capture. | 167 // The capture parameters for this capture. |
| 168 media::VideoCaptureParams capture_params_; | 168 media::VideoCaptureParams capture_params_; |
| 169 | 169 |
| 170 // YUV readback pipeline. | 170 // YUV readback pipeline. |
| 171 scoped_ptr<content::ReadbackYUVInterface> yuv_readback_pipeline_; | 171 scoped_ptr<content::ReadbackYUVInterface> yuv_readback_pipeline_; |
| 172 | 172 |
| 173 // Cursor state. | 173 // Cursor state. |
| 174 ui::Cursor last_cursor_; | 174 ui::Cursor last_cursor_; |
| 175 gfx::Point cursor_hot_point_; | 175 gfx::Point cursor_hot_point_; |
| 176 SkBitmap scaled_cursor_bitmap_; | 176 SkBitmap scaled_cursor_bitmap_; |
| 177 | 177 |
| 178 DISALLOW_COPY_AND_ASSIGN(DesktopVideoCaptureMachine); | 178 DISALLOW_COPY_AND_ASSIGN(DesktopVideoCaptureMachine); |
| 179 }; | 179 }; |
| 180 | 180 |
| 181 DesktopVideoCaptureMachine::DesktopVideoCaptureMachine( | 181 DesktopVideoCaptureMachine::DesktopVideoCaptureMachine( |
| 182 const DesktopMediaID& source) | 182 const DesktopMediaID& source) |
| 183 : desktop_window_(NULL), | 183 : desktop_window_(NULL), |
| 184 desktop_layer_(NULL), | |
| 185 timer_(true, true), | 184 timer_(true, true), |
| 186 window_id_(source) {} | 185 window_id_(source) {} |
| 187 | 186 |
| 188 DesktopVideoCaptureMachine::~DesktopVideoCaptureMachine() {} | 187 DesktopVideoCaptureMachine::~DesktopVideoCaptureMachine() {} |
| 189 | 188 |
| 190 bool DesktopVideoCaptureMachine::Start( | 189 bool DesktopVideoCaptureMachine::Start( |
| 191 const scoped_refptr<ThreadSafeCaptureOracle>& oracle_proxy, | 190 const scoped_refptr<ThreadSafeCaptureOracle>& oracle_proxy, |
| 192 const media::VideoCaptureParams& params) { | 191 const media::VideoCaptureParams& params) { |
| 193 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 192 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 194 | 193 |
| 195 desktop_window_ = content::DesktopMediaID::GetAuraWindowById(window_id_); | 194 desktop_window_ = content::DesktopMediaID::GetAuraWindowById(window_id_); |
| 196 if (!desktop_window_) | 195 if (!desktop_window_) |
| 197 return false; | 196 return false; |
| 198 | 197 |
| 199 // If the desktop layer is already destroyed then return failure. | 198 // If the associated layer is already destroyed then return failure. |
| 200 desktop_layer_ = desktop_window_->layer(); | 199 ui::Layer* layer = desktop_window_->layer(); |
| 201 if (!desktop_layer_) | 200 if (!layer) |
| 202 return false; | 201 return false; |
| 203 | 202 |
| 204 DCHECK(oracle_proxy.get()); | 203 DCHECK(oracle_proxy.get()); |
| 205 oracle_proxy_ = oracle_proxy; | 204 oracle_proxy_ = oracle_proxy; |
| 206 capture_params_ = params; | 205 capture_params_ = params; |
| 207 | 206 |
| 208 // Update capture size. | 207 // Update capture size. |
| 209 UpdateCaptureSize(); | 208 UpdateCaptureSize(); |
| 210 | 209 |
| 211 // Start observing window events. | 210 // Start observing window events. |
| 212 desktop_window_->AddObserver(this); | 211 desktop_window_->AddObserver(this); |
| 213 | 212 |
| 214 // Start observing compositor updates. | 213 // Start observing compositor updates. |
| 215 ui::Compositor* compositor = desktop_layer_->GetCompositor(); | 214 if (desktop_window_->GetHost()) |
| 216 if (!compositor) | 215 desktop_window_->GetHost()->compositor()->AddObserver(this); |
| 217 return false; | |
| 218 | |
| 219 compositor->AddObserver(this); | |
| 220 | 216 |
| 221 // Starts timer. | 217 // Starts timer. |
| 222 timer_.Start(FROM_HERE, oracle_proxy_->capture_period(), | 218 timer_.Start(FROM_HERE, oracle_proxy_->capture_period(), |
| 223 base::Bind(&DesktopVideoCaptureMachine::Capture, AsWeakPtr(), | 219 base::Bind(&DesktopVideoCaptureMachine::Capture, AsWeakPtr(), |
| 224 false)); | 220 false)); |
| 225 | 221 |
| 226 started_ = true; | 222 started_ = true; |
| 227 return true; | 223 return true; |
| 228 } | 224 } |
| 229 | 225 |
| 230 void DesktopVideoCaptureMachine::Stop(const base::Closure& callback) { | 226 void DesktopVideoCaptureMachine::Stop(const base::Closure& callback) { |
| 231 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 227 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 232 | 228 |
| 233 // Stop observing window events. | 229 // Stop observing compositor and window events. |
| 234 if (desktop_window_) { | 230 if (desktop_window_) { |
| 231 if (desktop_window_->GetHost()) | |
| 232 desktop_window_->GetHost()->compositor()->RemoveObserver(this); | |
| 235 desktop_window_->RemoveObserver(this); | 233 desktop_window_->RemoveObserver(this); |
| 236 desktop_window_ = NULL; | 234 desktop_window_ = NULL; |
| 237 } | 235 } |
| 238 | 236 |
| 239 // Stop observing compositor updates. | |
| 240 if (desktop_layer_) { | |
| 241 ui::Compositor* compositor = desktop_layer_->GetCompositor(); | |
| 242 if (compositor) | |
| 243 compositor->RemoveObserver(this); | |
| 244 desktop_layer_ = NULL; | |
| 245 } | |
| 246 | |
| 247 // Stop timer. | 237 // Stop timer. |
| 248 timer_.Stop(); | 238 timer_.Stop(); |
| 249 | 239 |
| 250 started_ = false; | 240 started_ = false; |
| 251 | 241 |
| 252 callback.Run(); | 242 callback.Run(); |
| 253 } | 243 } |
| 254 | 244 |
| 255 void DesktopVideoCaptureMachine::UpdateCaptureSize() { | 245 void DesktopVideoCaptureMachine::UpdateCaptureSize() { |
| 256 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 246 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 257 if (oracle_proxy_ && desktop_layer_) { | 247 if (oracle_proxy_ && desktop_window_) { |
| 248 ui::Layer* layer = desktop_window_->layer(); | |
| 258 oracle_proxy_->UpdateCaptureSize(ui::ConvertSizeToPixel( | 249 oracle_proxy_->UpdateCaptureSize(ui::ConvertSizeToPixel( |
| 259 desktop_layer_, desktop_layer_->bounds().size())); | 250 layer, layer->bounds().size())); |
| 260 } | 251 } |
| 261 ClearCursorState(); | 252 ClearCursorState(); |
| 262 } | 253 } |
| 263 | 254 |
| 264 void DesktopVideoCaptureMachine::Capture(bool dirty) { | 255 void DesktopVideoCaptureMachine::Capture(bool dirty) { |
| 265 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 256 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 266 | 257 |
| 267 // Do not capture if the desktop layer is already destroyed. | 258 // Do not capture if the desktop window is already destroyed. |
|
danakj
2014/06/19 22:22:05
Can this happen now that we watch for OnWindowRemo
piman
2014/06/19 23:11:48
I think currently it does because OnCompositingEnd
danakj
2014/06/19 23:22:37
Ah, then LGTM but it sounds like it'd be nice to f
| |
| 268 if (!desktop_layer_) | 259 if (!desktop_window_) |
| 269 return; | 260 return; |
| 270 | 261 |
| 271 scoped_refptr<media::VideoFrame> frame; | 262 scoped_refptr<media::VideoFrame> frame; |
| 272 ThreadSafeCaptureOracle::CaptureFrameCallback capture_frame_cb; | 263 ThreadSafeCaptureOracle::CaptureFrameCallback capture_frame_cb; |
| 273 | 264 |
| 274 const base::TimeTicks start_time = base::TimeTicks::Now(); | 265 const base::TimeTicks start_time = base::TimeTicks::Now(); |
| 275 const VideoCaptureOracle::Event event = | 266 const VideoCaptureOracle::Event event = |
| 276 dirty ? VideoCaptureOracle::kCompositorUpdate | 267 dirty ? VideoCaptureOracle::kCompositorUpdate |
| 277 : VideoCaptureOracle::kTimerPoll; | 268 : VideoCaptureOracle::kTimerPoll; |
| 278 if (oracle_proxy_->ObserveEventAndDecideCapture( | 269 if (oracle_proxy_->ObserveEventAndDecideCapture( |
| 279 event, start_time, &frame, &capture_frame_cb)) { | 270 event, start_time, &frame, &capture_frame_cb)) { |
| 280 scoped_ptr<cc::CopyOutputRequest> request = | 271 scoped_ptr<cc::CopyOutputRequest> request = |
| 281 cc::CopyOutputRequest::CreateRequest( | 272 cc::CopyOutputRequest::CreateRequest( |
| 282 base::Bind(&DesktopVideoCaptureMachine::DidCopyOutput, | 273 base::Bind(&DesktopVideoCaptureMachine::DidCopyOutput, |
| 283 AsWeakPtr(), frame, start_time, capture_frame_cb)); | 274 AsWeakPtr(), frame, start_time, capture_frame_cb)); |
| 284 gfx::Rect window_rect = | 275 gfx::Rect window_rect = |
| 285 ui::ConvertRectToPixel(desktop_window_->layer(), | 276 ui::ConvertRectToPixel(desktop_window_->layer(), |
| 286 gfx::Rect(desktop_window_->bounds().width(), | 277 gfx::Rect(desktop_window_->bounds().width(), |
| 287 desktop_window_->bounds().height())); | 278 desktop_window_->bounds().height())); |
| 288 request->set_area(window_rect); | 279 request->set_area(window_rect); |
| 289 desktop_layer_->RequestCopyOfOutput(request.Pass()); | 280 desktop_window_->layer()->RequestCopyOfOutput(request.Pass()); |
| 290 } | 281 } |
| 291 } | 282 } |
| 292 | 283 |
| 293 void CopyOutputFinishedForVideo( | 284 void CopyOutputFinishedForVideo( |
| 294 base::TimeTicks start_time, | 285 base::TimeTicks start_time, |
| 295 const ThreadSafeCaptureOracle::CaptureFrameCallback& capture_frame_cb, | 286 const ThreadSafeCaptureOracle::CaptureFrameCallback& capture_frame_cb, |
| 296 const scoped_refptr<media::VideoFrame>& target, | 287 const scoped_refptr<media::VideoFrame>& target, |
| 297 const SkBitmap& cursor_bitmap, | 288 const SkBitmap& cursor_bitmap, |
| 298 const gfx::Point& cursor_position, | 289 const gfx::Point& cursor_position, |
| 299 scoped_ptr<cc::SingleReleaseCallback> release_callback, | 290 scoped_ptr<cc::SingleReleaseCallback> release_callback, |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 343 } | 334 } |
| 344 } | 335 } |
| 345 } | 336 } |
| 346 | 337 |
| 347 bool DesktopVideoCaptureMachine::ProcessCopyOutputResponse( | 338 bool DesktopVideoCaptureMachine::ProcessCopyOutputResponse( |
| 348 scoped_refptr<media::VideoFrame> video_frame, | 339 scoped_refptr<media::VideoFrame> video_frame, |
| 349 base::TimeTicks start_time, | 340 base::TimeTicks start_time, |
| 350 const ThreadSafeCaptureOracle::CaptureFrameCallback& capture_frame_cb, | 341 const ThreadSafeCaptureOracle::CaptureFrameCallback& capture_frame_cb, |
| 351 scoped_ptr<cc::CopyOutputResult> result) { | 342 scoped_ptr<cc::CopyOutputResult> result) { |
| 352 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 343 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 353 if (result->IsEmpty() || result->size().IsEmpty() || !desktop_layer_) | 344 if (result->IsEmpty() || result->size().IsEmpty() || !desktop_window_) |
| 354 return false; | 345 return false; |
| 355 | 346 |
| 356 if (capture_params_.requested_format.pixel_format == | 347 if (capture_params_.requested_format.pixel_format == |
| 357 media::PIXEL_FORMAT_TEXTURE) { | 348 media::PIXEL_FORMAT_TEXTURE) { |
| 358 DCHECK(!video_frame); | 349 DCHECK(!video_frame); |
| 359 cc::TextureMailbox texture_mailbox; | 350 cc::TextureMailbox texture_mailbox; |
| 360 scoped_ptr<cc::SingleReleaseCallback> release_callback; | 351 scoped_ptr<cc::SingleReleaseCallback> release_callback; |
| 361 result->TakeTexture(&texture_mailbox, &release_callback); | 352 result->TakeTexture(&texture_mailbox, &release_callback); |
| 362 DCHECK(texture_mailbox.IsTexture()); | 353 DCHECK(texture_mailbox.IsTexture()); |
| 363 if (!texture_mailbox.IsTexture()) | 354 if (!texture_mailbox.IsTexture()) |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 430 capture_frame_cb, | 421 capture_frame_cb, |
| 431 video_frame, | 422 video_frame, |
| 432 scaled_cursor_bitmap_, | 423 scaled_cursor_bitmap_, |
| 433 cursor_position_in_frame, | 424 cursor_position_in_frame, |
| 434 base::Passed(&release_callback))); | 425 base::Passed(&release_callback))); |
| 435 return true; | 426 return true; |
| 436 } | 427 } |
| 437 | 428 |
| 438 gfx::Point DesktopVideoCaptureMachine::UpdateCursorState( | 429 gfx::Point DesktopVideoCaptureMachine::UpdateCursorState( |
| 439 const gfx::Rect& region_in_frame) { | 430 const gfx::Rect& region_in_frame) { |
| 440 const gfx::Rect desktop_bounds = desktop_layer_->bounds(); | 431 const gfx::Rect desktop_bounds = desktop_window_->layer()->bounds(); |
| 441 gfx::NativeCursor cursor = | 432 gfx::NativeCursor cursor = |
| 442 desktop_window_->GetHost()->last_cursor(); | 433 desktop_window_->GetHost()->last_cursor(); |
| 443 if (last_cursor_ != cursor) { | 434 if (last_cursor_ != cursor) { |
| 444 SkBitmap cursor_bitmap; | 435 SkBitmap cursor_bitmap; |
| 445 if (ui::GetCursorBitmap(cursor, &cursor_bitmap, &cursor_hot_point_)) { | 436 if (ui::GetCursorBitmap(cursor, &cursor_bitmap, &cursor_hot_point_)) { |
| 446 scaled_cursor_bitmap_ = skia::ImageOperations::Resize( | 437 scaled_cursor_bitmap_ = skia::ImageOperations::Resize( |
| 447 cursor_bitmap, | 438 cursor_bitmap, |
| 448 skia::ImageOperations::RESIZE_BEST, | 439 skia::ImageOperations::RESIZE_BEST, |
| 449 cursor_bitmap.width() * region_in_frame.width() / | 440 cursor_bitmap.width() * region_in_frame.width() / |
| 450 desktop_bounds.width(), | 441 desktop_bounds.width(), |
| 451 cursor_bitmap.height() * region_in_frame.height() / | 442 cursor_bitmap.height() * region_in_frame.height() / |
| 452 desktop_bounds.height()); | 443 desktop_bounds.height()); |
| 453 last_cursor_ = cursor; | 444 last_cursor_ = cursor; |
| 454 } else { | 445 } else { |
| 455 // Clear cursor state if ui::GetCursorBitmap failed so that we do not | 446 // Clear cursor state if ui::GetCursorBitmap failed so that we do not |
| 456 // render cursor on the captured frame. | 447 // render cursor on the captured frame. |
| 457 ClearCursorState(); | 448 ClearCursorState(); |
| 458 } | 449 } |
| 459 } | 450 } |
| 460 | 451 |
| 461 gfx::Point cursor_position = aura::Env::GetInstance()->last_mouse_location(); | 452 gfx::Point cursor_position = aura::Env::GetInstance()->last_mouse_location(); |
| 462 aura::client::GetScreenPositionClient(desktop_window_->GetRootWindow())-> | 453 aura::client::GetScreenPositionClient(desktop_window_->GetRootWindow())-> |
| 463 ConvertPointFromScreen(desktop_window_, &cursor_position); | 454 ConvertPointFromScreen(desktop_window_, &cursor_position); |
| 464 const gfx::Point hot_point_in_dip = ui::ConvertPointToDIP( | 455 const gfx::Point hot_point_in_dip = ui::ConvertPointToDIP( |
| 465 desktop_layer_, cursor_hot_point_); | 456 desktop_window_->layer(), cursor_hot_point_); |
| 466 cursor_position.Offset(-desktop_bounds.x() - hot_point_in_dip.x(), | 457 cursor_position.Offset(-desktop_bounds.x() - hot_point_in_dip.x(), |
| 467 -desktop_bounds.y() - hot_point_in_dip.y()); | 458 -desktop_bounds.y() - hot_point_in_dip.y()); |
| 468 return gfx::Point( | 459 return gfx::Point( |
| 469 region_in_frame.x() + cursor_position.x() * region_in_frame.width() / | 460 region_in_frame.x() + cursor_position.x() * region_in_frame.width() / |
| 470 desktop_bounds.width(), | 461 desktop_bounds.width(), |
| 471 region_in_frame.y() + cursor_position.y() * region_in_frame.height() / | 462 region_in_frame.y() + cursor_position.y() * region_in_frame.height() / |
| 472 desktop_bounds.height()); | 463 desktop_bounds.height()); |
| 473 } | 464 } |
| 474 | 465 |
| 475 void DesktopVideoCaptureMachine::ClearCursorState() { | 466 void DesktopVideoCaptureMachine::ClearCursorState() { |
| (...skipping 14 matching lines...) Expand all Loading... | |
| 490 } | 481 } |
| 491 | 482 |
| 492 void DesktopVideoCaptureMachine::OnWindowDestroyed(aura::Window* window) { | 483 void DesktopVideoCaptureMachine::OnWindowDestroyed(aura::Window* window) { |
| 493 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 484 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 494 | 485 |
| 495 Stop(base::Bind(&base::DoNothing)); | 486 Stop(base::Bind(&base::DoNothing)); |
| 496 | 487 |
| 497 oracle_proxy_->ReportError("OnWindowDestroyed()"); | 488 oracle_proxy_->ReportError("OnWindowDestroyed()"); |
| 498 } | 489 } |
| 499 | 490 |
| 491 void DesktopVideoCaptureMachine::OnWindowAddedToRootWindow( | |
| 492 aura::Window* window) { | |
| 493 if (window == desktop_window_) | |
|
piman
2014/06/19 23:11:49
nit: you can DCHECK, since that's the only window
hshi1
2014/06/19 23:53:07
Done.
| |
| 494 window->GetHost()->compositor()->AddObserver(this); | |
| 495 } | |
| 496 | |
| 497 void DesktopVideoCaptureMachine::OnWindowRemovingFromRootWindow( | |
| 498 aura::Window* window, | |
| 499 aura::Window* new_root) { | |
| 500 if (window == desktop_window_) | |
|
piman
2014/06/19 23:11:49
same here.
hshi1
2014/06/19 23:53:07
Done.
| |
| 501 window->GetHost()->compositor()->RemoveObserver(this); | |
| 502 } | |
| 503 | |
| 500 void DesktopVideoCaptureMachine::OnCompositingEnded( | 504 void DesktopVideoCaptureMachine::OnCompositingEnded( |
| 501 ui::Compositor* compositor) { | 505 ui::Compositor* compositor) { |
| 502 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, base::Bind( | 506 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, base::Bind( |
| 503 &DesktopVideoCaptureMachine::Capture, AsWeakPtr(), true)); | 507 &DesktopVideoCaptureMachine::Capture, AsWeakPtr(), true)); |
| 504 } | 508 } |
| 505 | 509 |
| 506 } // namespace | 510 } // namespace |
| 507 | 511 |
| 508 DesktopCaptureDeviceAura::DesktopCaptureDeviceAura( | 512 DesktopCaptureDeviceAura::DesktopCaptureDeviceAura( |
| 509 const DesktopMediaID& source) | 513 const DesktopMediaID& source) |
| (...skipping 18 matching lines...) Expand all Loading... | |
| 528 scoped_ptr<Client> client) { | 532 scoped_ptr<Client> client) { |
| 529 DVLOG(1) << "Allocating " << params.requested_format.frame_size.ToString(); | 533 DVLOG(1) << "Allocating " << params.requested_format.frame_size.ToString(); |
| 530 core_->AllocateAndStart(params, client.Pass()); | 534 core_->AllocateAndStart(params, client.Pass()); |
| 531 } | 535 } |
| 532 | 536 |
| 533 void DesktopCaptureDeviceAura::StopAndDeAllocate() { | 537 void DesktopCaptureDeviceAura::StopAndDeAllocate() { |
| 534 core_->StopAndDeAllocate(); | 538 core_->StopAndDeAllocate(); |
| 535 } | 539 } |
| 536 | 540 |
| 537 } // namespace content | 541 } // namespace content |
| OLD | NEW |