Eliot Miranda uploaded a new version of VMMaker to project VM Maker: http://source.squeak.org/VMMaker/VMMaker.oscog-eem.2949.mcz ==================== Summary ==================== Name: VMMaker.oscog-eem.2949 Author: eem Time: 12 April 2021, 2:46:31.537712 pm UUID: 2fd2c871-435a-4312-ac4c-79c95820c5a4 Ancestors: VMMaker.oscog-eem.2948 Add CameraPlugin primSetCameraBuffers to avoid a copy when reading a frame. =============== Diff against VMMaker.oscog-eem.2948 =============== Item was changed: ----- Method: CameraPlugin>>primGetFrame (in category 'primitives') ----- primGetFrame "Copy a camera frame into the given Bitmap. The Bitmap should be for a Form of depth 32 that is the same width and height as the current camera frame. Fail if the camera is not open or if the bitmap is not the right size. If successful, answer the number of frames received from the camera since the last call. If this is zero, then there has been no change." | cameraNum bitmapOop bitmap pixCount result | <export: true> <var: 'bitmap' type: #'unsigned char *'> cameraNum := interpreterProxy stackIntegerValue: 1. bitmapOop := interpreterProxy stackValue: 0. interpreterProxy success: (interpreterProxy isWords: bitmapOop). interpreterProxy failed ifTrue: [^ 0]. bitmap := self cCoerce: (interpreterProxy firstIndexableField: bitmapOop) to: #'unsigned char *'. pixCount := interpreterProxy stSizeOf: bitmapOop. result := self Camera: cameraNum Get: bitmap Frame: pixCount. result < 0 ifTrue: + [^interpreterProxy primitiveFailFor: result negated]. - [^interpreterProxy primitiveFail]. interpreterProxy methodReturnInteger: result! Item was added: + ----- Method: CameraPlugin>>primSetCameraBuffers (in category 'primitives') ----- + primSetCameraBuffers + "Sets one or two frame buffers to receive camera frames. The buffer(s) must be big enough and pinned. + Provides these two interfaces: + camera: cameraNum setFrameBuffer: pinnedNonPointers + camera: cameraNum setFrameBufferA: pinnedNonPointers B: pinnedNonPointersOrNil" + + <export: true> + | cameraNum failCode bufferOne bufferTwo | + interpreterProxy methodArgumentCount + caseOf: { + [3] -> [cameraNum := interpreterProxy stackValue: 2. + bufferOne := interpreterProxy stackValue: 1. + bufferTwo := interpreterProxy stackValue: 0]. + [2] -> [cameraNum := interpreterProxy stackValue: 1. + bufferOne := interpreterProxy stackValue: 0. + bufferTwo := nil] } + otherwise: + [^interpreterProxy primitiveFailFor: PrimErrBadNumArgs]. + + ((interpreterProxy isIntegerObject: cameraNum) + and: [(interpreterProxy isWordsOrBytes: bufferOne) + and: [(interpreterProxy isPinned: bufferOne) + and: [bufferTwo isNil + or: [bufferTwo = interpreterProxy nilObject + or: [(interpreterProxy isWordsOrBytes: bufferTwo) + and: [interpreterProxy isPinned: bufferTwo]]]]]]) ifFalse: + [^interpreterProxy primitiveFailFor: PrimErrBadArgument]. + + failCode := self Camera: (interpreterProxy integerValueOf: cameraNum) + SetFrame: bufferOne + Buffers: (bufferTwo = interpreterProxy nilObject ifFalse: [bufferTwo]). "coerce nilObject to nil" + failCode ~= 0 ifTrue: [^interpreterProxy primitiveFailFor: failCode]. + + interpreterProxy methodReturnReceiver! |
Free forum by Nabble | Edit this page |