-
Notifications
You must be signed in to change notification settings - Fork 481
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(🏞️): fix default image sampling and add full control of sampling…
… options (#2880) fixes #2507 This adds full control to the sampling options to the user but it also fix the default sampling options as well as making it consistent on all APIs (image, atlas, shader in declarative/imperative).
- Loading branch information
1 parent
d54e29b
commit 8b14242
Showing
28 changed files
with
279 additions
and
112 deletions.
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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,54 @@ | ||
#pragma once | ||
|
||
#include "include/core/SkSamplingOptions.h" | ||
|
||
namespace RNSkia { | ||
|
||
static PropId PropNameCubicB = JsiPropId::get("B"); | ||
static PropId PropNameCubicC = JsiPropId::get("C"); | ||
static PropId PropNameFilter = JsiPropId::get("filter"); | ||
static PropId PropNameMipmap = JsiPropId::get("mipmap"); | ||
|
||
class SamplingProp : public DerivedProp<SkSamplingOptions> { | ||
public: | ||
explicit SamplingProp(PropId name, | ||
const std::function<void(BaseNodeProp *)> &onChange) | ||
: DerivedProp(onChange) { | ||
_prop = defineProperty<NodeProp>(name); | ||
} | ||
|
||
static SkSamplingOptions processSamplingOptions(const JsiValue &value) { | ||
SkSamplingOptions samplingOptions(SkFilterMode::kLinear); | ||
if (value.getType() == PropType::Object) { | ||
if (value.hasValue(PropNameCubicB) && value.hasValue(PropNameCubicC)) { | ||
auto B = | ||
static_cast<float>(value.getValue(PropNameCubicB).getAsNumber()); | ||
auto C = | ||
static_cast<float>(value.getValue(PropNameCubicC).getAsNumber()); | ||
samplingOptions = SkSamplingOptions({B, C}); | ||
} else if (value.hasValue(PropNameFilter)) { | ||
auto filter = static_cast<SkFilterMode>( | ||
value.getValue(PropNameFilter).getAsNumber()); | ||
if (value.hasValue(PropNameMipmap)) { | ||
auto mipmap = static_cast<SkMipmapMode>( | ||
value.getValue(PropNameMipmap).getAsNumber()); | ||
samplingOptions = SkSamplingOptions(filter, mipmap); | ||
} else { | ||
samplingOptions = SkSamplingOptions(filter); | ||
} | ||
} | ||
} | ||
|
||
return samplingOptions; | ||
} | ||
|
||
void updateDerivedValue() override { | ||
if (_prop->isSet()) { | ||
setDerivedValue(SamplingProp::processSamplingOptions(_prop->value())); | ||
} | ||
} | ||
|
||
private: | ||
NodeProp *_prop; | ||
}; | ||
} // namespace RNSkia |
Binary file modified
BIN
+29.8 KB
(200%)
packages/skia/src/__tests__/snapshots/animated-images/bird.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
+5.11 KB
(110%)
packages/skia/src/__tests__/snapshots/images/bundle-android.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
+4.89 KB
(110%)
packages/skia/src/__tests__/snapshots/images/bundle-node.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.