| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/renderer/media/capturefromelement/html_video_element_capturer_
source.h" | 5 #include "content/renderer/media/capturefromelement/html_video_element_capturer_
source.h" |
| 6 | 6 |
| 7 #include "base/location.h" | 7 #include "base/location.h" |
| 8 #include "base/memory/ptr_util.h" | 8 #include "base/memory/ptr_util.h" |
| 9 #include "base/single_thread_task_runner.h" | 9 #include "base/single_thread_task_runner.h" |
| 10 #include "base/threading/thread_task_runner_handle.h" | 10 #include "base/threading/thread_task_runner_handle.h" |
| (...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 127 TRACE_EVENT0("video", "HtmlVideoElementCapturerSource::sendNewFrame"); | 127 TRACE_EVENT0("video", "HtmlVideoElementCapturerSource::sendNewFrame"); |
| 128 DCHECK(thread_checker_.CalledOnValidThread()); | 128 DCHECK(thread_checker_.CalledOnValidThread()); |
| 129 | 129 |
| 130 if (!web_media_player_ || new_frame_callback_.is_null()) | 130 if (!web_media_player_ || new_frame_callback_.is_null()) |
| 131 return; | 131 return; |
| 132 | 132 |
| 133 const base::TimeTicks current_time = base::TimeTicks::Now(); | 133 const base::TimeTicks current_time = base::TimeTicks::Now(); |
| 134 const blink::WebSize resolution = web_media_player_->naturalSize(); | 134 const blink::WebSize resolution = web_media_player_->naturalSize(); |
| 135 | 135 |
| 136 cc::PaintCanvas* canvas = surface_->getCanvas(); | 136 cc::PaintCanvas* canvas = surface_->getCanvas(); |
| 137 cc::PaintFlags paint; | 137 cc::PaintFlags flags; |
| 138 paint.setBlendMode(SkBlendMode::kSrc); | 138 flags.setBlendMode(SkBlendMode::kSrc); |
| 139 paint.setFilterQuality(kLow_SkFilterQuality); | 139 flags.setFilterQuality(kLow_SkFilterQuality); |
| 140 web_media_player_->paint( | 140 web_media_player_->paint( |
| 141 canvas, blink::WebRect(0, 0, resolution.width, resolution.height), paint); | 141 canvas, blink::WebRect(0, 0, resolution.width, resolution.height), flags); |
| 142 DCHECK_NE(kUnknown_SkColorType, canvas->imageInfo().colorType()); | 142 DCHECK_NE(kUnknown_SkColorType, canvas->imageInfo().colorType()); |
| 143 DCHECK_EQ(canvas->imageInfo().width(), resolution.width); | 143 DCHECK_EQ(canvas->imageInfo().width(), resolution.width); |
| 144 DCHECK_EQ(canvas->imageInfo().height(), resolution.height); | 144 DCHECK_EQ(canvas->imageInfo().height(), resolution.height); |
| 145 | 145 |
| 146 SkBitmap bitmap; | 146 SkBitmap bitmap; |
| 147 bitmap.setInfo(canvas->imageInfo()); | 147 bitmap.setInfo(canvas->imageInfo()); |
| 148 canvas->readPixels(&bitmap, 0, 0); | 148 canvas->readPixels(&bitmap, 0, 0); |
| 149 | 149 |
| 150 DCHECK_NE(kUnknown_SkColorType, bitmap.colorType()); | 150 DCHECK_NE(kUnknown_SkColorType, bitmap.colorType()); |
| 151 DCHECK(!bitmap.drawsNothing()); | 151 DCHECK(!bitmap.drawsNothing()); |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 198 next_capture_time_ = current_time; | 198 next_capture_time_ = current_time; |
| 199 } | 199 } |
| 200 // Schedule next capture. | 200 // Schedule next capture. |
| 201 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( | 201 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( |
| 202 FROM_HERE, base::Bind(&HtmlVideoElementCapturerSource::sendNewFrame, | 202 FROM_HERE, base::Bind(&HtmlVideoElementCapturerSource::sendNewFrame, |
| 203 weak_factory_.GetWeakPtr()), | 203 weak_factory_.GetWeakPtr()), |
| 204 next_capture_time_ - current_time); | 204 next_capture_time_ - current_time); |
| 205 } | 205 } |
| 206 | 206 |
| 207 } // namespace content | 207 } // namespace content |
| OLD | NEW |