Quantcast

The Trunk: Graphics-eem.371.mcz

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

The Trunk: Graphics-eem.371.mcz

commits-2
Eliot Miranda uploaded a new version of Graphics to project The Trunk:
http://source.squeak.org/trunk/Graphics-eem.371.mcz

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

Name: Graphics-eem.371
Author: eem
Time: 16 March 2017, 11:16:07.724754 am
UUID: 47843a60-a6e4-40c8-bf26-9c4d18dba3d1
Ancestors: Graphics-ul.370

Add error codes to the copy and warp bits primitives.  Respond to the #'object moved' error code by retrying.  Clean up the failure code to reduce duplication.

=============== Diff against Graphics-ul.370 ===============

Item was changed:
  ----- Method: BitBlt>>copyBits (in category 'copying') -----
  copyBits
  "Primitive. Perform the movement of bits from the source form to the
  destination form. Fail if any variables are not of the right type (Integer,
  Float, or Form) or if the combination rule is not implemented.
  In addition to the original 16 combination rules, this BitBlt supports
  16 fail (to simulate paint)
  17 fail (to simulate mask)
  18 sourceWord + destinationWord
  19 sourceWord - destinationWord
  20 rgbAdd: sourceWord with: destinationWord
  21 rgbSub: sourceWord with: destinationWord
  22 rgbDiff: sourceWord with: destinationWord
  23 tallyIntoMap: destinationWord
  24 alphaBlend: sourceWord with: destinationWord
  25 pixPaint: sourceWord with: destinationWord
  26 pixMask: sourceWord with: destinationWord
  27 rgbMax: sourceWord with: destinationWord
  28 rgbMin: sourceWord with: destinationWord
  29 rgbMin: sourceWord bitInvert32 with: destinationWord
  "
+ <primitive: 'primitiveCopyBits' module: 'BitBltPlugin' error: ec>
- <primitive: 'primitiveCopyBits' module: 'BitBltPlugin'>
 
- "Check for compressed source, destination or halftone forms"
  (combinationRule >= 30 and: [combinationRule <= 31]) ifTrue:
  ["No alpha specified -- re-run with alpha = 1.0"
  ^ self copyBitsTranslucent: 255].
+ "Check for object movement during a surface callback, compressed source, destination or halftone forms.
+ Simply retry."
+ (ec == #'object moved'
+ or: [(sourceForm isForm and: [sourceForm unhibernate])
+ or: [(destForm isForm and: [destForm unhibernate])
+ or: [halftoneForm isForm and: [halftoneForm unhibernate]]]]) ifTrue:
+ [^self copyBits].
- ((sourceForm isForm) and: [sourceForm unhibernate])
- ifTrue: [^ self copyBits].
- ((destForm isForm) and: [destForm unhibernate])
- ifTrue: [^ self copyBits].
- ((halftoneForm isForm) and: [halftoneForm unhibernate])
- ifTrue: [^ self copyBits].
 
  "Check for unimplmented rules"
+ combinationRule = Form oldPaint ifTrue: [^self paintBits].
+ combinationRule = Form oldErase1bitShape ifTrue: [^self eraseBits].
- combinationRule = Form oldPaint ifTrue: [^ self paintBits].
- combinationRule = Form oldErase1bitShape ifTrue: [^ self eraseBits].
 
  "Check if BitBlt doesn't support full color maps"
+ (colorMap notNil and: [colorMap isColormap]) ifTrue:
+ [colorMap := colorMap colors.
- (colorMap notNil and:[colorMap isColormap]) ifTrue:[
- colorMap := colorMap colors.
  ^self copyBits].
+ "Check if clipping got way out of range"
+ self clipRange.
- "Check if clipping gots us way out of range"
- self clipRange ifTrue:[self roundVariables. ^self copyBitsAgain].
-
  "Convert all numeric parameters to integers and try again."
  self roundVariables.
+ ^self copyBitsAgain!
- ^ self copyBitsAgain!

Item was changed:
  ----- Method: BitBlt>>copyBitsAgain (in category 'private') -----
  copyBitsAgain
  "Primitive. See BitBlt|copyBits, also a Primitive. Essential. See Object
  documentation whatIsAPrimitive."
 
+ <primitive: 'primitiveCopyBits' module: 'BitBltPlugin' error: ec>
- <primitive: 'primitiveCopyBits' module: 'BitBltPlugin'>
  self primitiveFailed!

Item was changed:
  ----- Method: WarpBlt>>warpBitsSmoothing:sourceMap: (in category 'primitives') -----
  warpBitsSmoothing: n sourceMap: sourceMap
  | deltaP12 deltaP43 pA pB deltaPAB sp fixedPtOne poker pix nSteps |
+ <primitive: 'primitiveWarpBits' module: 'BitBltPlugin' error: ec>
- <primitive: 'primitiveWarpBits' module: 'BitBltPlugin'>
 
  "Check for compressed source, destination or halftone forms"
+ "Check for object movement during a surface callback, compressed source, destination or halftone forms.
+ Simply retry."
+ (ec == #'object moved'
+ or: [(sourceForm isForm and: [sourceForm unhibernate])
+ or: [(destForm isForm and: [destForm unhibernate])
+ or: [halftoneForm isForm and: [halftoneForm unhibernate]]]]) ifTrue:
+ [^self warpBitsSmoothing: n sourceMap: sourceMap].
- ((sourceForm isForm) and: [sourceForm unhibernate])
- ifTrue: [^ self warpBitsSmoothing: n sourceMap: sourceMap].
- ((destForm isForm) and: [destForm unhibernate])
- ifTrue: [^ self warpBitsSmoothing: n sourceMap: sourceMap].
- ((halftoneForm isForm) and: [halftoneForm unhibernate])
- ifTrue: [^ self warpBitsSmoothing: n sourceMap: sourceMap].
 
  (width < 1) | (height < 1) ifTrue: [^ self].
  fixedPtOne := 16384.  "1.0 in fixed-pt representation"
  n > 1 ifTrue:
  [(destForm depth < 16 and: [colorMap == nil])
  ifTrue: ["color map is required to smooth non-RGB dest"
  ^ self primitiveFail].
  pix := Array new: n*n].
 
  nSteps := height-1 max: 1.
  deltaP12 := (self deltaFrom: p1x to: p2x nSteps: nSteps)
  @ (self deltaFrom: p1y to: p2y nSteps: nSteps).
  pA := (self startFrom: p1x to: p2x offset: nSteps*deltaP12 x)
  @ (self startFrom: p1y to: p2y offset: nSteps*deltaP12 y).
  deltaP43 := (self deltaFrom: p4x to: p3x nSteps: nSteps)
  @ (self deltaFrom: p4y to: p3y nSteps: nSteps).
  pB := (self startFrom: p4x to: p3x offset: nSteps*deltaP43 x)
  @ (self startFrom: p4y to: p3y offset: nSteps*deltaP43 y).
 
  poker := BitBlt bitPokerToForm: destForm.
  poker clipRect: self clipRect.
  nSteps := width-1 max: 1.
  destY to: destY+height-1 do:
  [:y |
  deltaPAB := (self deltaFrom: pA x to: pB x nSteps: nSteps)
  @ (self deltaFrom: pA y to: pB y nSteps: nSteps).
  sp := (self startFrom: pA x to: pB x offset: nSteps*deltaPAB x)
  @ (self startFrom: pA y to: pB y offset: nSteps*deltaPAB x).
  destX to: destX+width-1 do:
  [:x |
  n = 1
  ifTrue:
  [poker pixelAt: x@y
  put: (sourceForm pixelValueAt: sp // fixedPtOne asPoint)]
  ifFalse:
  [0 to: n-1 do:
  [:dx | 0 to: n-1 do:
  [:dy |
  pix at: dx*n+dy+1 put:
  (sourceForm pixelValueAt: sp
  + (deltaPAB*dx//n)
  + (deltaP12*dy//n)
  // fixedPtOne asPoint)]].
  poker pixelAt: x@y put: (self mixPix: pix
+ sourceMap: sourceMap
+ destMap: colorMap)].
- sourceMap: sourceMap
- destMap: colorMap)].
  sp := sp + deltaPAB].
  pA := pA + deltaP12.
  pB := pB + deltaP43]!


Loading...