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/blink/skcanvas_video_renderer.h" | 5 #include "media/blink/skcanvas_video_renderer.h" |
6 | 6 |
7 #include "gpu/GLES2/gl2extchromium.h" | 7 #include "gpu/GLES2/gl2extchromium.h" |
8 #include "gpu/command_buffer/client/gles2_interface.h" | 8 #include "gpu/command_buffer/client/gles2_interface.h" |
9 #include "gpu/command_buffer/common/mailbox_holder.h" | 9 #include "gpu/command_buffer/common/mailbox_holder.h" |
10 #include "media/base/video_frame.h" | 10 #include "media/base/video_frame.h" |
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
163 gpu::gles2::GLES2Interface* gl_; | 163 gpu::gles2::GLES2Interface* gl_; |
164 | 164 |
165 DISALLOW_IMPLICIT_CONSTRUCTORS(SyncPointClientImpl); | 165 DISALLOW_IMPLICIT_CONSTRUCTORS(SyncPointClientImpl); |
166 }; | 166 }; |
167 | 167 |
168 } // anonymous namespace | 168 } // anonymous namespace |
169 | 169 |
170 // Generates an RGB image from a VideoFrame. Convert YUV to RGB plain on GPU. | 170 // Generates an RGB image from a VideoFrame. Convert YUV to RGB plain on GPU. |
171 class VideoImageGenerator : public SkImageGenerator { | 171 class VideoImageGenerator : public SkImageGenerator { |
172 public: | 172 public: |
173 VideoImageGenerator(const scoped_refptr<VideoFrame>& frame) : frame_(frame) { | 173 VideoImageGenerator(const scoped_refptr<VideoFrame>& frame) |
| 174 : SkImageGenerator( |
| 175 SkImageInfo::MakeN32Premul(frame->visible_rect().width(), |
| 176 frame->visible_rect().height())) |
| 177 , frame_(frame) { |
174 DCHECK(frame_.get()); | 178 DCHECK(frame_.get()); |
175 } | 179 } |
176 ~VideoImageGenerator() override {} | 180 ~VideoImageGenerator() override {} |
177 | 181 |
178 void set_frame(const scoped_refptr<VideoFrame>& frame) { frame_ = frame; } | 182 void set_frame(const scoped_refptr<VideoFrame>& frame) { frame_ = frame; } |
179 | 183 |
180 protected: | 184 protected: |
181 bool onGetInfo(SkImageInfo* info) override { | |
182 info->fWidth = frame_->visible_rect().width(); | |
183 info->fHeight = frame_->visible_rect().height(); | |
184 info->fColorType = kN32_SkColorType; | |
185 info->fAlphaType = kPremul_SkAlphaType; | |
186 return true; | |
187 } | |
188 | |
189 Result onGetPixels(const SkImageInfo& info, | 185 Result onGetPixels(const SkImageInfo& info, |
190 void* pixels, | 186 void* pixels, |
191 size_t row_bytes, | 187 size_t row_bytes, |
192 SkPMColor ctable[], | 188 SkPMColor ctable[], |
193 int* ctable_count) override { | 189 int* ctable_count) override { |
194 if (!frame_.get()) | 190 if (!frame_.get()) |
195 return kInvalidInput; | 191 return kInvalidInput; |
196 // If skia couldn't do the YUV conversion on GPU, we will on CPU. | 192 // If skia couldn't do the YUV conversion on GPU, we will on CPU. |
197 SkCanvasVideoRenderer::ConvertVideoFrameToRGBPixels( | 193 SkCanvasVideoRenderer::ConvertVideoFrameToRGBPixels( |
198 frame_, pixels, row_bytes); | 194 frame_, pixels, row_bytes); |
(...skipping 442 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
641 last_frame_timestamp_ = media::kNoTimestamp(); | 637 last_frame_timestamp_ = media::kNoTimestamp(); |
642 } | 638 } |
643 | 639 |
644 void SkCanvasVideoRenderer::ResetAcceleratedLastFrame() { | 640 void SkCanvasVideoRenderer::ResetAcceleratedLastFrame() { |
645 accelerated_last_frame_.reset(); | 641 accelerated_last_frame_.reset(); |
646 accelerated_generator_ = nullptr; | 642 accelerated_generator_ = nullptr; |
647 accelerated_last_frame_timestamp_ = media::kNoTimestamp(); | 643 accelerated_last_frame_timestamp_ = media::kNoTimestamp(); |
648 } | 644 } |
649 | 645 |
650 } // namespace media | 646 } // namespace media |
OLD | NEW |