| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "cc/resources/video_resource_updater.h" | 5 #include "cc/resources/video_resource_updater.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "cc/output/gl_renderer.h" | 8 #include "cc/output/gl_renderer.h" |
| 9 #include "cc/resources/resource_provider.h" | 9 #include "cc/resources/resource_provider.h" |
| 10 #include "gpu/GLES2/gl2extchromium.h" | 10 #include "gpu/GLES2/gl2extchromium.h" |
| (...skipping 28 matching lines...) Expand all Loading... |
| 39 const scoped_refptr<media::VideoFrame>& video_frame) { | 39 const scoped_refptr<media::VideoFrame>& video_frame) { |
| 40 // If these fail, we'll have to add logic that handles offset bitmap/texture | 40 // If these fail, we'll have to add logic that handles offset bitmap/texture |
| 41 // UVs. For now, just expect (0, 0) offset, since all our decoders so far | 41 // UVs. For now, just expect (0, 0) offset, since all our decoders so far |
| 42 // don't offset. | 42 // don't offset. |
| 43 DCHECK_EQ(video_frame->visible_rect().x(), 0); | 43 DCHECK_EQ(video_frame->visible_rect().x(), 0); |
| 44 DCHECK_EQ(video_frame->visible_rect().y(), 0); | 44 DCHECK_EQ(video_frame->visible_rect().y(), 0); |
| 45 | 45 |
| 46 switch (video_frame->format()) { | 46 switch (video_frame->format()) { |
| 47 // Acceptable inputs. | 47 // Acceptable inputs. |
| 48 case media::VideoFrame::YV12: | 48 case media::VideoFrame::YV12: |
| 49 case media::VideoFrame::YV12A: | |
| 50 case media::VideoFrame::YV16: | 49 case media::VideoFrame::YV16: |
| 51 case media::VideoFrame::NATIVE_TEXTURE: | 50 case media::VideoFrame::NATIVE_TEXTURE: |
| 52 #if defined(GOOGLE_TV) | 51 #if defined(GOOGLE_TV) |
| 53 case media::VideoFrame::HOLE: | 52 case media::VideoFrame::HOLE: |
| 54 #endif | 53 #endif |
| 55 return true; | 54 return true; |
| 56 | 55 |
| 57 // Unacceptable inputs. ¯\(°_o)/¯ | 56 // Unacceptable inputs. ¯\(°_o)/¯ |
| 58 case media::VideoFrame::INVALID: | 57 case media::VideoFrame::INVALID: |
| 59 case media::VideoFrame::RGB32: | 58 case media::VideoFrame::RGB32: |
| (...skipping 10 matching lines...) Expand all Loading... |
| 70 media::VideoFrame::Format input_frame_format, | 69 media::VideoFrame::Format input_frame_format, |
| 71 gfx::Size coded_size, | 70 gfx::Size coded_size, |
| 72 GLenum output_resource_format, | 71 GLenum output_resource_format, |
| 73 int plane_index) { | 72 int plane_index) { |
| 74 if (output_resource_format == kYUVResourceFormat) { | 73 if (output_resource_format == kYUVResourceFormat) { |
| 75 if (plane_index == media::VideoFrame::kYPlane) | 74 if (plane_index == media::VideoFrame::kYPlane) |
| 76 return coded_size; | 75 return coded_size; |
| 77 | 76 |
| 78 switch (input_frame_format) { | 77 switch (input_frame_format) { |
| 79 case media::VideoFrame::YV12: | 78 case media::VideoFrame::YV12: |
| 80 case media::VideoFrame::YV12A: | |
| 81 return gfx::ToFlooredSize(gfx::ScaleSize(coded_size, 0.5f, 0.5f)); | 79 return gfx::ToFlooredSize(gfx::ScaleSize(coded_size, 0.5f, 0.5f)); |
| 82 case media::VideoFrame::YV16: | 80 case media::VideoFrame::YV16: |
| 83 return gfx::ToFlooredSize(gfx::ScaleSize(coded_size, 0.5f, 1.f)); | 81 return gfx::ToFlooredSize(gfx::ScaleSize(coded_size, 0.5f, 1.f)); |
| 84 | 82 |
| 85 case media::VideoFrame::INVALID: | 83 case media::VideoFrame::INVALID: |
| 86 case media::VideoFrame::RGB32: | 84 case media::VideoFrame::RGB32: |
| 87 case media::VideoFrame::EMPTY: | 85 case media::VideoFrame::EMPTY: |
| 88 case media::VideoFrame::I420: | 86 case media::VideoFrame::I420: |
| 89 case media::VideoFrame::NATIVE_TEXTURE: | 87 case media::VideoFrame::NATIVE_TEXTURE: |
| 90 #if defined(GOOGLE_TV) | 88 #if defined(GOOGLE_TV) |
| (...skipping 17 matching lines...) Expand all Loading... |
| 108 #if defined(GOOGLE_TV) | 106 #if defined(GOOGLE_TV) |
| 109 if (input_frame_format == media::VideoFrame::HOLE) { | 107 if (input_frame_format == media::VideoFrame::HOLE) { |
| 110 VideoFrameExternalResources external_resources; | 108 VideoFrameExternalResources external_resources; |
| 111 external_resources.type = VideoFrameExternalResources::HOLE; | 109 external_resources.type = VideoFrameExternalResources::HOLE; |
| 112 return external_resources; | 110 return external_resources; |
| 113 } | 111 } |
| 114 #endif | 112 #endif |
| 115 | 113 |
| 116 // Only YUV software video frames are supported. | 114 // Only YUV software video frames are supported. |
| 117 DCHECK(input_frame_format == media::VideoFrame::YV12 || | 115 DCHECK(input_frame_format == media::VideoFrame::YV12 || |
| 118 input_frame_format == media::VideoFrame::YV12A || | |
| 119 input_frame_format == media::VideoFrame::YV16); | 116 input_frame_format == media::VideoFrame::YV16); |
| 120 if (input_frame_format != media::VideoFrame::YV12 && | 117 if (input_frame_format != media::VideoFrame::YV12 && |
| 121 input_frame_format != media::VideoFrame::YV12A && | |
| 122 input_frame_format != media::VideoFrame::YV16) | 118 input_frame_format != media::VideoFrame::YV16) |
| 123 return VideoFrameExternalResources(); | 119 return VideoFrameExternalResources(); |
| 124 | 120 |
| 125 bool software_compositor = !resource_provider_->GraphicsContext3D(); | 121 bool software_compositor = !resource_provider_->GraphicsContext3D(); |
| 126 | 122 |
| 127 GLenum output_resource_format = kYUVResourceFormat; | 123 GLenum output_resource_format = kYUVResourceFormat; |
| 128 size_t output_plane_count = 3; | 124 size_t output_plane_count = 3; |
| 129 | 125 |
| 130 // TODO(skaslev): If we're in software compositing mode, we do the YUV -> RGB | 126 // TODO(skaslev): If we're in software compositing mode, we do the YUV -> RGB |
| 131 // conversion here. That involves an extra copy of each frame to a bitmap. | 127 // conversion here. That involves an extra copy of each frame to a bitmap. |
| (...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 382 } | 378 } |
| 383 | 379 |
| 384 PlaneResource recycled_resource(data.resource_id, | 380 PlaneResource recycled_resource(data.resource_id, |
| 385 data.resource_size, | 381 data.resource_size, |
| 386 data.resource_format, | 382 data.resource_format, |
| 387 sync_point); | 383 sync_point); |
| 388 updater->recycled_resources_.push_back(recycled_resource); | 384 updater->recycled_resources_.push_back(recycled_resource); |
| 389 } | 385 } |
| 390 | 386 |
| 391 } // namespace cc | 387 } // namespace cc |
| OLD | NEW |