| 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 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 183 SkCanvasVideoRenderer::SkCanvasVideoRenderer() | 183 SkCanvasVideoRenderer::SkCanvasVideoRenderer() |
| 184 : last_frame_timestamp_(media::kNoTimestamp()) { | 184 : last_frame_timestamp_(media::kNoTimestamp()) { |
| 185 } | 185 } |
| 186 | 186 |
| 187 SkCanvasVideoRenderer::~SkCanvasVideoRenderer() {} | 187 SkCanvasVideoRenderer::~SkCanvasVideoRenderer() {} |
| 188 | 188 |
| 189 void SkCanvasVideoRenderer::Paint(media::VideoFrame* video_frame, | 189 void SkCanvasVideoRenderer::Paint(media::VideoFrame* video_frame, |
| 190 SkCanvas* canvas, | 190 SkCanvas* canvas, |
| 191 const gfx::RectF& dest_rect, | 191 const gfx::RectF& dest_rect, |
| 192 uint8 alpha, | 192 uint8 alpha, |
| 193 SkXfermode::Mode mode, |
| 193 VideoRotation video_rotation) { | 194 VideoRotation video_rotation) { |
| 194 if (alpha == 0) { | 195 if (alpha == 0) { |
| 195 return; | 196 return; |
| 196 } | 197 } |
| 197 | 198 |
| 198 SkRect dest; | 199 SkRect dest; |
| 199 dest.set(dest_rect.x(), dest_rect.y(), dest_rect.right(), dest_rect.bottom()); | 200 dest.set(dest_rect.x(), dest_rect.y(), dest_rect.right(), dest_rect.bottom()); |
| 200 | 201 |
| 201 SkPaint paint; | 202 SkPaint paint; |
| 202 paint.setAlpha(alpha); | 203 paint.setAlpha(alpha); |
| (...skipping 23 matching lines...) Expand all Loading... |
| 226 break; | 227 break; |
| 227 case VIDEO_ROTATION_270: | 228 case VIDEO_ROTATION_270: |
| 228 last_frame_ = SkBitmapOperations::Rotate( | 229 last_frame_ = SkBitmapOperations::Rotate( |
| 229 last_frame_, SkBitmapOperations::ROTATION_270_CW); | 230 last_frame_, SkBitmapOperations::ROTATION_270_CW); |
| 230 break; | 231 break; |
| 231 } | 232 } |
| 232 | 233 |
| 233 last_frame_timestamp_ = video_frame->timestamp(); | 234 last_frame_timestamp_ = video_frame->timestamp(); |
| 234 } | 235 } |
| 235 | 236 |
| 236 // Use SRC mode so we completely overwrite the buffer (in case we have alpha) | 237 paint.setXfermodeMode(mode); |
| 237 // this means we don't need the extra cost of clearing the buffer first. | |
| 238 paint.setXfermode(SkXfermode::Create(SkXfermode::kSrc_Mode)); | |
| 239 | 238 |
| 240 // Paint using |last_frame_|. | 239 // Paint using |last_frame_|. |
| 241 paint.setFilterLevel(SkPaint::kLow_FilterLevel); | 240 paint.setFilterLevel(SkPaint::kLow_FilterLevel); |
| 242 canvas->drawBitmapRect(last_frame_, NULL, dest, &paint); | 241 canvas->drawBitmapRect(last_frame_, NULL, dest, &paint); |
| 243 } | 242 } |
| 244 | 243 |
| 244 void SkCanvasVideoRenderer::Copy(media::VideoFrame* video_frame, |
| 245 SkCanvas* canvas) { |
| 246 Paint(video_frame, |
| 247 canvas, |
| 248 video_frame->visible_rect(), |
| 249 0xff, |
| 250 SkXfermode::kSrc_Mode, |
| 251 media::VIDEO_ROTATION_0); |
| 252 } |
| 253 |
| 245 } // namespace media | 254 } // namespace media |
| OLD | NEW |