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 454 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
465 | 465 |
466 std::unique_ptr<media::HalfFloatMaker> half_float_maker; | 466 std::unique_ptr<media::HalfFloatMaker> half_float_maker; |
467 if (resource_provider_->YuvResourceFormat(bits_per_channel) == | 467 if (resource_provider_->YuvResourceFormat(bits_per_channel) == |
468 viz::LUMINANCE_F16) { | 468 viz::LUMINANCE_F16) { |
469 half_float_maker = | 469 half_float_maker = |
470 media::HalfFloatMaker::NewHalfFloatMaker(bits_per_channel); | 470 media::HalfFloatMaker::NewHalfFloatMaker(bits_per_channel); |
471 external_resources.offset = half_float_maker->Offset(); | 471 external_resources.offset = half_float_maker->Offset(); |
472 external_resources.multiplier = half_float_maker->Multiplier(); | 472 external_resources.multiplier = half_float_maker->Multiplier(); |
473 } | 473 } |
474 | 474 |
| 475 if (resource_provider_->YuvResourceFormat(bits_per_channel) == viz::R16_EXT) { |
| 476 int shift = 16 - bits_per_channel; |
| 477 external_resources.multiplier = |
| 478 (1 << shift) + 1.0 / (1 << (bits_per_channel - shift)); |
| 479 external_resources.offset = 0; |
| 480 } |
| 481 |
475 for (size_t i = 0; i < plane_resources.size(); ++i) { | 482 for (size_t i = 0; i < plane_resources.size(); ++i) { |
476 PlaneResource& plane_resource = *plane_resources[i]; | 483 PlaneResource& plane_resource = *plane_resources[i]; |
477 // Update each plane's resource id with its content. | 484 // Update each plane's resource id with its content. |
478 DCHECK_EQ(plane_resource.resource_format(), | 485 DCHECK_EQ(plane_resource.resource_format(), |
479 resource_provider_->YuvResourceFormat(bits_per_channel)); | 486 resource_provider_->YuvResourceFormat(bits_per_channel)); |
480 | 487 |
481 if (!plane_resource.Matches(video_frame->unique_id(), i)) { | 488 if (!plane_resource.Matches(video_frame->unique_id(), i)) { |
482 // TODO(hubbe): Move upload code to media/. | 489 // TODO(hubbe): Move upload code to media/. |
483 // We need to transfer data from |video_frame| to the plane resource. | 490 // We need to transfer data from |video_frame| to the plane resource. |
484 // TODO(reveman): Can use GpuMemoryBuffers here to improve performance. | 491 // TODO(reveman): Can use GpuMemoryBuffers here to improve performance. |
(...skipping 12 matching lines...) Expand all Loading... |
497 size_t upload_image_stride = | 504 size_t upload_image_stride = |
498 MathUtil::CheckedRoundUp<size_t>(bytes_per_row, 4u); | 505 MathUtil::CheckedRoundUp<size_t>(bytes_per_row, 4u); |
499 | 506 |
500 bool needs_conversion = false; | 507 bool needs_conversion = false; |
501 int shift = 0; | 508 int shift = 0; |
502 | 509 |
503 // viz::LUMINANCE_F16 uses half-floats, so we always need a conversion | 510 // viz::LUMINANCE_F16 uses half-floats, so we always need a conversion |
504 // step. | 511 // step. |
505 if (plane_resource.resource_format() == viz::LUMINANCE_F16) { | 512 if (plane_resource.resource_format() == viz::LUMINANCE_F16) { |
506 needs_conversion = true; | 513 needs_conversion = true; |
| 514 } else if (plane_resource.resource_format() == viz::R16_EXT) { |
| 515 // R16_EXT can represent 16-bit int, so we don't need a conversion step. |
| 516 needs_conversion = false; |
507 } else if (bits_per_channel > 8) { | 517 } else if (bits_per_channel > 8) { |
508 // If bits_per_channel > 8 and we can't use viz::LUMINANCE_F16, we need | 518 // If bits_per_channel > 8 and we can't use viz::LUMINANCE_F16, we need |
509 // to shift the data down and create an 8-bit texture. | 519 // to shift the data down and create an 8-bit texture. |
510 needs_conversion = true; | 520 needs_conversion = true; |
511 shift = bits_per_channel - 8; | 521 shift = bits_per_channel - 8; |
512 } | 522 } |
513 const uint8_t* pixels; | 523 const uint8_t* pixels; |
514 if (static_cast<int>(upload_image_stride) == video_stride_bytes && | 524 if (static_cast<int>(upload_image_stride) == video_stride_bytes && |
515 !needs_conversion) { | 525 !needs_conversion) { |
516 pixels = video_frame->data(i); | 526 pixels = video_frame->data(i); |
(...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
731 if (lost_resource) { | 741 if (lost_resource) { |
732 resource_it->clear_refs(); | 742 resource_it->clear_refs(); |
733 updater->DeleteResource(resource_it); | 743 updater->DeleteResource(resource_it); |
734 return; | 744 return; |
735 } | 745 } |
736 | 746 |
737 resource_it->remove_ref(); | 747 resource_it->remove_ref(); |
738 } | 748 } |
739 | 749 |
740 } // namespace cc | 750 } // namespace cc |
OLD | NEW |