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 "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 372 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
383 int y_shift = (frame_->format() == media::VideoFrame::YV16) ? 0 : 1; | 383 int y_shift = (frame_->format() == media::VideoFrame::YV16) ? 0 : 1; |
384 if (plane == media::VideoFrame::kYPlane) { | 384 if (plane == media::VideoFrame::kYPlane) { |
385 offset = (frame_->stride(media::VideoFrame::kYPlane) * | 385 offset = (frame_->stride(media::VideoFrame::kYPlane) * |
386 frame_->visible_rect().y()) + | 386 frame_->visible_rect().y()) + |
387 frame_->visible_rect().x(); | 387 frame_->visible_rect().x(); |
388 } else { | 388 } else { |
389 offset = (frame_->stride(media::VideoFrame::kUPlane) * | 389 offset = (frame_->stride(media::VideoFrame::kUPlane) * |
390 (frame_->visible_rect().y() >> y_shift)) + | 390 (frame_->visible_rect().y() >> y_shift)) + |
391 (frame_->visible_rect().x() >> 1); | 391 (frame_->visible_rect().x() >> 1); |
392 } | 392 } |
393 row_bytes[plane] = static_cast<size_t>(frame_->stride(plane)); | 393 |
394 planes[plane] = frame_->data(plane) + offset; | 394 // Copy the frame to the supplied memory. |
| 395 // TODO: Find a way (API change?) to avoid this copy. |
| 396 char* out_line = static_cast<char*>(planes[plane]); |
| 397 int out_line_stride = row_bytes[plane]; |
| 398 uint8* in_line = frame_->data(plane) + offset; |
| 399 int in_line_stride = frame_->stride(plane); |
| 400 int plane_height = sizes[plane].height(); |
| 401 if (in_line_stride == out_line_stride) { |
| 402 memcpy(out_line, in_line, plane_height * in_line_stride); |
| 403 } else { |
| 404 // Different line padding so need to copy one line at a time. |
| 405 int bytes_to_copy_per_line = out_line_stride < in_line_stride |
| 406 ? out_line_stride |
| 407 : in_line_stride; |
| 408 for (int line_no = 0; line_no < plane_height; line_no++) { |
| 409 memcpy(out_line, in_line, bytes_to_copy_per_line); |
| 410 in_line += in_line_stride; |
| 411 out_line += out_line_stride; |
| 412 } |
| 413 } |
395 } | 414 } |
396 } | 415 } |
397 return true; | 416 return true; |
398 } | 417 } |
399 | 418 |
400 private: | 419 private: |
401 scoped_refptr<VideoFrame> frame_; | 420 scoped_refptr<VideoFrame> frame_; |
402 | 421 |
403 DISALLOW_IMPLICIT_CONSTRUCTORS(VideoImageGenerator); | 422 DISALLOW_IMPLICIT_CONSTRUCTORS(VideoImageGenerator); |
404 }; | 423 }; |
(...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
616 last_frame_timestamp_ = media::kNoTimestamp(); | 635 last_frame_timestamp_ = media::kNoTimestamp(); |
617 } | 636 } |
618 | 637 |
619 void SkCanvasVideoRenderer::ResetAcceleratedLastFrame() { | 638 void SkCanvasVideoRenderer::ResetAcceleratedLastFrame() { |
620 accelerated_last_frame_.reset(); | 639 accelerated_last_frame_.reset(); |
621 accelerated_generator_ = nullptr; | 640 accelerated_generator_ = nullptr; |
622 accelerated_last_frame_timestamp_ = media::kNoTimestamp(); | 641 accelerated_last_frame_timestamp_ = media::kNoTimestamp(); |
623 } | 642 } |
624 | 643 |
625 } // namespace media | 644 } // namespace media |
OLD | NEW |