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

Side by Side Diff: content/renderer/media/html_video_element_capturer_source.cc

Issue 2276033002: Pass SkPaint instead of its alpha and mode in WebMediaPlayer::paint (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: android should compile Created 4 years, 3 months 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 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
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);
138 web_media_player_->paint( 141 web_media_player_->paint(
139 canvas, blink::WebRect(0, 0, resolution.width, resolution.height), 142 canvas, blink::WebRect(0, 0, resolution.width, resolution.height),
140 0xFF /* alpha */, SkXfermode::kSrc_Mode); 143 paint);
141 DCHECK_NE(kUnknown_SkColorType, canvas->imageInfo().colorType()); 144 DCHECK_NE(kUnknown_SkColorType, canvas->imageInfo().colorType());
142 DCHECK_EQ(canvas->imageInfo().width(), resolution.width); 145 DCHECK_EQ(canvas->imageInfo().width(), resolution.width);
143 DCHECK_EQ(canvas->imageInfo().height(), resolution.height); 146 DCHECK_EQ(canvas->imageInfo().height(), resolution.height);
144 147
145 const SkBitmap bitmap = skia::ReadPixels(canvas); 148 const SkBitmap bitmap = skia::ReadPixels(canvas);
146 DCHECK_NE(kUnknown_SkColorType, bitmap.colorType()); 149 DCHECK_NE(kUnknown_SkColorType, bitmap.colorType());
147 DCHECK(!bitmap.drawsNothing()); 150 DCHECK(!bitmap.drawsNothing());
148 DCHECK(bitmap.getPixels()); 151 DCHECK(bitmap.getPixels());
149 if (bitmap.colorType() != kN32_SkColorType) { 152 if (bitmap.colorType() != kN32_SkColorType) {
150 DLOG(ERROR) << "Only supported color type is kN32_SkColorType (ARGB/ABGR)"; 153 DLOG(ERROR) << "Only supported color type is kN32_SkColorType (ARGB/ABGR)";
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
194 next_capture_time_ = current_time; 197 next_capture_time_ = current_time;
195 } 198 }
196 // Schedule next capture. 199 // Schedule next capture.
197 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( 200 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask(
198 FROM_HERE, base::Bind(&HtmlVideoElementCapturerSource::sendNewFrame, 201 FROM_HERE, base::Bind(&HtmlVideoElementCapturerSource::sendNewFrame,
199 weak_factory_.GetWeakPtr()), 202 weak_factory_.GetWeakPtr()),
200 next_capture_time_ - current_time); 203 next_capture_time_ - current_time);
201 } 204 }
202 205
203 } // namespace content 206 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698