Ver Fonte

skia: fixed drawing background

mattias há 1 ano atrás
pai
commit
9345319536
1 ficheiros alterados com 15 adições e 10 exclusões
  1. 15 10
      src/skia/fresnel.skiarenderer.pas

+ 15 - 10
src/skia/fresnel.skiarenderer.pas

@@ -618,10 +618,19 @@ var
 begin
   if El=nil then ;
 
-  With Params.BoundingBox.Box do
+  With Params do
     begin
-    r:=RectF(0,0,Width,Height);
-    r.Offset(Left+Origin.X,Top+Origin.Y);
+    if HasBorder then begin
+      // with border
+        r:=RectF(Width[ffsLeft]/2,
+                 Width[ffsTop]/2,
+                 BoundingBox.Box.Width-Width[ffsRight]/2,
+                 BoundingBox.Box.Height-Width[ffsBottom]/2);
+    end else begin
+      // no border
+      r:=RectF(0,0,BoundingBox.Box.Width,BoundingBox.Box.Height);
+    end;
+    r.Offset(BoundingBox.Box.Left+Origin.X,BoundingBox.Box.Top+Origin.Y);
     end;
 
   if Params.BackgroundImage is TFresnelCSSLinearGradient then
@@ -661,7 +670,6 @@ end;
 procedure TFresnelSkiaRenderer.DrawElBorder(El: TFresnelElement; Params: TBorderAndBackground);
 
 var
-  HasBorder, HasRadius, SameBorderWidth: Boolean;
   r: TRectF;
   SkPaint: ISkPaint;
   Oval: ISkRoundRect;
@@ -671,9 +679,6 @@ begin
   if El=nil then ;
   // Radii are calculated in prepare step.
 
-  SameBorderWidth:=Params.SameBorderWidth;
-  HasBorder:=Params.HasBorder;
-  HasRadius:=Params.HasRadius;
   With Params do
     begin
     if HasBorder then begin
@@ -691,14 +696,14 @@ begin
   //writeln('TFresnelSkiaRenderer.DrawElBorder ',El.GetPath,' Box=',Params.Box.ToString,' Origin=',Origin.ToString,' r=',r.Left,',',r.Top,',',r.Right,',',r.Bottom);
 
   // draw border
-  if HasBorder then
+  if Params.HasBorder then
   begin
-    if not SameBorderWidth then ; // todo
+    if not Params.SameBorderWidth then ; // todo
     SkPaint:=TSkPaint.Create(TSkPaintStyle.Stroke);
     SkPaint.setColor(FPColorToSkia(Params.Color[ffsLeft]));
     SkPaint.SetStrokeWidth(Params.Width[ffsLeft]);
     SkPaint.SetAntiAlias(true);
-    if HasRadius then
+    if Params.HasRadius then
     begin
       Oval:=TSkRoundRect.Create;
       Oval.SetRect(r,SkiaParams.Radii);