     valuesIterator = @_cachedBitmaps.values()
     while !(vi = @_cachedBitmaps.next()).done
       cachedBitmap = vi.value
-      if cachedBitmap.lastFrameUsed < currentFrameNumber - 1 && cachedBitmap.bitmap.size.eq size
+      compareSize = cachedBitmap.size
+      if cachedBitmap.lastFrameUsed < currentFrameNumber - 1 && canUseBitmap cachedBitmap, size
         return cachedBitmap
 
   # return true if we have space to allocate a bitmap of the specified 'size'

  advanceFrame: ->
    @_currentFrameNumber++
    cfn = @_currentFrameNumber
    # timeout 1000, =>
    #   if cfn == @_currentFrameNumber
    #     log
    #       currentFrameNumber: @_currentFrameNumber
    #       numInUseCacheBitmaps: @_cachedBitmaps.length
    #       numUnusedCacheBitmaps: @_unusedCacheBitmaps.length
    #       cacheKByteSize: @_cacheByteSize/1024 | 0
    #       usedCacheKByteSize: (@_cacheByteSize - @_unusedCacheByteSize)/1024 | 0
    #       unusedCacheKByteSize: (@_unusedCacheByteSize)/1024 | 0
    #       bitmapsCreated: @_bitmapsCreated

  ##########################
  # PRIVATE

  doneWithCacheBitmap: (element) ->
    if cachedBitmap = mapRemove @_cachedBitmaps, element
      cachedBitmap.elementDoneWithCacheBitmap()
      byteSize = cachedBitmap.getByteSize()
      # console.error "doneWithCacheBitmap recycling for #{cachedBitmap.element?.inspectedName} bitmap = #{cachedBitmap.bitmap.size}"
      @_unusedCacheByteSize += byteSize
      @_cacheByteSize -= byteSize
      @_unusedCacheBitmaps.push cachedBitmap
      @_validateCacheByteSize()

  # called by element every time the draw-cache is used
  useDrawCache: (element) ->
