-
Notifications
You must be signed in to change notification settings - Fork 6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Displaylist ColorFilter objects #31491
Merged
fluttergithubbot
merged 8 commits into
flutter:main
from
flar:displaylist-colorfilter-objects
Feb 17, 2022
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
41f7b15
move ColorFilter attributes into an inspectable DL specific object
flar 99d159a
move de-Skia-ifying code to a DlColorFilter static factory, + formatting
flar e28062f
switch to virtual methods to clean up the code a bit at the cost of 8…
flar 9969ac4
formatter updates
flar 1f15d6c
update impeller to version supporting DlColorFilter
flar 28d8cbc
fix ordering of licenses
flar 2a01090
add test to be clear that objects from shared() are copies
flar 1aa7466
doc comments
flar 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 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 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 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 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 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 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 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 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,49 @@ | ||
// 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/display_list_color_filter.h" | ||
|
||
namespace flutter { | ||
|
||
std::shared_ptr<DlColorFilter> DlColorFilter::From(SkColorFilter* sk_filter) { | ||
if (sk_filter == nullptr) { | ||
return nullptr; | ||
} | ||
if (sk_filter == DlSrgbToLinearGammaColorFilter::sk_filter_.get()) { | ||
// Skia implements these filters as a singleton. | ||
return DlSrgbToLinearGammaColorFilter::instance; | ||
} | ||
if (sk_filter == DlLinearToSrgbGammaColorFilter::sk_filter_.get()) { | ||
// Skia implements these filters as a singleton. | ||
return DlLinearToSrgbGammaColorFilter::instance; | ||
} | ||
{ | ||
SkColor color; | ||
SkBlendMode mode; | ||
if (sk_filter->asAColorMode(&color, &mode)) { | ||
return std::make_shared<DlBlendColorFilter>(color, mode); | ||
} | ||
} | ||
{ | ||
float matrix[20]; | ||
if (sk_filter->asAColorMatrix(matrix)) { | ||
return std::make_shared<DlMatrixColorFilter>(matrix); | ||
} | ||
} | ||
return std::make_shared<DlUnknownColorFilter>(sk_ref_sp(sk_filter)); | ||
} | ||
|
||
const std::shared_ptr<DlSrgbToLinearGammaColorFilter> | ||
DlSrgbToLinearGammaColorFilter::instance = | ||
std::make_shared<DlSrgbToLinearGammaColorFilter>(); | ||
const sk_sp<SkColorFilter> DlSrgbToLinearGammaColorFilter::sk_filter_ = | ||
SkColorFilters::SRGBToLinearGamma(); | ||
|
||
const std::shared_ptr<DlLinearToSrgbGammaColorFilter> | ||
DlLinearToSrgbGammaColorFilter::instance = | ||
std::make_shared<DlLinearToSrgbGammaColorFilter>(); | ||
const sk_sp<SkColorFilter> DlLinearToSrgbGammaColorFilter::sk_filter_ = | ||
SkColorFilters::LinearToSRGBGamma(); | ||
|
||
} // namespace flutter |
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there any reason to not use a shared_ptr here? Even, for example, a shared_ptr?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we do that, then when the dispatcher wants to dispatch the op from the record in the DL, it has to reinstantiate the object.
Alternately, I suppose I could back off to storing the shared_ptr in the buffer, but then equals and destructor have to visit each node and manually compare or manually destruct. One of my goals was to embed the info directly in the DL buffer so that we could mass compare and mass free the buffers.