OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "media/filters/skcanvas_video_renderer.h" | 5 #include "media/filters/skcanvas_video_renderer.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "media/base/video_frame.h" | 8 #include "media/base/video_frame.h" |
9 #include "media/base/yuv_convert.h" | 9 #include "media/base/yuv_convert.h" |
10 #include "third_party/libyuv/include/libyuv.h" | 10 #include "third_party/libyuv/include/libyuv.h" |
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
207 | 207 |
208 // Generates an RGB image from a VideoFrame. | 208 // Generates an RGB image from a VideoFrame. |
209 class VideoImageGenerator : public SkImageGenerator { | 209 class VideoImageGenerator : public SkImageGenerator { |
210 public: | 210 public: |
211 VideoImageGenerator(const scoped_refptr<VideoFrame>& frame) : frame_(frame) {} | 211 VideoImageGenerator(const scoped_refptr<VideoFrame>& frame) : frame_(frame) {} |
212 virtual ~VideoImageGenerator() {} | 212 virtual ~VideoImageGenerator() {} |
213 | 213 |
214 void set_frame(const scoped_refptr<VideoFrame>& frame) { frame_ = frame; } | 214 void set_frame(const scoped_refptr<VideoFrame>& frame) { frame_ = frame; } |
215 | 215 |
216 protected: | 216 protected: |
217 virtual bool onGetInfo(SkImageInfo* info) OVERRIDE { | 217 virtual bool onGetInfo(SkImageInfo* info) override { |
218 info->fWidth = frame_->visible_rect().width(); | 218 info->fWidth = frame_->visible_rect().width(); |
219 info->fHeight = frame_->visible_rect().height(); | 219 info->fHeight = frame_->visible_rect().height(); |
220 info->fColorType = kN32_SkColorType; | 220 info->fColorType = kN32_SkColorType; |
221 info->fAlphaType = kPremul_SkAlphaType; | 221 info->fAlphaType = kPremul_SkAlphaType; |
222 return true; | 222 return true; |
223 } | 223 } |
224 | 224 |
225 virtual bool onGetPixels(const SkImageInfo& info, | 225 virtual bool onGetPixels(const SkImageInfo& info, |
226 void* pixels, | 226 void* pixels, |
227 size_t row_bytes, | 227 size_t row_bytes, |
228 SkPMColor ctable[], | 228 SkPMColor ctable[], |
229 int* ctable_count) OVERRIDE { | 229 int* ctable_count) override { |
230 if (!frame_.get()) | 230 if (!frame_.get()) |
231 return false; | 231 return false; |
232 if (!pixels) | 232 if (!pixels) |
233 return true; | 233 return true; |
234 // If skia couldn't do the YUV conversion, we will. | 234 // If skia couldn't do the YUV conversion, we will. |
235 ConvertVideoFrameToRGBPixels(frame_, pixels, row_bytes); | 235 ConvertVideoFrameToRGBPixels(frame_, pixels, row_bytes); |
236 frame_ = NULL; | 236 frame_ = NULL; |
237 return true; | 237 return true; |
238 } | 238 } |
239 | 239 |
240 virtual bool onGetYUV8Planes(SkISize sizes[3], | 240 virtual bool onGetYUV8Planes(SkISize sizes[3], |
241 void* planes[3], | 241 void* planes[3], |
242 size_t row_bytes[3], | 242 size_t row_bytes[3], |
243 SkYUVColorSpace* color_space) OVERRIDE { | 243 SkYUVColorSpace* color_space) override { |
244 if (!frame_.get() || !IsYUV(frame_->format())) | 244 if (!frame_.get() || !IsYUV(frame_->format())) |
245 return false; | 245 return false; |
246 | 246 |
247 if (color_space) { | 247 if (color_space) { |
248 if (IsJPEGColorSpace(frame_->format())) | 248 if (IsJPEGColorSpace(frame_->format())) |
249 *color_space = kJPEG_SkYUVColorSpace; | 249 *color_space = kJPEG_SkYUVColorSpace; |
250 else | 250 else |
251 *color_space = kRec601_SkYUVColorSpace; | 251 *color_space = kRec601_SkYUVColorSpace; |
252 } | 252 } |
253 | 253 |
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
370 SkCanvas* canvas) { | 370 SkCanvas* canvas) { |
371 Paint(video_frame, | 371 Paint(video_frame, |
372 canvas, | 372 canvas, |
373 video_frame->visible_rect(), | 373 video_frame->visible_rect(), |
374 0xff, | 374 0xff, |
375 SkXfermode::kSrc_Mode, | 375 SkXfermode::kSrc_Mode, |
376 media::VIDEO_ROTATION_0); | 376 media::VIDEO_ROTATION_0); |
377 } | 377 } |
378 | 378 |
379 } // namespace media | 379 } // namespace media |
OLD | NEW |