Implement Graphics.drawGraphicsData and readGraphicsData - #13
Conversation
Walk IGraphicsData by data_type into the existing fill/stroke/path APIs, keep recorded paths after tessellation, and serialize MOVE_TO/LINE_TO/CURVE_TO plus fills, strokes, and GraphicsEndFill.
…readGraphicsData reconstruction.
applyPattern replaces graphicsData[0]; if that slot was a stroke or empty, the clothing interiors never got the new GraphicsBitmapFill. Also clone queued ShapeTags and fall back to sourceGraphics / triangle contours.
Queued and active held the same live path objects as _recorded_*, so merging them in _collectRecordedPaths was redundant and could duplicate fills. Record once by identity and skip shape-fallback bitmaps already emitted from paths.
| newmat.alphaBlending = true; | ||
| newmat.useColorTransform = true; | ||
| newmat.bothSides = true; | ||
| return newmat; |
There was a problem hiding this comment.
@roncarbot you return newmat here but if you have a transform don't you need to return the correct _bitmapMaterialTransform material. what eventualities is the image arg used?
There was a problem hiding this comment.
Good catch to double-check. When image is set we intentionally return a per-image material (image.id + transform flag), not the shared _bitmapMaterialTransform. The shared transform material is only the fallback for the no-image path below (default 8×8 placeholder + animateUVs).
image is used for author-time / beginBitmapFill bitmaps so each BitmapData gets its own material (and its own mip/NPOT handling) instead of all fills fighting over one shared material. The transform flag on that path only turns on animateUVs for that per-image material — same UV-animation behaviour as _bitmapMaterialTransform, without sharing the texture slot.
There was a problem hiding this comment.
a per-image material is not needed, the material is only holding shader information (which is the same for every bitmap material) and the image is set on the style property of the shape. If you look at where getMaterialForBitmap() is implemented, it is accompanied by a style.image setting when appropriate
There was a problem hiding this comment.
You're right — I was over-fitting. Materials here are shared shader state; the bitmap belongs on style.image (both GraphicsFactoryFills and the ShapeTag path already set that). I've dropped the per-image material pool and the extra image arg; getMaterialForBitmap(transform) is back to the shared _bitmapMaterial / _bitmapMaterialTransform pair. Kept the mipmap=false sampler change, which was the part that actually fixed the black NPOT fills.
| && !this._shapes.length | ||
| && !this._recorded_fill_pathes.length | ||
| && this.sourceGraphics) | ||
| source = this.sourceGraphics; |
There was a problem hiding this comment.
I don't think sourceGraphics is being used for anything, can you check and if not, remove from source?
There was a problem hiding this comment.
It is still used — three places in this file:
start/endgetters fall through tosourceGraphicswhen this instance hasn’t set its own.copyTosetsgraphics.sourceGraphics = thisso clones keep a link back to the symbol Graphics.readGraphicsData(this block) — if the instance has no queued ShapeTags, no shapes, and no recorded fill paths, it reads fromsourceGraphicsso timeline instances that share / clone a symbol still reconstruct fills.
Happy to rename or tighten the fallback if you’d rather readGraphicsData only ever look at this, but I wouldn’t remove the field while those three paths still need it.
Bitmap lives on style.image; MaterialManager only needs one transform and one non-transform bitmap material. NPOT mipmap=false sampler fix stays.
Summary
Test plan