OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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/image_capture_frame_grabber.h" | 5 #include "content/renderer/media/image_capture_frame_grabber.h" |
6 | 6 |
7 #include "cc/paint/paint_canvas.h" | 7 #include "cc/paint/paint_canvas.h" |
8 #include "cc/paint/paint_surface.h" | 8 #include "cc/paint/paint_surface.h" |
9 #include "media/base/bind_to_current_loop.h" | 9 #include "media/base/bind_to_current_loop.h" |
10 #include "media/base/video_frame.h" | 10 #include "media/base/video_frame.h" |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
63 if (first_frame_received_) | 63 if (first_frame_received_) |
64 return; | 64 return; |
65 first_frame_received_ = true; | 65 first_frame_received_ = true; |
66 | 66 |
67 const SkAlphaType alpha = media::IsOpaque(frame->format()) | 67 const SkAlphaType alpha = media::IsOpaque(frame->format()) |
68 ? kOpaque_SkAlphaType | 68 ? kOpaque_SkAlphaType |
69 : kPremul_SkAlphaType; | 69 : kPremul_SkAlphaType; |
70 const SkImageInfo info = SkImageInfo::MakeN32( | 70 const SkImageInfo info = SkImageInfo::MakeN32( |
71 frame->visible_rect().width(), frame->visible_rect().height(), alpha); | 71 frame->visible_rect().width(), frame->visible_rect().height(), alpha); |
72 | 72 |
73 sk_sp<cc::PaintSurface> surface = cc::PaintSurface::MakeRaster(info); | 73 sk_sp<SkSurface> surface = SkSurface::MakeRaster(info); |
74 DCHECK(surface); | 74 DCHECK(surface); |
75 | 75 |
76 SkPixmap pixmap; | 76 SkPixmap pixmap; |
77 if (!cc::ToPixmap(surface->getCanvas(), &pixmap)) { | 77 if (!skia::GetWritablePixels(surface->getCanvas(), &pixmap)) { |
78 DLOG(ERROR) << "Error trying to map PaintSurface's pixels"; | 78 DLOG(ERROR) << "Error trying to map SkSurface's pixels"; |
79 callback.Run(sk_sp<SkImage>()); | 79 callback.Run(sk_sp<SkImage>()); |
80 return; | 80 return; |
81 } | 81 } |
82 | 82 |
83 const uint32 destination_pixel_format = | 83 const uint32 destination_pixel_format = |
84 (kN32_SkColorType == kRGBA_8888_SkColorType) ? libyuv::FOURCC_ABGR | 84 (kN32_SkColorType == kRGBA_8888_SkColorType) ? libyuv::FOURCC_ABGR |
85 : libyuv::FOURCC_ARGB; | 85 : libyuv::FOURCC_ARGB; |
86 | 86 |
87 libyuv::ConvertFromI420(frame->visible_data(media::VideoFrame::kYPlane), | 87 libyuv::ConvertFromI420(frame->visible_data(media::VideoFrame::kYPlane), |
88 frame->stride(media::VideoFrame::kYPlane), | 88 frame->stride(media::VideoFrame::kYPlane), |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
155 | 155 |
156 MediaStreamVideoSink::DisconnectFromTrack(); | 156 MediaStreamVideoSink::DisconnectFromTrack(); |
157 frame_grab_in_progress_ = false; | 157 frame_grab_in_progress_ = false; |
158 if (image) | 158 if (image) |
159 callbacks.PassCallbacks()->onSuccess(image); | 159 callbacks.PassCallbacks()->onSuccess(image); |
160 else | 160 else |
161 callbacks.PassCallbacks()->onError(); | 161 callbacks.PassCallbacks()->onError(); |
162 } | 162 } |
163 | 163 |
164 } // namespace content | 164 } // namespace content |
OLD | NEW |