This repository was archived by the owner on Feb 25, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 6k
Changes DlColor to support wide gamut colors (#54473) #54648
Merged
auto-submit
merged 5 commits into
flutter:main
from
gaaclarke:wide-gamut-framework-dlcolor2
Aug 20, 2024
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
107a9a2
Changes DlColor to support wide gamut colors (#54473)
gaaclarke 055303c
Made sure dlcolor is opaque black by default
gaaclarke 65d4573
fixed typo in test and added assert to avoid it
gaaclarke bbe7dd8
asserted colorspace
gaaclarke db4f334
removed asserts
gaaclarke File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
// Copyright 2013 The Flutter Authors. All rights reserved. | ||
// Use of this source code is governed by a BSD-style license that can be | ||
// found in the LICENSE file. | ||
|
||
#include "flutter/display_list/dl_color.h" | ||
|
||
namespace flutter { | ||
|
||
namespace { | ||
const std::array<DlScalar, 12> kP3ToSrgb = { | ||
1.306671048092539, -0.298061942172353, | ||
0.213228303487995, -0.213580156254466, // | ||
-0.117390025596251, 1.127722006101976, | ||
0.109727644608938, -0.109450321455370, // | ||
0.214813187718391, 0.054268702864647, | ||
1.406898424029350, -0.364892765879631}; | ||
|
||
DlColor transform(const DlColor& color, | ||
const std::array<DlScalar, 12>& matrix, | ||
DlColorSpace color_space) { | ||
return DlColor(color.getAlphaF(), | ||
matrix[0] * color.getRedF() + // | ||
matrix[1] * color.getGreenF() + // | ||
matrix[2] * color.getBlueF() + // | ||
matrix[3], // | ||
matrix[4] * color.getRedF() + // | ||
matrix[5] * color.getGreenF() + // | ||
matrix[6] * color.getBlueF() + // | ||
matrix[7], // | ||
matrix[8] * color.getRedF() + // | ||
matrix[9] * color.getGreenF() + // | ||
matrix[10] * color.getBlueF() + // | ||
matrix[11], // | ||
color_space); | ||
} | ||
} // namespace | ||
|
||
DlColor DlColor::withColorSpace(DlColorSpace color_space) const { | ||
switch (color_space_) { | ||
case DlColorSpace::kSRGB: | ||
switch (color_space) { | ||
case DlColorSpace::kSRGB: | ||
return *this; | ||
case DlColorSpace::kExtendedSRGB: | ||
return DlColor(alpha_, red_, green_, blue_, | ||
DlColorSpace::kExtendedSRGB); | ||
case DlColorSpace::kDisplayP3: | ||
FML_CHECK(false) << "not implemented"; | ||
return *this; | ||
} | ||
case DlColorSpace::kExtendedSRGB: | ||
switch (color_space) { | ||
case DlColorSpace::kSRGB: | ||
FML_CHECK(false) << "not implemented"; | ||
return *this; | ||
case DlColorSpace::kExtendedSRGB: | ||
return *this; | ||
case DlColorSpace::kDisplayP3: | ||
FML_CHECK(false) << "not implemented"; | ||
return *this; | ||
} | ||
case DlColorSpace::kDisplayP3: | ||
switch (color_space) { | ||
case DlColorSpace::kSRGB: | ||
FML_CHECK(false) << "not implemented"; | ||
return *this; | ||
case DlColorSpace::kExtendedSRGB: | ||
return transform(*this, kP3ToSrgb, DlColorSpace::kExtendedSRGB); | ||
case DlColorSpace::kDisplayP3: | ||
return *this; | ||
} | ||
} | ||
} | ||
|
||
} // namespace flutter |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.