| 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 "media/base/bind_to_current_loop.h" | 7 #include "media/base/bind_to_current_loop.h" |
| 8 #include "media/base/video_frame.h" | 8 #include "media/base/video_frame.h" |
| 9 #include "media/base/video_util.h" | 9 #include "media/base/video_util.h" |
| 10 #include "skia/ext/cdl_surface.h" |
| 10 #include "skia/ext/platform_canvas.h" | 11 #include "skia/ext/platform_canvas.h" |
| 11 #include "third_party/WebKit/public/platform/WebCallbacks.h" | 12 #include "third_party/WebKit/public/platform/WebCallbacks.h" |
| 12 #include "third_party/WebKit/public/platform/WebMediaStreamSource.h" | 13 #include "third_party/WebKit/public/platform/WebMediaStreamSource.h" |
| 13 #include "third_party/WebKit/public/platform/WebMediaStreamTrack.h" | 14 #include "third_party/WebKit/public/platform/WebMediaStreamTrack.h" |
| 14 #include "third_party/libyuv/include/libyuv.h" | 15 #include "third_party/libyuv/include/libyuv.h" |
| 15 #include "third_party/skia/include/core/SkImage.h" | 16 #include "third_party/skia/include/core/SkImage.h" |
| 16 #include "third_party/skia/include/core/SkSurface.h" | 17 #include "third_party/skia/include/core/SkSurface.h" |
| 17 | 18 |
| 18 namespace content { | 19 namespace content { |
| 19 | 20 |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 62 if (first_frame_received_) | 63 if (first_frame_received_) |
| 63 return; | 64 return; |
| 64 first_frame_received_ = true; | 65 first_frame_received_ = true; |
| 65 | 66 |
| 66 const SkAlphaType alpha = media::IsOpaque(frame->format()) | 67 const SkAlphaType alpha = media::IsOpaque(frame->format()) |
| 67 ? kOpaque_SkAlphaType | 68 ? kOpaque_SkAlphaType |
| 68 : kPremul_SkAlphaType; | 69 : kPremul_SkAlphaType; |
| 69 const SkImageInfo info = SkImageInfo::MakeN32( | 70 const SkImageInfo info = SkImageInfo::MakeN32( |
| 70 frame->visible_rect().width(), frame->visible_rect().height(), alpha); | 71 frame->visible_rect().width(), frame->visible_rect().height(), alpha); |
| 71 | 72 |
| 72 sk_sp<SkSurface> surface = SkSurface::MakeRaster(info); | 73 sk_sp<CdlSurface> surface = CdlSurface::MakeRaster(info); |
| 73 DCHECK(surface); | 74 DCHECK(surface); |
| 74 | 75 |
| 75 SkPixmap pixmap; | 76 SkPixmap pixmap; |
| 76 if (!skia::GetWritablePixels(surface->getCanvas(), &pixmap)) { | 77 if (!skia::GetWritablePixels(surface->getCanvas(), &pixmap)) { |
| 77 DLOG(ERROR) << "Error trying to map SkSurface's pixels"; | 78 DLOG(ERROR) << "Error trying to map SkSurface's pixels"; |
| 78 callback.Run(sk_sp<SkImage>()); | 79 callback.Run(sk_sp<SkImage>()); |
| 79 return; | 80 return; |
| 80 } | 81 } |
| 81 | 82 |
| 82 const uint32 destination_pixel_format = | 83 const uint32 destination_pixel_format = |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 154 | 155 |
| 155 MediaStreamVideoSink::DisconnectFromTrack(); | 156 MediaStreamVideoSink::DisconnectFromTrack(); |
| 156 frame_grab_in_progress_ = false; | 157 frame_grab_in_progress_ = false; |
| 157 if (image) | 158 if (image) |
| 158 callbacks.PassCallbacks()->onSuccess(image); | 159 callbacks.PassCallbacks()->onSuccess(image); |
| 159 else | 160 else |
| 160 callbacks.PassCallbacks()->onError(); | 161 callbacks.PassCallbacks()->onError(); |
| 161 } | 162 } |
| 162 | 163 |
| 163 } // namespace content | 164 } // namespace content |
| OLD | NEW |