fabricjs / fabric.js

Javascript Canvas Library, SVG-to-Canvas (& canvas-to-SVG) Parser
http://fabricjs.com
Other
29.06k stars 3.51k forks source link

[Feature]: Remove the need for `config.textureSize` #10197

Open miroljub1995 opened 4 weeks ago

miroljub1995 commented 4 weeks ago

CheckList

Description

Is it possible to detect textureSize based on dimensions of max image used. Currently we do not know what value to set for textureSize, instead, we have something like:

  applyFilters(filters?: BaseFilter<string, Record<string, any>>[]): void {
    const neededTextureSize = Math.max(this.width, this.height);

    if (config.textureSize < neededTextureSize) {
      config.textureSize = neededTextureSize;
      setFilterBackend(initFilterBackend());
    }

    super.applyFilters(filters);
  }

Do we really need this property in config, can something similar be implemented in fabric so that we do not have to extend FabricImage class?

Current State

Currently we need to set textureSize to some big enough value to support all images.

Additional Context

No response

asturur commented 4 weeks ago

The issue with maxTextureSize is that some hardware declare 16k and then will just break at 8k or less. ( intel integrated graphics of some years ago ). Just set it to 16k if you think all your users have modern gpus.