| 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/html_video_element_capturer_source.h" | 5 #include "content/renderer/media/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 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 128 TRACE_EVENT0("video", "HtmlVideoElementCapturerSource::sendNewFrame"); | 128 TRACE_EVENT0("video", "HtmlVideoElementCapturerSource::sendNewFrame"); |
| 129 DCHECK(thread_checker_.CalledOnValidThread()); | 129 DCHECK(thread_checker_.CalledOnValidThread()); |
| 130 | 130 |
| 131 if (!web_media_player_ || new_frame_callback_.is_null()) | 131 if (!web_media_player_ || new_frame_callback_.is_null()) |
| 132 return; | 132 return; |
| 133 | 133 |
| 134 const base::TimeTicks current_time = base::TimeTicks::Now(); | 134 const base::TimeTicks current_time = base::TimeTicks::Now(); |
| 135 const blink::WebSize resolution = web_media_player_->naturalSize(); | 135 const blink::WebSize resolution = web_media_player_->naturalSize(); |
| 136 | 136 |
| 137 SkCanvas* canvas = surface_->getCanvas(); | 137 SkCanvas* canvas = surface_->getCanvas(); |
| 138 SkPaint paint; |
| 139 paint.setXfermodeMode(SkXfermode::kSrc_Mode); |
| 140 paint.setFilterQuality(kLow_SkFilterQuality); |
| 141 paint.setAlpha(0xFF); |
| 138 web_media_player_->paint( | 142 web_media_player_->paint( |
| 139 canvas, blink::WebRect(0, 0, resolution.width, resolution.height), | 143 canvas, blink::WebRect(0, 0, resolution.width, resolution.height), |
| 140 0xFF /* alpha */, SkXfermode::kSrc_Mode); | 144 &paint); |
| 141 DCHECK_NE(kUnknown_SkColorType, canvas->imageInfo().colorType()); | 145 DCHECK_NE(kUnknown_SkColorType, canvas->imageInfo().colorType()); |
| 142 DCHECK_EQ(canvas->imageInfo().width(), resolution.width); | 146 DCHECK_EQ(canvas->imageInfo().width(), resolution.width); |
| 143 DCHECK_EQ(canvas->imageInfo().height(), resolution.height); | 147 DCHECK_EQ(canvas->imageInfo().height(), resolution.height); |
| 144 | 148 |
| 145 const SkBitmap bitmap = skia::ReadPixels(canvas); | 149 const SkBitmap bitmap = skia::ReadPixels(canvas); |
| 146 DCHECK_NE(kUnknown_SkColorType, bitmap.colorType()); | 150 DCHECK_NE(kUnknown_SkColorType, bitmap.colorType()); |
| 147 DCHECK(!bitmap.drawsNothing()); | 151 DCHECK(!bitmap.drawsNothing()); |
| 148 DCHECK(bitmap.getPixels()); | 152 DCHECK(bitmap.getPixels()); |
| 149 if (bitmap.colorType() != kN32_SkColorType) { | 153 if (bitmap.colorType() != kN32_SkColorType) { |
| 150 DLOG(ERROR) << "Only supported color type is kN32_SkColorType (ARGB/ABGR)"; | 154 DLOG(ERROR) << "Only supported color type is kN32_SkColorType (ARGB/ABGR)"; |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 194 next_capture_time_ = current_time; | 198 next_capture_time_ = current_time; |
| 195 } | 199 } |
| 196 // Schedule next capture. | 200 // Schedule next capture. |
| 197 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( | 201 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( |
| 198 FROM_HERE, base::Bind(&HtmlVideoElementCapturerSource::sendNewFrame, | 202 FROM_HERE, base::Bind(&HtmlVideoElementCapturerSource::sendNewFrame, |
| 199 weak_factory_.GetWeakPtr()), | 203 weak_factory_.GetWeakPtr()), |
| 200 next_capture_time_ - current_time); | 204 next_capture_time_ - current_time); |
| 201 } | 205 } |
| 202 | 206 |
| 203 } // namespace content | 207 } // namespace content |
| OLD | NEW |