 {ceil, round} = Math
 {defineModule, inspect, min, max, bound, log, createWithPostCreate, isString, isNumber, BaseObject, isPlainArray, timeout} = Foundation
 {point, rect, Matrix, point0, point1} = Atomic
+{isImage} = Canvas
 
 defineModule module, class BitmapElement extends ShadowableElement
 

    # returns true if the bitmap was released
    # returns false if there are still other references
    release: (url) ->
      return unless url
      # log "SourceToBitmapCache#release: #{url}"
      throw new Error "no references for #{url}" unless isNumber @_referenceCounts[url]
      if @_referenceCounts[url] == 0 || !isNumber @_referenceCounts[url]

    ###
    source:
      default:    null
      validate:   (v) ->
        !v ||
        (isImage v) ||
        (isString v)

      postSetter: (v) -> v && @_loadBitmapFromSource v

    ###
