Cocoa equivalent of the Carbon method getPtrSize

Posted by Michael Minerva on Stack Overflow See other posts from Stack Overflow or by Michael Minerva
Published on 2010-03-08T17:51:44Z Indexed on 2010/03/08 18:21 UTC
Read the original article Hit count: 702

Filed under:

I need to translate the a carbon method into cocoa into and I am having trouble finding any documentation about what the carbon method getPtrSize really does. From the code I am translating it seems that it returns the byte representation of an image but that doesn't really match up with the name. Could someone give me a good explanation of this method or link me to some documentation that describes it. The code I am translating is in a common lisp implementation called MCL that has a bridge to carbon (I am translating into CCL which is a common lisp implementation with a Cocoa bridge). Here is the MCL code (#_before a method call means that it is a carbon method):

(defmethod COPY-CONTENT-INTO ((Source inflatable-icon) (Destination inflatable-icon))
;; check for size compatibility to avoid disaster
(unless (and (= (rows Source) (rows Destination)) 
           (= (columns Source) (columns Destination))
           (= (#_getPtrSize (image Source)) (#_getPtrSize (image Destination))))
(error "cannot copy content of source into destination inflatable icon: incompatible sizes"))
;; given that they are the same size only copy content
(setf (is-upright Destination) (is-upright Source))
(setf (height Destination) (height Source))
(setf (dz Destination) (dz Source))
(setf (surfaces Destination) (surfaces Source))
(setf (distance Destination) (distance Source))
;; arrays
(noise-map Source)  ;; accessor makes array if needed
(noise-map Destination)  ;; ;; accessor makes array if needed
(dotimes (Row (rows Source))
  (dotimes (Column (columns Source))
    (setf (aref (noise-map Destination) Row Column) (aref (noise-map Source) Row    Column))
    (setf (aref (altitudes Destination) Row Column) (aref (altitudes Source) Row Column))))
  (setf (connectors Destination) (mapcar #'copy-instance (connectors Source)))
  (setf (visible-alpha-threshold Destination) (visible-alpha-threshold Source))
  ;; copy Image: slow byte copy
  (dotimes (I (#_getPtrSize (image Source)))
    (%put-byte (image Destination) (%get-byte (image Source) i) i))
  ;; flat texture optimization: do not copy texture-id -> destination should get its own texture id from OpenGL
  (setf (is-flat Destination) (is-flat Source))
  ;; do not compile flat textures: the display list overhead slows things down by about 2x
 (setf (auto-compile Destination) (not (is-flat Source)))
 ;; to make change visible we have to reset the compiled flag
 (setf (is-compiled Destination) nil))

© Stack Overflow or respective owner

Related posts about cocoa

Related posts about carbon