[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Public WebGL] Unclear "Texture Upload Width and Height" definition
The latest draft of WebGL 1.0 (10th Dec. 2014) is unclear on the size of the texture after upload from a HTMLImageElement and the current behavior differs for SVG vs non SVG images.
Snip from WebGL 1.0 latest:
> 6.7 Texture Upload Width and Height
> Unless width and height parameters are explicitly specified, the width and height of the texture
> set by texImage2D and the width and height of the sub-rectangle updated by texSubImage2D
> are determined based on the uploaded TexImageSource source object:
> source of type HTMLImageElement
> If a bitmap is uploaded, the width and height of the texture are set to the width and height
> of the uploaded bitmap in pixels. If an SVG image is uploaded, the width and height of the
> texture are set to the current values of the width and height properties of the
> HTMLImageElement object.
Regarding the uploaded size:
The phrase "are set to the width and height of the uploaded bitmap in pixels" is unspecific.
Explicitly specify which property of the HTMLImageElement will be used, i.e. "naturalWidth" and "naturalHeight".
The width and height property is modifiable and define the elements (probably scaled) width and height. Uploading a scaled image should not be part of the texture upload specification (and afaik isn't currently implemented). Explicitly defining what property will be used, will help developers understand behavior.
Regarding SVG support:
To determine the texture size, a developer would have to investigate the type of image element being uploaded, since the 'naturalWidth' is taken for non-SVG images whereas 'width' is taken for SVG images.
Strip specialization for SVG images and also take the naturalWidth / naturalHeight property for those type of images.
If a specific size of a SVG is needed, uploading a scaled SVG image is possible through the use of a 2D canvas and upload this. This is more cumbersome than using the widht / height property but a more streamlined API weighs more than this, imho.
Are there any known users of the scaling behavior for SVG graphics?
Google Germany GmbH
Registergericht und -nummer: Hamburg, HRB 86891
Sitz der Gesellschaft: Hamburg
Geschäftsführer: Graham Law, Christine Elizabeth Flores
If you received this communication by mistake, please don't forward it to anyone else (it may contain confidential or privileged information), please erase all copies of it, including all attachments, and please let the sender know it went to the wrong person. Thanks.
Diese E-Mail ist vertraulich. Wenn Sie nicht der richtige Adressat sind, leiten Sie diese bitte nicht weiter, informieren Sie den Absender und löschen Sie die E-Mail und alle Anhänge. Vielen Dank.