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 <limits> | 7 #include <limits> |
8 | 8 |
9 #include "base/macros.h" | 9 #include "base/macros.h" |
10 #include "gpu/GLES2/gl2extchromium.h" | 10 #include "gpu/GLES2/gl2extchromium.h" |
(...skipping 769 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
780 last_image_ = | 780 last_image_ = |
781 NewSkImageFromVideoFrameYUVTextures(video_frame.get(), context_3d); | 781 NewSkImageFromVideoFrameYUVTextures(video_frame.get(), context_3d); |
782 } else { | 782 } else { |
783 last_image_ = | 783 last_image_ = |
784 NewSkImageFromVideoFrameNative(video_frame.get(), context_3d); | 784 NewSkImageFromVideoFrameNative(video_frame.get(), context_3d); |
785 } | 785 } |
786 } else { | 786 } else { |
787 auto* video_generator = new VideoImageGenerator(video_frame); | 787 auto* video_generator = new VideoImageGenerator(video_frame); |
788 last_image_ = SkImage::MakeFromGenerator(video_generator); | 788 last_image_ = SkImage::MakeFromGenerator(video_generator); |
789 } | 789 } |
| 790 CorrectLastImageDimensions(gfx::RectToSkIRect(video_frame->visible_rect())); |
790 if (!last_image_) // Couldn't create the SkImage. | 791 if (!last_image_) // Couldn't create the SkImage. |
791 return false; | 792 return false; |
792 last_timestamp_ = video_frame->timestamp(); | 793 last_timestamp_ = video_frame->timestamp(); |
793 } | 794 } |
794 last_image_deleting_timer_.Reset(); | 795 last_image_deleting_timer_.Reset(); |
795 DCHECK(!!last_image_); | 796 DCHECK(!!last_image_); |
796 return true; | 797 return true; |
797 } | 798 } |
798 | 799 |
| 800 void SkCanvasVideoRenderer::CorrectLastImageDimensions( |
| 801 const SkIRect& visible_rect) { |
| 802 last_image_dimensions_for_testing_ = visible_rect.size(); |
| 803 if (!last_image_) |
| 804 return; |
| 805 if (last_image_->dimensions() != visible_rect.size() && |
| 806 last_image_->bounds().contains(visible_rect)) { |
| 807 last_image_ = last_image_->makeSubset(visible_rect); |
| 808 } |
| 809 } |
| 810 |
| 811 SkISize SkCanvasVideoRenderer::LastImageDimensionsForTesting() { |
| 812 return last_image_dimensions_for_testing_; |
| 813 } |
| 814 |
799 } // namespace media | 815 } // namespace media |
OLD | NEW |