| 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 <stddef.h> | 7 #include <stddef.h> |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <algorithm> | 10 #include <algorithm> |
| (...skipping 410 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 421 case media::PIXEL_FORMAT_YUV420P12: | 421 case media::PIXEL_FORMAT_YUV420P12: |
| 422 case media::PIXEL_FORMAT_YUV422P12: | 422 case media::PIXEL_FORMAT_YUV422P12: |
| 423 case media::PIXEL_FORMAT_YUV444P12: | 423 case media::PIXEL_FORMAT_YUV444P12: |
| 424 bits_per_channel = 12; | 424 bits_per_channel = 12; |
| 425 break; | 425 break; |
| 426 case media::PIXEL_FORMAT_Y16: | 426 case media::PIXEL_FORMAT_Y16: |
| 427 bits_per_channel = 16; | 427 bits_per_channel = 16; |
| 428 break; | 428 break; |
| 429 } | 429 } |
| 430 | 430 |
| 431 // TODO(dshwang): support PIXEL_FORMAT_Y16. crbug.com/624436 | 431 // Only YUV and Y16 software video frames are supported. |
| 432 DCHECK_NE(bits_per_channel, 16); | 432 DCHECK(media::IsYuvPlanar(input_frame_format) || |
| 433 | 433 input_frame_format == media::PIXEL_FORMAT_Y16); |
| 434 // Only YUV software video frames are supported. | |
| 435 if (!media::IsYuvPlanar(input_frame_format)) { | |
| 436 NOTREACHED() << media::VideoPixelFormatToString(input_frame_format); | |
| 437 return VideoFrameExternalResources(); | |
| 438 } | |
| 439 | 434 |
| 440 const bool software_compositor = context_provider_ == NULL; | 435 const bool software_compositor = context_provider_ == NULL; |
| 441 | 436 |
| 442 ResourceFormat output_resource_format = | 437 ResourceFormat output_resource_format; |
| 443 resource_provider_->YuvResourceFormat(bits_per_channel); | 438 if (input_frame_format == media::PIXEL_FORMAT_Y16) { |
| 439 // Unable to display directly as yuv planes so convert it to RGBA for |
| 440 // compositing. |
| 441 output_resource_format = RGBA_8888; |
| 442 } else { |
| 443 // Can be composited directly from yuv planes. |
| 444 output_resource_format = |
| 445 resource_provider_->YuvResourceFormat(bits_per_channel); |
| 446 } |
| 444 | 447 |
| 445 // If GPU compositing is enabled, but the output resource format | 448 // If GPU compositing is enabled, but the output resource format |
| 446 // returned by the resource provider is RGBA_8888, then a GPU driver | 449 // returned by the resource provider is RGBA_8888, then a GPU driver |
| 447 // bug workaround requires that YUV frames must be converted to RGB | 450 // bug workaround requires that YUV frames must be converted to RGB |
| 448 // before texture upload. | 451 // before texture upload. |
| 449 bool texture_needs_rgb_conversion = | 452 bool texture_needs_rgb_conversion = |
| 450 !software_compositor && | 453 !software_compositor && |
| 451 output_resource_format == ResourceFormat::RGBA_8888; | 454 output_resource_format == ResourceFormat::RGBA_8888; |
| 452 size_t output_plane_count = media::VideoFrame::NumPlanes(input_frame_format); | 455 size_t output_plane_count = media::VideoFrame::NumPlanes(input_frame_format); |
| 453 | 456 |
| (...skipping 347 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 801 if (lost_resource) { | 804 if (lost_resource) { |
| 802 resource_it->clear_refs(); | 805 resource_it->clear_refs(); |
| 803 updater->DeleteResource(resource_it); | 806 updater->DeleteResource(resource_it); |
| 804 return; | 807 return; |
| 805 } | 808 } |
| 806 | 809 |
| 807 resource_it->remove_ref(); | 810 resource_it->remove_ref(); |
| 808 } | 811 } |
| 809 | 812 |
| 810 } // namespace cc | 813 } // namespace cc |
| OLD | NEW |