From ffd34ceaa6a1aeb61023096225df33a9ce3a3386 Mon Sep 17 00:00:00 2001 From: Kris <1611248+Rinzwind@users.noreply.github.com> Date: Sun, 4 Feb 2024 11:13:05 +0100 Subject: [PATCH 1/3] Made #drawOn: on RSAthensMorph apply the world renderer canvas scale factor to the Athens surface and canvas. --- src/Roassal/RSAthensMorph.class.st | 24 +++++++++-------- src/Roassal/RSAthensRenderer.class.st | 38 +++++++++++++++++++++++---- 2 files changed, 46 insertions(+), 16 deletions(-) diff --git a/src/Roassal/RSAthensMorph.class.st b/src/Roassal/RSAthensMorph.class.st index 8ea962d9..639d7203 100644 --- a/src/Roassal/RSAthensMorph.class.st +++ b/src/Roassal/RSAthensMorph.class.st @@ -8,6 +8,7 @@ Class { #instVars : [ 'renderer', 'session', + 'surfaceScale', 'surface', 'isDrawing', 'roassalCanvas', @@ -60,7 +61,7 @@ RSAthensMorph >> checkSession [ { #category : #'surface management' } RSAthensMorph >> createSurface [ - surface := AthensCairoSurface extent: self extent asIntegerPoint. + surface := AthensCairoSurface extent: self extent asIntegerPoint * surfaceScale. session := Smalltalk session. roassalCanvas ifNotNil: [ roassalCanvas invalidate ] ] @@ -72,7 +73,7 @@ RSAthensMorph >> drawOn: aCanvas [ isDrawing := true. [ self checkSession. - self recreateSurfaceIfNecessary. + self recreateSurfaceIfNecessary: OSWorldRenderer canvasScaleFactor. aCanvas fillRectangle: self bounds fillStyle: roassalCanvas color @@ -83,10 +84,8 @@ RSAthensMorph >> drawOn: aCanvas [ surface hasBeenFreed ifTrue: [ self createSurface ]. [ aCanvas - image: surface asForm - at: self bounds origin asIntegerPoint - sourceRect: (0 @ 0 extent: surface extent) - rule: 34 ] + translucentFormSet: (FormSet extent: self extent asIntegerPoint depth: 32 forms: { surface asForm }) + at: self bounds origin asIntegerPoint ] on: Exception do: [ :ex | ex traceCr ] ] ensure: [ isDrawing := false ] @@ -118,7 +117,8 @@ RSAthensMorph >> drawShapes [ surface drawDuring: [ :athensCanvas | renderer surface: surface; - canvas: athensCanvas. + canvas: athensCanvas; + scale: surfaceScale. roassalCanvas accept: renderer. ] ] @@ -138,7 +138,7 @@ RSAthensMorph >> fullDrawOnAthensCanvas: aCanvas [ isDrawing := true. [ self checkSession. - self recreateSurfaceIfNecessary. + self recreateSurfaceIfNecessary: 1. aCanvas setPaint: roassalCanvas color. aCanvas drawShape: (bounds translateBy: bounds origin negated). @@ -217,6 +217,7 @@ RSAthensMorph >> hasFocus [ RSAthensMorph >> initialize [ super initialize. self eventProcessor: RSEventProcessor new. + surfaceScale := 0. self createSurface. session := Smalltalk session. isDrawing := false @@ -293,10 +294,11 @@ RSAthensMorph >> mouseWheel: evt [ ] { #category : #'session management' } -RSAthensMorph >> recreateSurfaceIfNecessary [ +RSAthensMorph >> recreateSurfaceIfNecessary: scale [ surface - ifNotNil: [ self extent asIntegerPoint ~= surface extent - ifTrue: [ self createSurface. + ifNotNil: [ (surfaceScale ~= scale or: [ self extent asIntegerPoint * surfaceScale ~= surface extent ]) + ifTrue: [ surfaceScale := scale. + self createSurface. roassalCanvas extent: self extent ] ] ] diff --git a/src/Roassal/RSAthensRenderer.class.st b/src/Roassal/RSAthensRenderer.class.st index cd5b10b9..e0ea1c09 100644 --- a/src/Roassal/RSAthensRenderer.class.st +++ b/src/Roassal/RSAthensRenderer.class.st @@ -23,6 +23,7 @@ Class { 'showRectangles', 'originMatrix', 'surface', + 'scale', 'dirtyRectangle' ], #category : 'Roassal-Rendering' @@ -580,6 +581,32 @@ RSAthensRenderer >> paintFor: shape form: form [ paint ] ] +{ #category : #'visiting - helpers' } +RSAthensRenderer >> pathTransformLoadMatrix [ + + athensCanvas pathTransform loadAffineTransform: + (AthensAffineTransform new + x: matrix x * scale; + y: matrix y * scale; + sx: matrix sx * scale; + sy: matrix sy * scale; + shx: matrix shx * scale; + shy: matrix shy * scale; + yourself) +] + +{ #category : #accessing } +RSAthensRenderer >> scale [ + + ^ scale +] + +{ #category : #accessing } +RSAthensRenderer >> scale: anObject [ + + scale := anObject +] + { #category : #'visiting - helpers' } RSAthensRenderer >> showEncompassingRectangleForLineIfNecessary: line [ showRectangles ifFalse: [ ^ self ]. @@ -630,7 +657,7 @@ RSAthensRenderer >> visitBorderIfNecessary: shape [ RSAthensRenderer >> visitBoundingShape: shape [ self visitShapeIfNecessary: shape block: [ | path paint | - athensCanvas pathTransform loadAffineTransform: matrix. + self pathTransformLoadMatrix. path := self getOrCreatePathOf: shape. paint := shape paintOn: self. paint ifNotNil: [ @@ -666,6 +693,7 @@ RSAthensRenderer >> visitCanvas: aRSCanvas [ athensCanvas setAA: aRSCanvas host antialiasing. aRSCanvas camera accept: self. transformeDirtyRectangle := self transform: dirtyRectangle. + athensCanvas pathTransform loadIdentity scaleBy: scale. aRSCanvas shouldClearBackground ifTrue: [ self clearRectangle: transformeDirtyRectangle ]. modifiedDirtyRectangle := self inverseTransform: transformeDirtyRectangle. @@ -674,14 +702,14 @@ RSAthensRenderer >> visitCanvas: aRSCanvas [ dirtyRectangle := transformeDirtyRectangle. matrix loadIdentity. originMatrix loadIdentity. - athensCanvas pathTransform loadIdentity. + athensCanvas pathTransform loadIdentity scaleBy: scale. athensCanvas clipBy: transformeDirtyRectangle during: [ (aRSCanvas fixedShapes entriesAtRectangle: dirtyRectangle) do: [ :each | each accept: self ] ]. aRSCanvas resetDirtyRectangle. aRSCanvas shouldShowDirtyRectangle ifFalse: [ ^ self ]. - athensCanvas pathTransform loadIdentity. + athensCanvas pathTransform loadIdentity scaleBy: scale. matrix loadIdentity. originMatrix loadIdentity. aRSCanvas camera accept: self. @@ -718,7 +746,7 @@ RSAthensRenderer >> visitLabel: label [ | lbtranslation | lbtranslation := label textExtents translationPoint asFloatPoint. matrix translateBy: lbtranslation. - athensCanvas pathTransform loadAffineTransform: matrix. + self pathTransformLoadMatrix. label hasBorder ifTrue: [ self drawPathLabel: label ] ifFalse: [ self drawSimpleLabel: label ]. @@ -752,7 +780,7 @@ RSAthensRenderer >> visitLabelDecoratorsIfNecessary: label [ RSAthensRenderer >> visitLine: line [ | path paint | (line intersects: dirtyRectangle) ifFalse: [ ^ self ]. - athensCanvas pathTransform loadAffineTransform: matrix. + self pathTransformLoadMatrix. path := self getOrCreatePathOf: line. paint := line paintOn: self. From 00f764a075a60b55d4d8a307e8862e75a57b473c Mon Sep 17 00:00:00 2001 From: Kris <1611248+Rinzwind@users.noreply.github.com> Date: Sun, 4 Feb 2024 17:16:43 +0100 Subject: [PATCH 2/3] Changed #drawOn: on RSAthensMorph to use the scale of the argument canvas instead of the world renderer canvas scale factor (which is used as the scale of the canvas in #getCanvas on OSWindowFormRenderer). --- src/Roassal/RSAthensMorph.class.st | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Roassal/RSAthensMorph.class.st b/src/Roassal/RSAthensMorph.class.st index 639d7203..bdcf0831 100644 --- a/src/Roassal/RSAthensMorph.class.st +++ b/src/Roassal/RSAthensMorph.class.st @@ -73,7 +73,7 @@ RSAthensMorph >> drawOn: aCanvas [ isDrawing := true. [ self checkSession. - self recreateSurfaceIfNecessary: OSWorldRenderer canvasScaleFactor. + self recreateSurfaceIfNecessary: aCanvas scale. aCanvas fillRectangle: self bounds fillStyle: roassalCanvas color From fc67a2578bc4a0b3525a02e962b3efbfea65c37c Mon Sep 17 00:00:00 2001 From: Kris <1611248+Rinzwind@users.noreply.github.com> Date: Sun, 4 Feb 2024 17:17:22 +0100 Subject: [PATCH 3/3] =?UTF-8?q?Fixed=20mistake=20made=20in=20commit=20ffd3?= =?UTF-8?q?4ceaa6a1aeb6=20(=E2=80=9CMade=20#drawOn:=20on=20RSAthensMorph?= =?UTF-8?q?=20apply=20[=E2=80=A6]=E2=80=9D):=20the=20BitBlt=20combination?= =?UTF-8?q?=20rule=20for=20drawing=20the=20surface=20on=20the=20argument?= =?UTF-8?q?=20canvas=20was=20erroneously=20changed=20from=2034=20(#blendAl?= =?UTF-8?q?phaScaled)=20to=2024=20(#blend).?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Roassal/RSAthensMorph.class.st | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/Roassal/RSAthensMorph.class.st b/src/Roassal/RSAthensMorph.class.st index bdcf0831..0dc17fce 100644 --- a/src/Roassal/RSAthensMorph.class.st +++ b/src/Roassal/RSAthensMorph.class.st @@ -84,8 +84,10 @@ RSAthensMorph >> drawOn: aCanvas [ surface hasBeenFreed ifTrue: [ self createSurface ]. [ aCanvas - translucentFormSet: (FormSet extent: self extent asIntegerPoint depth: 32 forms: { surface asForm }) - at: self bounds origin asIntegerPoint ] + formSet: (FormSet extent: self extent asIntegerPoint depth: 32 forms: { surface asForm }) + at: self bounds origin asIntegerPoint + sourceRect: (0 @ 0 extent: surface extent) + rule: Form blendAlphaScaled ] on: Exception do: [ :ex | ex traceCr ] ] ensure: [ isDrawing := false ]