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/renderers/skcanvas_video_renderer.h" | 5 #include "media/renderers/skcanvas_video_renderer.h" |
6 | 6 |
7 #include <GLES3/gl3.h> | 7 #include <GLES3/gl3.h> |
8 #include <limits> | 8 #include <limits> |
9 | 9 |
10 #include "base/macros.h" | 10 #include "base/macros.h" |
| 11 #include "base/memory/ptr_util.h" |
11 #include "cc/paint/paint_canvas.h" | 12 #include "cc/paint/paint_canvas.h" |
12 #include "cc/paint/paint_flags.h" | 13 #include "cc/paint/paint_flags.h" |
13 #include "gpu/GLES2/gl2extchromium.h" | 14 #include "gpu/GLES2/gl2extchromium.h" |
14 #include "gpu/command_buffer/client/gles2_interface.h" | 15 #include "gpu/command_buffer/client/gles2_interface.h" |
15 #include "gpu/command_buffer/common/mailbox_holder.h" | 16 #include "gpu/command_buffer/common/mailbox_holder.h" |
16 #include "media/base/data_buffer.h" | 17 #include "media/base/data_buffer.h" |
17 #include "media/base/video_frame.h" | 18 #include "media/base/video_frame.h" |
18 #include "skia/ext/texture_handle.h" | 19 #include "skia/ext/texture_handle.h" |
19 #include "third_party/libyuv/include/libyuv.h" | 20 #include "third_party/libyuv/include/libyuv.h" |
20 #include "third_party/skia/include/core/SkImage.h" | 21 #include "third_party/skia/include/core/SkImage.h" |
(...skipping 910 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
931 DCHECK(context_3d.gr_context); | 932 DCHECK(context_3d.gr_context); |
932 DCHECK(context_3d.gl); | 933 DCHECK(context_3d.gl); |
933 if (media::VideoFrame::NumPlanes(video_frame->format()) > 1) { | 934 if (media::VideoFrame::NumPlanes(video_frame->format()) > 1) { |
934 last_image_ = | 935 last_image_ = |
935 NewSkImageFromVideoFrameYUVTextures(video_frame.get(), context_3d); | 936 NewSkImageFromVideoFrameYUVTextures(video_frame.get(), context_3d); |
936 } else { | 937 } else { |
937 last_image_ = | 938 last_image_ = |
938 NewSkImageFromVideoFrameNative(video_frame.get(), context_3d); | 939 NewSkImageFromVideoFrameNative(video_frame.get(), context_3d); |
939 } | 940 } |
940 } else { | 941 } else { |
941 auto* video_generator = new VideoImageGenerator(video_frame); | 942 last_image_ = SkImage::MakeFromGenerator( |
942 last_image_ = SkImage::MakeFromGenerator(video_generator); | 943 base::MakeUnique<VideoImageGenerator>(video_frame)); |
943 } | 944 } |
944 CorrectLastImageDimensions(gfx::RectToSkIRect(video_frame->visible_rect())); | 945 CorrectLastImageDimensions(gfx::RectToSkIRect(video_frame->visible_rect())); |
945 if (!last_image_) // Couldn't create the SkImage. | 946 if (!last_image_) // Couldn't create the SkImage. |
946 return false; | 947 return false; |
947 last_timestamp_ = video_frame->timestamp(); | 948 last_timestamp_ = video_frame->timestamp(); |
948 } | 949 } |
949 last_image_deleting_timer_.Reset(); | 950 last_image_deleting_timer_.Reset(); |
950 DCHECK(!!last_image_); | 951 DCHECK(!!last_image_); |
951 return true; | 952 return true; |
952 } | 953 } |
953 | 954 |
954 void SkCanvasVideoRenderer::CorrectLastImageDimensions( | 955 void SkCanvasVideoRenderer::CorrectLastImageDimensions( |
955 const SkIRect& visible_rect) { | 956 const SkIRect& visible_rect) { |
956 last_image_dimensions_for_testing_ = visible_rect.size(); | 957 last_image_dimensions_for_testing_ = visible_rect.size(); |
957 if (!last_image_) | 958 if (!last_image_) |
958 return; | 959 return; |
959 if (last_image_->dimensions() != visible_rect.size() && | 960 if (last_image_->dimensions() != visible_rect.size() && |
960 last_image_->bounds().contains(visible_rect)) { | 961 last_image_->bounds().contains(visible_rect)) { |
961 last_image_ = last_image_->makeSubset(visible_rect); | 962 last_image_ = last_image_->makeSubset(visible_rect); |
962 } | 963 } |
963 } | 964 } |
964 | 965 |
965 SkISize SkCanvasVideoRenderer::LastImageDimensionsForTesting() { | 966 SkISize SkCanvasVideoRenderer::LastImageDimensionsForTesting() { |
966 return last_image_dimensions_for_testing_; | 967 return last_image_dimensions_for_testing_; |
967 } | 968 } |
968 | 969 |
969 } // namespace media | 970 } // namespace media |
OLD | NEW |