Graphics fixes?

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Graphics fixes?

Stéphane Ducasse
Hi nicolas

last week you pushed some squeak rendering fixes to pharo and I was wondering if the recent ones on squeak should be considered.

Stef



[hidden email]

 to squeak-dev, packages
show details 6:44 PM (15 hours ago)
Nicolas Cellier uploaded a new version of Graphics to project The Trunk:
http://source.squeak.org/trunk/Graphics-nice.121.mcz

==================== Summary ====================

Name: Graphics-nice.121
Author: nice
Time: 19 March 2010, 6:44:28.896 pm
UUID: 62e03b94-65c3-614f-b0f0-76c0476055e7
Ancestors: Graphics-ar.120

1) Add some missing pendingKernX reset.
2) explicit a loop dependency on stopCondition

=============== Diff against Graphics-ar.120 ===============

Item was changed:
 ----- Method: CharacterScanner>>plainTab (in category 'scanning') -----
 plainTab
       "This is the basic method of adjusting destX for a tab."
       destX := (alignment = Justified and: [self leadingTab not])
               ifTrue:         "embedded tabs in justified text are weird"
                       [destX + (textStyle tabWidth - (line justifiedTabDeltaFor: spaceCount)) max: destX]
               ifFalse:
                       [textStyle nextTabXFrom: destX
                               leftMargin: leftMargin
+                               rightMargin: rightMargin].
+       pendingKernX := 0.!
-                               rightMargin: rightMargin]!

Item was changed:
 ----- Method: DisplayScanner>>paddedSpace (in category 'stop conditions') -----
 paddedSpace
       "Each space is a stop condition when the alignment is right justified.
       Padding must be added to the base width of the space according to
       which space in the line this space is and according to the amount of
       space that remained at the end of the line when it was composed."

       spaceCount := spaceCount + 1.
       destX := destX + spaceWidth + (line justifiedPadFor: spaceCount font: font).
       lastIndex := lastIndex + 1.
+       pendingKernX := 0.
       ^ false!

Item was changed:
 ----- Method: CharacterBlockScanner>>characterBlockAtPoint:index:in: (in category 'scanning') -----
 characterBlockAtPoint: aPoint index: index in: textLine
       "This method is the Morphic characterBlock finder.  It combines
       MVC's characterBlockAtPoint:, -ForIndex:, and buildCharcterBlock:in:"
+       | runLength lineStop stopCondition |
-       | runLength lineStop done stopCondition |
       line := textLine.
       rightMargin := line rightMargin.
       lastIndex := line first.
       self setStopConditions.         "also sets font"
       characterIndex := index.  " == nil means scanning for point"
       characterPoint := aPoint.
       (characterPoint isNil or: [characterPoint y > line bottom])
               ifTrue: [characterPoint := line bottomRight].
       (text isEmpty or: [(characterPoint y < line top or: [characterPoint x < line left])
                               or: [characterIndex notNil and: [characterIndex < line first]]])
               ifTrue: [^ (CharacterBlock new stringIndex: line first text: text
                                       topLeft: line leftMargin@line top extent: 0 @ textStyle lineGrid)
                                       textLine: line].
       destX := leftMargin := line leftMarginForAlignment: alignment.
       destY := line top.
       runLength := text runLengthFor: line first.
       characterIndex
               ifNotNil:       [lineStop := characterIndex  "scanning for index"]
               ifNil:  [lineStop := line last  "scanning for point"].
       runStopIndex := lastIndex + (runLength - 1) min: lineStop.
       lastCharacterExtent := 0 @ line lineHeight.
       spaceCount := 0.

+       [
+               stopCondition := self scanCharactersFrom: lastIndex to: runStopIndex
-       done  := false.
-       [done] whileFalse:
-               [stopCondition := self scanCharactersFrom: lastIndex to: runStopIndex
                       in: text string rightX: characterPoint x
                       stopConditions: stopConditions kern: kern.
+               "see setStopConditions for stopping conditions for character block operations."
-               "see setStopConditions for stopping conditions for character block      operations."
               self lastCharacterExtentSetX: (specialWidth
                       ifNil: [font widthOf: (text at: lastIndex)]
                       ifNotNil: [specialWidth]).
+               self perform: stopCondition
+       ] whileFalse.
+       characterIndex
+               ifNil: [
+                       "Result for characterBlockAtPoint: "
+                       (stopCondition ~~ #cr and: [ lastIndex == line last
+                               and: [ aPoint x > ((characterPoint x) + (lastCharacterExtent x / 2)) ]])
+                                       ifTrue: [ "Correct for right half of last character in line"
+                                               ^ (CharacterBlock new stringIndex: lastIndex + 1
+                                                               text: text
+                                                               topLeft: characterPoint + (lastCharacterExtent x @ 0) + (font descentKern @ 0)
+                                                               extent:  0 @ lastCharacterExtent y)
+                                                       textLine: line ].
+                               ^ (CharacterBlock new
+                                       stringIndex: lastIndex
+                                       text: text topLeft: characterPoint + (font descentKern @ 0)
+                                       extent: lastCharacterExtent - (font baseKern @ 0))
+                                                       textLine: line]
+               ifNotNil: ["Result for characterBlockForIndex: "
+                               ^ (CharacterBlock new
+                                       stringIndex: characterIndex
+                                       text: text topLeft: characterPoint + ((font descentKern) - kern @ 0)
+                                       extent: lastCharacterExtent)
+                                                       textLine: line]!
-               (self perform: stopCondition) ifTrue:
-                       [characterIndex
-                               ifNil: [
-                                       "Result for characterBlockAtPoint: "
-                                       (stopCondition ~~ #cr and: [ lastIndex == line last
-                                               and: [ aPoint x > ((characterPoint x) + (lastCharacterExtent x / 2)) ]])
-                                                       ifTrue: [ "Correct for right half of last character in line"
-                                                               ^ (CharacterBlock new stringIndex: lastIndex + 1
-                                                                               text: text
-                                                                               topLeft: characterPoint + (lastCharacterExtent x @ 0) + (font descentKern @ 0)
-                                                                               extent:  0 @ lastCharacterExtent y)
-                                                                       textLine: line ].
-                                               ^ (CharacterBlock new stringIndex: lastIndex
-                                                       text: text topLeft: characterPoint + (font descentKern @ 0)
-                                                       extent: lastCharacterExtent - (font baseKern @ 0))
-                                                                       textLine: line]
-                               ifNotNil: ["Result for characterBlockForIndex: "
-                                               ^ (CharacterBlock new stringIndex: characterIndex
-                                                       text: text topLeft: characterPoint + ((font descentKern) - kern @ 0)
-                                                       extent: lastCharacterExtent)
-                                                                       textLine: line]]]!


_______________________________________________
Pharo-project mailing list
[hidden email]
http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project
Reply | Threaded
Open this post in threaded view
|

Re: Graphics fixes?

Nicolas Cellier
2010/3/20 Stéphane Ducasse <[hidden email]>:
> Hi nicolas
>
> last week you pushed some squeak rendering fixes to pharo and I was wondering if the recent ones on squeak should be considered.
>
> Stef
>
>

Yes.
I just analyzed the diffs between CharacterScanner & subclasses with
MultiCharacterScanner family and fixed the diffs.
It would be far better to have Test Cases !!!
Last change is a just a clean-up, Writing the whileFalse depending on
true exit condition rather than an infinite loop with exit returns
seems cleaner to me.

Nicolas

>
> [hidden email]
>
>  to squeak-dev, packages
> show details 6:44 PM (15 hours ago)
> Nicolas Cellier uploaded a new version of Graphics to project The Trunk:
> http://source.squeak.org/trunk/Graphics-nice.121.mcz
>
> ==================== Summary ====================
>
> Name: Graphics-nice.121
> Author: nice
> Time: 19 March 2010, 6:44:28.896 pm
> UUID: 62e03b94-65c3-614f-b0f0-76c0476055e7
> Ancestors: Graphics-ar.120
>
> 1) Add some missing pendingKernX reset.
> 2) explicit a loop dependency on stopCondition
>
> =============== Diff against Graphics-ar.120 ===============
>
> Item was changed:
>  ----- Method: CharacterScanner>>plainTab (in category 'scanning') -----
>  plainTab
>       "This is the basic method of adjusting destX for a tab."
>       destX := (alignment = Justified and: [self leadingTab not])
>               ifTrue:         "embedded tabs in justified text are weird"
>                       [destX + (textStyle tabWidth - (line justifiedTabDeltaFor: spaceCount)) max: destX]
>               ifFalse:
>                       [textStyle nextTabXFrom: destX
>                               leftMargin: leftMargin
> +                               rightMargin: rightMargin].
> +       pendingKernX := 0.!
> -                               rightMargin: rightMargin]!
>
> Item was changed:
>  ----- Method: DisplayScanner>>paddedSpace (in category 'stop conditions') -----
>  paddedSpace
>       "Each space is a stop condition when the alignment is right justified.
>       Padding must be added to the base width of the space according to
>       which space in the line this space is and according to the amount of
>       space that remained at the end of the line when it was composed."
>
>       spaceCount := spaceCount + 1.
>       destX := destX + spaceWidth + (line justifiedPadFor: spaceCount font: font).
>       lastIndex := lastIndex + 1.
> +       pendingKernX := 0.
>       ^ false!
>
> Item was changed:
>  ----- Method: CharacterBlockScanner>>characterBlockAtPoint:index:in: (in category 'scanning') -----
>  characterBlockAtPoint: aPoint index: index in: textLine
>       "This method is the Morphic characterBlock finder.  It combines
>       MVC's characterBlockAtPoint:, -ForIndex:, and buildCharcterBlock:in:"
> +       | runLength lineStop stopCondition |
> -       | runLength lineStop done stopCondition |
>       line := textLine.
>       rightMargin := line rightMargin.
>       lastIndex := line first.
>       self setStopConditions.         "also sets font"
>       characterIndex := index.  " == nil means scanning for point"
>       characterPoint := aPoint.
>       (characterPoint isNil or: [characterPoint y > line bottom])
>               ifTrue: [characterPoint := line bottomRight].
>       (text isEmpty or: [(characterPoint y < line top or: [characterPoint x < line left])
>                               or: [characterIndex notNil and: [characterIndex < line first]]])
>               ifTrue: [^ (CharacterBlock new stringIndex: line first text: text
>                                       topLeft: line leftMargin@line top extent: 0 @ textStyle lineGrid)
>                                       textLine: line].
>       destX := leftMargin := line leftMarginForAlignment: alignment.
>       destY := line top.
>       runLength := text runLengthFor: line first.
>       characterIndex
>               ifNotNil:       [lineStop := characterIndex  "scanning for index"]
>               ifNil:  [lineStop := line last  "scanning for point"].
>       runStopIndex := lastIndex + (runLength - 1) min: lineStop.
>       lastCharacterExtent := 0 @ line lineHeight.
>       spaceCount := 0.
>
> +       [
> +               stopCondition := self scanCharactersFrom: lastIndex to: runStopIndex
> -       done  := false.
> -       [done] whileFalse:
> -               [stopCondition := self scanCharactersFrom: lastIndex to: runStopIndex
>                       in: text string rightX: characterPoint x
>                       stopConditions: stopConditions kern: kern.
> +               "see setStopConditions for stopping conditions for character block operations."
> -               "see setStopConditions for stopping conditions for character block      operations."
>               self lastCharacterExtentSetX: (specialWidth
>                       ifNil: [font widthOf: (text at: lastIndex)]
>                       ifNotNil: [specialWidth]).
> +               self perform: stopCondition
> +       ] whileFalse.
> +       characterIndex
> +               ifNil: [
> +                       "Result for characterBlockAtPoint: "
> +                       (stopCondition ~~ #cr and: [ lastIndex == line last
> +                               and: [ aPoint x > ((characterPoint x) + (lastCharacterExtent x / 2)) ]])
> +                                       ifTrue: [ "Correct for right half of last character in line"
> +                                               ^ (CharacterBlock new stringIndex: lastIndex + 1
> +                                                               text: text
> +                                                               topLeft: characterPoint + (lastCharacterExtent x @ 0) + (font descentKern @ 0)
> +                                                               extent:  0 @ lastCharacterExtent y)
> +                                                       textLine: line ].
> +                               ^ (CharacterBlock new
> +                                       stringIndex: lastIndex
> +                                       text: text topLeft: characterPoint + (font descentKern @ 0)
> +                                       extent: lastCharacterExtent - (font baseKern @ 0))
> +                                                       textLine: line]
> +               ifNotNil: ["Result for characterBlockForIndex: "
> +                               ^ (CharacterBlock new
> +                                       stringIndex: characterIndex
> +                                       text: text topLeft: characterPoint + ((font descentKern) - kern @ 0)
> +                                       extent: lastCharacterExtent)
> +                                                       textLine: line]!
> -               (self perform: stopCondition) ifTrue:
> -                       [characterIndex
> -                               ifNil: [
> -                                       "Result for characterBlockAtPoint: "
> -                                       (stopCondition ~~ #cr and: [ lastIndex == line last
> -                                               and: [ aPoint x > ((characterPoint x) + (lastCharacterExtent x / 2)) ]])
> -                                                       ifTrue: [ "Correct for right half of last character in line"
> -                                                               ^ (CharacterBlock new stringIndex: lastIndex + 1
> -                                                                               text: text
> -                                                                               topLeft: characterPoint + (lastCharacterExtent x @ 0) + (font descentKern @ 0)
> -                                                                               extent:  0 @ lastCharacterExtent y)
> -                                                                       textLine: line ].
> -                                               ^ (CharacterBlock new stringIndex: lastIndex
> -                                                       text: text topLeft: characterPoint + (font descentKern @ 0)
> -                                                       extent: lastCharacterExtent - (font baseKern @ 0))
> -                                                                       textLine: line]
> -                               ifNotNil: ["Result for characterBlockForIndex: "
> -                                               ^ (CharacterBlock new stringIndex: characterIndex
> -                                                       text: text topLeft: characterPoint + ((font descentKern) - kern @ 0)
> -                                                       extent: lastCharacterExtent)
> -                                                                       textLine: line]]]!
>
>
> _______________________________________________
> Pharo-project mailing list
> [hidden email]
> http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project
>

_______________________________________________
Pharo-project mailing list
[hidden email]
http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project
Reply | Threaded
Open this post in threaded view
|

Re: Graphics fixes?

Stéphane Ducasse

On Mar 20, 2010, at 9:06 PM, Nicolas Cellier wrote:

> 2010/3/20 Stéphane Ducasse <[hidden email]>:
>> Hi nicolas
>>
>> last week you pushed some squeak rendering fixes to pharo and I was wondering if the recent ones on squeak should be considered.
>>
>> Stef
>>
>>
>
> Yes.
> I just analyzed the diffs between CharacterScanner & subclasses with
> MultiCharacterScanner family and fixed the diffs.

did you publish something I should integrate?

> It would be far better to have Test Cases !!!

Yes I plan to invest on that.

> Last change is a just a clean-up, Writing the whileFalse depending on
> true exit condition rather than an infinite loop with exit returns
> seems cleaner to me.
>
> Nicolas
>
>>
>> [hidden email]
>>
>>  to squeak-dev, packages
>> show details 6:44 PM (15 hours ago)
>> Nicolas Cellier uploaded a new version of Graphics to project The Trunk:
>> http://source.squeak.org/trunk/Graphics-nice.121.mcz
>>
>> ==================== Summary ====================
>>
>> Name: Graphics-nice.121
>> Author: nice
>> Time: 19 March 2010, 6:44:28.896 pm
>> UUID: 62e03b94-65c3-614f-b0f0-76c0476055e7
>> Ancestors: Graphics-ar.120
>>
>> 1) Add some missing pendingKernX reset.
>> 2) explicit a loop dependency on stopCondition
>>
>> =============== Diff against Graphics-ar.120 ===============
>>
>> Item was changed:
>>  ----- Method: CharacterScanner>>plainTab (in category 'scanning') -----
>>  plainTab
>>       "This is the basic method of adjusting destX for a tab."
>>       destX := (alignment = Justified and: [self leadingTab not])
>>               ifTrue:         "embedded tabs in justified text are weird"
>>                       [destX + (textStyle tabWidth - (line justifiedTabDeltaFor: spaceCount)) max: destX]
>>               ifFalse:
>>                       [textStyle nextTabXFrom: destX
>>                               leftMargin: leftMargin
>> +                               rightMargin: rightMargin].
>> +       pendingKernX := 0.!
>> -                               rightMargin: rightMargin]!
>>
>> Item was changed:
>>  ----- Method: DisplayScanner>>paddedSpace (in category 'stop conditions') -----
>>  paddedSpace
>>       "Each space is a stop condition when the alignment is right justified.
>>       Padding must be added to the base width of the space according to
>>       which space in the line this space is and according to the amount of
>>       space that remained at the end of the line when it was composed."
>>
>>       spaceCount := spaceCount + 1.
>>       destX := destX + spaceWidth + (line justifiedPadFor: spaceCount font: font).
>>       lastIndex := lastIndex + 1.
>> +       pendingKernX := 0.
>>       ^ false!
>>
>> Item was changed:
>>  ----- Method: CharacterBlockScanner>>characterBlockAtPoint:index:in: (in category 'scanning') -----
>>  characterBlockAtPoint: aPoint index: index in: textLine
>>       "This method is the Morphic characterBlock finder.  It combines
>>       MVC's characterBlockAtPoint:, -ForIndex:, and buildCharcterBlock:in:"
>> +       | runLength lineStop stopCondition |
>> -       | runLength lineStop done stopCondition |
>>       line := textLine.
>>       rightMargin := line rightMargin.
>>       lastIndex := line first.
>>       self setStopConditions.         "also sets font"
>>       characterIndex := index.  " == nil means scanning for point"
>>       characterPoint := aPoint.
>>       (characterPoint isNil or: [characterPoint y > line bottom])
>>               ifTrue: [characterPoint := line bottomRight].
>>       (text isEmpty or: [(characterPoint y < line top or: [characterPoint x < line left])
>>                               or: [characterIndex notNil and: [characterIndex < line first]]])
>>               ifTrue: [^ (CharacterBlock new stringIndex: line first text: text
>>                                       topLeft: line leftMargin@line top extent: 0 @ textStyle lineGrid)
>>                                       textLine: line].
>>       destX := leftMargin := line leftMarginForAlignment: alignment.
>>       destY := line top.
>>       runLength := text runLengthFor: line first.
>>       characterIndex
>>               ifNotNil:       [lineStop := characterIndex  "scanning for index"]
>>               ifNil:  [lineStop := line last  "scanning for point"].
>>       runStopIndex := lastIndex + (runLength - 1) min: lineStop.
>>       lastCharacterExtent := 0 @ line lineHeight.
>>       spaceCount := 0.
>>
>> +       [
>> +               stopCondition := self scanCharactersFrom: lastIndex to: runStopIndex
>> -       done  := false.
>> -       [done] whileFalse:
>> -               [stopCondition := self scanCharactersFrom: lastIndex to: runStopIndex
>>                       in: text string rightX: characterPoint x
>>                       stopConditions: stopConditions kern: kern.
>> +               "see setStopConditions for stopping conditions for character block operations."
>> -               "see setStopConditions for stopping conditions for character block      operations."
>>               self lastCharacterExtentSetX: (specialWidth
>>                       ifNil: [font widthOf: (text at: lastIndex)]
>>                       ifNotNil: [specialWidth]).
>> +               self perform: stopCondition
>> +       ] whileFalse.
>> +       characterIndex
>> +               ifNil: [
>> +                       "Result for characterBlockAtPoint: "
>> +                       (stopCondition ~~ #cr and: [ lastIndex == line last
>> +                               and: [ aPoint x > ((characterPoint x) + (lastCharacterExtent x / 2)) ]])
>> +                                       ifTrue: [ "Correct for right half of last character in line"
>> +                                               ^ (CharacterBlock new stringIndex: lastIndex + 1
>> +                                                               text: text
>> +                                                               topLeft: characterPoint + (lastCharacterExtent x @ 0) + (font descentKern @ 0)
>> +                                                               extent:  0 @ lastCharacterExtent y)
>> +                                                       textLine: line ].
>> +                               ^ (CharacterBlock new
>> +                                       stringIndex: lastIndex
>> +                                       text: text topLeft: characterPoint + (font descentKern @ 0)
>> +                                       extent: lastCharacterExtent - (font baseKern @ 0))
>> +                                                       textLine: line]
>> +               ifNotNil: ["Result for characterBlockForIndex: "
>> +                               ^ (CharacterBlock new
>> +                                       stringIndex: characterIndex
>> +                                       text: text topLeft: characterPoint + ((font descentKern) - kern @ 0)
>> +                                       extent: lastCharacterExtent)
>> +                                                       textLine: line]!
>> -               (self perform: stopCondition) ifTrue:
>> -                       [characterIndex
>> -                               ifNil: [
>> -                                       "Result for characterBlockAtPoint: "
>> -                                       (stopCondition ~~ #cr and: [ lastIndex == line last
>> -                                               and: [ aPoint x > ((characterPoint x) + (lastCharacterExtent x / 2)) ]])
>> -                                                       ifTrue: [ "Correct for right half of last character in line"
>> -                                                               ^ (CharacterBlock new stringIndex: lastIndex + 1
>> -                                                                               text: text
>> -                                                                               topLeft: characterPoint + (lastCharacterExtent x @ 0) + (font descentKern @ 0)
>> -                                                                               extent:  0 @ lastCharacterExtent y)
>> -                                                                       textLine: line ].
>> -                                               ^ (CharacterBlock new stringIndex: lastIndex
>> -                                                       text: text topLeft: characterPoint + (font descentKern @ 0)
>> -                                                       extent: lastCharacterExtent - (font baseKern @ 0))
>> -                                                                       textLine: line]
>> -                               ifNotNil: ["Result for characterBlockForIndex: "
>> -                                               ^ (CharacterBlock new stringIndex: characterIndex
>> -                                                       text: text topLeft: characterPoint + ((font descentKern) - kern @ 0)
>> -                                                       extent: lastCharacterExtent)
>> -                                                                       textLine: line]]]!
>>
>>
>> _______________________________________________
>> Pharo-project mailing list
>> [hidden email]
>> http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project
>>
>
> _______________________________________________
> Pharo-project mailing list
> [hidden email]
> http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project


_______________________________________________
Pharo-project mailing list
[hidden email]
http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project