update for shared state and improved performance

This commit is contained in:
Henry Schimke
2023-01-02 16:38:05 -06:00
parent 72f69dd6a0
commit 65f7c4d01b
46 changed files with 505 additions and 359 deletions

View File

@@ -16,7 +16,7 @@
//package com.google.zxing;
use std::rc::Rc;
use std::{cell::RefCell, rc::Rc};
use crate::{
common::{BitArray, BitMatrix},
@@ -51,7 +51,7 @@ pub trait Binarizer {
* @return The array of bits for this row (true means black).
* @throws NotFoundException if row can't be binarized
*/
fn getBlackRow(&self, y: usize, row: &mut BitArray) -> Result<BitArray, Exceptions>;
fn getBlackRow(&mut self, y: usize) -> Result<BitArray, Exceptions>;
/**
* Converts a 2D array of luminance data to 1 bit data. As above, assume this method is expensive
@@ -62,7 +62,7 @@ pub trait Binarizer {
* @return The 2D array of bits for the image (true means black).
* @throws NotFoundException if image can't be binarized to make a matrix
*/
fn getBlackMatrix(&self) -> Result<BitMatrix, Exceptions>;
fn getBlackMatrix(&mut self) -> Result<&BitMatrix, Exceptions>;
/**
* Creates a new object with the same type as this Binarizer implementation, but with pristine
@@ -72,7 +72,7 @@ pub trait Binarizer {
* @param source The LuminanceSource this Binarizer will operate on.
* @return A new concrete Binarizer implementation object.
*/
fn createBinarizer(&self, source: Box<dyn LuminanceSource>) -> Rc<dyn Binarizer>;
fn createBinarizer(&self, source: Box<dyn LuminanceSource>) -> Rc<RefCell<dyn Binarizer>>;
fn getWidth(&self) -> usize;