Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(327)

Side by Side Diff: ui/gfx/color_space.cc

Issue 2728173004: HDR: Do nonlinear blending in the compositor (Closed)
Patch Set: Fix windows build Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « ui/gfx/color_space.h ('k') | ui/gfx/color_space_win.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "ui/gfx/color_space.h" 5 #include "ui/gfx/color_space.h"
6 6
7 #include <map> 7 #include <map>
8 8
9 #include "base/lazy_instance.h" 9 #include "base/lazy_instance.h"
10 #include "base/synchronization/lock.h" 10 #include "base/synchronization/lock.h"
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after
194 matrix_ != MatrixID::INVALID && range_ != RangeID::INVALID; 194 matrix_ != MatrixID::INVALID && range_ != RangeID::INVALID;
195 } 195 }
196 196
197 // static 197 // static
198 ColorSpace ColorSpace::CreateSRGB() { 198 ColorSpace ColorSpace::CreateSRGB() {
199 return ColorSpace(PrimaryID::BT709, TransferID::IEC61966_2_1, MatrixID::RGB, 199 return ColorSpace(PrimaryID::BT709, TransferID::IEC61966_2_1, MatrixID::RGB,
200 RangeID::FULL); 200 RangeID::FULL);
201 } 201 }
202 202
203 // static 203 // static
204 ColorSpace ColorSpace::CreateExtendedSRGB() {
205 return ColorSpace(PrimaryID::BT709, TransferID::IEC61966_2_1_HDR,
206 MatrixID::RGB, RangeID::FULL);
207 }
208
209 // static
204 ColorSpace ColorSpace::CreateCustom(const SkMatrix44& to_XYZD50, 210 ColorSpace ColorSpace::CreateCustom(const SkMatrix44& to_XYZD50,
205 const SkColorSpaceTransferFn& fn) { 211 const SkColorSpaceTransferFn& fn) {
206 ColorSpace result(ColorSpace::PrimaryID::CUSTOM, 212 ColorSpace result(ColorSpace::PrimaryID::CUSTOM,
207 ColorSpace::TransferID::CUSTOM, ColorSpace::MatrixID::RGB, 213 ColorSpace::TransferID::CUSTOM, ColorSpace::MatrixID::RGB,
208 ColorSpace::RangeID::FULL); 214 ColorSpace::RangeID::FULL);
209 for (int row = 0; row < 3; ++row) { 215 for (int row = 0; row < 3; ++row) {
210 for (int col = 0; col < 3; ++col) { 216 for (int col = 0; col < 3; ++col) {
211 result.custom_primary_matrix_[3 * row + col] = to_XYZD50.get(row, col); 217 result.custom_primary_matrix_[3 * row + col] = to_XYZD50.get(row, col);
212 } 218 }
213 } 219 }
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
265 if (transfer_ == TransferID::CUSTOM && 271 if (transfer_ == TransferID::CUSTOM &&
266 memcmp(custom_transfer_params_, other.custom_transfer_params_, 272 memcmp(custom_transfer_params_, other.custom_transfer_params_,
267 sizeof(custom_transfer_params_))) 273 sizeof(custom_transfer_params_)))
268 return false; 274 return false;
269 return true; 275 return true;
270 } 276 }
271 277
272 bool ColorSpace::IsHDR() const { 278 bool ColorSpace::IsHDR() const {
273 return transfer_ == TransferID::SMPTEST2084 || 279 return transfer_ == TransferID::SMPTEST2084 ||
274 transfer_ == TransferID::ARIB_STD_B67 || 280 transfer_ == TransferID::ARIB_STD_B67 ||
275 transfer_ == TransferID::LINEAR_HDR; 281 transfer_ == TransferID::LINEAR_HDR ||
282 transfer_ == TransferID::IEC61966_2_1_HDR;
276 } 283 }
277 284
278 bool ColorSpace::operator!=(const ColorSpace& other) const { 285 bool ColorSpace::operator!=(const ColorSpace& other) const {
279 return !(*this == other); 286 return !(*this == other);
280 } 287 }
281 288
282 bool ColorSpace::operator<(const ColorSpace& other) const { 289 bool ColorSpace::operator<(const ColorSpace& other) const {
283 if (primaries_ < other.primaries_) 290 if (primaries_ < other.primaries_)
284 return true; 291 return true;
285 if (primaries_ > other.primaries_) 292 if (primaries_ > other.primaries_)
(...skipping 323 matching lines...) Expand 10 before | Expand all | Expand 10 after
609 fn->fG = 2.222222222222f; 616 fn->fG = 2.222222222222f;
610 return true; 617 return true;
611 case ColorSpace::TransferID::SMPTE240M: 618 case ColorSpace::TransferID::SMPTE240M:
612 fn->fA = 0.899626676224f; 619 fn->fA = 0.899626676224f;
613 fn->fB = 0.100373323776f; 620 fn->fB = 0.100373323776f;
614 fn->fC = 0.250000000000f; 621 fn->fC = 0.250000000000f;
615 fn->fD = 0.091286342118f; 622 fn->fD = 0.091286342118f;
616 fn->fG = 2.222222222222f; 623 fn->fG = 2.222222222222f;
617 return true; 624 return true;
618 case ColorSpace::TransferID::IEC61966_2_1: 625 case ColorSpace::TransferID::IEC61966_2_1:
626 case ColorSpace::TransferID::IEC61966_2_1_HDR:
619 fn->fA = 0.947867345704f; 627 fn->fA = 0.947867345704f;
620 fn->fB = 0.052132654296f; 628 fn->fB = 0.052132654296f;
621 fn->fC = 0.077399380805f; 629 fn->fC = 0.077399380805f;
622 fn->fD = 0.040449937172f; 630 fn->fD = 0.040449937172f;
623 fn->fG = 2.400000000000f; 631 fn->fG = 2.400000000000f;
624 return true; 632 return true;
625 case ColorSpace::TransferID::SMPTEST428_1: 633 case ColorSpace::TransferID::SMPTEST428_1:
626 fn->fA = 0.225615407568f; 634 fn->fA = 0.225615407568f;
627 fn->fE = -1.091041666667f; 635 fn->fE = -1.091041666667f;
628 fn->fG = 2.600000000000f; 636 fn->fG = 2.600000000000f;
(...skipping 15 matching lines...) Expand all
644 return false; 652 return false;
645 } 653 }
646 654
647 bool ColorSpace::GetInverseTransferFunction(SkColorSpaceTransferFn* fn) const { 655 bool ColorSpace::GetInverseTransferFunction(SkColorSpaceTransferFn* fn) const {
648 if (!GetTransferFunction(fn)) 656 if (!GetTransferFunction(fn))
649 return false; 657 return false;
650 *fn = SkTransferFnInverse(*fn); 658 *fn = SkTransferFnInverse(*fn);
651 return true; 659 return true;
652 } 660 }
653 661
662 bool ColorSpace::HasExtendedSkTransferFn() const {
663 return transfer_ == TransferID::LINEAR_HDR ||
664 transfer_ == TransferID::IEC61966_2_1_HDR;
665 }
666
654 void ColorSpace::GetTransferMatrix(SkMatrix44* matrix) const { 667 void ColorSpace::GetTransferMatrix(SkMatrix44* matrix) const {
655 float Kr = 0; 668 float Kr = 0;
656 float Kb = 0; 669 float Kb = 0;
657 switch (matrix_) { 670 switch (matrix_) {
658 case ColorSpace::MatrixID::RGB: 671 case ColorSpace::MatrixID::RGB:
659 case ColorSpace::MatrixID::INVALID: 672 case ColorSpace::MatrixID::INVALID:
660 matrix->setIdentity(); 673 matrix->setIdentity();
661 return; 674 return;
662 675
663 case ColorSpace::MatrixID::BT709: 676 case ColorSpace::MatrixID::BT709:
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
764 case MatrixID::BT2020_NCL: 777 case MatrixID::BT2020_NCL:
765 case MatrixID::BT2020_CL: 778 case MatrixID::BT2020_CL:
766 case MatrixID::YDZDX: 779 case MatrixID::YDZDX:
767 matrix->setScale(255.0f/219.0f, 255.0f/224.0f, 255.0f/224.0f); 780 matrix->setScale(255.0f/219.0f, 255.0f/224.0f, 255.0f/224.0f);
768 matrix->postTranslate(-16.0f/219.0f, -15.5f/224.0f, -15.5f/224.0f); 781 matrix->postTranslate(-16.0f/219.0f, -15.5f/224.0f, -15.5f/224.0f);
769 break; 782 break;
770 } 783 }
771 } 784 }
772 785
773 } // namespace gfx 786 } // namespace gfx
OLDNEW
« no previous file with comments | « ui/gfx/color_space.h ('k') | ui/gfx/color_space_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698