| 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 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 204 break; | 204 break; |
| 205 } | 205 } |
| 206 } | 206 } |
| 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 DCHECK(frame_.get()); | 212 DCHECK(frame_.get()); |
| 213 } | 213 } |
| 214 virtual ~VideoImageGenerator() {} | 214 ~VideoImageGenerator() override {} |
| 215 | 215 |
| 216 void set_frame(const scoped_refptr<VideoFrame>& frame) { frame_ = frame; } | 216 void set_frame(const scoped_refptr<VideoFrame>& frame) { frame_ = frame; } |
| 217 | 217 |
| 218 protected: | 218 protected: |
| 219 virtual bool onGetInfo(SkImageInfo* info) override { | 219 bool onGetInfo(SkImageInfo* info) override { |
| 220 info->fWidth = frame_->visible_rect().width(); | 220 info->fWidth = frame_->visible_rect().width(); |
| 221 info->fHeight = frame_->visible_rect().height(); | 221 info->fHeight = frame_->visible_rect().height(); |
| 222 info->fColorType = kN32_SkColorType; | 222 info->fColorType = kN32_SkColorType; |
| 223 info->fAlphaType = kPremul_SkAlphaType; | 223 info->fAlphaType = kPremul_SkAlphaType; |
| 224 return true; | 224 return true; |
| 225 } | 225 } |
| 226 | 226 |
| 227 virtual bool onGetPixels(const SkImageInfo& info, | 227 bool onGetPixels(const SkImageInfo& info, |
| 228 void* pixels, | 228 void* pixels, |
| 229 size_t row_bytes, | 229 size_t row_bytes, |
| 230 SkPMColor ctable[], | 230 SkPMColor ctable[], |
| 231 int* ctable_count) override { | 231 int* ctable_count) override { |
| 232 if (!frame_.get()) | 232 if (!frame_.get()) |
| 233 return false; | 233 return false; |
| 234 if (!pixels) | 234 if (!pixels) |
| 235 return false; | 235 return false; |
| 236 // If skia couldn't do the YUV conversion, we will. | 236 // If skia couldn't do the YUV conversion, we will. |
| 237 ConvertVideoFrameToRGBPixels(frame_, pixels, row_bytes); | 237 ConvertVideoFrameToRGBPixels(frame_, pixels, row_bytes); |
| 238 return true; | 238 return true; |
| 239 } | 239 } |
| 240 | 240 |
| 241 virtual bool onGetYUV8Planes(SkISize sizes[3], | 241 bool onGetYUV8Planes(SkISize sizes[3], |
| 242 void* planes[3], | 242 void* planes[3], |
| 243 size_t row_bytes[3], | 243 size_t row_bytes[3], |
| 244 SkYUVColorSpace* color_space) override { | 244 SkYUVColorSpace* color_space) override { |
| 245 if (!frame_.get() || !IsYUV(frame_->format())) | 245 if (!frame_.get() || !IsYUV(frame_->format())) |
| 246 return false; | 246 return false; |
| 247 | 247 |
| 248 if (color_space) { | 248 if (color_space) { |
| 249 if (IsJPEGColorSpace(frame_->format())) | 249 if (IsJPEGColorSpace(frame_->format())) |
| 250 *color_space = kJPEG_SkYUVColorSpace; | 250 *color_space = kJPEG_SkYUVColorSpace; |
| 251 else | 251 else |
| 252 *color_space = kRec601_SkYUVColorSpace; | 252 *color_space = kRec601_SkYUVColorSpace; |
| 253 } | 253 } |
| 254 | 254 |
| (...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 390 SkCanvas* canvas) { | 390 SkCanvas* canvas) { |
| 391 Paint(video_frame, | 391 Paint(video_frame, |
| 392 canvas, | 392 canvas, |
| 393 video_frame->visible_rect(), | 393 video_frame->visible_rect(), |
| 394 0xff, | 394 0xff, |
| 395 SkXfermode::kSrc_Mode, | 395 SkXfermode::kSrc_Mode, |
| 396 media::VIDEO_ROTATION_0); | 396 media::VIDEO_ROTATION_0); |
| 397 } | 397 } |
| 398 | 398 |
| 399 } // namespace media | 399 } // namespace media |
| OLD | NEW |