[Webkit-unassigned] [Bug 120112] Typed Arrays have no public facing API

bugzilla-daemon at webkit.org bugzilla-daemon at webkit.org
Tue Oct 13 11:59:13 PDT 2015


https://bugs.webkit.org/show_bug.cgi?id=120112

--- Comment #26 from Filip Pizlo <fpizlo at apple.com> ---
(In reply to comment #24)
> > [Passing pointer to size_t to receive byteLength] I don't believe we have any other api that behaves in this way.
> All API functions that may throw an exception use this semantic (if I
> understood your concerns correctly).
> 
> JSValueRef exception = NULL;
> JSValueToObject(ctx, value, &exception);
> 
> I would argue that doing the same thing with a size_t is not really
> different. However...
> 
> > Mixing and matching what unit the length you're using is a recipe for mistakes.
> 
> Point taken. 
> 
> So I propose the following set of functions:
> 
> JSTypedArrayType JSObjectGetTypedArrayType(JSContextRef ctx, JSObjectRef
> object);
> JSObjectRef JSObjectMakeTypedArray(JSContextRef ctx, JSTypedArrayType
> arrayType, size_t numElements);
> void * JSObjectGetTypedArrayDataPtr(JSContextRef ctx, JSObjectRef object);
> size_t JSObjectGetTypedArrayByteLength(JSContextRef ctx, JSObjectRef object);
> size_t JSObjectGetTypedArrayNumElements(JSContextRef ctx, JSObjectRef
> object);
> 
> 
> > Also this API fails to allow sharing of data allocated elsewhere (...) Most other data related APIs on OS X allow specifying the external buffer
> 
> The JSC API *nowhere* adheres to this. Everything is copied all over the
> place. Even the somewhat lower level JSString functions copy everything.
> 
> Also, as far as I can tell, none of the existing Typed Array or ArrayBuffer
> constructors allow for using an external data pointer. The data is always
> allocated internally. The existing WebGL implementation in WebKit gets along
> just fine with this.
> 
> My proposed Typed Array API would still allow for most use cases to avoid
> copying. E.g. in Ejecta, the Canvas2D .getImageData() functions uses
> glReadPixels() directly with a Typed Array dataPtr I.e.:
> 
> 
> void *dataPtr = JSObjectGetTypedArrayDataPtr(ctx, array);
> size_t byteLength = JSObjectGetTypedArrayByteLength(ctx, array);
> if( byteLength >= width * height * bytesPerPixel ) {
> 	glReadPixels(x, y, width, height, format, type, dataPtr);
> }
> 
> 
> An additional "JSObjectMakeTypedArrayWithDataPtrNoCopy" function (not sure
> what's the right phrasing here) may have its place, but I still don't
> believe it's critical and it may even be more confusing than helpful.

This isn't about creating an API just for you.  Data APIs on OSX allow you to create data object wrappers that borrow (or take ownership) of some data blob.  What you are proposing is changes to an OSX API.  Therefore, we like to be consistent with how OSX does things.

-- 
You are receiving this mail because:
You are the assignee for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.webkit.org/pipermail/webkit-unassigned/attachments/20151013/9ee47eb5/attachment.html>


More information about the webkit-unassigned mailing list