Skip to content

Commit

Permalink
优化代码,无功能更新
Browse files Browse the repository at this point in the history
  • Loading branch information
sswi committed Feb 24, 2024
1 parent 787e769 commit aeacd41
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 11 deletions.
2 changes: 1 addition & 1 deletion AcrylicView.Samples/AcrylicView.Samples.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@
<Folder Include="Resources\Raw\Video\" />
</ItemGroup>

<ProjectExtensions><VisualStudio><UserProperties XamarinHotReloadWrongLinkerErrorInfoBarAcrylicViewSamplesHideInfoBar="True" /></VisualStudio></ProjectExtensions>
<ProjectExtensions><VisualStudio><UserProperties XamarinHotReloadDebuggerTimeoutExceptionAcrylicViewSamplesHideInfoBar="True" XamarinHotReloadWrongLinkerErrorInfoBarAcrylicViewSamplesHideInfoBar="True" /></VisualStudio></ProjectExtensions>

<ItemGroup>
<PackageReference Include="Microsoft.Maui.Controls" Version="8.0.7" />
Expand Down
6 changes: 2 additions & 4 deletions AcrylicView.Samples/MainPage.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -53,12 +53,10 @@
RowSpacing="20">

<!-- Row 1 -->
<ui:AcrylicView
BorderColor="WhiteSmoke"
<ui:AcrylicView BorderColor="WhiteSmoke"
BorderThickness="1"
CornerRadius="20">
<Grid
ColumnDefinitions="*,*,*,*"
<Grid ColumnDefinitions="*,*,*,*"
VerticalOptions="Center">
<StackLayout HorizontalOptions="Center">
<Label Style="{StaticResource IconStyle}"
Expand Down
2 changes: 1 addition & 1 deletion AcrylicView/Controls/AcrylicViewHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
{
public partial class AcrylicViewHandler
{
private static readonly PropertyMapper<IAcrylicView, AcrylicViewHandler> propertyMapper = new(ViewMapper)
private static readonly PropertyMapper<IAcrylicView, AcrylicViewHandler> propertyMapper = new()
{
[nameof(IAcrylicView.CornerRadius)] = MapCornerRadius,
[nameof(IAcrylicView.TintColor)] = MapTintColor,
Expand Down
2 changes: 1 addition & 1 deletion AcrylicView/Platforms/Android/AcrylicViewHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ private void UpdateColorblendLayer(IAcrylicView view)
{
if ((view.TintColor == null || view.TintColor == Colors.Transparent) && view.EffectStyle == EffectStyle.Custom)
{
colorBlendLayer.SetBackgroundDrawable(null);
colorBlendLayer.SetBackgroundDrawable(null);
}
else
{
Expand Down
11 changes: 7 additions & 4 deletions AcrylicView/Platforms/Android/RealtimeBlurView.cs
Original file line number Diff line number Diff line change
Expand Up @@ -430,8 +430,9 @@ public bool OnPreDraw()
{
bool redrawBitmap = blurView.mBlurredBitmap != oldBmp;

//获取view所在的左上角位置
//获取view所在屏幕的左上角位置
decor.GetLocationOnScreen(locations);
//获取view在父视图中左上角位置
blurView.GetLocationOnScreen(locations);

//float x = locations[0];
Expand All @@ -444,9 +445,11 @@ public bool OnPreDraw()
RENDERING_COUNT++;
try
{
float _borderWidth = (float)(_density * (_borderThickness.Left + _borderThickness.Right));
float _borderHeight = (float)(_density * (_borderThickness.Top + _borderThickness.Bottom));
blurView.mBlurringCanvas.Scale((blurView.mBitmapToBlur.Width + _borderWidth) / blurView.Width, (blurView.mBitmapToBlur.Height + _borderHeight) / blurView.Height);
float sx = (float)blurView.mBitmapToBlur.Width / blurView.Width;
float sy = (float)blurView.mBitmapToBlur.Height / blurView.Height;

blurView.mBlurringCanvas.Scale(sx, sy);

blurView.mBlurringCanvas.Translate(-locations[0], -locations[1]);
decor.Background?.Draw(blurView.mBlurringCanvas);
decor.Draw(blurView.mBlurringCanvas);
Expand Down

0 comments on commit aeacd41

Please sign in to comment.