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 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
49 << video_frame->format(); | 49 << video_frame->format(); |
50 if (IsYUV(video_frame->format())) { | 50 if (IsYUV(video_frame->format())) { |
51 DCHECK_EQ(video_frame->stride(media::VideoFrame::kUPlane), | 51 DCHECK_EQ(video_frame->stride(media::VideoFrame::kUPlane), |
52 video_frame->stride(media::VideoFrame::kVPlane)); | 52 video_frame->stride(media::VideoFrame::kVPlane)); |
53 } | 53 } |
54 | 54 |
55 // Check if |bitmap| needs to be (re)allocated. | 55 // Check if |bitmap| needs to be (re)allocated. |
56 if (bitmap->isNull() || | 56 if (bitmap->isNull() || |
57 bitmap->width() != video_frame->visible_rect().width() || | 57 bitmap->width() != video_frame->visible_rect().width() || |
58 bitmap->height() != video_frame->visible_rect().height()) { | 58 bitmap->height() != video_frame->visible_rect().height()) { |
59 bitmap->setConfig(SkBitmap::kARGB_8888_Config, | 59 bitmap->allocN32Pixels(video_frame->visible_rect().width(), |
60 video_frame->visible_rect().width(), | 60 video_frame->visible_rect().height()); |
61 video_frame->visible_rect().height()); | |
62 bitmap->allocPixels(); | |
63 bitmap->setIsVolatile(true); | 61 bitmap->setIsVolatile(true); |
64 } | 62 } |
65 | 63 |
66 bitmap->lockPixels(); | 64 bitmap->lockPixels(); |
67 | 65 |
68 size_t y_offset = 0; | 66 size_t y_offset = 0; |
69 size_t uv_offset = 0; | 67 size_t uv_offset = 0; |
70 if (IsYUV(video_frame->format())) { | 68 if (IsYUV(video_frame->format())) { |
71 int y_shift = (video_frame->format() == media::VideoFrame::YV16) ? 0 : 1; | 69 int y_shift = (video_frame->format() == media::VideoFrame::YV16) ? 0 : 1; |
72 // Use the "left" and "top" of the destination rect to locate the offset | 70 // Use the "left" and "top" of the destination rect to locate the offset |
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
214 ConvertVideoFrameToBitmap(video_frame, &last_frame_); | 212 ConvertVideoFrameToBitmap(video_frame, &last_frame_); |
215 last_frame_timestamp_ = video_frame->timestamp(); | 213 last_frame_timestamp_ = video_frame->timestamp(); |
216 } | 214 } |
217 | 215 |
218 // Paint using |last_frame_|. | 216 // Paint using |last_frame_|. |
219 paint.setFilterLevel(SkPaint::kLow_FilterLevel); | 217 paint.setFilterLevel(SkPaint::kLow_FilterLevel); |
220 canvas->drawBitmapRect(last_frame_, NULL, dest, &paint); | 218 canvas->drawBitmapRect(last_frame_, NULL, dest, &paint); |
221 } | 219 } |
222 | 220 |
223 } // namespace media | 221 } // namespace media |
OLD | NEW |