| 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 29 matching lines...) Expand all Loading... |
| 40 | 40 |
| 41 int alpha_blend(int alpha, int src, int dst) { | 41 int alpha_blend(int alpha, int src, int dst) { |
| 42 return (src * alpha + dst * (255 - alpha)) / 255; | 42 return (src * alpha + dst * (255 - alpha)) / 255; |
| 43 } | 43 } |
| 44 | 44 |
| 45 // Helper function to composite a cursor bitmap on a YUV420 video frame. | 45 // Helper function to composite a cursor bitmap on a YUV420 video frame. |
| 46 void RenderCursorOnVideoFrame( | 46 void RenderCursorOnVideoFrame( |
| 47 const scoped_refptr<media::VideoFrame>& target, | 47 const scoped_refptr<media::VideoFrame>& target, |
| 48 const SkBitmap& cursor_bitmap, | 48 const SkBitmap& cursor_bitmap, |
| 49 const gfx::Point& cursor_position) { | 49 const gfx::Point& cursor_position) { |
| 50 DCHECK(target); | 50 DCHECK(target.get()); |
| 51 DCHECK(!cursor_bitmap.isNull()); | 51 DCHECK(!cursor_bitmap.isNull()); |
| 52 | 52 |
| 53 gfx::Rect rect = gfx::IntersectRects( | 53 gfx::Rect rect = gfx::IntersectRects( |
| 54 gfx::Rect(cursor_bitmap.width(), cursor_bitmap.height()) + | 54 gfx::Rect(cursor_bitmap.width(), cursor_bitmap.height()) + |
| 55 gfx::Vector2d(cursor_position.x(), cursor_position.y()), | 55 gfx::Vector2d(cursor_position.x(), cursor_position.y()), |
| 56 target->visible_rect()); | 56 target->visible_rect()); |
| 57 | 57 |
| 58 cursor_bitmap.lockPixels(); | 58 cursor_bitmap.lockPixels(); |
| 59 for (int y = rect.y(); y < rect.bottom(); ++y) { | 59 for (int y = rect.y(); y < rect.bottom(); ++y) { |
| 60 int cursor_y = y - cursor_position.y(); | 60 int cursor_y = y - cursor_position.y(); |
| (...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 246 // Stop timer. | 246 // Stop timer. |
| 247 timer_.Stop(); | 247 timer_.Stop(); |
| 248 | 248 |
| 249 started_ = false; | 249 started_ = false; |
| 250 | 250 |
| 251 callback.Run(); | 251 callback.Run(); |
| 252 } | 252 } |
| 253 | 253 |
| 254 void DesktopVideoCaptureMachine::UpdateCaptureSize() { | 254 void DesktopVideoCaptureMachine::UpdateCaptureSize() { |
| 255 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 255 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 256 if (oracle_proxy_ && desktop_window_) { | 256 if (oracle_proxy_.get() && desktop_window_) { |
| 257 ui::Layer* layer = desktop_window_->layer(); | 257 ui::Layer* layer = desktop_window_->layer(); |
| 258 gfx::Size capture_size = | 258 gfx::Size capture_size = |
| 259 ui::ConvertSizeToPixel(layer, layer->bounds().size()); | 259 ui::ConvertSizeToPixel(layer, layer->bounds().size()); |
| 260 #if defined(OS_CHROMEOS) | 260 #if defined(OS_CHROMEOS) |
| 261 // Pad desktop capture size to multiples of 16 pixels to accommodate HW | 261 // Pad desktop capture size to multiples of 16 pixels to accommodate HW |
| 262 // encoder. TODO(hshi): remove this hack. See http://crbug.com/402151 | 262 // encoder. TODO(hshi): remove this hack. See http://crbug.com/402151 |
| 263 capture_size.SetSize((capture_size.width() + 15) & ~15, | 263 capture_size.SetSize((capture_size.width() + 15) & ~15, |
| 264 (capture_size.height() + 15) & ~15); | 264 (capture_size.height() + 15) & ~15); |
| 265 #endif | 265 #endif |
| 266 oracle_proxy_->UpdateCaptureSize(capture_size); | 266 oracle_proxy_->UpdateCaptureSize(capture_size); |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 347 scoped_refptr<media::VideoFrame> video_frame, | 347 scoped_refptr<media::VideoFrame> video_frame, |
| 348 base::TimeTicks start_time, | 348 base::TimeTicks start_time, |
| 349 const ThreadSafeCaptureOracle::CaptureFrameCallback& capture_frame_cb, | 349 const ThreadSafeCaptureOracle::CaptureFrameCallback& capture_frame_cb, |
| 350 scoped_ptr<cc::CopyOutputResult> result) { | 350 scoped_ptr<cc::CopyOutputResult> result) { |
| 351 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 351 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 352 if (result->IsEmpty() || result->size().IsEmpty() || !desktop_window_) | 352 if (result->IsEmpty() || result->size().IsEmpty() || !desktop_window_) |
| 353 return false; | 353 return false; |
| 354 | 354 |
| 355 if (capture_params_.requested_format.pixel_format == | 355 if (capture_params_.requested_format.pixel_format == |
| 356 media::PIXEL_FORMAT_TEXTURE) { | 356 media::PIXEL_FORMAT_TEXTURE) { |
| 357 DCHECK(!video_frame); | 357 DCHECK(!video_frame.get()); |
| 358 cc::TextureMailbox texture_mailbox; | 358 cc::TextureMailbox texture_mailbox; |
| 359 scoped_ptr<cc::SingleReleaseCallback> release_callback; | 359 scoped_ptr<cc::SingleReleaseCallback> release_callback; |
| 360 result->TakeTexture(&texture_mailbox, &release_callback); | 360 result->TakeTexture(&texture_mailbox, &release_callback); |
| 361 DCHECK(texture_mailbox.IsTexture()); | 361 DCHECK(texture_mailbox.IsTexture()); |
| 362 if (!texture_mailbox.IsTexture()) | 362 if (!texture_mailbox.IsTexture()) |
| 363 return false; | 363 return false; |
| 364 video_frame = media::VideoFrame::WrapNativeTexture( | 364 video_frame = media::VideoFrame::WrapNativeTexture( |
| 365 make_scoped_ptr(new gpu::MailboxHolder(texture_mailbox.mailbox(), | 365 make_scoped_ptr(new gpu::MailboxHolder(texture_mailbox.mailbox(), |
| 366 texture_mailbox.target(), | 366 texture_mailbox.target(), |
| 367 texture_mailbox.sync_point())), | 367 texture_mailbox.sync_point())), |
| (...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 539 scoped_ptr<Client> client) { | 539 scoped_ptr<Client> client) { |
| 540 DVLOG(1) << "Allocating " << params.requested_format.frame_size.ToString(); | 540 DVLOG(1) << "Allocating " << params.requested_format.frame_size.ToString(); |
| 541 core_->AllocateAndStart(params, client.Pass()); | 541 core_->AllocateAndStart(params, client.Pass()); |
| 542 } | 542 } |
| 543 | 543 |
| 544 void DesktopCaptureDeviceAura::StopAndDeAllocate() { | 544 void DesktopCaptureDeviceAura::StopAndDeAllocate() { |
| 545 core_->StopAndDeAllocate(); | 545 core_->StopAndDeAllocate(); |
| 546 } | 546 } |
| 547 | 547 |
| 548 } // namespace content | 548 } // namespace content |
| OLD | NEW |